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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6c23e23ec271ff868b2bbf14314e139c52ad519a
4
- data.tar.gz: 24f90d7ea852fc24096b481865dc4bccbee0a6e9
3
+ metadata.gz: 13e5a62cc6dfe31c3942831fdd45e19a23310d6a
4
+ data.tar.gz: 46c128a1dd9733c51a84196b973b872a98114d88
5
5
  SHA512:
6
- metadata.gz: c2bbdd3785a079b941bc03644965a1ec5ddec7fddab15a36ef9b10b5d88ced60cadef34b61fcc1f099b6193c20d2c26abef45b7c13bda3833dbe6fd01a297660
7
- data.tar.gz: 625748662ea61acffa8f1d27c624ff4b3316a235a2e3434b602c45eac24203357cb3ff861e9e300c481bb2ae90ab828fd09e4f0ccdc5788911273c9f66808eed
6
+ metadata.gz: 1e3fc595bb943cbafa5e1f978d98cafdad587d11fd2f7c36a520c84d3f290e50e89cc8b980e12cd31ee5d907ca0c76ae4c4e9799ab7e2cb3d3d3258ba96eea51
7
+ data.tar.gz: 8815506210db91f888a4066dd1ba524d9474cb4802f655701769f7642a2d528befefb17675365e137bbd2b05cbb109f5bf82f890f785993525504941cb5fbbff
data/CHANGELOG CHANGED
@@ -1,4 +1,11 @@
1
- * Fri Mar 25 - version 0.5.3
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
@@ -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-03-25'
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
- return @desc[v] if @desc.has_key?(v)
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)
@@ -2,6 +2,8 @@ module HaveAPI::Client
2
2
  class ProtocolError < StandardError ; end
3
3
 
4
4
  class ActionFailed < StandardError
5
+ attr_reader :response
6
+
5
7
  def initialize(response)
6
8
  @response = response
7
9
  end
@@ -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=") { |id| @params[name][ param[:value_id].to_sym ] = 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
@@ -1,6 +1,6 @@
1
1
  module HaveAPI
2
2
  module Client
3
3
  PROTOCOL_VERSION = '1.0'
4
- VERSION = '0.5.3'
4
+ VERSION = '0.5.4'
5
5
  end
6
6
  end
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.3
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-03-25 00:00:00.000000000 Z
11
+ date: 2016-04-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler