acts_as_api 0.2.2 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +10 -0
- data/Gemfile +12 -0
- data/History.txt +8 -0
- data/README.rdoc +29 -225
- data/Rakefile +20 -28
- data/acts_as_api.gemspec +31 -0
- data/examples/introduction/docco.css +186 -0
- data/examples/introduction/index.html +340 -0
- data/examples/introduction/index.rb +132 -0
- data/examples/introduction/layout.mustache +64 -0
- data/lib/acts_as_api.rb +11 -25
- data/lib/acts_as_api/api_template.rb +14 -0
- data/lib/acts_as_api/base.rb +61 -56
- data/lib/acts_as_api/config.rb +34 -0
- data/lib/acts_as_api/rails_renderer.rb +15 -0
- data/lib/acts_as_api/rendering.rb +11 -8
- data/lib/acts_as_api/version.rb +4 -0
- data/spec/controllers/respond_with_users_controller_spec.rb +5 -0
- data/spec/controllers/users_controller_spec.rb +161 -0
- data/spec/models/base_spec.rb +437 -0
- data/spec/rails_app/.gitignore +4 -0
- data/spec/rails_app/Rakefile +7 -0
- data/spec/rails_app/app/controllers/application_controller.rb +3 -0
- data/spec/rails_app/app/controllers/respond_with_users_controller.rb +15 -0
- data/spec/rails_app/app/controllers/users_controller.rb +21 -0
- data/spec/rails_app/app/helpers/application_helper.rb +2 -0
- data/spec/rails_app/app/models/task.rb +3 -0
- data/spec/rails_app/app/models/untouched.rb +2 -0
- data/spec/rails_app/app/models/user.rb +69 -0
- data/spec/rails_app/app/views/layouts/application.html.erb +14 -0
- data/spec/rails_app/config.ru +4 -0
- data/spec/rails_app/config/application.rb +42 -0
- data/spec/rails_app/config/boot.rb +6 -0
- data/spec/rails_app/config/database.yml +23 -0
- data/spec/rails_app/config/environment.rb +5 -0
- data/spec/rails_app/config/environments/development.rb +26 -0
- data/spec/rails_app/config/environments/production.rb +49 -0
- data/spec/rails_app/config/environments/test.rb +35 -0
- data/spec/rails_app/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/rails_app/config/initializers/inflections.rb +10 -0
- data/spec/rails_app/config/initializers/mime_types.rb +5 -0
- data/spec/rails_app/config/initializers/secret_token.rb +7 -0
- data/spec/rails_app/config/initializers/session_store.rb +8 -0
- data/spec/rails_app/config/locales/en.yml +5 -0
- data/spec/rails_app/config/routes.rb +7 -0
- data/spec/rails_app/db/migrate/20110214201640_create_tables.rb +35 -0
- data/spec/rails_app/db/schema.rb +34 -0
- data/spec/rails_app/db/seeds.rb +7 -0
- data/spec/rails_app/lib/tasks/.gitkeep +0 -0
- data/spec/rails_app/public/404.html +26 -0
- data/spec/rails_app/public/422.html +26 -0
- data/spec/rails_app/public/500.html +26 -0
- data/spec/rails_app/public/favicon.ico +0 -0
- data/spec/rails_app/public/images/rails.png +0 -0
- data/spec/rails_app/public/index.html +239 -0
- data/spec/rails_app/public/javascripts/application.js +2 -0
- data/spec/rails_app/public/javascripts/controls.js +965 -0
- data/spec/rails_app/public/javascripts/dragdrop.js +974 -0
- data/spec/rails_app/public/javascripts/effects.js +1123 -0
- data/spec/rails_app/public/javascripts/prototype.js +6001 -0
- data/spec/rails_app/public/javascripts/rails.js +191 -0
- data/spec/rails_app/public/robots.txt +5 -0
- data/spec/rails_app/public/stylesheets/.gitkeep +0 -0
- data/spec/rails_app/script/rails +6 -0
- data/spec/spec_helper.rb +12 -13
- data/spec/support/api_test_helpers.rb +23 -0
- metadata +137 -35
- data/Manifest.txt +0 -15
- data/script/console +0 -10
- data/script/destroy +0 -14
- data/script/generate +0 -14
- data/spec/acts_as_api_spec.rb +0 -87
- data/tasks/rspec.rake +0 -21
data/Manifest.txt
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
README.rdoc
|
2
|
-
History.txt
|
3
|
-
Manifest.txt
|
4
|
-
Rakefile
|
5
|
-
lib/acts_as_api.rb
|
6
|
-
lib/acts_as_api/array.rb
|
7
|
-
lib/acts_as_api/base.rb
|
8
|
-
lib/acts_as_api/rendering.rb
|
9
|
-
script/console
|
10
|
-
script/destroy
|
11
|
-
script/generate
|
12
|
-
spec/acts_as_api_spec.rb
|
13
|
-
spec/spec.opts
|
14
|
-
spec/spec_helper.rb
|
15
|
-
tasks/rspec.rake
|
data/script/console
DELETED
@@ -1,10 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# File: script/console
|
3
|
-
irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
|
4
|
-
|
5
|
-
libs = " -r irb/completion"
|
6
|
-
# Perhaps use a console_lib to store any extra methods I may want available in the cosole
|
7
|
-
# libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
|
8
|
-
libs << " -r #{File.dirname(__FILE__) + '/../lib/acts_as_api.rb'}"
|
9
|
-
puts "Loading acts_as_api gem"
|
10
|
-
exec "#{irb} #{libs} --simple-prompt"
|
data/script/destroy
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
3
|
-
|
4
|
-
begin
|
5
|
-
require 'rubigen'
|
6
|
-
rescue LoadError
|
7
|
-
require 'rubygems'
|
8
|
-
require 'rubigen'
|
9
|
-
end
|
10
|
-
require 'rubigen/scripts/destroy'
|
11
|
-
|
12
|
-
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
13
|
-
RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
|
14
|
-
RubiGen::Scripts::Destroy.new.run(ARGV)
|
data/script/generate
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
3
|
-
|
4
|
-
begin
|
5
|
-
require 'rubigen'
|
6
|
-
rescue LoadError
|
7
|
-
require 'rubygems'
|
8
|
-
require 'rubigen'
|
9
|
-
end
|
10
|
-
require 'rubigen/scripts/generate'
|
11
|
-
|
12
|
-
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
13
|
-
RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
|
14
|
-
RubiGen::Scripts::Generate.new.run(ARGV)
|
data/spec/acts_as_api_spec.rb
DELETED
@@ -1,87 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
|
-
|
3
|
-
# Time to add your specs!
|
4
|
-
# http://rspec.info/
|
5
|
-
describe "setting up acts_as_api" do
|
6
|
-
|
7
|
-
before(:each) do
|
8
|
-
@luke = Customer.new({ :firstname => 'Luke', :lastname => 'Skywalker', :age => 25, :active => true })
|
9
|
-
@han = Customer.new({ :firstname => 'Han', :lastname => 'Solo', :age => 35, :active => true })
|
10
|
-
@leia = Customer.new({ :firstname => 'Princess', :lastname => 'Leia', :age => 25, :active => false })
|
11
|
-
|
12
|
-
# always reset the api_accessible values
|
13
|
-
Customer.write_inheritable_attribute(:api_accessible, Set.new )
|
14
|
-
end
|
15
|
-
|
16
|
-
it "should be disabled by default" do
|
17
|
-
Customer.acts_as_api?.should be_false
|
18
|
-
Customer.should_not respond_to :api_accessible
|
19
|
-
# now enable it
|
20
|
-
Customer.acts_as_api
|
21
|
-
# should respond now
|
22
|
-
Customer.acts_as_api?.should be_true
|
23
|
-
Customer.should respond_to :api_accessible
|
24
|
-
end
|
25
|
-
|
26
|
-
it "check simple attributes list" do
|
27
|
-
|
28
|
-
Customer.api_accessible :firstname, :lastname
|
29
|
-
|
30
|
-
response = @luke.as_api_response
|
31
|
-
|
32
|
-
response.should be_kind_of(Hash)
|
33
|
-
|
34
|
-
response.should have(2).keys
|
35
|
-
|
36
|
-
response.keys.should include(:firstname, :lastname)
|
37
|
-
|
38
|
-
response.values.should include(@luke.firstname, @luke.lastname)
|
39
|
-
|
40
|
-
end
|
41
|
-
|
42
|
-
it "check method call in attributes list" do
|
43
|
-
|
44
|
-
Customer.api_accessible :full_name
|
45
|
-
|
46
|
-
response = @luke.as_api_response
|
47
|
-
|
48
|
-
response.should be_kind_of(Hash)
|
49
|
-
|
50
|
-
response.should have(1).keys
|
51
|
-
|
52
|
-
response.keys.should include(:full_name)
|
53
|
-
|
54
|
-
response.values.should include(@luke.full_name)
|
55
|
-
|
56
|
-
end
|
57
|
-
|
58
|
-
|
59
|
-
it "check renaming the node/key of an attribute" do
|
60
|
-
|
61
|
-
end
|
62
|
-
|
63
|
-
it "check renaming the node/key of a method" do
|
64
|
-
|
65
|
-
end
|
66
|
-
|
67
|
-
it "check included associations in attributes list (DON'T act_as_api themselves)" do
|
68
|
-
|
69
|
-
end
|
70
|
-
|
71
|
-
|
72
|
-
it "check included associations in attributes list (DO act_as_api themselves)" do
|
73
|
-
|
74
|
-
end
|
75
|
-
|
76
|
-
it "check creating a sub node and putting an attribute in it" do
|
77
|
-
|
78
|
-
end
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
it "check creating multiple sub nodes and putting an attribute in it" do
|
83
|
-
|
84
|
-
end
|
85
|
-
|
86
|
-
|
87
|
-
end
|
data/tasks/rspec.rake
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
begin
|
2
|
-
require 'spec'
|
3
|
-
rescue LoadError
|
4
|
-
require 'rubygems' unless ENV['NO_RUBYGEMS']
|
5
|
-
require 'spec'
|
6
|
-
end
|
7
|
-
begin
|
8
|
-
require 'spec/rake/spectask'
|
9
|
-
rescue LoadError
|
10
|
-
puts <<-EOS
|
11
|
-
To use rspec for testing you must install rspec gem:
|
12
|
-
gem install rspec
|
13
|
-
EOS
|
14
|
-
exit(0)
|
15
|
-
end
|
16
|
-
|
17
|
-
desc "Run the specs under spec/models"
|
18
|
-
Spec::Rake::SpecTask.new do |t|
|
19
|
-
t.spec_opts = ['--options', "spec/spec.opts"]
|
20
|
-
t.spec_files = FileList['spec/**/*_spec.rb']
|
21
|
-
end
|