restly 0.0.1.alpha.6 → 0.0.1.alpha.7
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/README.md +11 -5
- data/lib/restly/associations.rb +6 -4
- data/lib/restly/associations/base/loaders.rb +0 -2
- data/lib/restly/associations/base/modifiers.rb +2 -1
- data/lib/restly/associations/belongs_to.rb +6 -1
- data/lib/restly/base.rb +3 -3
- data/lib/restly/base/includes.rb +5 -0
- data/lib/restly/base/instance/attributes.rb +2 -0
- data/lib/restly/client.rb +1 -1
- data/lib/restly/collection.rb +3 -3
- data/lib/restly/configuration.rb +4 -2
- data/lib/restly/embedded_associations/embedded_in.rb +1 -1
- data/lib/restly/embedded_associations/embeds_many.rb +1 -1
- data/lib/restly/embedded_associations/embeds_one.rb +1 -1
- data/lib/restly/error.rb +1 -4
- data/lib/restly/proxies/base.rb +2 -0
- data/lib/restly/version.rb +1 -1
- data/restly.gemspec +3 -0
- data/spec/restly/base/resource/batch_actions_spec.rb +8 -0
- data/spec/restly/base_spec.rb +1 -4
- data/spec/restly/embeddable_resources_spec.rb +1 -1
- data/spec/restly/embedded_associations/embedded_in_spec.rb +8 -0
- data/spec/restly/{embeddable_resources/embeds_one_spec.rb → embedded_associations/embeds_many_spec.rb} +1 -1
- data/spec/restly/embedded_associations/embeds_one_spec.rb +8 -0
- data/spec/spec_helper.rb +10 -15
- data/spec/support/memory_model.rb +105 -0
- data/spec/support/models.rb +23 -0
- data/spec/support/requester.rb +88 -0
- data/spec/support/routes.rb +95 -0
- data/spec/support/shared.rb +48 -0
- metadata +68 -7
- data/spec/restly/embeddable_resources/embeds_many_spec.rb +0 -8
data/README.md
CHANGED
@@ -100,28 +100,34 @@ In restly interacting with objects is familiar.
|
|
100
100
|
|
101
101
|
__Getting the Collection:__
|
102
102
|
|
103
|
-
```
|
103
|
+
```ruby
|
104
|
+
MyModel.all
|
105
|
+
```
|
104
106
|
|
105
107
|
__Finding an Instance:__
|
106
108
|
|
107
|
-
```
|
109
|
+
```ruby
|
110
|
+
my_instance = MyModel.find(1)
|
111
|
+
```
|
108
112
|
|
109
113
|
__Updating an Instance:__
|
110
114
|
|
111
|
-
```
|
115
|
+
```ruby
|
116
|
+
my_instance.update_attributes({my_attr: 'val'})
|
117
|
+
```
|
112
118
|
|
113
119
|
or
|
114
120
|
|
115
121
|
```ruby
|
116
122
|
my_instance.my_attr = 'val'
|
117
|
-
|
123
|
+
my_instance.save
|
118
124
|
```
|
119
125
|
|
120
126
|
__Creating an Instance__
|
121
127
|
|
122
128
|
```
|
123
129
|
my_instance
|
124
|
-
|
130
|
+
```
|
125
131
|
|
126
132
|
## Contributing
|
127
133
|
|
data/lib/restly/associations.rb
CHANGED
@@ -29,8 +29,6 @@ module Restly::Associations
|
|
29
29
|
|
30
30
|
class_attribute :resource_associations, instance_reader: false, instance_writer: false
|
31
31
|
|
32
|
-
attr_reader :association_attributes
|
33
|
-
|
34
32
|
self.resource_associations = AssociationsHash.new
|
35
33
|
|
36
34
|
inherited do
|
@@ -57,16 +55,20 @@ module Restly::Associations
|
|
57
55
|
|
58
56
|
private
|
59
57
|
|
58
|
+
def association_attributes
|
59
|
+
@association_attributes ||= {}
|
60
|
+
end
|
61
|
+
|
60
62
|
def set_association(attr, val)
|
61
63
|
association = self.class.reflect_on_resource_association(attr)
|
62
64
|
association.valid?(val)
|
63
|
-
|
65
|
+
association_attributes[attr] = val
|
64
66
|
end
|
65
67
|
|
66
68
|
def get_association(attr, options={})
|
67
69
|
association = self.class.reflect_on_resource_association(attr)
|
68
70
|
|
69
|
-
if (stubbed = association.stub self,
|
71
|
+
if (stubbed = association.stub self, association_attributes[attr]).present?
|
70
72
|
stubbed
|
71
73
|
elsif (loaded = association.load self, options).present?
|
72
74
|
loaded
|
@@ -12,8 +12,6 @@ module Restly::Associations::Base::Loaders
|
|
12
12
|
collection? ? association.load_collection(parent) : association.load_instance(parent)
|
13
13
|
end
|
14
14
|
|
15
|
-
private
|
16
|
-
|
17
15
|
def load_collection(parent, association_class = self.association_class)
|
18
16
|
raise Restly::Error::AssociationError, "Not a collection" unless collection?
|
19
17
|
collection = if embedded?
|
@@ -13,10 +13,11 @@ module Restly::Associations::Base::Modifiers
|
|
13
13
|
|
14
14
|
def with_path(parent, path = nil, association_class=self.association_class)
|
15
15
|
duplicate = self.dup
|
16
|
+
parent_path = parent.respond_to?(:path) ? parent.path : nil
|
16
17
|
duplicate.instance_variable_set :@association_class, if path
|
17
18
|
association_class.with_path(path)
|
18
19
|
else
|
19
|
-
association_class.with_path(association_resource_name, prepend:
|
20
|
+
association_class.with_path(association_resource_name, prepend: parent_path)
|
20
21
|
end
|
21
22
|
duplicate
|
22
23
|
end
|
@@ -4,7 +4,12 @@ class Restly::Associations::BelongsTo < Restly::Associations::Base
|
|
4
4
|
if polymorphic
|
5
5
|
set_polymorphic_class(parent).load(parent, options)
|
6
6
|
else
|
7
|
-
|
7
|
+
# Merge Options
|
8
|
+
options.reverse_merge!(self.options)
|
9
|
+
|
10
|
+
# Authorize and Set Path
|
11
|
+
association = authorize(options[:authorize])
|
12
|
+
association.load_instance(parent)
|
8
13
|
end
|
9
14
|
end
|
10
15
|
|
data/lib/restly/base.rb
CHANGED
@@ -64,9 +64,9 @@ module Restly
|
|
64
64
|
# Set Defaults on Inheritance
|
65
65
|
inherited do
|
66
66
|
field :id
|
67
|
-
self.resource_name
|
68
|
-
self.path
|
69
|
-
self.params
|
67
|
+
self.resource_name = name.gsub(/.*::/,'').underscore if name.present?
|
68
|
+
self.path = resource_name.pluralize
|
69
|
+
self.params = params.dup
|
70
70
|
end
|
71
71
|
|
72
72
|
# Run Active Support Load Hooks
|
data/lib/restly/base/includes.rb
CHANGED
@@ -10,6 +10,11 @@ module Restly::Base::Includes
|
|
10
10
|
@client ||= Restly::Client.new
|
11
11
|
end
|
12
12
|
|
13
|
+
def client=(client)
|
14
|
+
raise Restly::Error::InvalidClient, "Client is invalid!"
|
15
|
+
@client = client
|
16
|
+
end
|
17
|
+
|
13
18
|
def connection
|
14
19
|
connection = @connection || Restly::Connection.tokenize(client, current_token)
|
15
20
|
connection.cache ||= cache
|
data/lib/restly/client.rb
CHANGED
@@ -11,7 +11,7 @@ class Restly::Client < OAuth2::Client
|
|
11
11
|
self.options = Restly::Configuration.client_options.merge(opts)
|
12
12
|
self.ssl = opts.delete(:ssl) || Restly::Configuration.ssl
|
13
13
|
self.format = @format = opts.delete(:format) || Restly::Configuration.default_format
|
14
|
-
self.options[:connection_build]
|
14
|
+
self.options[:connection_build] ||= block
|
15
15
|
end
|
16
16
|
|
17
17
|
def ssl=(val)
|
data/lib/restly/collection.rb
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
class Restly::Collection < Array
|
2
|
-
|
2
|
+
extend ActiveSupport::Autoload
|
3
|
+
autoload :Pagination
|
4
|
+
|
3
5
|
include Restly::Base::Resource::Finders
|
4
6
|
include Restly::Base::Resource::BatchActions
|
5
7
|
include Restly::Base::GenericMethods
|
6
8
|
|
7
9
|
delegate :resource_name, :new, :client, to: :resource
|
8
10
|
|
9
|
-
# autoload :Pagination
|
10
|
-
|
11
11
|
attr_reader :resource
|
12
12
|
|
13
13
|
def initialize(resource, array=[], opts={})
|
data/lib/restly/configuration.rb
CHANGED
@@ -41,7 +41,9 @@ module Restly::Configuration
|
|
41
41
|
true
|
42
42
|
end
|
43
43
|
|
44
|
-
|
45
|
-
|
44
|
+
if defined?(Rails)
|
45
|
+
config_file = File.join(Rails.root, 'config', 'restly.yml')
|
46
|
+
load_config YAML.load_file(config_file)[Rails.env] if File.exists?(config_file)
|
47
|
+
end
|
46
48
|
|
47
49
|
end
|
data/lib/restly/error.rb
CHANGED
data/lib/restly/proxies/base.rb
CHANGED
data/lib/restly/version.rb
CHANGED
data/restly.gemspec
CHANGED
@@ -23,5 +23,8 @@ Gem::Specification.new do |gem|
|
|
23
23
|
|
24
24
|
gem.add_development_dependency "rspec"
|
25
25
|
gem.add_development_dependency "pry"
|
26
|
+
gem.add_development_dependency "faraday_simulation"
|
27
|
+
gem.add_development_dependency "faraday_middleware"
|
28
|
+
gem.add_development_dependency "multi_xml"
|
26
29
|
|
27
30
|
end
|
data/spec/restly/base_spec.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -6,23 +6,18 @@ require 'active_model'
|
|
6
6
|
require 'rspec'
|
7
7
|
require 'rspec/autorun'
|
8
8
|
require 'restly'
|
9
|
+
require 'support/models'
|
10
|
+
require 'support/routes'
|
9
11
|
|
12
|
+
class Post < Restly::Base
|
13
|
+
field :body
|
14
|
+
field :created_at
|
15
|
+
field :updated_at
|
16
|
+
end
|
10
17
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
client_id: 'default_id',
|
15
|
-
client_secret: 'default_secret',
|
16
|
-
default_format: 'json',
|
17
|
-
cache: false,
|
18
|
-
cache_opts: {
|
19
|
-
expires_in: 3600
|
20
|
-
}
|
21
|
-
}
|
22
|
-
)
|
23
|
-
|
24
|
-
Faraday.default_adapter = :test
|
18
|
+
Object.send :define_method, :logger do
|
19
|
+
@logger ||= Logger.new(STDOUT)
|
20
|
+
end
|
25
21
|
|
26
22
|
RSpec.configure do |conf|
|
27
|
-
include OAuth2
|
28
23
|
end
|
@@ -0,0 +1,105 @@
|
|
1
|
+
class MemoryModel < Hash
|
2
|
+
|
3
|
+
cattr_accessor :models
|
4
|
+
|
5
|
+
self.models = []
|
6
|
+
|
7
|
+
class RecordNotFound < StandardError
|
8
|
+
end
|
9
|
+
|
10
|
+
class_attribute :collection, :fields, instance_writer: false, instance_reader: false
|
11
|
+
|
12
|
+
class << self
|
13
|
+
|
14
|
+
delegate *(Array.instance_methods - Object.instance_methods), to: :collection
|
15
|
+
|
16
|
+
def inherited(subclass)
|
17
|
+
subclass.fields = {}
|
18
|
+
subclass.collection = []
|
19
|
+
subclass.send :field, :id
|
20
|
+
self.models << subclass
|
21
|
+
end
|
22
|
+
|
23
|
+
def all
|
24
|
+
collection
|
25
|
+
end
|
26
|
+
|
27
|
+
def truncate_all_models
|
28
|
+
models.each { |model| model.truncate }
|
29
|
+
end
|
30
|
+
|
31
|
+
def truncate
|
32
|
+
self.collection.clear
|
33
|
+
end
|
34
|
+
|
35
|
+
alias_method :delete_all, :truncate
|
36
|
+
|
37
|
+
def find(id)
|
38
|
+
instance = all[id - 1]
|
39
|
+
raise RecordNotFound, "Record was not found" unless instance
|
40
|
+
instance
|
41
|
+
end
|
42
|
+
|
43
|
+
def accepts_params
|
44
|
+
self.new.except(:id, :created_at, :updated_at).keys
|
45
|
+
end
|
46
|
+
|
47
|
+
def spec
|
48
|
+
{ attributes: new.keys,
|
49
|
+
actions: [
|
50
|
+
{
|
51
|
+
method: 'POST',
|
52
|
+
parameters: accepts_params
|
53
|
+
},
|
54
|
+
]
|
55
|
+
}
|
56
|
+
end
|
57
|
+
|
58
|
+
def field(attr, options={})
|
59
|
+
options.assert_valid_keys(:default)
|
60
|
+
self.fields[attr] = options[:default]
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
|
65
|
+
def initialize(hash={})
|
66
|
+
super
|
67
|
+
self.class.collection << @instance = merge!(fields.merge hash)
|
68
|
+
@instance[:id] = self.class.collection.index(@instance) + 1
|
69
|
+
end
|
70
|
+
|
71
|
+
def update(hash={})
|
72
|
+
self[:updated_at] = Time.now if fields.keys.include?(:updated_at)
|
73
|
+
merge!(hash).slice *fields.keys
|
74
|
+
end
|
75
|
+
|
76
|
+
def delete
|
77
|
+
self.class.collection.delete(self)
|
78
|
+
freeze
|
79
|
+
true
|
80
|
+
end
|
81
|
+
|
82
|
+
def merge(hash)
|
83
|
+
hash.assert_valid_keys(*self.class.fields.keys)
|
84
|
+
super
|
85
|
+
end
|
86
|
+
|
87
|
+
def merge!(hash)
|
88
|
+
hash.assert_valid_keys(*self.class.fields.keys)
|
89
|
+
super
|
90
|
+
end
|
91
|
+
|
92
|
+
def []=(key, value)
|
93
|
+
valid = {}
|
94
|
+
valid[key] = value
|
95
|
+
valid.assert_valid_keys(*self.class.fields.keys)
|
96
|
+
super(key, value)
|
97
|
+
end
|
98
|
+
|
99
|
+
private
|
100
|
+
|
101
|
+
def fields
|
102
|
+
self.class.fields.reduce({}) { |fields, (field, value)| fields[field] = value.is_a?(Proc) ? value.call : value ; fields }
|
103
|
+
end
|
104
|
+
|
105
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require "support/memory_model"
|
2
|
+
|
3
|
+
module SampleObjects
|
4
|
+
|
5
|
+
class User < MemoryModel
|
6
|
+
|
7
|
+
field :first_name
|
8
|
+
field :last_name
|
9
|
+
field :age
|
10
|
+
field :created_at, default: ->{ Time.now }
|
11
|
+
field :updated_at, default: ->{ Time.now }
|
12
|
+
|
13
|
+
end
|
14
|
+
|
15
|
+
class Post < MemoryModel
|
16
|
+
|
17
|
+
field :body
|
18
|
+
field :created_at, default: ->{ Time.now }
|
19
|
+
field :updated_at, default: ->{ Time.now }
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
class Requester
|
2
|
+
|
3
|
+
def initialize(env, &block)
|
4
|
+
@env = env
|
5
|
+
logger.debug "#{@env[:method].upcase} #{@env[:url].path}"
|
6
|
+
@action = instance_eval(&block)
|
7
|
+
end
|
8
|
+
|
9
|
+
def response
|
10
|
+
return @response if @response
|
11
|
+
@response ||= case format
|
12
|
+
when "json"
|
13
|
+
@action.to_json
|
14
|
+
when "xml"
|
15
|
+
@action.to_xml
|
16
|
+
else
|
17
|
+
@action.to_param
|
18
|
+
end
|
19
|
+
logger.debug " response body: #{@response}" if @response.present?
|
20
|
+
@response
|
21
|
+
end
|
22
|
+
|
23
|
+
def response_headers
|
24
|
+
return @response_headers if @response_headers
|
25
|
+
@response_headers ||= {
|
26
|
+
"Content-Type" => content_type
|
27
|
+
}
|
28
|
+
logger.debug " response headers: #{@response_headers}"
|
29
|
+
@response_headers
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def format
|
35
|
+
return @format if @format
|
36
|
+
@format ||= params[:format]
|
37
|
+
logger.debug " format: #{@format}"
|
38
|
+
@format
|
39
|
+
end
|
40
|
+
|
41
|
+
def model
|
42
|
+
["SampleObjects", params[:model].try(:classify)].join("::").try(:constantize)
|
43
|
+
end
|
44
|
+
|
45
|
+
def params
|
46
|
+
return @params if @params
|
47
|
+
@params ||= @env[:params].try(:with_indifferent_access) || {}
|
48
|
+
logger.debug " request params: #{@params}" if @params.present?
|
49
|
+
@params
|
50
|
+
end
|
51
|
+
|
52
|
+
def data
|
53
|
+
model_body = parsed[model.name.underscore] || {}
|
54
|
+
model_params = params[model.name.underscore] || {}
|
55
|
+
model_params.merge(model_body)
|
56
|
+
end
|
57
|
+
|
58
|
+
def parsed
|
59
|
+
return {} unless body.present?
|
60
|
+
case format
|
61
|
+
when "json"
|
62
|
+
JSON.parse(body)
|
63
|
+
when "xml"
|
64
|
+
Hash.from_xml(body)
|
65
|
+
else
|
66
|
+
{}
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def content_type
|
71
|
+
case format
|
72
|
+
when "json"
|
73
|
+
"application/json"
|
74
|
+
when "xml"
|
75
|
+
"application/xml"
|
76
|
+
else
|
77
|
+
"text/plain"
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
def body
|
82
|
+
return @body if @body
|
83
|
+
@body ||= @env[:body]
|
84
|
+
puts " request body: #{@body}" if @body.present?
|
85
|
+
@body
|
86
|
+
end
|
87
|
+
|
88
|
+
end
|
@@ -0,0 +1,95 @@
|
|
1
|
+
require "faraday_simulation"
|
2
|
+
require "faraday_middleware"
|
3
|
+
require "support/requester"
|
4
|
+
|
5
|
+
# Test Connection Object
|
6
|
+
connection = ->(builder){
|
7
|
+
builder.use Faraday::Request::UrlEncoded
|
8
|
+
|
9
|
+
builder.response :xml, :content_type => /\bxml$/
|
10
|
+
builder.response :json, :content_type => /\bjson$/
|
11
|
+
|
12
|
+
builder.use FaradaySimulation::Adapter do |stub|
|
13
|
+
|
14
|
+
# Associated
|
15
|
+
stub.get '/:model.:format' do |env|
|
16
|
+
req = Requester.new(env) { model.all }
|
17
|
+
[200, req.response_headers, req.response ]
|
18
|
+
end
|
19
|
+
|
20
|
+
stub.post '/:model.:format' do |env|
|
21
|
+
req = Requester.new(env) { model.new(data) }
|
22
|
+
[200, req.response_headers, req.response ]
|
23
|
+
end
|
24
|
+
|
25
|
+
stub.get '/:model/:id.:format' do |env|
|
26
|
+
req = Requester.new(env) { model.find(params[:id]) }
|
27
|
+
[200, req.response_headers, req.response ]
|
28
|
+
end
|
29
|
+
|
30
|
+
stub.put '/:model/:id.:format' do |env|
|
31
|
+
req = Requester.new(env) { model.find(params[:id]).update(data) }
|
32
|
+
[200, req.response_headers, req.response ]
|
33
|
+
end
|
34
|
+
|
35
|
+
stub.delete '/:model/:id.:format' do |env|
|
36
|
+
req = Requester.new(env) { model.find(params[:id]).delete }
|
37
|
+
[200, req.response_headers, req.response ]
|
38
|
+
end
|
39
|
+
|
40
|
+
stub.options '/:model/:id' do |env|
|
41
|
+
env[:params]["format"] = "json"
|
42
|
+
req = Requester.new(env) { model.spec }
|
43
|
+
[200, req.response_headers, req.response ]
|
44
|
+
end
|
45
|
+
|
46
|
+
# Associated
|
47
|
+
stub.get '/:parent_model/:parent_id/:model.:format' do |env|
|
48
|
+
req = Requester.new(env) { model.all }
|
49
|
+
[200, req.response_headers, req.response ]
|
50
|
+
end
|
51
|
+
|
52
|
+
stub.post '/:parent_model/:parent_id/:model.:format' do |env|
|
53
|
+
req = Requester.new(env) { model.new(data) }
|
54
|
+
[200, req.response_headers, req.response ]
|
55
|
+
end
|
56
|
+
|
57
|
+
stub.get '/:parent_model:model/:parent_id/:id.:format' do |env|
|
58
|
+
req = Requester.new(env) { model.find(params[:id]) }
|
59
|
+
[200, req.response_headers, req.response ]
|
60
|
+
end
|
61
|
+
|
62
|
+
stub.put '/:parent_model/:parent_id:model/:id.:format' do |env|
|
63
|
+
req = Requester.new(env) { model.find(params[:id]).update(data) }
|
64
|
+
[200, req.response_headers, req.response ]
|
65
|
+
end
|
66
|
+
|
67
|
+
stub.delete '/:parent_model/:parent_id/:model/:id.:format' do |env|
|
68
|
+
req = Requester.new(env) { model.find(params[:id]).delete }
|
69
|
+
[200, req.response_headers, req.response ]
|
70
|
+
end
|
71
|
+
|
72
|
+
stub.options '/:parent_model/:parent_id/:model/:id' do |env|
|
73
|
+
env[:params]["format"] = "json"
|
74
|
+
req = Requester.new(env) { model.spec }
|
75
|
+
[200, req.response_headers, req.response ]
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
79
|
+
}
|
80
|
+
|
81
|
+
Restly::Configuration.load_config(
|
82
|
+
{
|
83
|
+
site: 'http://fakesi.te',
|
84
|
+
cache: false,
|
85
|
+
use_oauth: true,
|
86
|
+
client_options: {
|
87
|
+
connection_build: connection
|
88
|
+
},
|
89
|
+
oauth_options: {
|
90
|
+
client_id: 'default_id',
|
91
|
+
client_secret: 'default_secret',
|
92
|
+
default_format: 'json'
|
93
|
+
},
|
94
|
+
}
|
95
|
+
)
|
@@ -0,0 +1,48 @@
|
|
1
|
+
class Contact < Restly::Base
|
2
|
+
|
3
|
+
field :first_name
|
4
|
+
field :last_name
|
5
|
+
field :created_at
|
6
|
+
field :updated_at
|
7
|
+
|
8
|
+
has_many_resources :comments
|
9
|
+
has_many_resources :posts
|
10
|
+
|
11
|
+
end
|
12
|
+
|
13
|
+
class Post < Restly::Base
|
14
|
+
|
15
|
+
field :title
|
16
|
+
field :body
|
17
|
+
field :created_at
|
18
|
+
field :updated_at
|
19
|
+
|
20
|
+
belongs_to_resource :contact
|
21
|
+
has_many_resources :comments
|
22
|
+
has_one_resource :rating
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
class Comment < Restly::Base
|
27
|
+
|
28
|
+
# root_accessible false # Todo
|
29
|
+
|
30
|
+
field :content
|
31
|
+
field :created_at
|
32
|
+
field :updated_at
|
33
|
+
|
34
|
+
belongs_to_resource :contact
|
35
|
+
embedded_in :post
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
class Rating < Restly::Base
|
40
|
+
|
41
|
+
# root_accessible false # Todo
|
42
|
+
|
43
|
+
field :stars
|
44
|
+
field :count
|
45
|
+
|
46
|
+
belongs_to :post
|
47
|
+
|
48
|
+
end
|
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.
|
4
|
+
version: 0.0.1.alpha.7
|
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-11-
|
12
|
+
date: 2012-11-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: oauth2
|
@@ -107,6 +107,54 @@ dependencies:
|
|
107
107
|
- - ! '>='
|
108
108
|
- !ruby/object:Gem::Version
|
109
109
|
version: '0'
|
110
|
+
- !ruby/object:Gem::Dependency
|
111
|
+
name: faraday_simulation
|
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
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
name: faraday_middleware
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
129
|
+
none: false
|
130
|
+
requirements:
|
131
|
+
- - ! '>='
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
134
|
+
type: :development
|
135
|
+
prerelease: false
|
136
|
+
version_requirements: !ruby/object:Gem::Requirement
|
137
|
+
none: false
|
138
|
+
requirements:
|
139
|
+
- - ! '>='
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0'
|
142
|
+
- !ruby/object:Gem::Dependency
|
143
|
+
name: multi_xml
|
144
|
+
requirement: !ruby/object:Gem::Requirement
|
145
|
+
none: false
|
146
|
+
requirements:
|
147
|
+
- - ! '>='
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
version: '0'
|
150
|
+
type: :development
|
151
|
+
prerelease: false
|
152
|
+
version_requirements: !ruby/object:Gem::Requirement
|
153
|
+
none: false
|
154
|
+
requirements:
|
155
|
+
- - ! '>='
|
156
|
+
- !ruby/object:Gem::Version
|
157
|
+
version: '0'
|
110
158
|
description: ! ' Allows your app to authenticate a resource with oauth'
|
111
159
|
email:
|
112
160
|
- jason@waldrip.net
|
@@ -254,6 +302,7 @@ files:
|
|
254
302
|
- spec/restly/base/instance/write_callbacks_spec.rb
|
255
303
|
- spec/restly/base/instance_spec.rb
|
256
304
|
- spec/restly/base/mass_assignment_security_spec.rb
|
305
|
+
- spec/restly/base/resource/batch_actions_spec.rb
|
257
306
|
- spec/restly/base/resource/finders_spec.rb
|
258
307
|
- spec/restly/base/resource_spec.rb
|
259
308
|
- spec/restly/base_spec.rb
|
@@ -264,9 +313,10 @@ files:
|
|
264
313
|
- spec/restly/configuration_spec.rb
|
265
314
|
- spec/restly/connection_spec.rb
|
266
315
|
- spec/restly/controller_methods_spec.rb
|
267
|
-
- spec/restly/embeddable_resources/embeds_many_spec.rb
|
268
|
-
- spec/restly/embeddable_resources/embeds_one_spec.rb
|
269
316
|
- spec/restly/embeddable_resources_spec.rb
|
317
|
+
- spec/restly/embedded_associations/embedded_in_spec.rb
|
318
|
+
- spec/restly/embedded_associations/embeds_many_spec.rb
|
319
|
+
- spec/restly/embedded_associations/embeds_one_spec.rb
|
270
320
|
- spec/restly/middleware_spec.rb
|
271
321
|
- spec/restly/nested_attributes_spec.rb
|
272
322
|
- spec/restly/proxies/associations/collection_spec.rb
|
@@ -276,6 +326,11 @@ files:
|
|
276
326
|
- spec/restly/proxies/with_params_spec.rb
|
277
327
|
- spec/restly/thread_local_spec.rb
|
278
328
|
- spec/spec_helper.rb
|
329
|
+
- spec/support/memory_model.rb
|
330
|
+
- spec/support/models.rb
|
331
|
+
- spec/support/requester.rb
|
332
|
+
- spec/support/routes.rb
|
333
|
+
- spec/support/shared.rb
|
279
334
|
homepage: http://github.com/jwaldrip/restly
|
280
335
|
licenses: []
|
281
336
|
post_install_message:
|
@@ -379,6 +434,7 @@ test_files:
|
|
379
434
|
- spec/restly/base/instance/write_callbacks_spec.rb
|
380
435
|
- spec/restly/base/instance_spec.rb
|
381
436
|
- spec/restly/base/mass_assignment_security_spec.rb
|
437
|
+
- spec/restly/base/resource/batch_actions_spec.rb
|
382
438
|
- spec/restly/base/resource/finders_spec.rb
|
383
439
|
- spec/restly/base/resource_spec.rb
|
384
440
|
- spec/restly/base_spec.rb
|
@@ -389,9 +445,10 @@ test_files:
|
|
389
445
|
- spec/restly/configuration_spec.rb
|
390
446
|
- spec/restly/connection_spec.rb
|
391
447
|
- spec/restly/controller_methods_spec.rb
|
392
|
-
- spec/restly/embeddable_resources/embeds_many_spec.rb
|
393
|
-
- spec/restly/embeddable_resources/embeds_one_spec.rb
|
394
448
|
- spec/restly/embeddable_resources_spec.rb
|
449
|
+
- spec/restly/embedded_associations/embedded_in_spec.rb
|
450
|
+
- spec/restly/embedded_associations/embeds_many_spec.rb
|
451
|
+
- spec/restly/embedded_associations/embeds_one_spec.rb
|
395
452
|
- spec/restly/middleware_spec.rb
|
396
453
|
- spec/restly/nested_attributes_spec.rb
|
397
454
|
- spec/restly/proxies/associations/collection_spec.rb
|
@@ -401,4 +458,8 @@ test_files:
|
|
401
458
|
- spec/restly/proxies/with_params_spec.rb
|
402
459
|
- spec/restly/thread_local_spec.rb
|
403
460
|
- spec/spec_helper.rb
|
404
|
-
|
461
|
+
- spec/support/memory_model.rb
|
462
|
+
- spec/support/models.rb
|
463
|
+
- spec/support/requester.rb
|
464
|
+
- spec/support/routes.rb
|
465
|
+
- spec/support/shared.rb
|