This is a Sinatra application template.
Clone this repository.
$ git clone [email protected]/TTPS-ruby/sinatra_app_template.git
Remove the origin:
$ git remote rm origin
And then execute:
$ bundle
$ bundle exec rackup
$ bundle exec rake
$ curl -G --data 'param1=value1¶m2=value2' -vvv http://localhost:9292/
get '/load' do
#Load a clean development database to test
ActiveRecord::Base.connection.execute('DELETE FROM SQLITE_SEQUENCE WHERE name="resources";')
ActiveRecord::Base.connection.execute('DELETE FROM SQLITE_SEQUENCE WHERE name="bookings";')
Resource.destroy_all
Booking.destroy_all
resource = Resource.create(
name: 'Computadora',
description: 'Notebook con 4GB de RAM y 256 GB de espacio en disco con Linux')
booking = resource.bookings.create(
start: "2013-10-26T10:00:00Z".to_time.utc.iso8601,
end: ("2013-10-26T11:00:00Z".to_time.utc.iso8601),
status: 'approved',
user: '[email protected]')
booking.update(status: 'approved')
booking = resource.bookings.create(
start: "2013-10-26T11:00:00Z".to_time.utc.iso8601,
end: ("2013-10-26T12:30:00Z".to_time.utc.iso8601),
status: 'approved',
user: '[email protected]')
resource = Resource.create(
name: "Monitor",
description: "Monitor de 24 pulgadas SAMSUNG")
resource = Resource.create(
name: "Sala de reuniones",
description: "Sala de reuniones con máquinas y proyector")
Test que faltan:
grep -i 'get\|post\|put\|delete' app.rb
- delete '/resources/:resource_id/bookings/:booking_id'
get '/resources'get '/resources/:resource_id'get '/resources/:resource_id/availability'get '/resources/:resource_id/bookings'FIX too many methods- get '/resources/:resource_id/bookings/:booking_id'
post '/resources'- post '/resources/:resource_id/bookings'
put '/resources/:resource_id'- put '/resources/:resource_id/bookings/:booking_id'
Los recursos de la API no se asocian a una entidad, por lo tanto los recursos serán comunes a todos los proyectos redmine. Si desea puede modificar la API agregando a los recursos un campo entity al recurso que podría usarse en este caso como id de proyecto. Entonces, la API debería agregar un servicio:
GET /resources_for_entity/:entity
que devolvería los recursos para una entidad específica
Sería conveniente agregar en la API un servicio de agregado y modificación de recursos:
POST /resources
crea un nuevo recurso (terminado)PUT /resources/:id
actualiza los datos de un recurso (validar test)
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
See the LICENSE.