restfulie 1.0.0 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +20 -0
- data/.gitmodules +3 -0
- data/.rspec +2 -0
- data/Rakefile +9 -41
- data/full-examples/.gitignore +4 -0
- data/full-examples/README.textile +1 -0
- data/full-examples/mikemaze/README.textile +6 -0
- data/full-examples/mikemaze/maze_basic.rb +37 -0
- data/full-examples/mikemaze/maze_solver_spec.rb +108 -0
- data/full-examples/rest_from_scratch/part_1/.gitignore +4 -0
- data/full-examples/rest_from_scratch/part_1/.rspec +1 -0
- data/full-examples/rest_from_scratch/part_1/Gemfile +33 -0
- data/full-examples/rest_from_scratch/part_1/README +256 -0
- data/full-examples/rest_from_scratch/part_1/Rakefile +7 -0
- data/full-examples/rest_from_scratch/part_1/app/controllers/application_controller.rb +3 -0
- data/full-examples/rest_from_scratch/part_1/app/controllers/items_controller.rb +20 -0
- data/full-examples/rest_from_scratch/part_1/app/helpers/application_helper.rb +2 -0
- data/full-examples/rest_from_scratch/part_1/app/helpers/items_helper.rb +2 -0
- data/full-examples/rest_from_scratch/part_1/app/models/item.rb +2 -0
- data/full-examples/rest_from_scratch/part_1/app/views/items/_form.html.erb +25 -0
- data/full-examples/rest_from_scratch/part_1/app/views/items/edit.html.erb +6 -0
- data/full-examples/rest_from_scratch/part_1/app/views/items/index.html.erb +25 -0
- data/full-examples/rest_from_scratch/part_1/app/views/items/new.html.erb +5 -0
- data/full-examples/rest_from_scratch/part_1/app/views/items/show.html.erb +15 -0
- data/full-examples/rest_from_scratch/part_1/app/views/layouts/application.html.erb +14 -0
- data/full-examples/rest_from_scratch/part_1/autotest/discover.rb +1 -0
- data/full-examples/rest_from_scratch/part_1/config.ru +4 -0
- data/full-examples/rest_from_scratch/part_1/config/application.rb +42 -0
- data/full-examples/rest_from_scratch/part_1/config/boot.rb +13 -0
- data/full-examples/rest_from_scratch/part_1/config/database.yml +22 -0
- data/full-examples/rest_from_scratch/part_1/config/environment.rb +5 -0
- data/full-examples/rest_from_scratch/part_1/config/environments/development.rb +26 -0
- data/full-examples/rest_from_scratch/part_1/config/environments/production.rb +49 -0
- data/full-examples/rest_from_scratch/part_1/config/environments/test.rb +35 -0
- data/full-examples/rest_from_scratch/part_1/config/initializers/backtrace_silencers.rb +7 -0
- data/full-examples/rest_from_scratch/part_1/config/initializers/inflections.rb +10 -0
- data/full-examples/rest_from_scratch/part_1/config/initializers/mime_types.rb +5 -0
- data/full-examples/rest_from_scratch/part_1/config/initializers/secret_token.rb +7 -0
- data/full-examples/rest_from_scratch/part_1/config/initializers/session_store.rb +8 -0
- data/full-examples/rest_from_scratch/part_1/config/locales/en.yml +5 -0
- data/full-examples/rest_from_scratch/part_1/config/routes.rb +60 -0
- data/full-examples/rest_from_scratch/part_1/db/migrate/20100830171258_create_items.rb +14 -0
- data/full-examples/rest_from_scratch/part_1/db/schema.rb +22 -0
- data/full-examples/rest_from_scratch/part_1/db/seeds.rb +7 -0
- data/full-examples/rest_from_scratch/part_1/lib/tasks/.gitkeep +0 -0
- data/full-examples/rest_from_scratch/part_1/public/404.html +26 -0
- data/full-examples/rest_from_scratch/part_1/public/422.html +26 -0
- data/full-examples/rest_from_scratch/part_1/public/500.html +26 -0
- data/full-examples/rest_from_scratch/part_1/public/favicon.ico +0 -0
- data/full-examples/rest_from_scratch/part_1/public/images/rails.png +0 -0
- data/full-examples/rest_from_scratch/part_1/public/index.html +239 -0
- data/full-examples/rest_from_scratch/part_1/public/javascripts/application.js +2 -0
- data/full-examples/rest_from_scratch/part_1/public/javascripts/controls.js +965 -0
- data/full-examples/rest_from_scratch/part_1/public/javascripts/dragdrop.js +974 -0
- data/full-examples/rest_from_scratch/part_1/public/javascripts/effects.js +1123 -0
- data/full-examples/rest_from_scratch/part_1/public/javascripts/prototype.js +6001 -0
- data/full-examples/rest_from_scratch/part_1/public/javascripts/rails.js +175 -0
- data/full-examples/rest_from_scratch/part_1/public/robots.txt +5 -0
- data/full-examples/rest_from_scratch/part_1/public/stylesheets/.gitkeep +0 -0
- data/full-examples/rest_from_scratch/part_1/public/stylesheets/scaffold.css +56 -0
- data/full-examples/rest_from_scratch/part_1/script/rails +6 -0
- data/full-examples/rest_from_scratch/part_1/spec/items_spec.rb +31 -0
- data/full-examples/rest_from_scratch/part_1/spec/spec_helper.rb +27 -0
- data/full-examples/rest_from_scratch/part_1/test/fixtures/items.yml +9 -0
- data/full-examples/rest_from_scratch/part_1/test/functional/items_controller_test.rb +49 -0
- data/full-examples/rest_from_scratch/part_1/test/performance/browsing_test.rb +9 -0
- data/full-examples/rest_from_scratch/part_1/test/test_helper.rb +13 -0
- data/full-examples/rest_from_scratch/part_1/test/unit/helpers/items_helper_test.rb +4 -0
- data/full-examples/rest_from_scratch/part_1/test/unit/item_test.rb +8 -0
- data/full-examples/rest_from_scratch/part_1/vendor/plugins/.gitkeep +0 -0
- data/full-examples/rest_from_scratch/part_2/.gitignore +4 -0
- data/full-examples/rest_from_scratch/part_2/.rspec +1 -0
- data/full-examples/rest_from_scratch/part_2/Gemfile +34 -0
- data/full-examples/rest_from_scratch/part_2/README +256 -0
- data/full-examples/rest_from_scratch/part_2/Rakefile +7 -0
- data/full-examples/rest_from_scratch/part_2/app/controllers/application_controller.rb +3 -0
- data/full-examples/rest_from_scratch/part_2/app/controllers/baskets_controller.rb +25 -0
- data/full-examples/rest_from_scratch/part_2/app/controllers/items_controller.rb +20 -0
- data/full-examples/rest_from_scratch/part_2/app/controllers/payments_controller.rb +17 -0
- data/full-examples/rest_from_scratch/part_2/app/helpers/application_helper.rb +2 -0
- data/full-examples/rest_from_scratch/part_2/app/helpers/baskets_helper.rb +2 -0
- data/full-examples/rest_from_scratch/part_2/app/helpers/items_helper.rb +2 -0
- data/full-examples/rest_from_scratch/part_2/app/helpers/payments_helper.rb +2 -0
- data/full-examples/rest_from_scratch/part_2/app/models/basket.rb +11 -0
- data/full-examples/rest_from_scratch/part_2/app/models/item.rb +2 -0
- data/full-examples/rest_from_scratch/part_2/app/models/payment.rb +3 -0
- data/full-examples/rest_from_scratch/part_2/app/views/baskets/show.tokamak +9 -0
- data/full-examples/rest_from_scratch/part_2/app/views/items/_show.tokamak +6 -0
- data/full-examples/rest_from_scratch/part_2/app/views/items/index.tokamak +14 -0
- data/full-examples/rest_from_scratch/part_2/app/views/layouts/application.html.erb +14 -0
- data/full-examples/rest_from_scratch/part_2/autotest/discover.rb +1 -0
- data/full-examples/rest_from_scratch/part_2/config.ru +4 -0
- data/full-examples/rest_from_scratch/part_2/config/application.rb +42 -0
- data/full-examples/rest_from_scratch/part_2/config/boot.rb +13 -0
- data/full-examples/rest_from_scratch/part_2/config/database.yml +22 -0
- data/full-examples/rest_from_scratch/part_2/config/environment.rb +5 -0
- data/full-examples/rest_from_scratch/part_2/config/environments/development.rb +26 -0
- data/full-examples/rest_from_scratch/part_2/config/environments/production.rb +49 -0
- data/full-examples/rest_from_scratch/part_2/config/environments/test.rb +35 -0
- data/full-examples/rest_from_scratch/part_2/config/initializers/backtrace_silencers.rb +7 -0
- data/full-examples/rest_from_scratch/part_2/config/initializers/inflections.rb +10 -0
- data/full-examples/rest_from_scratch/part_2/config/initializers/mime_types.rb +5 -0
- data/full-examples/rest_from_scratch/part_2/config/initializers/secret_token.rb +7 -0
- data/full-examples/rest_from_scratch/part_2/config/initializers/session_store.rb +8 -0
- data/full-examples/rest_from_scratch/part_2/config/locales/en.yml +5 -0
- data/full-examples/rest_from_scratch/part_2/config/routes.rb +65 -0
- data/full-examples/rest_from_scratch/part_2/db/migrate/20100830171258_create_items.rb +16 -0
- data/full-examples/rest_from_scratch/part_2/db/migrate/20100830180139_create_baskets.rb +12 -0
- data/full-examples/rest_from_scratch/part_2/db/migrate/20100830180203_create_payments.rb +16 -0
- data/full-examples/rest_from_scratch/part_2/db/migrate/20100830185456_connect_baskets_to_items.rb +13 -0
- data/full-examples/rest_from_scratch/part_2/db/schema.rb +43 -0
- data/full-examples/rest_from_scratch/part_2/db/seeds.rb +7 -0
- data/full-examples/rest_from_scratch/part_2/lib/tasks/.gitkeep +0 -0
- data/full-examples/rest_from_scratch/part_2/public/404.html +26 -0
- data/full-examples/rest_from_scratch/part_2/public/422.html +26 -0
- data/full-examples/rest_from_scratch/part_2/public/500.html +26 -0
- data/full-examples/rest_from_scratch/part_2/public/favicon.ico +0 -0
- data/full-examples/rest_from_scratch/part_2/public/images/rails.png +0 -0
- data/full-examples/rest_from_scratch/part_2/public/index.html +239 -0
- data/full-examples/rest_from_scratch/part_2/public/javascripts/application.js +2 -0
- data/full-examples/rest_from_scratch/part_2/public/javascripts/controls.js +965 -0
- data/full-examples/rest_from_scratch/part_2/public/javascripts/dragdrop.js +974 -0
- data/full-examples/rest_from_scratch/part_2/public/javascripts/effects.js +1123 -0
- data/full-examples/rest_from_scratch/part_2/public/javascripts/prototype.js +6001 -0
- data/full-examples/rest_from_scratch/part_2/public/javascripts/rails.js +175 -0
- data/full-examples/rest_from_scratch/part_2/public/robots.txt +5 -0
- data/full-examples/rest_from_scratch/part_2/public/stylesheets/.gitkeep +0 -0
- data/full-examples/rest_from_scratch/part_2/public/stylesheets/scaffold.css +56 -0
- data/full-examples/rest_from_scratch/part_2/script/rails +6 -0
- data/full-examples/rest_from_scratch/part_2/spec/full_cycle_spec.rb +31 -0
- data/full-examples/rest_from_scratch/part_2/spec/items_spec.rb +31 -0
- data/full-examples/rest_from_scratch/part_2/spec/spec_helper.rb +27 -0
- data/full-examples/rest_from_scratch/part_2/test/fixtures/items.yml +9 -0
- data/full-examples/rest_from_scratch/part_2/test/functional/items_controller_test.rb +49 -0
- data/full-examples/rest_from_scratch/part_2/test/performance/browsing_test.rb +9 -0
- data/full-examples/rest_from_scratch/part_2/test/test_helper.rb +13 -0
- data/full-examples/rest_from_scratch/part_2/test/unit/helpers/items_helper_test.rb +4 -0
- data/full-examples/rest_from_scratch/part_2/test/unit/item_test.rb +8 -0
- data/full-examples/rest_from_scratch/part_2/vendor/plugins/.gitkeep +0 -0
- data/full-examples/rest_from_scratch/part_3/.gitignore +4 -0
- data/full-examples/rest_from_scratch/part_3/.rspec +1 -0
- data/full-examples/rest_from_scratch/part_3/Gemfile +33 -0
- data/full-examples/rest_from_scratch/part_3/README +256 -0
- data/full-examples/rest_from_scratch/part_3/Rakefile +7 -0
- data/full-examples/rest_from_scratch/part_3/app/controllers/application_controller.rb +3 -0
- data/full-examples/rest_from_scratch/part_3/app/controllers/baskets_controller.rb +34 -0
- data/full-examples/rest_from_scratch/part_3/app/controllers/items_controller.rb +20 -0
- data/full-examples/rest_from_scratch/part_3/app/controllers/payments_controller.rb +17 -0
- data/full-examples/rest_from_scratch/part_3/app/helpers/application_helper.rb +2 -0
- data/full-examples/rest_from_scratch/part_3/app/helpers/baskets_helper.rb +2 -0
- data/full-examples/rest_from_scratch/part_3/app/helpers/items_helper.rb +2 -0
- data/full-examples/rest_from_scratch/part_3/app/helpers/payments_helper.rb +2 -0
- data/full-examples/rest_from_scratch/part_3/app/models/basket.rb +11 -0
- data/full-examples/rest_from_scratch/part_3/app/models/item.rb +2 -0
- data/full-examples/rest_from_scratch/part_3/app/models/payment.rb +3 -0
- data/full-examples/rest_from_scratch/part_3/app/views/baskets/show.tokamak +9 -0
- data/full-examples/rest_from_scratch/part_3/app/views/items/_show.tokamak +6 -0
- data/full-examples/rest_from_scratch/part_3/app/views/items/index.tokamak +14 -0
- data/full-examples/rest_from_scratch/part_3/app/views/layouts/application.html.erb +14 -0
- data/full-examples/rest_from_scratch/part_3/autotest/discover.rb +1 -0
- data/full-examples/rest_from_scratch/part_3/config.ru +4 -0
- data/full-examples/rest_from_scratch/part_3/config/application.rb +42 -0
- data/full-examples/rest_from_scratch/part_3/config/boot.rb +13 -0
- data/full-examples/rest_from_scratch/part_3/config/database.yml +22 -0
- data/full-examples/rest_from_scratch/part_3/config/environment.rb +5 -0
- data/full-examples/rest_from_scratch/part_3/config/environments/development.rb +26 -0
- data/full-examples/rest_from_scratch/part_3/config/environments/production.rb +49 -0
- data/full-examples/rest_from_scratch/part_3/config/environments/test.rb +35 -0
- data/full-examples/rest_from_scratch/part_3/config/initializers/backtrace_silencers.rb +7 -0
- data/full-examples/rest_from_scratch/part_3/config/initializers/inflections.rb +10 -0
- data/full-examples/rest_from_scratch/part_3/config/initializers/mime_types.rb +5 -0
- data/full-examples/rest_from_scratch/part_3/config/initializers/secret_token.rb +7 -0
- data/full-examples/rest_from_scratch/part_3/config/initializers/session_store.rb +8 -0
- data/full-examples/rest_from_scratch/part_3/config/locales/en.yml +5 -0
- data/full-examples/rest_from_scratch/part_3/config/routes.rb +67 -0
- data/full-examples/rest_from_scratch/part_3/db/migrate/20100830171258_create_items.rb +16 -0
- data/full-examples/rest_from_scratch/part_3/db/migrate/20100830180139_create_baskets.rb +12 -0
- data/full-examples/rest_from_scratch/part_3/db/migrate/20100830180203_create_payments.rb +16 -0
- data/full-examples/rest_from_scratch/part_3/db/migrate/20100830185456_connect_baskets_to_items.rb +13 -0
- data/full-examples/rest_from_scratch/part_3/db/schema.rb +43 -0
- data/full-examples/rest_from_scratch/part_3/db/seeds.rb +7 -0
- data/full-examples/rest_from_scratch/part_3/lib/tasks/.gitkeep +0 -0
- data/full-examples/rest_from_scratch/part_3/public/404.html +26 -0
- data/full-examples/rest_from_scratch/part_3/public/422.html +26 -0
- data/full-examples/rest_from_scratch/part_3/public/500.html +26 -0
- data/full-examples/rest_from_scratch/part_3/public/favicon.ico +0 -0
- data/full-examples/rest_from_scratch/part_3/public/images/rails.png +0 -0
- data/full-examples/rest_from_scratch/part_3/public/index.html +239 -0
- data/full-examples/rest_from_scratch/part_3/public/javascripts/application.js +2 -0
- data/full-examples/rest_from_scratch/part_3/public/javascripts/controls.js +965 -0
- data/full-examples/rest_from_scratch/part_3/public/javascripts/dragdrop.js +974 -0
- data/full-examples/rest_from_scratch/part_3/public/javascripts/effects.js +1123 -0
- data/full-examples/rest_from_scratch/part_3/public/javascripts/prototype.js +6001 -0
- data/full-examples/rest_from_scratch/part_3/public/javascripts/rails.js +175 -0
- data/full-examples/rest_from_scratch/part_3/public/robots.txt +5 -0
- data/full-examples/rest_from_scratch/part_3/public/stylesheets/.gitkeep +0 -0
- data/full-examples/rest_from_scratch/part_3/public/stylesheets/scaffold.css +56 -0
- data/full-examples/rest_from_scratch/part_3/script/rails +6 -0
- data/full-examples/rest_from_scratch/part_3/spec/buying_process_spec.rb +24 -0
- data/full-examples/rest_from_scratch/part_3/spec/client/buying_process.rb +23 -0
- data/full-examples/rest_from_scratch/part_3/spec/client/scenarios/buying_process.scenario +15 -0
- data/full-examples/rest_from_scratch/part_3/spec/client/steps/buying_process.rb +56 -0
- data/full-examples/rest_from_scratch/part_3/spec/full_cycle_spec.rb +30 -0
- data/full-examples/rest_from_scratch/part_3/spec/items_spec.rb +31 -0
- data/full-examples/rest_from_scratch/part_3/spec/spec_helper.rb +27 -0
- data/full-examples/rest_from_scratch/part_3/test/fixtures/items.yml +9 -0
- data/full-examples/rest_from_scratch/part_3/test/functional/items_controller_test.rb +49 -0
- data/full-examples/rest_from_scratch/part_3/test/performance/browsing_test.rb +9 -0
- data/full-examples/rest_from_scratch/part_3/test/test_helper.rb +13 -0
- data/full-examples/rest_from_scratch/part_3/test/unit/helpers/items_helper_test.rb +4 -0
- data/full-examples/rest_from_scratch/part_3/test/unit/item_test.rb +8 -0
- data/full-examples/rest_from_scratch/part_3/vendor/plugins/.gitkeep +0 -0
- data/init.rb +1 -0
- data/lib/restfulie/client/README.textile +33 -0
- data/lib/restfulie/client/feature/fake_response.rb +13 -0
- data/lib/restfulie/client/feature/follow_request.rb +29 -11
- data/lib/restfulie/client/feature/{throw_error.rb → throw_error_request.rb} +3 -2
- data/lib/restfulie/client/feature/verb.rb +12 -19
- data/lib/restfulie/common.rb +1 -1
- data/lib/restfulie/server.rb +1 -1
- data/lib/restfulie/server/action_controller/base.rb +0 -2
- data/lib/restfulie/server/action_controller/restful_responder.rb +2 -2
- data/lib/restfulie/server/action_controller/trait/cacheable.rb +22 -9
- data/lib/restfulie/server/hypertemplate.rb +3 -0
- data/lib/restfulie/version.rb +2 -2
- data/restfulie.gemspec +42 -0
- data/script/console +8 -0
- data/site/README +1 -0
- data/site/Rakefile +10 -0
- data/site/app/controllers/application_controller.rb +11 -0
- data/site/app/controllers/java_controller.rb +53 -0
- data/site/app/controllers/javascript_controller.rb +12 -0
- data/site/app/controllers/restful_csharp_controller.rb +12 -0
- data/site/app/controllers/ruby_controller.rb +24 -0
- data/site/app/controllers/systems_controller.rb +14 -0
- data/site/app/helpers/application_helper.rb +10 -0
- data/site/app/helpers/documentation_helper.rb +2 -0
- data/site/app/views/java/features.html.erb +99 -0
- data/site/app/views/java/hypermedia.html.erb +97 -0
- data/site/app/views/java/server.html.erb +0 -0
- data/site/app/views/layouts/_blackmenu.html.erb +11 -0
- data/site/app/views/layouts/_uppermenu.html.erb +24 -0
- data/site/app/views/layouts/application.html.erb +50 -0
- data/site/app/views/layouts/java.html.erb +72 -0
- data/site/app/views/layouts/javascript.html.erb +62 -0
- data/site/app/views/layouts/restful_csharp.html.erb +81 -0
- data/site/app/views/layouts/restful_java.html.erb +87 -0
- data/site/app/views/shared/_examples.html.erb +29 -0
- data/site/app/views/shared/_negotiation.html.erb +9 -0
- data/site/app/views/shared/_simple_representation.html.erb +37 -0
- data/site/app/views/systems/features.html.erb +106 -0
- data/site/app/views/systems/index.html.erb +97 -0
- data/site/app/views/systems/support.html.erb +54 -0
- data/site/config/boot.rb +110 -0
- data/site/config/database.yml +22 -0
- data/site/config/environments/development.rb +17 -0
- data/site/config/environments/production.rb +28 -0
- data/site/config/environments/test.rb +28 -0
- data/site/config/initializers/backtrace_silencers.rb +7 -0
- data/site/config/initializers/inflections.rb +10 -0
- data/site/config/initializers/mime_types.rb +5 -0
- data/site/config/initializers/new_rails_defaults.rb +21 -0
- data/site/config/initializers/session_store.rb +15 -0
- data/site/config/locales/en.yml +5 -0
- data/site/config/routes.rb +56 -0
- data/site/db/seeds.rb +7 -0
- data/site/public/404.html +30 -0
- data/site/public/422.html +30 -0
- data/site/public/500.html +30 -0
- data/site/public/caelumobjects-restful-rails.pdf +0 -0
- data/site/public/docs.html +164 -0
- data/site/public/favicon.ico +0 -0
- data/site/public/images/bgBarHome-trans.png +0 -0
- data/site/public/images/bgHeader.png +0 -0
- data/site/public/images/bgSubMenu-trans.png +0 -0
- data/site/public/images/code_java_01.png +0 -0
- data/site/public/images/code_java_02.png +0 -0
- data/site/public/images/code_net_01.png +0 -0
- data/site/public/images/code_net_02.png +0 -0
- data/site/public/images/code_ruby_01.png +0 -0
- data/site/public/images/code_ruby_02.png +0 -0
- data/site/public/images/dependency.png +0 -0
- data/site/public/images/ldl-trans.png +0 -0
- data/site/public/images/leftBGBtn.png +0 -0
- data/site/public/images/logoCaelumGray-trans.png +0 -0
- data/site/public/images/negotiation.png +0 -0
- data/site/public/images/rails.png +0 -0
- data/site/public/images/restfulieSprites-trans.png +0 -0
- data/site/public/images/rightBGBtn.png +0 -0
- data/site/public/images/service.png +0 -0
- data/site/public/images/subMenuBottom-trans.png +0 -0
- data/site/public/images/subMenuTop-trans.png +0 -0
- data/site/public/javascripts/application.js +2 -0
- data/site/public/javascripts/controls.js +963 -0
- data/site/public/javascripts/dragdrop.js +973 -0
- data/site/public/javascripts/effects.js +1128 -0
- data/site/public/javascripts/prototype.js +4320 -0
- data/site/public/robots.txt +5 -0
- data/site/public/stylesheets/menu.css +98 -0
- data/site/public/stylesheets/screen.css +345 -0
- data/site/public/stylesheets/uppermenu.css +87 -0
- data/site/script/about +4 -0
- data/site/script/console +3 -0
- data/site/script/dbconsole +3 -0
- data/site/script/destroy +3 -0
- data/site/script/generate +3 -0
- data/site/script/performance/benchmarker +3 -0
- data/site/script/performance/profiler +3 -0
- data/site/script/plugin +3 -0
- data/site/script/runner +3 -0
- data/site/script/server +3 -0
- data/site/test/functional/documentation_controller_test.rb +8 -0
- data/site/test/performance/browsing_test.rb +9 -0
- data/site/test/test_helper.rb +38 -0
- data/site/test/unit/helpers/documentation_helper_test.rb +4 -0
- data/spec/integration/twitter.rb +945 -0
- data/spec/integration/twitter_spec.rb +24 -0
- data/spec/spec_helper.rb +4 -0
- data/spec/unit/client/base_spec.rb +9 -0
- data/spec/unit/client/cache/fake_spec.rb +23 -0
- data/spec/unit/client/cache/http_ext_spec.rb +182 -0
- data/spec/unit/client/cache/restrictions_spec.rb +24 -0
- data/spec/unit/client/configuration_spec.rb +54 -0
- data/spec/unit/client/ext/open_search_spec.rb +28 -0
- data/spec/unit/client/feature/conneg_when_unaccepted_spec.rb +45 -0
- data/spec/unit/client/feature/open_search/pattern_matcher_spec.rb +21 -0
- data/spec/unit/client/feature/rescue_exception_spec.rb +27 -0
- data/spec/unit/client/feature/retry_when_unavailable_spec.rb +38 -0
- data/spec/unit/client/feature/verb_spec.rb +37 -0
- data/spec/unit/client/http/link_header_spec.rb +43 -0
- data/spec/unit/client/mikyung/concatenator_spec.rb +14 -0
- data/spec/unit/client/mikyung/rest_process_model_spec.rb +140 -0
- data/spec/unit/client/mikyung/steady_state_walker_spec.rb +39 -0
- data/spec/unit/client/mikyung/then_condition_spec.rb +38 -0
- data/spec/unit/client/mikyung/when_condition_spec.rb +59 -0
- data/spec/unit/client/mikyung_spec.rb +72 -0
- data/spec/unit/client/stack_navigator.rb +75 -0
- data/spec/unit/common/errors_spec.rb +33 -0
- data/spec/unit/restfulie_spec.rb +30 -0
- data/spec/unit/server/action_controller/trait/cacheable_spec.rb +48 -0
- data/spec/unit/server/action_controller/trait/created_spec.rb +50 -0
- data/spec/unit/server/configuration_spec.rb +36 -0
- data/spec/unit/server/core_ext/array_spec.rb +35 -0
- data/spec/unit/server/restfulie_controller_spec.rb +110 -0
- data/spec/unit/spec_helper.rb +1 -0
- data/tests/.gitignore +5 -0
- data/tests/.rspec +1 -0
- data/tests/Gemfile +42 -0
- data/tests/README +256 -0
- data/tests/Rakefile +7 -0
- data/tests/app/controllers/albums_controller.rb +10 -0
- data/tests/app/controllers/application_controller.rb +3 -0
- data/tests/app/controllers/artists_controller.rb +12 -0
- data/tests/app/controllers/cacheable_songs_controller.rb +28 -0
- data/tests/app/controllers/projects_controller.rb +13 -0
- data/tests/app/controllers/render_controller.rb +15 -0
- data/tests/app/controllers/songs_controller.rb +2 -0
- data/tests/app/helpers/albums_helper.rb +2 -0
- data/tests/app/helpers/application_helper.rb +2 -0
- data/tests/app/helpers/artists_helper.rb +2 -0
- data/tests/app/helpers/cacheable_clients_helper.rb +2 -0
- data/tests/app/helpers/projects_helper.rb +2 -0
- data/tests/app/helpers/render_helper.rb +2 -0
- data/tests/app/helpers/songs_helper.rb +2 -0
- data/tests/app/models/album.rb +4 -0
- data/tests/app/models/artist.rb +2 -0
- data/tests/app/models/song.rb +3 -0
- data/tests/app/views/albums/_member.tokamak +11 -0
- data/tests/app/views/albums/index.tokamak +26 -0
- data/tests/app/views/albums/show.tokamak +3 -0
- data/tests/app/views/artists/_form.html.erb +25 -0
- data/tests/app/views/artists/edit.html.erb +6 -0
- data/tests/app/views/artists/index.html.erb +25 -0
- data/tests/app/views/artists/new.html.erb +5 -0
- data/tests/app/views/artists/show.html.erb +15 -0
- data/tests/app/views/cacheable_clients/collection.tokamak +0 -0
- data/tests/app/views/cacheable_clients/empty.tokamak +0 -0
- data/tests/app/views/cacheable_clients/single.tokamak +0 -0
- data/tests/app/views/layouts/application.html.erb +14 -0
- data/tests/app/views/projects/index.atom.tokamak +14 -0
- data/tests/app/views/projects/new.atom.tokamak +7 -0
- data/tests/app/views/projects/new.tokamak +0 -0
- data/tests/app/views/projects/show.tokamak +7 -0
- data/tests/autotest/discover.rb +2 -0
- data/tests/config.ru +4 -0
- data/tests/config/application.rb +42 -0
- data/tests/config/boot.rb +13 -0
- data/tests/config/database.yml +22 -0
- data/tests/config/environment.rb +5 -0
- data/tests/config/environments/development.rb +22 -0
- data/tests/config/environments/production.rb +49 -0
- data/tests/config/environments/test.rb +35 -0
- data/tests/config/initializers/backtrace_silencers.rb +7 -0
- data/tests/config/initializers/inflections.rb +10 -0
- data/tests/config/initializers/mime_types.rb +5 -0
- data/tests/config/initializers/secret_token.rb +7 -0
- data/tests/config/initializers/session_store.rb +8 -0
- data/tests/config/locales/en.yml +5 -0
- data/tests/config/routes.rb +66 -0
- data/tests/db/migrate/20100817165415_create_albums.rb +15 -0
- data/tests/db/migrate/20100817165436_create_songs.rb +16 -0
- data/tests/db/migrate/20100819165238_create_artists.rb +14 -0
- data/tests/db/schema.rb +39 -0
- data/tests/db/seeds.rb +7 -0
- data/tests/lib/tasks/.gitkeep +0 -0
- data/tests/public/404.html +26 -0
- data/tests/public/422.html +26 -0
- data/tests/public/500.html +26 -0
- data/tests/public/favicon.ico +0 -0
- data/tests/public/images/rails.png +0 -0
- data/tests/public/index.html +262 -0
- data/tests/public/javascripts/application.js +2 -0
- data/tests/public/javascripts/controls.js +965 -0
- data/tests/public/javascripts/dragdrop.js +974 -0
- data/tests/public/javascripts/effects.js +1123 -0
- data/tests/public/javascripts/prototype.js +6001 -0
- data/tests/public/javascripts/rails.js +175 -0
- data/tests/public/robots.txt +5 -0
- data/tests/public/stylesheets/.gitkeep +0 -0
- data/tests/public/stylesheets/scaffold.css +56 -0
- data/tests/script/rails +6 -0
- data/tests/spec/controllers/integration/albums_controller_spec.rb +60 -0
- data/tests/spec/controllers/integration/cacheable_songs_controller_spec.rb +43 -0
- data/tests/spec/controllers/integration/controller_base_spec.rb +35 -0
- data/tests/spec/controllers/integration/created_responder_spec.rb +35 -0
- data/tests/spec/controllers/integration/params_parser_spec.rb +150 -0
- data/tests/spec/controllers/integration/projects_controller_spec.rb +30 -0
- data/tests/spec/requests/_integration_client.txt +1 -0
- data/tests/spec/requests/base_spec.rb2 +142 -0
- data/tests/spec/requests/fake_server.rb +107 -0
- data/tests/spec/requests/http/adapter_spec.rb +105 -0
- data/tests/spec/requests/http/content_type_spec.rb +88 -0
- data/tests/spec/requests/http/errors_spec.rb +130 -0
- data/tests/spec/requests/http/history_spec.rb +56 -0
- data/tests/spec/requests/http/marshal_spec.rb2 +113 -0
- data/tests/spec/requests/http/parameters_spec.rb +12 -0
- data/tests/spec/spec.opts +5 -0
- data/tests/spec/spec_helper.rb +61 -0
- data/tests/spec/support/atoms/full.rb.txt +63 -0
- data/tests/spec/support/atoms/related_songs +30 -0
- data/tests/spec/support/atoms/song_1 +11 -0
- data/tests/spec/support/atoms/song_2 +11 -0
- data/tests/spec/support/atoms/song_3 +11 -0
- data/tests/spec/support/atoms/song_4 +11 -0
- data/tests/spec/support/atoms/songs +51 -0
- data/tests/spec/support/atoms/songs_top_ten +27 -0
- data/tests/spec/support/data_helper.rb +13 -0
- data/tests/test/performance/browsing_test.rb +9 -0
- data/tests/test/test_helper.rb +13 -0
- data/tests/vendor/plugins/.gitkeep +0 -0
- metadata +534 -97
- data/lib/restfulie/server/tokamak.rb +0 -6
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class ItemsControllerTest < ActionController::TestCase
|
4
|
+
setup do
|
5
|
+
@item = items(:one)
|
6
|
+
end
|
7
|
+
|
8
|
+
test "should get index" do
|
9
|
+
get :index
|
10
|
+
assert_response :success
|
11
|
+
assert_not_nil assigns(:items)
|
12
|
+
end
|
13
|
+
|
14
|
+
test "should get new" do
|
15
|
+
get :new
|
16
|
+
assert_response :success
|
17
|
+
end
|
18
|
+
|
19
|
+
test "should create item" do
|
20
|
+
assert_difference('Item.count') do
|
21
|
+
post :create, :item => @item.attributes
|
22
|
+
end
|
23
|
+
|
24
|
+
assert_redirected_to item_path(assigns(:item))
|
25
|
+
end
|
26
|
+
|
27
|
+
test "should show item" do
|
28
|
+
get :show, :id => @item.to_param
|
29
|
+
assert_response :success
|
30
|
+
end
|
31
|
+
|
32
|
+
test "should get edit" do
|
33
|
+
get :edit, :id => @item.to_param
|
34
|
+
assert_response :success
|
35
|
+
end
|
36
|
+
|
37
|
+
test "should update item" do
|
38
|
+
put :update, :id => @item.to_param, :item => @item.attributes
|
39
|
+
assert_redirected_to item_path(assigns(:item))
|
40
|
+
end
|
41
|
+
|
42
|
+
test "should destroy item" do
|
43
|
+
assert_difference('Item.count', -1) do
|
44
|
+
delete :destroy, :id => @item.to_param
|
45
|
+
end
|
46
|
+
|
47
|
+
assert_redirected_to items_path
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
ENV["RAILS_ENV"] = "test"
|
2
|
+
require File.expand_path('../../config/environment', __FILE__)
|
3
|
+
require 'rails/test_help'
|
4
|
+
|
5
|
+
class ActiveSupport::TestCase
|
6
|
+
# Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
|
7
|
+
#
|
8
|
+
# Note: You'll currently still have to declare fixtures explicitly in integration tests
|
9
|
+
# -- they do not yet inherit this setting
|
10
|
+
fixtures :all
|
11
|
+
|
12
|
+
# Add more helper methods to be used by all tests here...
|
13
|
+
end
|
File without changes
|
data/init.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'lib', 'restfulie')
|
@@ -0,0 +1,33 @@
|
|
1
|
+
Retrieving resources
|
2
|
+
|
3
|
+
There are 2 ways to initially access a resource:
|
4
|
+
|
5
|
+
* Directly accessing an entry point, without using any class:
|
6
|
+
|
7
|
+
<pre>
|
8
|
+
book = Restfulie.at("http://resource.entrypoint.com/book/5").as('application/atom+xml').get!
|
9
|
+
book.title #=> "Hello world!"
|
10
|
+
</pre>
|
11
|
+
|
12
|
+
With this usage, there is no need to create a class, because Restfulie will return a model which respond to each representation's attribute.
|
13
|
+
|
14
|
+
Within the REST style, clients should not expect type safety, therefore the above example is the best way to access a REST server.
|
15
|
+
|
16
|
+
* Using an existing class:
|
17
|
+
|
18
|
+
<pre>
|
19
|
+
class Book
|
20
|
+
include Restfulie::Client::Base
|
21
|
+
|
22
|
+
uses_restfulie do |config|
|
23
|
+
config.entry_point = 'http://restfulie.com/books'
|
24
|
+
config.default_headers = {
|
25
|
+
:get => { 'Accept' => 'application/atom+xml' },
|
26
|
+
:post => { 'Content-Type' => 'application/atom+xml' }
|
27
|
+
}
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
books = Book.get!
|
32
|
+
p books.length #=> 5
|
33
|
+
</pre>
|
@@ -17,24 +17,42 @@ class Restfulie::Client::Feature::FollowRequest
|
|
17
17
|
if !resp.respond_to?(:code)
|
18
18
|
return resp
|
19
19
|
end
|
20
|
-
|
21
|
-
if
|
22
|
-
|
23
|
-
resp
|
24
|
-
else
|
25
|
-
location = resp.response.headers['location'] || resp.response.headers['Location']
|
26
|
-
raise Error::AutoFollowWithoutLocationError.new(request, resp) unless location
|
27
|
-
# use the first location available
|
28
|
-
location = location[0]
|
29
|
-
Restfulie.at(location).accepts(request.headers['Accept']).get
|
30
|
-
end
|
20
|
+
|
21
|
+
if should_follow?(resp)
|
22
|
+
follow_this resp, request
|
31
23
|
else
|
32
24
|
resp
|
33
25
|
end
|
34
26
|
end
|
35
27
|
|
36
28
|
protected
|
29
|
+
|
30
|
+
def should_follow?(response)
|
31
|
+
code = response.code.to_i
|
32
|
+
if code==201 && !response.body.empty?
|
33
|
+
false
|
34
|
+
else
|
35
|
+
follow_codes.include?(code)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def follow_this(response, request)
|
40
|
+
location = extract_location(response)
|
41
|
+
req = Restfulie.at(location)
|
42
|
+
if accept = request.headers['Accept']
|
43
|
+
req.accepts(accept)
|
44
|
+
end
|
45
|
+
req.get
|
46
|
+
end
|
37
47
|
|
48
|
+
def extract_location(response)
|
49
|
+
location = response.response.headers['location'] || response.response.headers['Location']
|
50
|
+
if location.nil?
|
51
|
+
raise Restfulie::Client::HTTP::Error::AutoFollowWithoutLocationError.new(request, response)
|
52
|
+
end
|
53
|
+
location.first
|
54
|
+
end
|
55
|
+
|
38
56
|
def follow_codes
|
39
57
|
@follow_codes ||= [201,301,302,303,307]
|
40
58
|
end
|
@@ -2,12 +2,13 @@
|
|
2
2
|
#
|
3
3
|
# To use it, load it in your dsl:
|
4
4
|
# Restfulie.at("http://localhost:3000/product/2").throw_error.get
|
5
|
-
class Restfulie::Client::Feature::
|
5
|
+
class Restfulie::Client::Feature::ThrowErrorRequest
|
6
6
|
def execute(flow, request, env)
|
7
7
|
result = flow.continue(request, env)
|
8
8
|
if result.kind_of? Exception
|
9
9
|
Restfulie::Common::Logger.logger.error(result)
|
10
|
-
|
10
|
+
response = Restfulie::Client::Feature::FakeResponse.new(503, "")
|
11
|
+
raise Restfulie::Client::HTTP::Error::ServerNotAvailableError.new(request, response, result )
|
11
12
|
end
|
12
13
|
case result.response.code
|
13
14
|
when 100..299
|
@@ -56,19 +56,16 @@ module Restfulie::Client::Feature::Verb
|
|
56
56
|
# * <tt>path: '/posts'</tt>
|
57
57
|
# * <tt>headers: {'Accept' => '*/*', 'Content-Type' => 'application/atom+xml'}</tt>
|
58
58
|
def get!(params = {})
|
59
|
-
|
60
|
-
|
61
|
-
request :throw_error
|
62
|
-
request_flow
|
59
|
+
request :throw_error_request
|
60
|
+
get params
|
63
61
|
end
|
64
62
|
|
65
63
|
# HEAD HTTP verb {Error}
|
66
64
|
# * <tt>path: '/posts'</tt>
|
67
65
|
# * <tt>headers: {'Accept' => '*/*', 'Content-Type' => 'application/atom+xml'}</tt>
|
68
66
|
def head!
|
69
|
-
|
70
|
-
|
71
|
-
request_flow
|
67
|
+
request :throw_error_request
|
68
|
+
head
|
72
69
|
end
|
73
70
|
|
74
71
|
# POST HTTP verb {Error}
|
@@ -76,9 +73,8 @@ module Restfulie::Client::Feature::Verb
|
|
76
73
|
# * <tt>payload: 'some text'</tt>
|
77
74
|
# * <tt>headers: {'Accept' => '*/*', 'Content-Type' => 'application/atom+xml'}</tt>
|
78
75
|
def post!(payload, options = {:recipe => nil})
|
79
|
-
|
80
|
-
|
81
|
-
request_flow :body => payload
|
76
|
+
request :throw_error_request
|
77
|
+
post payload
|
82
78
|
end
|
83
79
|
|
84
80
|
# PATCH HTTP verb {Error}
|
@@ -86,9 +82,8 @@ module Restfulie::Client::Feature::Verb
|
|
86
82
|
# * <tt>payload: 'some text'</tt>
|
87
83
|
# * <tt>headers: {'Accept' => '*/*', 'Content-Type' => 'application/atom+xml'}</tt>
|
88
84
|
def patch!(payload)
|
89
|
-
|
90
|
-
|
91
|
-
request_flow :body => payload
|
85
|
+
request :throw_error_request
|
86
|
+
patch payload
|
92
87
|
end
|
93
88
|
|
94
89
|
# PUT HTTP verb {Error}
|
@@ -96,18 +91,16 @@ module Restfulie::Client::Feature::Verb
|
|
96
91
|
# * <tt>payload: 'some text'</tt>
|
97
92
|
# * <tt>headers: {'Accept' => '*/*', 'Content-Type' => 'application/atom+xml'}</tt>
|
98
93
|
def put!(payload)
|
99
|
-
|
100
|
-
|
101
|
-
request_flow :body => payload
|
94
|
+
request :throw_error_request
|
95
|
+
put payload
|
102
96
|
end
|
103
97
|
|
104
98
|
# DELETE HTTP verb {Error}
|
105
99
|
# * <tt>path: '/posts'</tt>
|
106
100
|
# * <tt>headers: {'Accept' => '*/*', 'Content-Type' => 'application/atom+xml'}</tt>
|
107
101
|
def delete!
|
108
|
-
|
109
|
-
|
110
|
-
request_flow
|
102
|
+
request :throw_error_request
|
103
|
+
delete
|
111
104
|
end
|
112
105
|
|
113
106
|
protected
|
data/lib/restfulie/common.rb
CHANGED
data/lib/restfulie/server.rb
CHANGED
@@ -7,8 +7,6 @@ module Restfulie
|
|
7
7
|
# Needs to require responder_legacy.rb
|
8
8
|
base.responder = Restfulie::Server::ActionController::RestfulResponder
|
9
9
|
base.extend(Restfulie::Server::ActionController::Base::ClassMethods)
|
10
|
-
# Atom representation is added by default
|
11
|
-
Restfulie::Server::ActionController::ParamsParser.register('application/atom+xml', Tokamak::Atom)
|
12
10
|
end
|
13
11
|
|
14
12
|
module ClassMethods
|
@@ -43,14 +43,11 @@ module Restfulie::Server::ActionController
|
|
43
43
|
module Trait
|
44
44
|
module Cacheable
|
45
45
|
|
46
|
-
CACHES = [::Expires.new, ::LastModifieds.new]
|
47
|
-
|
48
46
|
def to_format
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
if ::ActionController::Base.perform_caching && cached
|
47
|
+
|
48
|
+
cache_request()
|
49
|
+
|
50
|
+
if is_cached?
|
54
51
|
set_public_cache_control(headers)
|
55
52
|
controller.response.headers["Cache-Control"] = headers.join(', ')
|
56
53
|
fresh = request.fresh?(controller.response)
|
@@ -63,9 +60,25 @@ module Restfulie::Server::ActionController
|
|
63
60
|
super
|
64
61
|
end
|
65
62
|
end
|
66
|
-
|
63
|
+
|
64
|
+
def caches
|
65
|
+
[::Expires.new, ::LastModifieds.new]
|
66
|
+
end
|
67
|
+
|
68
|
+
|
67
69
|
private
|
68
|
-
|
70
|
+
|
71
|
+
def cache_request
|
72
|
+
headers = cache_control_headers
|
73
|
+
cached = caches.inject(false) do |cached, cache|
|
74
|
+
cached || cache.do_http_cache(self, headers)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def is_cached?
|
79
|
+
::ActionController::Base.perform_caching && cached
|
80
|
+
end
|
81
|
+
|
69
82
|
def set_public_cache_control(headers)
|
70
83
|
headers.delete("private")
|
71
84
|
headers.delete("no-cache")
|
data/lib/restfulie/version.rb
CHANGED
data/restfulie.gemspec
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "restfulie/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "restfulie"
|
7
|
+
s.version = Restfulie::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Guilherme Silveira, Caue Guerra, Luis Cipriani, Everton Ribeiro, George Guimaraes, Paulo Ahagon, and many more!"]
|
10
|
+
s.email = %q{guilherme.silveira@caelum.com.br}
|
11
|
+
s.homepage = %q{http://restfulie.caelumobjects.com}
|
12
|
+
s.summary = %q{Hypermedia aware resource based library in ruby (client side) and ruby on rails (server side).}
|
13
|
+
s.description = %q{restfulie}
|
14
|
+
|
15
|
+
s.rubyforge_project = "restfulie"
|
16
|
+
|
17
|
+
s.files = `git ls-files`.split("\n")
|
18
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
19
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
|
+
s.require_paths = ["lib"]
|
21
|
+
|
22
|
+
if s.respond_to? :specification_version then
|
23
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
24
|
+
s.specification_version = 3
|
25
|
+
end
|
26
|
+
|
27
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
28
|
+
s.add_runtime_dependency("nokogiri", [">= 1.4.2"])
|
29
|
+
s.add_runtime_dependency("json_pure", [">= 1.2.4"])
|
30
|
+
s.add_development_dependency("sqlite3-ruby")
|
31
|
+
else
|
32
|
+
s.add_dependency("nokogiri", [">= 1.4.2"])
|
33
|
+
s.add_dependency("json_pure", [">= 1.2.4"])
|
34
|
+
s.add_dependency("sqlite3-ruby")
|
35
|
+
end
|
36
|
+
|
37
|
+
s.add_dependency("rack-conneg")
|
38
|
+
s.add_dependency("sqlite3-ruby")
|
39
|
+
s.add_dependency('hypertemplate', "~> 1.2.0")
|
40
|
+
s.add_dependency('medie', "~> 1.0.0")
|
41
|
+
s.add_dependency('respondie', "~> 0.9.0")
|
42
|
+
end
|