ruby-satisfaction 0.6.7 → 0.7.0
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/Gemfile.lock +1 -1
- data/README.markdown +22 -0
- data/lib/satisfaction.rb +7 -1
- data/lib/satisfaction/company.rb +1 -5
- data/lib/satisfaction/identity_map.rb +7 -7
- data/lib/satisfaction/person.rb +1 -5
- data/lib/satisfaction/product.rb +1 -5
- data/lib/satisfaction/reply.rb +1 -5
- data/lib/satisfaction/resource.rb +7 -6
- data/lib/satisfaction/resource/attributes.rb +1 -1
- data/lib/satisfaction/tag.rb +1 -5
- data/lib/satisfaction/topic.rb +1 -5
- data/lib/satisfaction/version.rb +2 -2
- data/spec/satisfaction/identity_map_spec.rb +1 -1
- metadata +6 -6
data/Gemfile.lock
CHANGED
data/README.markdown
CHANGED
@@ -11,6 +11,28 @@ For questions, please visit the [Get Satisfaction API community][3]
|
|
11
11
|
|
12
12
|
Changelog
|
13
13
|
=========
|
14
|
+
0.7.0
|
15
|
+
|
16
|
+
* Revised Sfn::Resource so that it supports calls to API endpoints for nested resources
|
17
|
+
(e.g. /companies/cid/products/pid/topics).
|
18
|
+
|
19
|
+
IMPORTANT NOTE: This version changes the gem behavior in a way that may introduce backwards incompatibility. In
|
20
|
+
particular, with prior versions, the following code:
|
21
|
+
|
22
|
+
Satisfaction.new.companies['company_domain'].products['p_slug'].topics['t_slug'].tags
|
23
|
+
|
24
|
+
ignores the chained context of the final method call and simply sends a GET request to the following API endpoint:
|
25
|
+
|
26
|
+
/topics/t_slug/tags
|
27
|
+
|
28
|
+
With this version, however, the gem will make API calls for nested resources in the API that correspond to the chained
|
29
|
+
method calls. In particular, the above code will instead attempt to send a GET request to the following endpoint:
|
30
|
+
|
31
|
+
/companies/company_domain/products/p_slug/topics/t_slug/tags
|
32
|
+
|
33
|
+
In this particular case, the endpoint does not exist in the Get Satisfaction REST API, so API calls made to it will
|
34
|
+
yield a 404 Not Found response error.
|
35
|
+
|
14
36
|
0.6.7
|
15
37
|
|
16
38
|
* Fixed Sfn::Loader#get so it uses cached content when a 304 Not Modified is received.
|
data/lib/satisfaction.rb
CHANGED
@@ -102,7 +102,13 @@ class Satisfaction
|
|
102
102
|
end
|
103
103
|
|
104
104
|
def authorize_url(token)
|
105
|
-
|
105
|
+
uri = URI.parse(options[:authorize_url])
|
106
|
+
if uri.query.present?
|
107
|
+
uri.query += "&oauth_token=#{token.token}"
|
108
|
+
else
|
109
|
+
uri.query = "oauth_token=#{token.token}"
|
110
|
+
end
|
111
|
+
uri.to_s
|
106
112
|
end
|
107
113
|
|
108
114
|
def access_token(token)
|
data/lib/satisfaction/company.rb
CHANGED
@@ -2,10 +2,6 @@ class Sfn::Company < Sfn::Resource
|
|
2
2
|
|
3
3
|
attributes :domain, :name, :logo, :description
|
4
4
|
|
5
|
-
def path
|
6
|
-
"/companies/#{@id}"
|
7
|
-
end
|
8
|
-
|
9
5
|
def setup_associations
|
10
6
|
has_many :people, :url => "#{path}/people"
|
11
7
|
has_many :topics, :url => "#{path}/topics"
|
@@ -15,4 +11,4 @@ class Sfn::Company < Sfn::Resource
|
|
15
11
|
|
16
12
|
end
|
17
13
|
|
18
|
-
end
|
14
|
+
end
|
@@ -6,16 +6,16 @@ class Sfn::IdentityMap
|
|
6
6
|
@pages = {}
|
7
7
|
end
|
8
8
|
|
9
|
-
def get_record(klass, id, &block)
|
10
|
-
result = @records[[klass, id]]
|
9
|
+
def get_record(klass, id, path='', &block)
|
10
|
+
result = @records[[klass, id, path]]
|
11
11
|
result ||= begin
|
12
|
-
obj = yield(klass, id)
|
13
|
-
@records[[klass, id]] = obj
|
12
|
+
obj = yield(klass, id, path)
|
13
|
+
@records[[klass, id, path]] = obj
|
14
14
|
end
|
15
15
|
result
|
16
16
|
end
|
17
17
|
|
18
|
-
def expire_record(klass, id)
|
19
|
-
@records[[klass, id]] = nil
|
18
|
+
def expire_record(klass, id, path='')
|
19
|
+
@records[[klass, id, path]] = nil
|
20
20
|
end
|
21
|
-
end
|
21
|
+
end
|
data/lib/satisfaction/person.rb
CHANGED
@@ -1,10 +1,6 @@
|
|
1
1
|
class Sfn::Person < Sfn::Resource
|
2
2
|
attributes :name, :id, :photo, :tagline
|
3
3
|
|
4
|
-
def path
|
5
|
-
"/people/#{@id}"
|
6
|
-
end
|
7
|
-
|
8
4
|
def setup_associations
|
9
5
|
has_many :replies, :url => "#{path}/replies"
|
10
6
|
has_many :topics, :url => "#{path}/topics"
|
@@ -21,4 +17,4 @@ class Me < Sfn::Person
|
|
21
17
|
@id = self.attributes["id"]
|
22
18
|
setup_associations
|
23
19
|
end
|
24
|
-
end
|
20
|
+
end
|
data/lib/satisfaction/product.rb
CHANGED
@@ -3,10 +3,6 @@ class Sfn::Product < Sfn::Resource
|
|
3
3
|
attribute :last_active_at, :type => Time
|
4
4
|
attribute :created_at, :type => Time
|
5
5
|
|
6
|
-
def path
|
7
|
-
"/products/#{@id}"
|
8
|
-
end
|
9
|
-
|
10
6
|
def setup_associations
|
11
7
|
has_many :topics, :url => "#{path}/topics"
|
12
8
|
has_many :people, :url => "#{path}/people"
|
@@ -14,4 +10,4 @@ class Sfn::Product < Sfn::Resource
|
|
14
10
|
has_many :tags, :url => "#{path}/tags"
|
15
11
|
end
|
16
12
|
|
17
|
-
end
|
13
|
+
end
|
data/lib/satisfaction/reply.rb
CHANGED
@@ -4,18 +4,19 @@ class Sfn::Resource < Sfn::HasSatisfaction
|
|
4
4
|
require 'satisfaction/resource/attributes'
|
5
5
|
include ::Associations
|
6
6
|
include Attributes
|
7
|
-
attr_reader :id
|
7
|
+
attr_reader :id, :prefix
|
8
8
|
include Sfn::Util
|
9
9
|
|
10
10
|
|
11
|
-
def initialize(id, satisfaction)
|
11
|
+
def initialize(id, satisfaction, prefix='')
|
12
12
|
super satisfaction
|
13
13
|
@id = id
|
14
|
+
@prefix = prefix
|
14
15
|
setup_associations if respond_to?(:setup_associations)
|
15
16
|
end
|
16
17
|
|
17
18
|
def path
|
18
|
-
|
19
|
+
"#{prefix}/#{@id}"
|
19
20
|
end
|
20
21
|
|
21
22
|
def load
|
@@ -82,8 +83,8 @@ class Sfn::ResourceCollection < Sfn::HasSatisfaction
|
|
82
83
|
|
83
84
|
def get(id, options={})
|
84
85
|
#options currently ignored
|
85
|
-
satisfaction.identity_map.get_record(klass, id) do
|
86
|
-
klass.new(id, satisfaction)
|
86
|
+
satisfaction.identity_map.get_record(klass, id, path) do
|
87
|
+
klass.new(id, satisfaction, path)
|
87
88
|
end
|
88
89
|
end
|
89
90
|
|
@@ -206,4 +207,4 @@ class Sfn::Page < Sfn::HasSatisfaction
|
|
206
207
|
result
|
207
208
|
end
|
208
209
|
end
|
209
|
-
end
|
210
|
+
end
|
data/lib/satisfaction/tag.rb
CHANGED
@@ -1,14 +1,10 @@
|
|
1
1
|
class Sfn::Tag < Sfn::Resource
|
2
2
|
attributes :name
|
3
3
|
|
4
|
-
def path
|
5
|
-
"/tags/#{@id}"
|
6
|
-
end
|
7
|
-
|
8
4
|
def setup_associations
|
9
5
|
has_many :topics, :url => "#{path}/topics"
|
10
6
|
has_many :companies, :url => "#{path}/companies"
|
11
7
|
has_many :products, :url => "#{path}/products"
|
12
8
|
end
|
13
9
|
|
14
|
-
end
|
10
|
+
end
|
data/lib/satisfaction/topic.rb
CHANGED
@@ -4,10 +4,6 @@ class Sfn::Topic < Sfn::Resource
|
|
4
4
|
attribute :created_at, :type => Time
|
5
5
|
attribute :author, :type => Sfn::Person
|
6
6
|
|
7
|
-
def path
|
8
|
-
"/topics/#{@id}"
|
9
|
-
end
|
10
|
-
|
11
7
|
def setup_associations
|
12
8
|
has_many :replies, :url => "#{path}/replies"
|
13
9
|
has_many :people, :url => "#{path}/people"
|
@@ -17,4 +13,4 @@ class Sfn::Topic < Sfn::Resource
|
|
17
13
|
belongs_to :company
|
18
14
|
end
|
19
15
|
|
20
|
-
end
|
16
|
+
end
|
data/lib/satisfaction/version.rb
CHANGED
@@ -38,7 +38,7 @@ describe "Identity Map" do
|
|
38
38
|
end
|
39
39
|
|
40
40
|
it "should work with pages too" do
|
41
|
-
c1 = @sfn.companies.
|
41
|
+
c1 = @sfn.companies.page(1, :q => 'satisfaction').first
|
42
42
|
c2 = @sfn.companies.page(1, :q => 'satisfaction').first
|
43
43
|
|
44
44
|
c1.object_id.should == c2.object_id
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-satisfaction
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 3
|
5
|
+
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
- 6
|
9
8
|
- 7
|
10
|
-
|
9
|
+
- 0
|
10
|
+
version: 0.7.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Get Satisfaction
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-09-12 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -280,7 +280,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
280
280
|
requirements: []
|
281
281
|
|
282
282
|
rubyforge_project: ruby-satisfaction
|
283
|
-
rubygems_version: 1.
|
283
|
+
rubygems_version: 1.3.7
|
284
284
|
signing_key:
|
285
285
|
specification_version: 3
|
286
286
|
summary: Get Satisfaction ruby client
|