acts_as_api_sequel 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/.travis.yml +5 -0
- data/Gemfile +13 -0
- data/History.txt +108 -0
- data/README.md +126 -0
- data/Rakefile +48 -0
- data/acts_as_api.gemspec +28 -0
- data/examples/introduction/docco.css +186 -0
- data/examples/introduction/index.html +338 -0
- data/examples/introduction/index.rb +144 -0
- data/examples/introduction/layout.mustache +67 -0
- data/lib/acts_as_api.rb +46 -0
- data/lib/acts_as_api/adapters.rb +5 -0
- data/lib/acts_as_api/adapters/mongoid.rb +11 -0
- data/lib/acts_as_api/api_template.rb +139 -0
- data/lib/acts_as_api/array.rb +21 -0
- data/lib/acts_as_api/base.rb +88 -0
- data/lib/acts_as_api/config.rb +58 -0
- data/lib/acts_as_api/exceptions.rb +4 -0
- data/lib/acts_as_api/rails_renderer.rb +17 -0
- data/lib/acts_as_api/rendering.rb +95 -0
- data/lib/acts_as_api/responder.rb +39 -0
- data/lib/acts_as_api/version.rb +3 -0
- data/spec/README.md +55 -0
- data/spec/active_record_dummy/.gitignore +15 -0
- data/spec/active_record_dummy/Gemfile +16 -0
- data/spec/active_record_dummy/README.rdoc +261 -0
- data/spec/active_record_dummy/Rakefile +7 -0
- data/spec/active_record_dummy/app/assets/images/rails.png +0 -0
- data/spec/active_record_dummy/app/assets/javascripts/application.js +15 -0
- data/spec/active_record_dummy/app/assets/stylesheets/application.css +13 -0
- data/spec/active_record_dummy/app/controllers/application_controller.rb +3 -0
- data/spec/active_record_dummy/app/helpers/application_helper.rb +2 -0
- data/spec/active_record_dummy/app/mailers/.gitkeep +0 -0
- data/spec/active_record_dummy/app/models/.gitkeep +0 -0
- data/spec/active_record_dummy/app/models/profile.rb +4 -0
- data/spec/active_record_dummy/app/models/task.rb +4 -0
- data/spec/active_record_dummy/app/models/untouched.rb +2 -0
- data/spec/active_record_dummy/app/models/user.rb +186 -0
- data/spec/active_record_dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/active_record_dummy/config.ru +4 -0
- data/spec/active_record_dummy/config/application.rb +59 -0
- data/spec/active_record_dummy/config/boot.rb +6 -0
- data/spec/active_record_dummy/config/database.yml +25 -0
- data/spec/active_record_dummy/config/environment.rb +5 -0
- data/spec/active_record_dummy/config/environments/development.rb +37 -0
- data/spec/active_record_dummy/config/environments/production.rb +67 -0
- data/spec/active_record_dummy/config/environments/test.rb +37 -0
- data/spec/active_record_dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/active_record_dummy/config/initializers/generators.rb +2 -0
- data/spec/active_record_dummy/config/initializers/inflections.rb +15 -0
- data/spec/active_record_dummy/config/initializers/mime_types.rb +5 -0
- data/spec/active_record_dummy/config/initializers/secret_token.rb +7 -0
- data/spec/active_record_dummy/config/initializers/session_store.rb +8 -0
- data/spec/active_record_dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/active_record_dummy/config/locales/en.yml +5 -0
- data/spec/active_record_dummy/config/routes.rb +59 -0
- data/spec/active_record_dummy/db/migrate/20110214201640_create_tables.rb +44 -0
- data/spec/active_record_dummy/db/schema.rb +47 -0
- data/spec/active_record_dummy/db/seeds.rb +7 -0
- data/spec/active_record_dummy/doc/README_FOR_APP +2 -0
- data/spec/active_record_dummy/lib/assets/.gitkeep +0 -0
- data/spec/active_record_dummy/lib/tasks/.gitkeep +0 -0
- data/spec/active_record_dummy/log/.gitkeep +0 -0
- data/spec/active_record_dummy/public/404.html +26 -0
- data/spec/active_record_dummy/public/422.html +26 -0
- data/spec/active_record_dummy/public/500.html +25 -0
- data/spec/active_record_dummy/public/favicon.ico +0 -0
- data/spec/active_record_dummy/public/index.html +241 -0
- data/spec/active_record_dummy/public/robots.txt +5 -0
- data/spec/active_record_dummy/script/rails +6 -0
- data/spec/active_record_dummy/vendor/assets/javascripts/.gitkeep +0 -0
- data/spec/active_record_dummy/vendor/assets/stylesheets/.gitkeep +0 -0
- data/spec/active_record_dummy/vendor/plugins/.gitkeep +0 -0
- data/spec/controllers/plain_objects_controller_spec.rb +36 -0
- data/spec/controllers/respond_with_users_controller_spec.rb +142 -0
- data/spec/controllers/users_controller_spec.rb +15 -0
- data/spec/models/model_spec.rb +31 -0
- data/spec/mongoid_dummy/.gitignore +15 -0
- data/spec/mongoid_dummy/Gemfile +18 -0
- data/spec/mongoid_dummy/README.rdoc +261 -0
- data/spec/mongoid_dummy/Rakefile +7 -0
- data/spec/mongoid_dummy/app/assets/images/rails.png +0 -0
- data/spec/mongoid_dummy/app/assets/javascripts/application.js +15 -0
- data/spec/mongoid_dummy/app/assets/stylesheets/application.css +13 -0
- data/spec/mongoid_dummy/app/controllers/application_controller.rb +3 -0
- data/spec/mongoid_dummy/app/helpers/application_helper.rb +2 -0
- data/spec/mongoid_dummy/app/mailers/.gitkeep +0 -0
- data/spec/mongoid_dummy/app/models/.gitkeep +0 -0
- data/spec/mongoid_dummy/app/models/profile.rb +10 -0
- data/spec/mongoid_dummy/app/models/task.rb +12 -0
- data/spec/mongoid_dummy/app/models/untouched.rb +7 -0
- data/spec/mongoid_dummy/app/models/user.rb +48 -0
- data/spec/mongoid_dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/mongoid_dummy/config.ru +4 -0
- data/spec/mongoid_dummy/config/application.rb +65 -0
- data/spec/mongoid_dummy/config/boot.rb +6 -0
- data/spec/mongoid_dummy/config/environment.rb +5 -0
- data/spec/mongoid_dummy/config/environments/development.rb +31 -0
- data/spec/mongoid_dummy/config/environments/production.rb +64 -0
- data/spec/mongoid_dummy/config/environments/test.rb +35 -0
- data/spec/mongoid_dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/mongoid_dummy/config/initializers/generators.rb +2 -0
- data/spec/mongoid_dummy/config/initializers/include_acts_as_api.rb +3 -0
- data/spec/mongoid_dummy/config/initializers/inflections.rb +15 -0
- data/spec/mongoid_dummy/config/initializers/mime_types.rb +5 -0
- data/spec/mongoid_dummy/config/initializers/secret_token.rb +7 -0
- data/spec/mongoid_dummy/config/initializers/session_store.rb +8 -0
- data/spec/mongoid_dummy/config/initializers/wrap_parameters.rb +10 -0
- data/spec/mongoid_dummy/config/locales/en.yml +5 -0
- data/spec/mongoid_dummy/config/mongoid.yml +120 -0
- data/spec/mongoid_dummy/config/routes.rb +59 -0
- data/spec/mongoid_dummy/db/seeds.rb +7 -0
- data/spec/mongoid_dummy/doc/README_FOR_APP +2 -0
- data/spec/mongoid_dummy/lib/assets/.gitkeep +0 -0
- data/spec/mongoid_dummy/lib/tasks/.gitkeep +0 -0
- data/spec/mongoid_dummy/log/.gitkeep +0 -0
- data/spec/mongoid_dummy/public/404.html +26 -0
- data/spec/mongoid_dummy/public/422.html +26 -0
- data/spec/mongoid_dummy/public/500.html +25 -0
- data/spec/mongoid_dummy/public/favicon.ico +0 -0
- data/spec/mongoid_dummy/public/index.html +241 -0
- data/spec/mongoid_dummy/public/robots.txt +5 -0
- data/spec/mongoid_dummy/script/rails +6 -0
- data/spec/mongoid_dummy/vendor/assets/javascripts/.gitkeep +0 -0
- data/spec/mongoid_dummy/vendor/assets/stylesheets/.gitkeep +0 -0
- data/spec/mongoid_dummy/vendor/plugins/.gitkeep +0 -0
- data/spec/shared_engine/.gitignore +7 -0
- data/spec/shared_engine/Gemfile +14 -0
- data/spec/shared_engine/MIT-LICENSE +20 -0
- data/spec/shared_engine/README.rdoc +3 -0
- data/spec/shared_engine/Rakefile +29 -0
- data/spec/shared_engine/app/assets/images/shared_engine/.gitkeep +0 -0
- data/spec/shared_engine/app/assets/javascripts/shared_engine/application.js +15 -0
- data/spec/shared_engine/app/assets/stylesheets/shared_engine/application.css +13 -0
- data/spec/shared_engine/app/controllers/shared_engine/application_controller.rb +4 -0
- data/spec/shared_engine/app/controllers/shared_engine/plain_objects_controller.rb +14 -0
- data/spec/shared_engine/app/controllers/shared_engine/respond_with_users_controller.rb +64 -0
- data/spec/shared_engine/app/controllers/shared_engine/users_controller.rb +71 -0
- data/spec/shared_engine/app/helpers/shared_engine/application_helper.rb +4 -0
- data/spec/shared_engine/app/models/plain_object.rb +17 -0
- data/spec/shared_engine/app/models/user_template.rb +154 -0
- data/spec/shared_engine/app/views/layouts/shared_engine/application.html.erb +14 -0
- data/spec/shared_engine/config/routes.rb +28 -0
- data/spec/shared_engine/dummy/README.rdoc +261 -0
- data/spec/shared_engine/dummy/Rakefile +7 -0
- data/spec/shared_engine/dummy/app/assets/javascripts/application.js +15 -0
- data/spec/shared_engine/dummy/app/assets/stylesheets/application.css +13 -0
- data/spec/shared_engine/dummy/app/controllers/application_controller.rb +3 -0
- data/spec/shared_engine/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/shared_engine/dummy/app/mailers/.gitkeep +0 -0
- data/spec/shared_engine/dummy/app/models/.gitkeep +0 -0
- data/spec/shared_engine/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/shared_engine/dummy/config.ru +4 -0
- data/spec/shared_engine/dummy/config/application.rb +62 -0
- data/spec/shared_engine/dummy/config/boot.rb +10 -0
- data/spec/shared_engine/dummy/config/database.yml +25 -0
- data/spec/shared_engine/dummy/config/environment.rb +5 -0
- data/spec/shared_engine/dummy/config/environments/development.rb +37 -0
- data/spec/shared_engine/dummy/config/environments/production.rb +67 -0
- data/spec/shared_engine/dummy/config/environments/test.rb +37 -0
- data/spec/shared_engine/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/shared_engine/dummy/config/initializers/inflections.rb +15 -0
- data/spec/shared_engine/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/shared_engine/dummy/config/initializers/secret_token.rb +7 -0
- data/spec/shared_engine/dummy/config/initializers/session_store.rb +8 -0
- data/spec/shared_engine/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/shared_engine/dummy/config/locales/en.yml +5 -0
- data/spec/shared_engine/dummy/config/routes.rb +4 -0
- data/spec/shared_engine/dummy/lib/assets/.gitkeep +0 -0
- data/spec/shared_engine/dummy/log/.gitkeep +0 -0
- data/spec/shared_engine/dummy/public/404.html +26 -0
- data/spec/shared_engine/dummy/public/422.html +26 -0
- data/spec/shared_engine/dummy/public/500.html +25 -0
- data/spec/shared_engine/dummy/public/favicon.ico +0 -0
- data/spec/shared_engine/dummy/script/rails +6 -0
- data/spec/shared_engine/lib/magic/rails/engine.rb +69 -0
- data/spec/shared_engine/lib/shared_engine.rb +4 -0
- data/spec/shared_engine/lib/shared_engine/engine.rb +5 -0
- data/spec/shared_engine/lib/shared_engine/version.rb +3 -0
- data/spec/shared_engine/lib/tasks/shared_engine_tasks.rake +4 -0
- data/spec/shared_engine/script/rails +8 -0
- data/spec/shared_engine/shared_engine.gemspec +22 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +22 -0
- data/spec/support/api_test_helpers.rb +23 -0
- data/spec/support/controller_examples.rb +458 -0
- data/spec/support/it_supports.rb +3 -0
- data/spec/support/model_examples/associations.rb +272 -0
- data/spec/support/model_examples/callbacks.rb +38 -0
- data/spec/support/model_examples/closures.rb +49 -0
- data/spec/support/model_examples/conditional_if.rb +165 -0
- data/spec/support/model_examples/conditional_unless.rb +165 -0
- data/spec/support/model_examples/enabled.rb +10 -0
- data/spec/support/model_examples/extending.rb +112 -0
- data/spec/support/model_examples/methods.rb +23 -0
- data/spec/support/model_examples/options.rb +53 -0
- data/spec/support/model_examples/renaming.rb +50 -0
- data/spec/support/model_examples/simple.rb +23 -0
- data/spec/support/model_examples/sub_nodes.rb +105 -0
- data/spec/support/model_examples/undefined.rb +7 -0
- data/spec/support/model_examples/untouched.rb +13 -0
- data/spec/support/routing.rb +4 -0
- data/spec/support/simple_fixtures.rb +59 -0
- metadata +499 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 6d82a3f078dfaaf88beec7b3210cbc1b53e95b79
|
4
|
+
data.tar.gz: 0b7c7a359449a41db7a3b711dadf656a81e991b8
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c7f6a77c0be31f58b7ef7cad39c2aa7468b7b2491ce7e61b25bc7a95eac51f3d329f3a4b509003c986b6905055c2be8e90d39ff52fc7baa4b05944e66b83b72b
|
7
|
+
data.tar.gz: 1de3320e5dccc7b079b27805a0efb2b4fd3d0e680ef7b9bd5f13b0e88a7a81348449070089e0bf1907f79671616054b9eedff8098d5dfc0f09542b30cf0844d1
|
data/.gitignore
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
nbproject/
|
2
|
+
pkg/*
|
3
|
+
.bundle
|
4
|
+
Gemfile.lock
|
5
|
+
test
|
6
|
+
acts_as_api.tmproj
|
7
|
+
spec/active_record_dummy/db/*.sqlite3
|
8
|
+
spec/active_record_dummy/tmp/**/*
|
9
|
+
spec/active_record_dummy/log/*.log
|
10
|
+
spec/mongoid_dummy/tmp/**/*
|
11
|
+
spec/mongoid_dummy/log/*.log
|
12
|
+
.rspec
|
13
|
+
.rvmrc
|
14
|
+
*.sqlite3-journal
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
|
3
|
+
# Specify your gem's dependencies in acts_as_api.gemspec
|
4
|
+
gemspec
|
5
|
+
|
6
|
+
group :test do
|
7
|
+
gem 'sqlite3-ruby'
|
8
|
+
gem 'mongoid', '>= 3.0.1'
|
9
|
+
gem 'rspec', '>= 2.9.0'
|
10
|
+
gem 'rspec-rails', '>= 2.5.0'
|
11
|
+
gem 'webrat'
|
12
|
+
gem 'shared_engine', :path => './spec/shared_engine'
|
13
|
+
end
|
data/History.txt
ADDED
@@ -0,0 +1,108 @@
|
|
1
|
+
=== 0.4.2 2013-12-28
|
2
|
+
|
3
|
+
* Fixed problem with rendering of POROs (see PR #88)
|
4
|
+
|
5
|
+
=== 0.4.1 2012-07-18
|
6
|
+
|
7
|
+
* Added support for Mongoid 3
|
8
|
+
|
9
|
+
=== 0.4 2012-04-30
|
10
|
+
|
11
|
+
* Added support for a second parameter (options) to pass to as_api_response
|
12
|
+
|
13
|
+
=== 0.3.11 2011-11-06
|
14
|
+
|
15
|
+
* Added :postfix, :prefix options for template rendering
|
16
|
+
|
17
|
+
=== 0.3.10 2011-10-03
|
18
|
+
|
19
|
+
* Fixed Mongoid problems, when no ActiveRecord is available (Ticket #36)
|
20
|
+
|
21
|
+
=== 0.3.9 2011-09-24
|
22
|
+
|
23
|
+
* Spec suite now running on Rails 3.1
|
24
|
+
* Fixed naming issue with ActiveRecord::Relation (Ticket #35)
|
25
|
+
|
26
|
+
=== 0.3.8 2011-06-21
|
27
|
+
|
28
|
+
* Fixed Rails 3.1 deprecation warning
|
29
|
+
|
30
|
+
=== 0.3.7 2011-06-13
|
31
|
+
|
32
|
+
* Added before/around/after callbacks
|
33
|
+
|
34
|
+
=== 0.3.6 2011-05-13
|
35
|
+
|
36
|
+
* Finally added Mongoid Support out of the box
|
37
|
+
* Support for Rails 3 Responders
|
38
|
+
|
39
|
+
=== 0.3.4 2011-04-26
|
40
|
+
|
41
|
+
* Fixed a bug concerning the inheritance of sub templates/additional options
|
42
|
+
|
43
|
+
=== 0.3.3 2011-04-24
|
44
|
+
|
45
|
+
* Added support for :if and :unless options
|
46
|
+
|
47
|
+
=== 0.3.2 2011-04-20
|
48
|
+
|
49
|
+
* Raise an exception if a specified api template is not found
|
50
|
+
|
51
|
+
=== 0.3.1 2011-04-08
|
52
|
+
|
53
|
+
* Added the :template option to specify sub templates
|
54
|
+
|
55
|
+
* Fixed a bug concerning extended api templates
|
56
|
+
|
57
|
+
=== 0.3.0 2011-02-22
|
58
|
+
|
59
|
+
* Added bundler support
|
60
|
+
|
61
|
+
* Added mongoid support
|
62
|
+
|
63
|
+
* Removed lots of unnecessary dependencies esp. ActiveRecord
|
64
|
+
|
65
|
+
=== 0.2.2 2010-10-21
|
66
|
+
|
67
|
+
* Version bump only for changing the github account in the docs.
|
68
|
+
|
69
|
+
=== 0.2.1 2010-09-20
|
70
|
+
|
71
|
+
* Updated to work with Rails 3.0.0
|
72
|
+
|
73
|
+
* Added support for multiple renderings of the same model (e.g. useful for versioning).
|
74
|
+
Note that the interface of acts as api changed, soyou have to update your code.
|
75
|
+
|
76
|
+
* Updated dependecies to user Rails 3.0.0 libs instead of beta.
|
77
|
+
|
78
|
+
=== 0.1.10 2010-07-23
|
79
|
+
|
80
|
+
* More Bugfixes. When you want to render an Array of records (e.g. from MyRecord.all)
|
81
|
+
make sure you pass the :root options to render_as_api - in case it will return an empty array
|
82
|
+
|
83
|
+
=== 0.1.7 2010-07-05
|
84
|
+
|
85
|
+
* Fixed bug with multi-word models.
|
86
|
+
|
87
|
+
=== 0.1.4 2010-07-04
|
88
|
+
|
89
|
+
* Added better documentation.
|
90
|
+
|
91
|
+
=== 0.1.3 2010-07-04
|
92
|
+
|
93
|
+
* Support for including methods of associated models.
|
94
|
+
* Better root name determination for arrays.
|
95
|
+
|
96
|
+
=== 0.0.3 2010-07-01
|
97
|
+
|
98
|
+
* 1 small bugfix
|
99
|
+
|
100
|
+
=== 0.0.2 2010-07-01
|
101
|
+
|
102
|
+
* 1 major enhancement:
|
103
|
+
* Added a wrapping root node for JSON responses by default.
|
104
|
+
|
105
|
+
=== 0.0.1 2010-06-27
|
106
|
+
|
107
|
+
* 1 major enhancement:
|
108
|
+
* Initial release
|
data/README.md
ADDED
@@ -0,0 +1,126 @@
|
|
1
|
+
# acts_as_api ![acts_as_api on travis ci](https://secure.travis-ci.org/fabrik42/acts_as_api.png?branch=master)
|
2
|
+
|
3
|
+
acts_as_api makes creating XML/JSON responses in Rails 3 easy and fun.
|
4
|
+
|
5
|
+
It provides a simple interface to determine the representation of your model data, that should be rendered in your API responses.
|
6
|
+
|
7
|
+
In addition to Rails it theoretically can be used with any ruby app and any database (__ActiveRecord__ and __Mongoid__ are supported out of the box) as it only has few dependencies.
|
8
|
+
|
9
|
+
The lib is _very_ fast in generating your responses and battle tested in production with platforms like [Diaspora](https://joindiaspora.com) or [flinc](https://flinc.org).
|
10
|
+
|
11
|
+
## Introduction
|
12
|
+
|
13
|
+
acts_as_api enriches the models and controllers of your app in a Rails-like way so you can easily determine how your API responses should look like:
|
14
|
+
|
15
|
+
```ruby
|
16
|
+
class User < ActiveRecord::Base
|
17
|
+
|
18
|
+
acts_as_api
|
19
|
+
|
20
|
+
api_accessible :public do |template|
|
21
|
+
template.add :first_name
|
22
|
+
template.add :age
|
23
|
+
end
|
24
|
+
# will render json: { "user": { "first_name": "John", "age": 26 } }
|
25
|
+
|
26
|
+
api_accessible :private, :extend => :public do |template|
|
27
|
+
template.add :last_name
|
28
|
+
template.add :email
|
29
|
+
end
|
30
|
+
# will render json: { "user": { "first_name": "John", "last_name": "Doe", "age": 26, "email": "john@example.org" } }
|
31
|
+
|
32
|
+
end
|
33
|
+
```
|
34
|
+
|
35
|
+
## Getting started
|
36
|
+
|
37
|
+
A nice introduction about acts_as_api with examples can be found here:
|
38
|
+
|
39
|
+
http://fabrik42.github.com/acts_as_api
|
40
|
+
|
41
|
+
See the Wiki for a lot of usage examples and features:
|
42
|
+
|
43
|
+
https://github.com/fabrik42/acts_as_api/wiki
|
44
|
+
|
45
|
+
There are a lot of how-tos like:
|
46
|
+
|
47
|
+
* [Extending existing api templates](https://github.com/fabrik42/acts_as_api/wiki/Extending-an-existing-api-template)
|
48
|
+
* [Include attributes and all other kinds of methods of your model](https://github.com/fabrik42/acts_as_api/wiki/Calling-a-method-of-the-model)
|
49
|
+
* [Include child associations (if they also act_as_api this will be considered)](https://github.com/fabrik42/acts_as_api/wiki/Including-a-child-association)
|
50
|
+
* [Rename attributes, methods, associations](https://github.com/fabrik42/acts_as_api/wiki/Renaming-an-attribute)
|
51
|
+
* [Keep your API templates out of your models](https://github.com/fabrik42/acts_as_api/wiki/Keep-your-api-templates-out-of-your-models)
|
52
|
+
* [and much more...](https://github.com/fabrik42/acts_as_api/wiki)
|
53
|
+
|
54
|
+
## Features:
|
55
|
+
|
56
|
+
* DRY templates for your api responses
|
57
|
+
* Ships with support for __ActiveRecord__ and __Mongoid__
|
58
|
+
* Support for Rails 3 Responders
|
59
|
+
* Plays very well together with client libs like [Backbone.js](http://documentcloud.github.com/backbone), [RestKit](http://restkit.org) (iOS) or [gson](http://code.google.com/p/google-gson) (Android).
|
60
|
+
* Easy but very flexible syntax for defining the templates
|
61
|
+
* XML, JSON and JSON-P support out of the box, easy to extend
|
62
|
+
* Minimal dependecies (you can also use it without Rails)
|
63
|
+
* Supports multiple api rendering templates per model. This is especially useful for API versioning or for example for private vs. public access points to a user’s profile.
|
64
|
+
|
65
|
+
### Requirements:
|
66
|
+
|
67
|
+
* ActiveModel (>= 3.0.0)
|
68
|
+
* ActiveSupport (>= 3.0.0)
|
69
|
+
* Rack (>= 1.1.0)
|
70
|
+
|
71
|
+
### Links
|
72
|
+
|
73
|
+
* Introduction: http://fabrik42.github.com/acts_as_api
|
74
|
+
|
75
|
+
* Docs: http://rdoc.info/projects/fabrik42/acts_as_api
|
76
|
+
|
77
|
+
* Found a bug? http://github.com/fabrik42/acts_as_api/issues
|
78
|
+
|
79
|
+
* Wiki: https://github.com/fabrik42/acts_as_api/wiki
|
80
|
+
|
81
|
+
* Want to contribute - the spec suite is explained here: https://github.com/fabrik42/acts_as_api/tree/master/spec
|
82
|
+
|
83
|
+
### Travis CI build status ![acts_as_api on travis ci](https://secure.travis-ci.org/fabrik42/acts_as_api.png?branch=master)
|
84
|
+
|
85
|
+
Specs run with 1.9.3: http://travis-ci.org/#!/fabrik42/acts_as_api
|
86
|
+
|
87
|
+
### Tested with:
|
88
|
+
|
89
|
+
It has been used in production with the following ruby versions.
|
90
|
+
|
91
|
+
They are not integrated in Travis, because optional dependencies (like Mongoid 3) don't support these Ruby versions.
|
92
|
+
|
93
|
+
* MRI 1.9.3-p125
|
94
|
+
* MRI 1.9.2-p290
|
95
|
+
* MRI 1.8.7-p358
|
96
|
+
* But it just should work fine with other versions too... :)
|
97
|
+
|
98
|
+
### Downwards Compatibility
|
99
|
+
|
100
|
+
Note that upgrading to 0.3.0 will break code that worked with previous versions due to a complete overhaul of the lib.
|
101
|
+
For a legacy version of this readme file look here: https://github.com/fabrik42/acts_as_api/wiki/legacy-acts_as_api-0.2-readme
|
102
|
+
|
103
|
+
### LICENSE:
|
104
|
+
|
105
|
+
(The MIT License)
|
106
|
+
|
107
|
+
Copyright (c) 2010 Christian Bäuerlein
|
108
|
+
|
109
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
110
|
+
a copy of this software and associated documentation files (the
|
111
|
+
'Software'), to deal in the Software without restriction, including
|
112
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
113
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
114
|
+
permit persons to whom the Software is furnished to do so, subject to
|
115
|
+
the following conditions:
|
116
|
+
|
117
|
+
The above copyright notice and this permission notice shall be
|
118
|
+
included in all copies or substantial portions of the Software.
|
119
|
+
|
120
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
121
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
122
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
123
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
124
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
125
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
126
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'bundler'
|
2
|
+
require 'rspec/core'
|
3
|
+
require 'rspec/core/rake_task'
|
4
|
+
|
5
|
+
Bundler::GemHelper.install_tasks
|
6
|
+
|
7
|
+
RSpec::Core::RakeTask.new
|
8
|
+
|
9
|
+
namespace :spec do
|
10
|
+
|
11
|
+
supported_orms = %w(mongoid active_record)
|
12
|
+
|
13
|
+
supported_orms.each do |orm|
|
14
|
+
desc "Run #{orm} specs only"
|
15
|
+
RSpec::Core::RakeTask.new(orm) do |t|
|
16
|
+
t.rspec_opts = ["--color"]
|
17
|
+
end
|
18
|
+
|
19
|
+
task "prepare_#{orm}" do
|
20
|
+
ENV['ACTS_AS_API_ORM'] = orm
|
21
|
+
end
|
22
|
+
|
23
|
+
Rake::Task["spec:#{orm}"].prerequisites << "spec:prepare_#{orm}"
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
# task :all => supported_orms.map{|orm| "spec:#{orm}"}
|
28
|
+
|
29
|
+
desc "Runs specs for all ORMs (#{supported_orms.join(', ')})"
|
30
|
+
task :all do
|
31
|
+
supported_orms.each do |orm|
|
32
|
+
puts "Starting to run specs for #{orm}..."
|
33
|
+
system("bundle exec rake spec:#{orm}")
|
34
|
+
raise "#{orm} failed!" unless $?.exitstatus == 0
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
|
41
|
+
gemspec = Gem::Specification.load("acts_as_api.gemspec")
|
42
|
+
|
43
|
+
task :default => "spec:all"
|
44
|
+
|
45
|
+
desc "Generate the gh_pages site"
|
46
|
+
task :rocco do
|
47
|
+
system "bundle exec rocco examples/introduction/index.rb -t examples/introduction/layout.mustache"
|
48
|
+
end
|
data/acts_as_api.gemspec
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "acts_as_api/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "acts_as_api_sequel"
|
7
|
+
s.version = ActsAsApi::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Roupen Mouradian"]
|
10
|
+
s.email = ["roupen.mouradian@gmail.com"]
|
11
|
+
s.homepage = "https://github.com/roupen/acts_as_api"
|
12
|
+
s.summary = %q{Original acts_as_api library by Christian Bäuerlein with sequel}
|
13
|
+
s.description = %q{acts_as_api library adjusted to support sequel models}
|
14
|
+
|
15
|
+
s.add_dependency('activemodel','>= 3.0.0')
|
16
|
+
s.add_dependency('activesupport','>= 3.0.0')
|
17
|
+
s.add_dependency('rack','>= 1.1.0')
|
18
|
+
|
19
|
+
s.add_development_dependency('rails', ['>= 3.2.16'])
|
20
|
+
s.add_development_dependency('mongoid', ['>= 3.0.1'])
|
21
|
+
|
22
|
+
s.rdoc_options = ['--charset=UTF-8']
|
23
|
+
|
24
|
+
s.files = `git ls-files`.split("\n")
|
25
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
26
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
27
|
+
s.require_paths = ["lib"]
|
28
|
+
end
|
@@ -0,0 +1,186 @@
|
|
1
|
+
/*--------------------- Layout and Typography ----------------------------*/
|
2
|
+
body {
|
3
|
+
font-family: 'Palatino Linotype', 'Book Antiqua', Palatino, FreeSerif, serif;
|
4
|
+
font-size: 15px;
|
5
|
+
line-height: 22px;
|
6
|
+
color: #252519;
|
7
|
+
margin: 0; padding: 0;
|
8
|
+
}
|
9
|
+
a {
|
10
|
+
color: #261a3b;
|
11
|
+
}
|
12
|
+
a:visited {
|
13
|
+
color: #261a3b;
|
14
|
+
}
|
15
|
+
p {
|
16
|
+
margin: 0 0 15px 0;
|
17
|
+
}
|
18
|
+
h1, h2, h3, h4, h5, h6 {
|
19
|
+
margin: 0px 0 15px 0;
|
20
|
+
}
|
21
|
+
h1 {
|
22
|
+
margin-top: 40px;
|
23
|
+
}
|
24
|
+
#container {
|
25
|
+
position: relative;
|
26
|
+
}
|
27
|
+
#background {
|
28
|
+
position: fixed;
|
29
|
+
top: 0; left: 525px; right: 0; bottom: 0;
|
30
|
+
background: #f5f5ff;
|
31
|
+
border-left: 1px solid #e5e5ee;
|
32
|
+
z-index: -1;
|
33
|
+
}
|
34
|
+
#jump_to, #jump_page {
|
35
|
+
background: white;
|
36
|
+
-webkit-box-shadow: 0 0 25px #777; -moz-box-shadow: 0 0 25px #777;
|
37
|
+
-webkit-border-bottom-left-radius: 5px; -moz-border-radius-bottomleft: 5px;
|
38
|
+
font: 10px Arial;
|
39
|
+
text-transform: uppercase;
|
40
|
+
cursor: pointer;
|
41
|
+
text-align: right;
|
42
|
+
}
|
43
|
+
#jump_to, #jump_wrapper {
|
44
|
+
position: fixed;
|
45
|
+
right: 0; top: 0;
|
46
|
+
padding: 5px 10px;
|
47
|
+
}
|
48
|
+
#jump_wrapper {
|
49
|
+
padding: 0;
|
50
|
+
display: none;
|
51
|
+
}
|
52
|
+
#jump_to:hover #jump_wrapper {
|
53
|
+
display: block;
|
54
|
+
}
|
55
|
+
#jump_page {
|
56
|
+
padding: 5px 0 3px;
|
57
|
+
margin: 0 0 25px 25px;
|
58
|
+
}
|
59
|
+
#jump_page .source {
|
60
|
+
display: block;
|
61
|
+
padding: 5px 10px;
|
62
|
+
text-decoration: none;
|
63
|
+
border-top: 1px solid #eee;
|
64
|
+
}
|
65
|
+
#jump_page .source:hover {
|
66
|
+
background: #f5f5ff;
|
67
|
+
}
|
68
|
+
#jump_page .source:first-child {
|
69
|
+
}
|
70
|
+
table td {
|
71
|
+
border: 0;
|
72
|
+
outline: 0;
|
73
|
+
}
|
74
|
+
td.docs, th.docs {
|
75
|
+
max-width: 450px;
|
76
|
+
min-width: 450px;
|
77
|
+
min-height: 5px;
|
78
|
+
padding: 10px 25px 1px 50px;
|
79
|
+
overflow-x: hidden;
|
80
|
+
vertical-align: top;
|
81
|
+
text-align: left;
|
82
|
+
}
|
83
|
+
.docs pre {
|
84
|
+
margin: 15px 0 15px;
|
85
|
+
padding-left: 15px;
|
86
|
+
}
|
87
|
+
.docs p tt, .docs p code {
|
88
|
+
background: #f8f8ff;
|
89
|
+
border: 1px solid #dedede;
|
90
|
+
font-size: 12px;
|
91
|
+
padding: 0 0.2em;
|
92
|
+
}
|
93
|
+
.pilwrap {
|
94
|
+
position: relative;
|
95
|
+
}
|
96
|
+
.pilcrow {
|
97
|
+
font: 12px Arial;
|
98
|
+
text-decoration: none;
|
99
|
+
color: #454545;
|
100
|
+
position: absolute;
|
101
|
+
top: 3px; left: -20px;
|
102
|
+
padding: 1px 2px;
|
103
|
+
opacity: 0;
|
104
|
+
-webkit-transition: opacity 0.2s linear;
|
105
|
+
}
|
106
|
+
td.docs:hover .pilcrow {
|
107
|
+
opacity: 1;
|
108
|
+
}
|
109
|
+
td.code, th.code {
|
110
|
+
padding: 14px 15px 16px 25px;
|
111
|
+
width: 100%;
|
112
|
+
vertical-align: top;
|
113
|
+
background: #f5f5ff;
|
114
|
+
border-left: 1px solid #e5e5ee;
|
115
|
+
}
|
116
|
+
pre, tt, code {
|
117
|
+
font-size: 12px; line-height: 18px;
|
118
|
+
font-family: Monaco, Consolas, "Lucida Console", monospace;
|
119
|
+
margin: 0; padding: 0;
|
120
|
+
}
|
121
|
+
|
122
|
+
|
123
|
+
/*---------------------- Syntax Highlighting -----------------------------*/
|
124
|
+
td.linenos { background-color: #f0f0f0; padding-right: 10px; }
|
125
|
+
span.lineno { background-color: #f0f0f0; padding: 0 5px 0 5px; }
|
126
|
+
body .hll { background-color: #ffffcc }
|
127
|
+
body .c { color: #408080; font-style: italic } /* Comment */
|
128
|
+
body .err { border: 1px solid #FF0000 } /* Error */
|
129
|
+
body .k { color: #954121 } /* Keyword */
|
130
|
+
body .o { color: #666666 } /* Operator */
|
131
|
+
body .cm { color: #408080; font-style: italic } /* Comment.Multiline */
|
132
|
+
body .cp { color: #BC7A00 } /* Comment.Preproc */
|
133
|
+
body .c1 { color: #408080; font-style: italic } /* Comment.Single */
|
134
|
+
body .cs { color: #408080; font-style: italic } /* Comment.Special */
|
135
|
+
body .gd { color: #A00000 } /* Generic.Deleted */
|
136
|
+
body .ge { font-style: italic } /* Generic.Emph */
|
137
|
+
body .gr { color: #FF0000 } /* Generic.Error */
|
138
|
+
body .gh { color: #000080; font-weight: bold } /* Generic.Heading */
|
139
|
+
body .gi { color: #00A000 } /* Generic.Inserted */
|
140
|
+
body .go { color: #808080 } /* Generic.Output */
|
141
|
+
body .gp { color: #000080; font-weight: bold } /* Generic.Prompt */
|
142
|
+
body .gs { font-weight: bold } /* Generic.Strong */
|
143
|
+
body .gu { color: #800080; font-weight: bold } /* Generic.Subheading */
|
144
|
+
body .gt { color: #0040D0 } /* Generic.Traceback */
|
145
|
+
body .kc { color: #954121 } /* Keyword.Constant */
|
146
|
+
body .kd { color: #954121; font-weight: bold } /* Keyword.Declaration */
|
147
|
+
body .kn { color: #954121; font-weight: bold } /* Keyword.Namespace */
|
148
|
+
body .kp { color: #954121 } /* Keyword.Pseudo */
|
149
|
+
body .kr { color: #954121; font-weight: bold } /* Keyword.Reserved */
|
150
|
+
body .kt { color: #B00040 } /* Keyword.Type */
|
151
|
+
body .m { color: #666666 } /* Literal.Number */
|
152
|
+
body .s { color: #219161 } /* Literal.String */
|
153
|
+
body .na { color: #7D9029 } /* Name.Attribute */
|
154
|
+
body .nb { color: #954121 } /* Name.Builtin */
|
155
|
+
body .nc { color: #0000FF; font-weight: bold } /* Name.Class */
|
156
|
+
body .no { color: #880000 } /* Name.Constant */
|
157
|
+
body .nd { color: #AA22FF } /* Name.Decorator */
|
158
|
+
body .ni { color: #999999; font-weight: bold } /* Name.Entity */
|
159
|
+
body .ne { color: #D2413A; font-weight: bold } /* Name.Exception */
|
160
|
+
body .nf { color: #0000FF } /* Name.Function */
|
161
|
+
body .nl { color: #A0A000 } /* Name.Label */
|
162
|
+
body .nn { color: #0000FF; font-weight: bold } /* Name.Namespace */
|
163
|
+
body .nt { color: #954121; font-weight: bold } /* Name.Tag */
|
164
|
+
body .nv { color: #19469D } /* Name.Variable */
|
165
|
+
body .ow { color: #AA22FF; font-weight: bold } /* Operator.Word */
|
166
|
+
body .w { color: #bbbbbb } /* Text.Whitespace */
|
167
|
+
body .mf { color: #666666 } /* Literal.Number.Float */
|
168
|
+
body .mh { color: #666666 } /* Literal.Number.Hex */
|
169
|
+
body .mi { color: #666666 } /* Literal.Number.Integer */
|
170
|
+
body .mo { color: #666666 } /* Literal.Number.Oct */
|
171
|
+
body .sb { color: #219161 } /* Literal.String.Backtick */
|
172
|
+
body .sc { color: #219161 } /* Literal.String.Char */
|
173
|
+
body .sd { color: #219161; font-style: italic } /* Literal.String.Doc */
|
174
|
+
body .s2 { color: #219161 } /* Literal.String.Double */
|
175
|
+
body .se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */
|
176
|
+
body .sh { color: #219161 } /* Literal.String.Heredoc */
|
177
|
+
body .si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */
|
178
|
+
body .sx { color: #954121 } /* Literal.String.Other */
|
179
|
+
body .sr { color: #BB6688 } /* Literal.String.Regex */
|
180
|
+
body .s1 { color: #219161 } /* Literal.String.Single */
|
181
|
+
body .ss { color: #19469D } /* Literal.String.Symbol */
|
182
|
+
body .bp { color: #954121 } /* Name.Builtin.Pseudo */
|
183
|
+
body .vc { color: #19469D } /* Name.Variable.Class */
|
184
|
+
body .vg { color: #19469D } /* Name.Variable.Global */
|
185
|
+
body .vi { color: #19469D } /* Name.Variable.Instance */
|
186
|
+
body .il { color: #666666 } /* Literal.Number.Integer.Long */
|