desk_api 0.5.5 → 0.5.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/desk_api/resource.rb +18 -3
- data/lib/desk_api/version.rb +1 -1
- data/spec/desk_api/resource_spec.rb +24 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d914c86063667152312c7edde4be07dc3cc6a525
|
4
|
+
data.tar.gz: 765f425f167b138fe446b6ebec821184338c1f6b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f9cc0b3c685040c35a78e16b83a7f81471c4d2298ae9393a6c3a94e7617746d4a4508756d94f4b2f69e27f527e59614429d17badf7feef7d11b134018023f61b
|
7
|
+
data.tar.gz: 329472a4d554b535336fc62f63d7169136afa1b99583bae0533b953e2bf977190064ad9b06a4834e1e97f078c501a1eca959482403879bea8e8f661d6d93c7b3
|
data/lib/desk_api/resource.rb
CHANGED
@@ -101,7 +101,7 @@ class DeskApi::Resource
|
|
101
101
|
protected
|
102
102
|
|
103
103
|
def clean_base_url
|
104
|
-
Addressable::URI.parse(href).path.gsub(/\/(search|\d+)$/, '')
|
104
|
+
Addressable::URI.parse(href).path.gsub(/\/(search|\d+)$/, '')
|
105
105
|
end
|
106
106
|
|
107
107
|
def exec!(reload = false)
|
@@ -146,7 +146,7 @@ private
|
|
146
146
|
|
147
147
|
return nil if links[method].nil?
|
148
148
|
return links[method] if links[method].kind_of?(self.class)
|
149
|
-
|
149
|
+
|
150
150
|
links[method] = self.class.new(@_client, self.class.build_self_link(links[method]))
|
151
151
|
end
|
152
152
|
|
@@ -162,4 +162,19 @@ private
|
|
162
162
|
|
163
163
|
super(method, *args, &block)
|
164
164
|
end
|
165
|
-
|
165
|
+
|
166
|
+
public
|
167
|
+
def respond_to?(method, include_private = false)
|
168
|
+
self.exec! unless @_loaded
|
169
|
+
|
170
|
+
meth = method.to_s
|
171
|
+
|
172
|
+
return true if is_embedded?(meth)
|
173
|
+
return true if is_link?(meth)
|
174
|
+
return true if meth.end_with?('=') and is_field?(meth[0...-1])
|
175
|
+
return true if is_field?(meth)
|
176
|
+
|
177
|
+
super
|
178
|
+
end
|
179
|
+
|
180
|
+
end
|
data/lib/desk_api/version.rb
CHANGED
@@ -66,6 +66,29 @@ describe DeskApi::Resource do
|
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
69
|
+
context '#respond_to', :vcr do
|
70
|
+
before do
|
71
|
+
@company = DeskApi::Resource.new(subject, {
|
72
|
+
'_links' => {'self'=>{'href'=>'/api/v2/cases','class'=>'page'}},
|
73
|
+
'name' => 'foo'
|
74
|
+
}, true)
|
75
|
+
end
|
76
|
+
|
77
|
+
it 'loads the resource to find a suitable method' do
|
78
|
+
@company.instance_variable_set(:@_loaded, false)
|
79
|
+
@company.should_receive(:exec!)
|
80
|
+
@company.respond_to?(:name)
|
81
|
+
end
|
82
|
+
|
83
|
+
it 'returns true if method found in definition' do
|
84
|
+
@company.respond_to?(:name).should be_true
|
85
|
+
end
|
86
|
+
|
87
|
+
it 'returns false if method does not exist' do
|
88
|
+
@company.respond_to?(:no_method_here).should be_false
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
69
92
|
context '#by_url', :vcr do
|
70
93
|
it 'finds resources by url' do
|
71
94
|
subject.articles.by_url('/api/v2/articles/1295677').should be_an_instance_of(DeskApi::Resource)
|
@@ -321,4 +344,4 @@ describe DeskApi::Resource do
|
|
321
344
|
@company.name.should eq('Desk.com')
|
322
345
|
end
|
323
346
|
end
|
324
|
-
end
|
347
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: desk_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thomas Stachl
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-02-
|
11
|
+
date: 2014-02-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday_middleware
|