Install all gems:
$ bundle install
Update the database with new data model:
$ rails db:migrate
Feed the database with default seeds:
$ rails db:seed
Start the web server on http://localhost:3000
by default:
$ rails server
Run all RSpec tests and Rubocop:
$ rails test
HTTP verbs | Paths | Used for |
---|---|---|
POST | api/v1/responses | Determintes if w is generated by G |
GET | api/v1/responses | List all responses - DEPRECATED |
Boolean Output: w ∈ L(G) only if S ∈ X1n.:
$ curl -X POST -H 'Content-type: application/json' -d '{}' localhost:3000/api/v1/responses
{
"grammar": [
{
"producer": "S",
"products": ["BA", "A"]
},
{
"producer": "A",
"products": ["CA","a"]
},
{
"producer": "B",
"products": ["BB","b"]
},
{
"producer": "C",
"products": ["BA", "c"]
}
],
"word": "bca"
}
{
"id": 12,
"word": "bca",
"isAdmitted": true,
"created_at": "2022-10-18T02:14:45.389Z",
"updated_at": "2022-10-18T02:14:45.389Z"
}
{
"response": true,
"matrix": [
[
[
"A"
],
[
[
"A"
]
],
[
[],
[
"S"
]
]
],
[
[
"A"
],
[
[
"S"
]
],
null
],
[
[
"B"
],
null,
null
]
]
}
Get responses in postgress database:
$ curl localhost:3000/api/v1/responses
[
{
"id": 8,
"word": "bbab",
"isAdmitted": true,
"created_at": "2022-10-18T01:50:28.200Z",
"updated_at": "2022-10-18T01:50:28.200Z"
},
{
"id": 9,
"word": "bbab",
"isAdmitted": true,
"created_at": "2022-10-18T01:53:37.901Z",
"updated_at": "2022-10-18T01:53:37.901Z"
},
{
"id": 10,
"word": "aab",
"isAdmitted": true,
"created_at": "2022-10-18T01:54:40.336Z",
"updated_at": "2022-10-18T01:54:40.336Z"
},
{
"id": 11,
"word": "aab",
"isAdmitted": true,
"created_at": "2022-10-18T01:55:11.980Z",
"updated_at": "2022-10-18T01:55:11.980Z"
},
{
"id": 12,
"word": "bca",
"isAdmitted": true,
"created_at": "2022-10-18T02:14:45.389Z",
"updated_at": "2022-10-18T02:14:45.389Z"
}
]