resource_inclusion 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +3 -0
- data/Gemfile +9 -0
- data/Gemfile.lock +95 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +126 -0
- data/Rakefile +44 -0
- data/lib/resource_inclusion/class_methods.rb +24 -0
- data/lib/resource_inclusion/instance_methods.rb +9 -0
- data/lib/resource_inclusion/resource_include_responder.rb +10 -0
- data/lib/resource_inclusion/resource_inclusion.rb +13 -0
- data/lib/resource_inclusion/version.rb +3 -0
- data/lib/resource_inclusion.rb +4 -0
- data/resource_inclusion.gemspec +97 -0
- data/test/app/Gemfile +8 -0
- data/test/app/Gemfile.lock +88 -0
- data/test/app/Rakefile +7 -0
- data/test/app/app/controllers/application_controller.rb +4 -0
- data/test/app/app/controllers/comments_controller.rb +17 -0
- data/test/app/app/models/comment.rb +3 -0
- data/test/app/app/models/user.rb +2 -0
- data/test/app/config/application.rb +17 -0
- data/test/app/config/boot.rb +13 -0
- data/test/app/config/database.yml +17 -0
- data/test/app/config/environment.rb +5 -0
- data/test/app/config/environments/test.rb +35 -0
- data/test/app/config/routes.rb +3 -0
- data/test/app/config.ru +4 -0
- data/test/app/db/development.sqlite3 +0 -0
- data/test/app/db/migrate/20110111090943_initial_test.rb +22 -0
- data/test/app/db/test.sqlite3 +0 -0
- data/test/app/log/development.log +288 -0
- data/test/app/log/test.log +90 -0
- data/test/app/spec/controllers/comments_controller_spec.rb +53 -0
- data/test/app/spec/spec_helper.rb +27 -0
- data/test/app/spec/support/xpath_matcher.rb +108 -0
- metadata +170 -0
data/CHANGELOG
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
abstract (1.0.0)
|
5
|
+
actionmailer (3.0.3)
|
6
|
+
actionpack (= 3.0.3)
|
7
|
+
mail (~> 2.2.9)
|
8
|
+
actionpack (3.0.3)
|
9
|
+
activemodel (= 3.0.3)
|
10
|
+
activesupport (= 3.0.3)
|
11
|
+
builder (~> 2.1.2)
|
12
|
+
erubis (~> 2.6.6)
|
13
|
+
i18n (~> 0.4)
|
14
|
+
rack (~> 1.2.1)
|
15
|
+
rack-mount (~> 0.6.13)
|
16
|
+
rack-test (~> 0.5.6)
|
17
|
+
tzinfo (~> 0.3.23)
|
18
|
+
activemodel (3.0.3)
|
19
|
+
activesupport (= 3.0.3)
|
20
|
+
builder (~> 2.1.2)
|
21
|
+
i18n (~> 0.4)
|
22
|
+
activerecord (3.0.3)
|
23
|
+
activemodel (= 3.0.3)
|
24
|
+
activesupport (= 3.0.3)
|
25
|
+
arel (~> 2.0.2)
|
26
|
+
tzinfo (~> 0.3.23)
|
27
|
+
activeresource (3.0.3)
|
28
|
+
activemodel (= 3.0.3)
|
29
|
+
activesupport (= 3.0.3)
|
30
|
+
activesupport (3.0.3)
|
31
|
+
arel (2.0.6)
|
32
|
+
builder (2.1.2)
|
33
|
+
diff-lcs (1.1.2)
|
34
|
+
erubis (2.6.6)
|
35
|
+
abstract (>= 1.0.0)
|
36
|
+
git (1.2.5)
|
37
|
+
i18n (0.5.0)
|
38
|
+
jeweler (1.5.2)
|
39
|
+
bundler (~> 1.0.0)
|
40
|
+
git (>= 1.2.5)
|
41
|
+
rake
|
42
|
+
mail (2.2.14)
|
43
|
+
activesupport (>= 2.3.6)
|
44
|
+
i18n (>= 0.4.0)
|
45
|
+
mime-types (~> 1.16)
|
46
|
+
treetop (~> 1.4.8)
|
47
|
+
mime-types (1.16)
|
48
|
+
polyglot (0.3.1)
|
49
|
+
rack (1.2.1)
|
50
|
+
rack-mount (0.6.13)
|
51
|
+
rack (>= 1.0.0)
|
52
|
+
rack-test (0.5.7)
|
53
|
+
rack (>= 1.0)
|
54
|
+
rails (3.0.3)
|
55
|
+
actionmailer (= 3.0.3)
|
56
|
+
actionpack (= 3.0.3)
|
57
|
+
activerecord (= 3.0.3)
|
58
|
+
activeresource (= 3.0.3)
|
59
|
+
activesupport (= 3.0.3)
|
60
|
+
bundler (~> 1.0)
|
61
|
+
railties (= 3.0.3)
|
62
|
+
railties (3.0.3)
|
63
|
+
actionpack (= 3.0.3)
|
64
|
+
activesupport (= 3.0.3)
|
65
|
+
rake (>= 0.8.7)
|
66
|
+
thor (~> 0.14.4)
|
67
|
+
rake (0.8.7)
|
68
|
+
rspec (2.3.0)
|
69
|
+
rspec-core (~> 2.3.0)
|
70
|
+
rspec-expectations (~> 2.3.0)
|
71
|
+
rspec-mocks (~> 2.3.0)
|
72
|
+
rspec-core (2.3.0)
|
73
|
+
rspec-expectations (2.3.0)
|
74
|
+
diff-lcs (~> 1.1.2)
|
75
|
+
rspec-mocks (2.3.0)
|
76
|
+
rspec-rails (2.3.0)
|
77
|
+
actionpack (~> 3.0)
|
78
|
+
activesupport (~> 3.0)
|
79
|
+
railties (~> 3.0)
|
80
|
+
rspec (~> 2.3.0)
|
81
|
+
sqlite3-ruby (1.3.2)
|
82
|
+
thor (0.14.6)
|
83
|
+
treetop (1.4.9)
|
84
|
+
polyglot (>= 0.3.1)
|
85
|
+
tzinfo (0.3.23)
|
86
|
+
|
87
|
+
PLATFORMS
|
88
|
+
java
|
89
|
+
ruby
|
90
|
+
|
91
|
+
DEPENDENCIES
|
92
|
+
jeweler
|
93
|
+
rails (~> 3.0.1)
|
94
|
+
rspec-rails
|
95
|
+
sqlite3-ruby
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2010 John-Mason P. Shackelford
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,126 @@
|
|
1
|
+
== Resource Inclusion
|
2
|
+
|
3
|
+
Resource Inclusion uses the power of Responders in Rails 3 to enable a macro
|
4
|
+
for specifying that resources rendered as xml or json include associated
|
5
|
+
resources. This may be used in conjunction with Inherited Resources to keep your
|
6
|
+
controllers lean and mean.
|
7
|
+
|
8
|
+
Given a model such as:
|
9
|
+
|
10
|
+
create_table :users do |t|
|
11
|
+
t.string :login_id
|
12
|
+
t.string :display_name
|
13
|
+
t.string :email
|
14
|
+
end
|
15
|
+
|
16
|
+
create_table :comments do |t|
|
17
|
+
t.text :text
|
18
|
+
t.references :user
|
19
|
+
end
|
20
|
+
|
21
|
+
Our CommentsController need only have the following to include the user's
|
22
|
+
attributes:
|
23
|
+
|
24
|
+
class CommentsController < ApplicationController
|
25
|
+
|
26
|
+
inherit_resources
|
27
|
+
|
28
|
+
include_resources :user
|
29
|
+
|
30
|
+
# If you like to type, you could have written the following, but you still
|
31
|
+
# would lack the behavior for other actions which return the resources.
|
32
|
+
#
|
33
|
+
# def index
|
34
|
+
# index! do |format|
|
35
|
+
# format.xml{ render :xml => collection.to_xml( render_options ) }
|
36
|
+
# format.json{ render :json => collection.to_json( render_options ) }
|
37
|
+
# end
|
38
|
+
# end
|
39
|
+
#
|
40
|
+
# def show
|
41
|
+
# show! do |format|
|
42
|
+
# format.xml{ render :xml => resource.to_xml( render_options ) }
|
43
|
+
# format.xml{ render :json => resource.to_json( render_options ) }
|
44
|
+
# end
|
45
|
+
# end
|
46
|
+
#
|
47
|
+
# def render_options
|
48
|
+
# { :include => [:user] }
|
49
|
+
# end
|
50
|
+
#
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
Thus /comments/1.xml would render:
|
55
|
+
|
56
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
57
|
+
<comment>
|
58
|
+
<id type="integer">1</id>
|
59
|
+
<text>This is comment text.</text>
|
60
|
+
<user-id type="integer">1</user-id>
|
61
|
+
<user>
|
62
|
+
<login-id>aperson</login-id>
|
63
|
+
<display-name>A. Person</display-name>
|
64
|
+
<email>a.person@somedomain.com</email>
|
65
|
+
<id type="integer">1</id>
|
66
|
+
</user>
|
67
|
+
</comment>
|
68
|
+
|
69
|
+
The output for the json format would be analogous.
|
70
|
+
|
71
|
+
== Installation
|
72
|
+
|
73
|
+
Resource Inclusion requires Rails 3.
|
74
|
+
|
75
|
+
You can let bundler to install Resource Inclusion by adding this line to your application's Gemfile:
|
76
|
+
|
77
|
+
gem 'resource_inclusion', '0.0.1'
|
78
|
+
|
79
|
+
And then execute:
|
80
|
+
|
81
|
+
bundle install
|
82
|
+
|
83
|
+
Add resource_inclusion to your app/controllers/application_controller.rb file (or
|
84
|
+
to any of your other controllers):
|
85
|
+
|
86
|
+
class ApplicationController < ActionController::Base
|
87
|
+
|
88
|
+
resource_inclusion
|
89
|
+
|
90
|
+
end
|
91
|
+
|
92
|
+
Then use the macro to your controllers as shown above.
|
93
|
+
|
94
|
+
== Limitations
|
95
|
+
|
96
|
+
In this release of Resource Inclusion the macros support no configuration
|
97
|
+
options beyond what you can pass to serializer (#to_xml or #to_json) with the
|
98
|
+
:include option. These options will be passed to the serializer for any action
|
99
|
+
that uses ActionController#respond_with and with all formats, excluding HTML.
|
100
|
+
|
101
|
+
For more on #respond_with see:
|
102
|
+
* http://apidock.com/rails/ActionController/MimeResponds/respond_with
|
103
|
+
* http://davidwparker.com/2010/03/09/api-in-rails-respond-to-and-respond-with/
|
104
|
+
* http://railscasts.com/episodes/224-controllers-in-rails-3
|
105
|
+
|
106
|
+
Note that this plug-in has no dependency on Inherited Resources and should work
|
107
|
+
just fine without it. That said, I have not tested with in an application
|
108
|
+
which doesn't use Inherited Resources so I'll be interested in feedback from
|
109
|
+
users.
|
110
|
+
|
111
|
+
== Acknowledgments
|
112
|
+
|
113
|
+
Thanks to Jose Valim for pointing me in the right direction and his must-have
|
114
|
+
Inherit Resources plug-in. If are on Rails 3, wish to expose an REST API and are
|
115
|
+
not using this plug-in, you probably writing more code than you should be. See:
|
116
|
+
|
117
|
+
* https://github.com/josevalim/inherited_resources
|
118
|
+
|
119
|
+
== Bugs and Feedback
|
120
|
+
|
121
|
+
Feedback is welcome. If you discover any bugs or want to drop a line, file
|
122
|
+
issues on GitHub or contact me personally via GitHub.
|
123
|
+
|
124
|
+
Copyright (c) 2010 John-Mason P. Shackelford
|
125
|
+
|
126
|
+
See the attached MIT License.
|
data/Rakefile
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/testtask'
|
3
|
+
require 'rake/rdoctask'
|
4
|
+
require File.join(File.dirname(__FILE__), 'lib', 'resource_inclusion', 'version')
|
5
|
+
|
6
|
+
begin
|
7
|
+
require 'jeweler'
|
8
|
+
Jeweler::Tasks.new do |s|
|
9
|
+
s.name = "resource_inclusion"
|
10
|
+
s.version = ResourceInclusion::VERSION.dup
|
11
|
+
# s.rubyforge_project = "resource_inclusion"
|
12
|
+
s.summary = "A handy macro for including associated models in your REST APIs."
|
13
|
+
s.email = "jpshack@gmail.com"
|
14
|
+
s.homepage = "http://github.com/jpshackelford/resource_inclusion"
|
15
|
+
s.description = "Resource Inclusion allows one to specify once per controller associated resources to be included when a resource is serialized."
|
16
|
+
s.authors = ['John-Mason P. Shackelford']
|
17
|
+
s.files = FileList["*", "{lib}/**/*", "{test}/**/*"]
|
18
|
+
end
|
19
|
+
|
20
|
+
Jeweler::GemcutterTasks.new
|
21
|
+
rescue LoadError
|
22
|
+
puts "Jeweler, or one of its dependencies, is not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
|
23
|
+
end
|
24
|
+
|
25
|
+
AppDir = File.join(File.dirname(__FILE__), 'test', 'app')
|
26
|
+
|
27
|
+
desc 'Run tests for InheritedResources.'
|
28
|
+
task :test do
|
29
|
+
Dir.chdir( AppDir ) do
|
30
|
+
sh %{ bundle exec rake }
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
task :default => :test
|
35
|
+
|
36
|
+
desc 'Generate documentation for InheritedResources.'
|
37
|
+
Rake::RDocTask.new(:rdoc) do |rdoc|
|
38
|
+
rdoc.rdoc_dir = 'rdoc'
|
39
|
+
rdoc.title = 'ResourceInclusion'
|
40
|
+
rdoc.options << '--line-numbers' << '--inline-source'
|
41
|
+
rdoc.rdoc_files.include('README.rdoc')
|
42
|
+
rdoc.rdoc_files.include('MIT-LICENSE')
|
43
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
44
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module ResourceInclusion
|
2
|
+
module ClassMethods
|
3
|
+
|
4
|
+
protected
|
5
|
+
|
6
|
+
# Pass arguments to the serializer with the :include option, e.g.
|
7
|
+
# object.to_xml(:include => your_args).
|
8
|
+
def include_resource(*args)
|
9
|
+
|
10
|
+
@included_resources = args.dup.freeze
|
11
|
+
|
12
|
+
# TODO Is there a shortcut for appending a responder?
|
13
|
+
unless self.responder.include?( ResourceInclusion::ResourceIncludeResponder )
|
14
|
+
klass = Class.new( self.responder )
|
15
|
+
klass.send(:include, ResourceInclusion::ResourceIncludeResponder)
|
16
|
+
self.responder = klass
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
alias include_resources include_resource
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class ActionController::Base
|
2
|
+
|
3
|
+
# Add the #include_resource and #include_resources macros.
|
4
|
+
def self.resource_inclusion
|
5
|
+
|
6
|
+
self.class_eval do
|
7
|
+
extend ResourceInclusion::ClassMethods
|
8
|
+
include ResourceInclusion::InstanceMethods
|
9
|
+
end
|
10
|
+
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
@@ -0,0 +1,97 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{resource_inclusion}
|
8
|
+
s.version = "0.0.1"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["John-Mason P. Shackelford"]
|
12
|
+
s.date = %q{2011-01-11}
|
13
|
+
s.description = %q{Resource Inclusion allows one to specify once per controller associated resources to be included when a resource is serialized.}
|
14
|
+
s.email = %q{jpshack@gmail.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"README.rdoc"
|
17
|
+
]
|
18
|
+
s.files = [
|
19
|
+
"CHANGELOG",
|
20
|
+
"Gemfile",
|
21
|
+
"Gemfile.lock",
|
22
|
+
"MIT-LICENSE",
|
23
|
+
"README.rdoc",
|
24
|
+
"Rakefile",
|
25
|
+
"lib/resource_inclusion.rb",
|
26
|
+
"lib/resource_inclusion/class_methods.rb",
|
27
|
+
"lib/resource_inclusion/instance_methods.rb",
|
28
|
+
"lib/resource_inclusion/resource_include_responder.rb",
|
29
|
+
"lib/resource_inclusion/resource_inclusion.rb",
|
30
|
+
"lib/resource_inclusion/version.rb",
|
31
|
+
"resource_inclusion.gemspec",
|
32
|
+
"test/app/Gemfile",
|
33
|
+
"test/app/Gemfile.lock",
|
34
|
+
"test/app/Rakefile",
|
35
|
+
"test/app/app/controllers/application_controller.rb",
|
36
|
+
"test/app/app/controllers/comments_controller.rb",
|
37
|
+
"test/app/app/models/comment.rb",
|
38
|
+
"test/app/app/models/user.rb",
|
39
|
+
"test/app/config.ru",
|
40
|
+
"test/app/config/application.rb",
|
41
|
+
"test/app/config/boot.rb",
|
42
|
+
"test/app/config/database.yml",
|
43
|
+
"test/app/config/environment.rb",
|
44
|
+
"test/app/config/environments/test.rb",
|
45
|
+
"test/app/config/routes.rb",
|
46
|
+
"test/app/db/development.sqlite3",
|
47
|
+
"test/app/db/migrate/20110111090943_initial_test.rb",
|
48
|
+
"test/app/db/test.sqlite3",
|
49
|
+
"test/app/log/development.log",
|
50
|
+
"test/app/log/test.log",
|
51
|
+
"test/app/spec/controllers/comments_controller_spec.rb",
|
52
|
+
"test/app/spec/spec_helper.rb",
|
53
|
+
"test/app/spec/support/xpath_matcher.rb"
|
54
|
+
]
|
55
|
+
s.homepage = %q{http://github.com/jpshackelford/resource_inclusion}
|
56
|
+
s.require_paths = ["lib"]
|
57
|
+
s.rubygems_version = %q{1.3.7}
|
58
|
+
s.summary = %q{A handy macro for including associated models in your REST APIs.}
|
59
|
+
s.test_files = [
|
60
|
+
"test/app/app/controllers/application_controller.rb",
|
61
|
+
"test/app/app/controllers/comments_controller.rb",
|
62
|
+
"test/app/app/models/comment.rb",
|
63
|
+
"test/app/app/models/user.rb",
|
64
|
+
"test/app/config/application.rb",
|
65
|
+
"test/app/config/boot.rb",
|
66
|
+
"test/app/config/environment.rb",
|
67
|
+
"test/app/config/environments/test.rb",
|
68
|
+
"test/app/config/routes.rb",
|
69
|
+
"test/app/db/migrate/20110111090943_initial_test.rb",
|
70
|
+
"test/app/spec/controllers/comments_controller_spec.rb",
|
71
|
+
"test/app/spec/spec_helper.rb",
|
72
|
+
"test/app/spec/support/xpath_matcher.rb"
|
73
|
+
]
|
74
|
+
|
75
|
+
if s.respond_to? :specification_version then
|
76
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
77
|
+
s.specification_version = 3
|
78
|
+
|
79
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
80
|
+
s.add_runtime_dependency(%q<rails>, ["~> 3.0.1"])
|
81
|
+
s.add_development_dependency(%q<sqlite3-ruby>, [">= 0"])
|
82
|
+
s.add_development_dependency(%q<rspec-rails>, [">= 0"])
|
83
|
+
s.add_development_dependency(%q<jeweler>, [">= 0"])
|
84
|
+
else
|
85
|
+
s.add_dependency(%q<rails>, ["~> 3.0.1"])
|
86
|
+
s.add_dependency(%q<sqlite3-ruby>, [">= 0"])
|
87
|
+
s.add_dependency(%q<rspec-rails>, [">= 0"])
|
88
|
+
s.add_dependency(%q<jeweler>, [">= 0"])
|
89
|
+
end
|
90
|
+
else
|
91
|
+
s.add_dependency(%q<rails>, ["~> 3.0.1"])
|
92
|
+
s.add_dependency(%q<sqlite3-ruby>, [">= 0"])
|
93
|
+
s.add_dependency(%q<rspec-rails>, [">= 0"])
|
94
|
+
s.add_dependency(%q<jeweler>, [">= 0"])
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
data/test/app/Gemfile
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
abstract (1.0.0)
|
5
|
+
actionmailer (3.0.3)
|
6
|
+
actionpack (= 3.0.3)
|
7
|
+
mail (~> 2.2.9)
|
8
|
+
actionpack (3.0.3)
|
9
|
+
activemodel (= 3.0.3)
|
10
|
+
activesupport (= 3.0.3)
|
11
|
+
builder (~> 2.1.2)
|
12
|
+
erubis (~> 2.6.6)
|
13
|
+
i18n (~> 0.4)
|
14
|
+
rack (~> 1.2.1)
|
15
|
+
rack-mount (~> 0.6.13)
|
16
|
+
rack-test (~> 0.5.6)
|
17
|
+
tzinfo (~> 0.3.23)
|
18
|
+
activemodel (3.0.3)
|
19
|
+
activesupport (= 3.0.3)
|
20
|
+
builder (~> 2.1.2)
|
21
|
+
i18n (~> 0.4)
|
22
|
+
activerecord (3.0.3)
|
23
|
+
activemodel (= 3.0.3)
|
24
|
+
activesupport (= 3.0.3)
|
25
|
+
arel (~> 2.0.2)
|
26
|
+
tzinfo (~> 0.3.23)
|
27
|
+
activeresource (3.0.3)
|
28
|
+
activemodel (= 3.0.3)
|
29
|
+
activesupport (= 3.0.3)
|
30
|
+
activesupport (3.0.3)
|
31
|
+
arel (2.0.6)
|
32
|
+
builder (2.1.2)
|
33
|
+
diff-lcs (1.1.2)
|
34
|
+
erubis (2.6.6)
|
35
|
+
abstract (>= 1.0.0)
|
36
|
+
i18n (0.5.0)
|
37
|
+
mail (2.2.14)
|
38
|
+
activesupport (>= 2.3.6)
|
39
|
+
i18n (>= 0.4.0)
|
40
|
+
mime-types (~> 1.16)
|
41
|
+
treetop (~> 1.4.8)
|
42
|
+
mime-types (1.16)
|
43
|
+
polyglot (0.3.1)
|
44
|
+
rack (1.2.1)
|
45
|
+
rack-mount (0.6.13)
|
46
|
+
rack (>= 1.0.0)
|
47
|
+
rack-test (0.5.7)
|
48
|
+
rack (>= 1.0)
|
49
|
+
rails (3.0.3)
|
50
|
+
actionmailer (= 3.0.3)
|
51
|
+
actionpack (= 3.0.3)
|
52
|
+
activerecord (= 3.0.3)
|
53
|
+
activeresource (= 3.0.3)
|
54
|
+
activesupport (= 3.0.3)
|
55
|
+
bundler (~> 1.0)
|
56
|
+
railties (= 3.0.3)
|
57
|
+
railties (3.0.3)
|
58
|
+
actionpack (= 3.0.3)
|
59
|
+
activesupport (= 3.0.3)
|
60
|
+
rake (>= 0.8.7)
|
61
|
+
thor (~> 0.14.4)
|
62
|
+
rake (0.8.7)
|
63
|
+
rspec (2.3.0)
|
64
|
+
rspec-core (~> 2.3.0)
|
65
|
+
rspec-expectations (~> 2.3.0)
|
66
|
+
rspec-mocks (~> 2.3.0)
|
67
|
+
rspec-core (2.3.0)
|
68
|
+
rspec-expectations (2.3.0)
|
69
|
+
diff-lcs (~> 1.1.2)
|
70
|
+
rspec-mocks (2.3.0)
|
71
|
+
rspec-rails (2.3.0)
|
72
|
+
actionpack (~> 3.0)
|
73
|
+
activesupport (~> 3.0)
|
74
|
+
railties (~> 3.0)
|
75
|
+
rspec (~> 2.3.0)
|
76
|
+
sqlite3-ruby (1.3.2)
|
77
|
+
thor (0.14.6)
|
78
|
+
treetop (1.4.9)
|
79
|
+
polyglot (>= 0.3.1)
|
80
|
+
tzinfo (0.3.23)
|
81
|
+
|
82
|
+
PLATFORMS
|
83
|
+
ruby
|
84
|
+
|
85
|
+
DEPENDENCIES
|
86
|
+
rails (~> 3.0.1)
|
87
|
+
rspec-rails
|
88
|
+
sqlite3-ruby
|
data/test/app/Rakefile
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
2
|
+
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
3
|
+
|
4
|
+
require File.expand_path('../config/application', __FILE__)
|
5
|
+
require 'rake'
|
6
|
+
|
7
|
+
App::Application.load_tasks
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class CommentsController < ApplicationController
|
2
|
+
|
3
|
+
respond_to :xml, :json
|
4
|
+
|
5
|
+
include_resource :user
|
6
|
+
|
7
|
+
def index
|
8
|
+
@comments = Comment.all
|
9
|
+
respond_with(@comments)
|
10
|
+
end
|
11
|
+
|
12
|
+
def show
|
13
|
+
@comment = Comment.find(params[:id])
|
14
|
+
respond_with(@comment)
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require File.expand_path('../boot', __FILE__)
|
2
|
+
|
3
|
+
require 'rails/all'
|
4
|
+
|
5
|
+
$:.unshift File.expand_path(File.dirname(__FILE__) + '/../../../lib')
|
6
|
+
require 'resource_inclusion'
|
7
|
+
|
8
|
+
# If you have a Gemfile, require the gems listed there, including any gems
|
9
|
+
# you've limited to :test, :development, or :production.
|
10
|
+
Bundler.require(:default, Rails.env) if defined?(Bundler)
|
11
|
+
|
12
|
+
module App
|
13
|
+
class Application < Rails::Application
|
14
|
+
config.encoding = "utf-8"
|
15
|
+
config.filter_parameters += [:password]
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
|
3
|
+
# Set up gems listed in the Gemfile.
|
4
|
+
gemfile = File.expand_path('../../Gemfile', __FILE__)
|
5
|
+
begin
|
6
|
+
ENV['BUNDLE_GEMFILE'] = gemfile
|
7
|
+
require 'bundler'
|
8
|
+
Bundler.setup
|
9
|
+
rescue Bundler::GemNotFound => e
|
10
|
+
STDERR.puts e.message
|
11
|
+
STDERR.puts "Try running `bundle install`."
|
12
|
+
exit!
|
13
|
+
end if File.exist?(gemfile)
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# SQLite version 3.x
|
2
|
+
# gem install sqlite3-ruby (not necessary on OS X Leopard)
|
3
|
+
development:
|
4
|
+
adapter: sqlite3
|
5
|
+
database: db/development.sqlite3
|
6
|
+
pool: 5
|
7
|
+
timeout: 5000
|
8
|
+
|
9
|
+
# Warning: The database defined as "test" will be erased and
|
10
|
+
# re-generated from your development database when you run "rake".
|
11
|
+
# Do not set this db to the same as development or production.
|
12
|
+
test:
|
13
|
+
adapter: sqlite3
|
14
|
+
database: db/test.sqlite3
|
15
|
+
pool: 5
|
16
|
+
timeout: 5000
|
17
|
+
|