restly 0.0.1.alpha.1 → 0.0.1.alpha.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. data/.rspec +2 -0
  2. data/README.md +63 -3
  3. data/lib/generators/restly_config_generator.rb +13 -0
  4. data/lib/generators/restly_model_generator.rb +18 -0
  5. data/lib/generators/templates/config.yml.erb +32 -0
  6. data/lib/generators/templates/model.rb.erb +9 -0
  7. data/lib/restly/associations/base.rb +83 -12
  8. data/lib/restly/associations/belongs_to.rb +23 -6
  9. data/lib/restly/associations/embeddable_resources/embeds_many.rb +4 -0
  10. data/lib/restly/associations/embeddable_resources/embeds_one.rb +4 -0
  11. data/lib/restly/associations/embeddable_resources.rb +15 -4
  12. data/lib/restly/associations/has_many.rb +0 -9
  13. data/lib/restly/associations/has_one.rb +0 -9
  14. data/lib/restly/associations.rb +75 -15
  15. data/lib/restly/base/generic_methods.rb +10 -2
  16. data/lib/restly/base/includes.rb +0 -22
  17. data/lib/restly/base/instance/attributes.rb +26 -16
  18. data/lib/restly/base/instance/persistence.rb +6 -1
  19. data/lib/restly/base/{write_callbacks.rb → instance/write_callbacks.rb} +1 -1
  20. data/lib/restly/base/instance.rb +15 -9
  21. data/lib/restly/base.rb +3 -4
  22. data/lib/restly/client.rb +2 -2
  23. data/lib/restly/collection/pagination.rb +1 -1
  24. data/lib/restly/concerned_inheritance.rb +30 -0
  25. data/lib/restly/configuration.rb +20 -18
  26. data/lib/restly/error.rb +18 -20
  27. data/lib/restly/nested_attributes.rb +4 -3
  28. data/lib/restly/proxies/{auth.rb → authorization.rb} +1 -1
  29. data/lib/restly/proxies/base.rb +4 -0
  30. data/lib/restly/proxies/{params.rb → with_params.rb} +1 -1
  31. data/lib/restly/proxies/with_path.rb +24 -0
  32. data/lib/restly/proxies.rb +3 -4
  33. data/lib/restly/railtie.rb +5 -0
  34. data/lib/restly/version.rb +1 -1
  35. data/lib/restly.rb +2 -0
  36. data/restly.gemspec +0 -1
  37. data/spec/restly/associations/base_spec.rb +8 -0
  38. data/spec/restly/associations/belongs_to_spec.rb +8 -0
  39. data/spec/restly/associations/embeddable_resources/embeds_many_spec.rb +8 -0
  40. data/spec/restly/associations/embeddable_resources/embeds_one_spec.rb +8 -0
  41. data/spec/restly/associations/embeddable_resources_spec.rb +8 -0
  42. data/spec/restly/associations/has_many_spec.rb +8 -0
  43. data/spec/restly/associations/has_one_spec.rb +8 -0
  44. data/spec/restly/associations_spec.rb +8 -0
  45. data/spec/restly/base/fields_spec.rb +8 -0
  46. data/spec/restly/base/generic_methods_spec.rb +8 -0
  47. data/spec/restly/base/includes_spec.rb +8 -0
  48. data/spec/restly/base/instance/actions_spec.rb +8 -0
  49. data/spec/restly/base/instance/attributes_spec.rb +8 -0
  50. data/spec/restly/base/instance/persistence_spec.rb +8 -0
  51. data/spec/restly/base/instance/write_callbacks_spec.rb +8 -0
  52. data/spec/restly/base/instance_spec.rb +8 -0
  53. data/spec/restly/base/mass_assignment_security_spec.rb +8 -0
  54. data/spec/restly/base/resource/finders_spec.rb +8 -0
  55. data/spec/restly/base/resource_spec.rb +8 -0
  56. data/spec/restly/base_spec.rb +5 -51
  57. data/spec/restly/client_spec.rb +8 -0
  58. data/spec/restly/collection/pagination_spec.rb +8 -0
  59. data/spec/restly/collection_spec.rb +8 -0
  60. data/spec/restly/concearned_inheritance_spec.rb +8 -0
  61. data/spec/restly/configuration_spec.rb +8 -0
  62. data/spec/restly/connection_spec.rb +8 -0
  63. data/spec/restly/controller_methods_spec.rb +8 -0
  64. data/spec/restly/middleware_spec.rb +8 -0
  65. data/spec/restly/nested_attributes_spec.rb +8 -0
  66. data/spec/restly/proxies/associations/collection_spec.rb +8 -0
  67. data/spec/restly/proxies/associations/instance_spec.rb +8 -0
  68. data/spec/restly/proxies/authorization_spec.rb +8 -0
  69. data/spec/restly/proxies/base_spec.rb +8 -0
  70. data/spec/restly/proxies/with_params_spec.rb +8 -0
  71. data/spec/restly/thread_local_spec.rb +8 -0
  72. data/spec/{helper.rb → spec_helper.rb} +0 -3
  73. metadata +82 -26
  74. data/lib/restly/associations/builder.rb +0 -30
  75. data/spec/fakewebs.rb +0 -0
@@ -0,0 +1,8 @@
1
+ require "rspec"
2
+ require "spec_helper"
3
+
4
+ describe Restly::Base::Resource do
5
+
6
+ it "should have specs"
7
+
8
+ end
@@ -1,60 +1,14 @@
1
- require "helper"
1
+ require "spec_helper"
2
2
  require "pry"
3
3
 
4
4
  describe Restly::Base do
5
5
 
6
- subject { BaseSample }
7
-
8
- before do
9
- class BaseSample < Restly::Base
10
- end
11
- end
12
-
13
- after do
14
- Object.send(:remove_const, :BaseSample)
6
+ subject do
7
+ Restly::Base.stub(:name) { 'RestlyTestObject' }
8
+ Class.new(Restly::Base)
15
9
  end
16
10
 
17
- describe "Defaults" do
18
-
19
- it "has the default generated resource_name" do
20
- subject.resource_name.should == 'base_sample'
21
- end
22
-
23
- it "has an Oauth2 client" do
24
- subject.client.is_a?(OAuth2::Client).should == true
25
- end
26
-
27
- it "client has the default site" do
28
- subject.client.site.should == Restly::Configuration.site
29
- end
30
-
31
- it "client has the default client id" do
32
- subject.client.id.should == Restly::Configuration.client_id
33
- end
34
-
35
- it "client has the default client secret" do
36
- subject.client.secret.should == Restly::Configuration.client_secret
37
- end
11
+ it "should have specs"
38
12
 
39
- end
40
-
41
- describe "Inherited Default Overrides" do
42
-
43
- it "inherited can set a custom site" do
44
- subject.site = "http://example_b.com"
45
- subject.client.site.should_not == Restly::Configuration.client_id
46
- end
47
-
48
- it "inherited can set a custom client_id" do
49
- subject.client_id = "custom_id"
50
- subject.client.id.should_not == Restly::Configuration.client_id
51
- end
52
-
53
- it "inherited can set a custom client_secret" do
54
- subject.client_secret = "custom_secret"
55
- subject.client.secret.should_not == Restly::Configuration.client_id
56
- end
57
-
58
- end
59
13
 
60
14
  end
@@ -0,0 +1,8 @@
1
+ require "rspec"
2
+ require "spec_helper"
3
+
4
+ describe Restly::Client do
5
+
6
+ it "should have specs"
7
+
8
+ end
@@ -0,0 +1,8 @@
1
+ require "rspec"
2
+ require "spec_helper"
3
+
4
+ describe Restly::Collection::Pagination do
5
+
6
+ it "should have specs"
7
+
8
+ end
@@ -0,0 +1,8 @@
1
+ require "rspec"
2
+ require "spec_helper"
3
+
4
+ describe Restly::Collection do
5
+
6
+ it "should have specs"
7
+
8
+ end
@@ -0,0 +1,8 @@
1
+ require "rspec"
2
+ require "spec_helper"
3
+
4
+ describe Restly::ConcernedInheritance do
5
+
6
+ it "should have specs"
7
+
8
+ end
@@ -0,0 +1,8 @@
1
+ require "rspec"
2
+ require "spec_helper"
3
+
4
+ describe Restly::Configuration do
5
+
6
+ it "should have specs"
7
+
8
+ end
@@ -0,0 +1,8 @@
1
+ require "rspec"
2
+ require "spec_helper"
3
+
4
+ describe Restly::Connection do
5
+
6
+ it "should have specs"
7
+
8
+ end
@@ -0,0 +1,8 @@
1
+ require "rspec"
2
+ require "spec_helper"
3
+
4
+ describe Restly::ControllerMethods do
5
+
6
+ it "should have specs"
7
+
8
+ end
@@ -0,0 +1,8 @@
1
+ require "rspec"
2
+ require "spec_helper"
3
+
4
+ describe Restly::Middleware do
5
+
6
+ it "should have specs"
7
+
8
+ end
@@ -0,0 +1,8 @@
1
+ require "rspec"
2
+ require "spec_helper"
3
+
4
+ describe Restly::NestedAttributes do
5
+
6
+ it "should have specs"
7
+
8
+ end
@@ -0,0 +1,8 @@
1
+ require "rspec"
2
+ require "spec_helper"
3
+
4
+ describe Restly::Proxies::Associations::Collection do
5
+
6
+ it "should have specs"
7
+
8
+ end
@@ -0,0 +1,8 @@
1
+ require "rspec"
2
+ require "spec_helper"
3
+
4
+ describe Restly::Proxies::Associations::Instance do
5
+
6
+ it "should have specs"
7
+
8
+ end
@@ -0,0 +1,8 @@
1
+ require "rspec"
2
+ require "spec_helper"
3
+
4
+ describe Restly::Proxies::Authorization do
5
+
6
+ it "should have specs"
7
+
8
+ end
@@ -0,0 +1,8 @@
1
+ require "rspec"
2
+ require "spec_helper"
3
+
4
+ describe Restly::Proxies::Base do
5
+
6
+ it "should have specs"
7
+
8
+ end
@@ -0,0 +1,8 @@
1
+ require "rspec"
2
+ require "spec_helper"
3
+
4
+ describe Restly::Proxies::WithParams do
5
+
6
+ it "should have specs"
7
+
8
+ end
@@ -0,0 +1,8 @@
1
+ require "rspec"
2
+ require "spec_helper"
3
+
4
+ describe Restly::ThreadLocal do
5
+
6
+ it "should have specs"
7
+
8
+ end
@@ -3,12 +3,9 @@ require 'bundler/setup'
3
3
 
4
4
  require 'active_support/all'
5
5
  require 'active_model'
6
- #require 'addressable/uri'
7
6
  require 'rspec'
8
7
  require 'rspec/autorun'
9
8
  require 'restly'
10
- require 'fakeweb'
11
- require 'fakewebs'
12
9
 
13
10
 
14
11
  Restly::Configuration.load_config(
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: restly
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1.alpha.1
4
+ version: 0.0.1.alpha.2
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-23 00:00:00.000000000 Z
12
+ date: 2012-10-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: oauth2
@@ -107,22 +107,6 @@ dependencies:
107
107
  - - ! '>='
108
108
  - !ruby/object:Gem::Version
109
109
  version: '0'
110
- - !ruby/object:Gem::Dependency
111
- name: fakeweb
112
- requirement: !ruby/object:Gem::Requirement
113
- none: false
114
- requirements:
115
- - - ! '>='
116
- - !ruby/object:Gem::Version
117
- version: '0'
118
- type: :development
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- none: false
122
- requirements:
123
- - - ! '>='
124
- - !ruby/object:Gem::Version
125
- version: '0'
126
110
  description: ! ' Allows your app to authenticate a resource with oauth'
127
111
  email:
128
112
  - jason@waldrip.net
@@ -131,15 +115,19 @@ extensions: []
131
115
  extra_rdoc_files: []
132
116
  files:
133
117
  - .gitignore
118
+ - .rspec
134
119
  - Gemfile
135
120
  - LICENSE.txt
136
121
  - README.md
137
122
  - Rakefile
123
+ - lib/generators/restly_config_generator.rb
124
+ - lib/generators/restly_model_generator.rb
125
+ - lib/generators/templates/config.yml.erb
126
+ - lib/generators/templates/model.rb.erb
138
127
  - lib/restly.rb
139
128
  - lib/restly/associations.rb
140
129
  - lib/restly/associations/base.rb
141
130
  - lib/restly/associations/belongs_to.rb
142
- - lib/restly/associations/builder.rb
143
131
  - lib/restly/associations/embeddable_resources.rb
144
132
  - lib/restly/associations/embeddable_resources/embeds_many.rb
145
133
  - lib/restly/associations/embeddable_resources/embeds_one.rb
@@ -153,13 +141,14 @@ files:
153
141
  - lib/restly/base/instance/actions.rb
154
142
  - lib/restly/base/instance/attributes.rb
155
143
  - lib/restly/base/instance/persistence.rb
144
+ - lib/restly/base/instance/write_callbacks.rb
156
145
  - lib/restly/base/mass_assignment_security.rb
157
146
  - lib/restly/base/resource.rb
158
147
  - lib/restly/base/resource/finders.rb
159
- - lib/restly/base/write_callbacks.rb
160
148
  - lib/restly/client.rb
161
149
  - lib/restly/collection.rb
162
150
  - lib/restly/collection/pagination.rb
151
+ - lib/restly/concerned_inheritance.rb
163
152
  - lib/restly/configuration.rb
164
153
  - lib/restly/connection.rb
165
154
  - lib/restly/controller_methods.rb
@@ -169,16 +158,50 @@ files:
169
158
  - lib/restly/proxies.rb
170
159
  - lib/restly/proxies/associations/collection.rb
171
160
  - lib/restly/proxies/associations/instance.rb
172
- - lib/restly/proxies/auth.rb
161
+ - lib/restly/proxies/authorization.rb
173
162
  - lib/restly/proxies/base.rb
174
- - lib/restly/proxies/params.rb
163
+ - lib/restly/proxies/with_params.rb
164
+ - lib/restly/proxies/with_path.rb
175
165
  - lib/restly/railtie.rb
176
166
  - lib/restly/thread_local.rb
177
167
  - lib/restly/version.rb
178
168
  - restly.gemspec
179
- - spec/fakewebs.rb
180
- - spec/helper.rb
169
+ - spec/restly/associations/base_spec.rb
170
+ - spec/restly/associations/belongs_to_spec.rb
171
+ - spec/restly/associations/embeddable_resources/embeds_many_spec.rb
172
+ - spec/restly/associations/embeddable_resources/embeds_one_spec.rb
173
+ - spec/restly/associations/embeddable_resources_spec.rb
174
+ - spec/restly/associations/has_many_spec.rb
175
+ - spec/restly/associations/has_one_spec.rb
176
+ - spec/restly/associations_spec.rb
177
+ - spec/restly/base/fields_spec.rb
178
+ - spec/restly/base/generic_methods_spec.rb
179
+ - spec/restly/base/includes_spec.rb
180
+ - spec/restly/base/instance/actions_spec.rb
181
+ - spec/restly/base/instance/attributes_spec.rb
182
+ - spec/restly/base/instance/persistence_spec.rb
183
+ - spec/restly/base/instance/write_callbacks_spec.rb
184
+ - spec/restly/base/instance_spec.rb
185
+ - spec/restly/base/mass_assignment_security_spec.rb
186
+ - spec/restly/base/resource/finders_spec.rb
187
+ - spec/restly/base/resource_spec.rb
181
188
  - spec/restly/base_spec.rb
189
+ - spec/restly/client_spec.rb
190
+ - spec/restly/collection/pagination_spec.rb
191
+ - spec/restly/collection_spec.rb
192
+ - spec/restly/concearned_inheritance_spec.rb
193
+ - spec/restly/configuration_spec.rb
194
+ - spec/restly/connection_spec.rb
195
+ - spec/restly/controller_methods_spec.rb
196
+ - spec/restly/middleware_spec.rb
197
+ - spec/restly/nested_attributes_spec.rb
198
+ - spec/restly/proxies/associations/collection_spec.rb
199
+ - spec/restly/proxies/associations/instance_spec.rb
200
+ - spec/restly/proxies/authorization_spec.rb
201
+ - spec/restly/proxies/base_spec.rb
202
+ - spec/restly/proxies/with_params_spec.rb
203
+ - spec/restly/thread_local_spec.rb
204
+ - spec/spec_helper.rb
182
205
  homepage: http://github.com/jwaldrip/restly
183
206
  licenses: []
184
207
  post_install_message:
@@ -204,7 +227,40 @@ signing_key:
204
227
  specification_version: 3
205
228
  summary: Allows your app to authenticate a resource with oauth
206
229
  test_files:
207
- - spec/fakewebs.rb
208
- - spec/helper.rb
230
+ - spec/restly/associations/base_spec.rb
231
+ - spec/restly/associations/belongs_to_spec.rb
232
+ - spec/restly/associations/embeddable_resources/embeds_many_spec.rb
233
+ - spec/restly/associations/embeddable_resources/embeds_one_spec.rb
234
+ - spec/restly/associations/embeddable_resources_spec.rb
235
+ - spec/restly/associations/has_many_spec.rb
236
+ - spec/restly/associations/has_one_spec.rb
237
+ - spec/restly/associations_spec.rb
238
+ - spec/restly/base/fields_spec.rb
239
+ - spec/restly/base/generic_methods_spec.rb
240
+ - spec/restly/base/includes_spec.rb
241
+ - spec/restly/base/instance/actions_spec.rb
242
+ - spec/restly/base/instance/attributes_spec.rb
243
+ - spec/restly/base/instance/persistence_spec.rb
244
+ - spec/restly/base/instance/write_callbacks_spec.rb
245
+ - spec/restly/base/instance_spec.rb
246
+ - spec/restly/base/mass_assignment_security_spec.rb
247
+ - spec/restly/base/resource/finders_spec.rb
248
+ - spec/restly/base/resource_spec.rb
209
249
  - spec/restly/base_spec.rb
250
+ - spec/restly/client_spec.rb
251
+ - spec/restly/collection/pagination_spec.rb
252
+ - spec/restly/collection_spec.rb
253
+ - spec/restly/concearned_inheritance_spec.rb
254
+ - spec/restly/configuration_spec.rb
255
+ - spec/restly/connection_spec.rb
256
+ - spec/restly/controller_methods_spec.rb
257
+ - spec/restly/middleware_spec.rb
258
+ - spec/restly/nested_attributes_spec.rb
259
+ - spec/restly/proxies/associations/collection_spec.rb
260
+ - spec/restly/proxies/associations/instance_spec.rb
261
+ - spec/restly/proxies/authorization_spec.rb
262
+ - spec/restly/proxies/base_spec.rb
263
+ - spec/restly/proxies/with_params_spec.rb
264
+ - spec/restly/thread_local_spec.rb
265
+ - spec/spec_helper.rb
210
266
  has_rdoc:
@@ -1,30 +0,0 @@
1
- module Restly::Associations::Builder
2
-
3
- def build(relationship, opts)
4
-
5
- # Base Model
6
- model = opts[:class_name] || relationship.to_s.singularize.camelize
7
-
8
- # Namespace
9
- namespace = opts[:namespace] || self.class.name.gsub(/::\w+$/, '')
10
- model = [namespace, model].compact.join('::')
11
-
12
- # Polymorphic Relationships
13
- if opts[:polymorphic]
14
- polymorphic_type = send(:"#{resource}_type")
15
- model = [namespace, polymorphic_type].compact.join('::')
16
- end
17
-
18
- # Constantize
19
- model = model.constantize
20
-
21
- # Auto-authorization, fail with error!
22
- if (!model.authorized? && self.respond_to?(:authorized?) && self.authorized?) || (opts[:authorize])
23
- model.authorize(opts[:authorize] || self.connection)
24
- else
25
- model
26
- end
27
-
28
- end
29
-
30
- end
data/spec/fakewebs.rb DELETED
File without changes