haveapi-client 0.5.3 → 0.5.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +8 -1
- data/haveapi-client.gemspec +1 -1
- data/lib/haveapi/client/communicator.rb +1 -4
- data/lib/haveapi/client/exceptions.rb +2 -0
- data/lib/haveapi/client/resource.rb +9 -0
- data/lib/haveapi/client/resource_instance.rb +17 -1
- data/lib/haveapi/client/version.rb +1 -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: 13e5a62cc6dfe31c3942831fdd45e19a23310d6a
|
4
|
+
data.tar.gz: 46c128a1dd9733c51a84196b973b872a98114d88
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1e3fc595bb943cbafa5e1f978d98cafdad587d11fd2f7c36a520c84d3f290e50e89cc8b980e12cd31ee5d907ca0c76ae4c4e9799ab7e2cb3d3d3258ba96eea51
|
7
|
+
data.tar.gz: 8815506210db91f888a4066dd1ba524d9474cb4802f655701769f7642a2d528befefb17675365e137bbd2b05cbb109f5bf82f890f785993525504941cb5fbbff
|
data/CHANGELOG
CHANGED
@@ -1,4 +1,11 @@
|
|
1
|
-
*
|
1
|
+
* Mon Apr 18 2016 - version 0.5.4
|
2
|
+
- ActionFailed: add reader for response
|
3
|
+
- Resource: save description and create a reader for it
|
4
|
+
- Communicator: do not cache API description per version
|
5
|
+
- ResourceInstance: id writer changes associated instance object
|
6
|
+
- ResourceInstance.resolve: set @prepared_args
|
7
|
+
|
8
|
+
* Fri Mar 25 2016 - version 0.5.3
|
2
9
|
- Depend on rest-client 1.8
|
3
10
|
|
4
11
|
* Thu Mar 03 2016 - version 0.5.2
|
data/haveapi-client.gemspec
CHANGED
@@ -6,7 +6,7 @@ require 'haveapi/client/version'
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = 'haveapi-client'
|
8
8
|
spec.version = HaveAPI::Client::VERSION
|
9
|
-
spec.date = '2016-
|
9
|
+
spec.date = '2016-04-18'
|
10
10
|
spec.authors = ['Jakub Skokan']
|
11
11
|
spec.email = ['jakub.skokan@vpsfree.cz']
|
12
12
|
spec.summary =
|
@@ -24,7 +24,6 @@ module HaveAPI::Client
|
|
24
24
|
@rest = RestClient::Resource.new(@url)
|
25
25
|
@version = v
|
26
26
|
@identity = 'haveapi-client-ruby'
|
27
|
-
@desc = {}
|
28
27
|
end
|
29
28
|
|
30
29
|
# @return [:compatible] if perfectly compatible
|
@@ -58,9 +57,7 @@ module HaveAPI::Client
|
|
58
57
|
end
|
59
58
|
|
60
59
|
def describe_api(v=nil)
|
61
|
-
|
62
|
-
|
63
|
-
@desc[v] = description_for(path_for(v), v.nil? ? {describe: :default} : {})
|
60
|
+
description_for(path_for(v), v.nil? ? {describe: :default} : {})
|
64
61
|
end
|
65
62
|
|
66
63
|
def describe_resource(path)
|
@@ -14,6 +14,8 @@ module HaveAPI::Client
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def setup(description)
|
17
|
+
@description = description
|
18
|
+
|
17
19
|
description[:actions].each do |name, desc|
|
18
20
|
action = HaveAPI::Client::Action.new(@api, name, desc, [])
|
19
21
|
define_action(action)
|
@@ -59,6 +61,13 @@ module HaveAPI::Client
|
|
59
61
|
@name
|
60
62
|
end
|
61
63
|
|
64
|
+
# Return resource description.
|
65
|
+
# Method is prefixed with an underscore to prevent name collision
|
66
|
+
# with ResourceInstance attributes.
|
67
|
+
def _description
|
68
|
+
@description
|
69
|
+
end
|
70
|
+
|
62
71
|
protected
|
63
72
|
# Define access/write methods for action +action+.
|
64
73
|
def define_action(action)
|
@@ -84,6 +84,7 @@ module HaveAPI::Client
|
|
84
84
|
setup_from_clone(@resource)
|
85
85
|
define_attributes
|
86
86
|
|
87
|
+
@prepared_args = @response.meta[:url_params]
|
87
88
|
@resolved = true
|
88
89
|
self
|
89
90
|
end
|
@@ -114,7 +115,22 @@ module HaveAPI::Client
|
|
114
115
|
ensure_method(:"#{name}_id") { @params[name][ param[:value_id].to_sym ] }
|
115
116
|
|
116
117
|
# id writer
|
117
|
-
ensure_method(:"#{name}_id=")
|
118
|
+
ensure_method(:"#{name}_id=") do |id|
|
119
|
+
@params[name][ param[:value_id].to_sym ] = id
|
120
|
+
|
121
|
+
@resource_instances[name] = find_association(
|
122
|
+
param,
|
123
|
+
{
|
124
|
+
param[:value_id] => id,
|
125
|
+
:_meta => {
|
126
|
+
resolved: false,
|
127
|
+
# TODO: this will not work for nested resources, as they have
|
128
|
+
# multiple IDs
|
129
|
+
url_params: [id],
|
130
|
+
},
|
131
|
+
}
|
132
|
+
)
|
133
|
+
end
|
118
134
|
|
119
135
|
# value reader
|
120
136
|
ensure_method(name) do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: haveapi-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jakub Skokan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-04-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|