motion-resource 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.
Files changed (38) hide show
  1. data/.gitignore +9 -0
  2. data/Gemfile +8 -0
  3. data/README.md +53 -0
  4. data/Rakefile +14 -0
  5. data/app/app_delegate.rb +7 -0
  6. data/examples/Colr/.gitignore +13 -0
  7. data/examples/Colr/Rakefile +10 -0
  8. data/examples/Colr/app/app_delegate.rb +10 -0
  9. data/examples/Colr/app/color.rb +15 -0
  10. data/examples/Colr/app/color_view_controller.rb +46 -0
  11. data/examples/Colr/app/initializer.rb +2 -0
  12. data/examples/Colr/app/main_navigation_controller.rb +6 -0
  13. data/examples/Colr/app/tag.rb +5 -0
  14. data/examples/Colr/app/tags_view_controller.rb +23 -0
  15. data/lib/motion-resource.rb +5 -0
  16. data/lib/motion-resource/associations.rb +94 -0
  17. data/lib/motion-resource/attributes.rb +37 -0
  18. data/lib/motion-resource/base.rb +51 -0
  19. data/lib/motion-resource/crud.rb +33 -0
  20. data/lib/motion-resource/find.rb +67 -0
  21. data/lib/motion-resource/requests.rb +64 -0
  22. data/lib/motion-resource/string.rb +23 -0
  23. data/lib/motion-resource/urls.rb +29 -0
  24. data/lib/motion-resource/version.rb +3 -0
  25. data/motion-resource.gemspec +20 -0
  26. data/spec/env.rb +41 -0
  27. data/spec/motion-resource/associations/belongs_to_spec.rb +116 -0
  28. data/spec/motion-resource/associations/has_many_spec.rb +128 -0
  29. data/spec/motion-resource/associations/has_one_spec.rb +69 -0
  30. data/spec/motion-resource/associations/scope_spec.rb +21 -0
  31. data/spec/motion-resource/attributes_spec.rb +64 -0
  32. data/spec/motion-resource/base_spec.rb +54 -0
  33. data/spec/motion-resource/crud_spec.rb +141 -0
  34. data/spec/motion-resource/find_spec.rb +90 -0
  35. data/spec/motion-resource/requests_spec.rb +119 -0
  36. data/spec/motion-resource/string_spec.rb +26 -0
  37. data/spec/motion-resource/urls_spec.rb +52 -0
  38. metadata +140 -0
@@ -0,0 +1,26 @@
1
+ class DelegateObject
2
+ attr_accessor :id, :name
3
+ end
4
+
5
+ describe "String" do
6
+ it "should fill url params from params hash" do
7
+ string = "accounts/:id/users/:name".fill_url_params(id: 10, name: 'john')
8
+ string.should == "accounts/10/users/john"
9
+ end
10
+
11
+ it "should fill url params from delegate object" do
12
+ obj = DelegateObject.new
13
+ obj.id = 10
14
+ obj.name = 'john'
15
+ string = "accounts/:id/users/:name".fill_url_params({}, obj)
16
+ string.should == "accounts/10/users/john"
17
+ end
18
+
19
+ it "should not crash when a param is unknown" do
20
+ lambda { "accounts/:id".fill_url_params({}) }.should.not.raise
21
+ end
22
+
23
+ it "should not crash when params hash contains an unused value" do
24
+ lambda { "accounts".fill_url_params(foo: 'bar') }.should.not.raise
25
+ end
26
+ end
@@ -0,0 +1,52 @@
1
+ describe "urls" do
2
+ it "should define collection url" do
3
+ MotionResource::Base.should.respond_to :collection_url
4
+ end
5
+
6
+ it "should define member url" do
7
+ MotionResource::Base.should.respond_to :member_url
8
+ end
9
+
10
+ it "should define root url" do
11
+ MotionResource::Base.should.respond_to :root_url
12
+ end
13
+
14
+ it "should define url extension" do
15
+ MotionResource::Base.should.respond_to :extension
16
+ end
17
+
18
+ it "should default to json for extension" do
19
+ MotionResource::Base.extension.should == '.json'
20
+ end
21
+
22
+ it "should define custom url method" do
23
+ comment = Comment.new
24
+ comment.should.respond_to :by_user_url
25
+ comment.by_user_url.should.is_a String
26
+ end
27
+
28
+ it "should accept params in custom url method" do
29
+ comment = Comment.new
30
+ comment.should.respond_to :by_user_url
31
+ comment.by_user_url(name: "john").should == "comments/by_user/john"
32
+ end
33
+
34
+ it "should define custom url singleton method" do
35
+ Comment.should.respond_to :by_user_url
36
+ Comment.by_user_url.should.is_a String
37
+ end
38
+
39
+ it "should define convenience collection_url method" do
40
+ comment = Comment.new
41
+ comment.should.respond_to :collection_url
42
+ comment.collection_url.should.is_a String
43
+ comment.collection_url.should == 'comments'
44
+ end
45
+
46
+ it "should define convenience member_url method" do
47
+ comment = Comment.new
48
+ comment.should.respond_to :member_url
49
+ comment.member_url.should.is_a String
50
+ comment.member_url(id: 10).should == 'comments/10'
51
+ end
52
+ end
metadata ADDED
@@ -0,0 +1,140 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: motion-resource
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.0.1
6
+ platform: ruby
7
+ authors:
8
+ - Thomas Kadauke
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2012-11-29 00:00:00 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: bubble-wrap
17
+ requirement: &id001 !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: "0"
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: *id001
26
+ - !ruby/object:Gem::Dependency
27
+ name: motion-support
28
+ requirement: &id002 !ruby/object:Gem::Requirement
29
+ none: false
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: "0"
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: *id002
37
+ - !ruby/object:Gem::Dependency
38
+ name: rake
39
+ requirement: &id003 !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ version: "0"
45
+ type: :development
46
+ prerelease: false
47
+ version_requirements: *id003
48
+ description: Access RESTful resources from your iOS app. Inspired by ActiveResource.
49
+ email:
50
+ - thomas.kadauke@googlemail.com
51
+ executables: []
52
+
53
+ extensions: []
54
+
55
+ extra_rdoc_files: []
56
+
57
+ files:
58
+ - .gitignore
59
+ - Gemfile
60
+ - README.md
61
+ - Rakefile
62
+ - app/app_delegate.rb
63
+ - examples/Colr/.gitignore
64
+ - examples/Colr/Rakefile
65
+ - examples/Colr/app/app_delegate.rb
66
+ - examples/Colr/app/color.rb
67
+ - examples/Colr/app/color_view_controller.rb
68
+ - examples/Colr/app/initializer.rb
69
+ - examples/Colr/app/main_navigation_controller.rb
70
+ - examples/Colr/app/tag.rb
71
+ - examples/Colr/app/tags_view_controller.rb
72
+ - lib/motion-resource.rb
73
+ - lib/motion-resource/associations.rb
74
+ - lib/motion-resource/attributes.rb
75
+ - lib/motion-resource/base.rb
76
+ - lib/motion-resource/crud.rb
77
+ - lib/motion-resource/find.rb
78
+ - lib/motion-resource/requests.rb
79
+ - lib/motion-resource/string.rb
80
+ - lib/motion-resource/urls.rb
81
+ - lib/motion-resource/version.rb
82
+ - motion-resource.gemspec
83
+ - spec/env.rb
84
+ - spec/motion-resource/associations/belongs_to_spec.rb
85
+ - spec/motion-resource/associations/has_many_spec.rb
86
+ - spec/motion-resource/associations/has_one_spec.rb
87
+ - spec/motion-resource/associations/scope_spec.rb
88
+ - spec/motion-resource/attributes_spec.rb
89
+ - spec/motion-resource/base_spec.rb
90
+ - spec/motion-resource/crud_spec.rb
91
+ - spec/motion-resource/find_spec.rb
92
+ - spec/motion-resource/requests_spec.rb
93
+ - spec/motion-resource/string_spec.rb
94
+ - spec/motion-resource/urls_spec.rb
95
+ homepage: https://github.com/tkadauke/motion-resource
96
+ licenses: []
97
+
98
+ post_install_message:
99
+ rdoc_options: []
100
+
101
+ require_paths:
102
+ - lib
103
+ required_ruby_version: !ruby/object:Gem::Requirement
104
+ none: false
105
+ requirements:
106
+ - - ">="
107
+ - !ruby/object:Gem::Version
108
+ hash: 1460069226748132029
109
+ segments:
110
+ - 0
111
+ version: "0"
112
+ required_rubygems_version: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ hash: 1460069226748132029
118
+ segments:
119
+ - 0
120
+ version: "0"
121
+ requirements: []
122
+
123
+ rubyforge_project:
124
+ rubygems_version: 1.8.17
125
+ signing_key:
126
+ specification_version: 3
127
+ summary: Access RESTful resources from your iOS app
128
+ test_files:
129
+ - spec/env.rb
130
+ - spec/motion-resource/associations/belongs_to_spec.rb
131
+ - spec/motion-resource/associations/has_many_spec.rb
132
+ - spec/motion-resource/associations/has_one_spec.rb
133
+ - spec/motion-resource/associations/scope_spec.rb
134
+ - spec/motion-resource/attributes_spec.rb
135
+ - spec/motion-resource/base_spec.rb
136
+ - spec/motion-resource/crud_spec.rb
137
+ - spec/motion-resource/find_spec.rb
138
+ - spec/motion-resource/requests_spec.rb
139
+ - spec/motion-resource/string_spec.rb
140
+ - spec/motion-resource/urls_spec.rb