restfully 0.8.2 → 0.8.3

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.
@@ -43,6 +43,7 @@ module Restfully
43
43
  res = HTTP::Response.new(session, 200, {
44
44
  'Content-Type' => self_link.types[0]
45
45
  }, item_media_type.io)
46
+
46
47
  @items[hash] = Resource.new(session, res, req).load
47
48
  end
48
49
  block.call @items[hash]
@@ -70,6 +70,8 @@ module Restfully
70
70
  end
71
71
  end
72
72
  if element.attributes["href"]
73
+ h["id"] ||= element.attributes["id"] if element.attributes["id"]
74
+ h["name"] ||= element.attributes["name"] if element.attributes["name"]
73
75
  h["link"] ||= []
74
76
  h["link"].push({
75
77
  "href" => element.attributes["href"],
@@ -191,7 +193,7 @@ module Restfully
191
193
  end
192
194
 
193
195
  def complete?
194
- if property.reject{|k,v| k==HIDDEN_TYPE_KEY}.empty? && links.find(&:self?)
196
+ if property.reject{|k,v| [HIDDEN_TYPE_KEY, "id", "name"].include?(k)}.empty? && links.find(&:self?)
195
197
  false
196
198
  else
197
199
  true
@@ -24,7 +24,7 @@ module Restfully
24
24
  # resource["uid"]
25
25
  # => "rennes"
26
26
  def [](key)
27
- unless collection?
27
+ if !media_type.property(key) && !collection?
28
28
  expand
29
29
  end
30
30
  media_type.property(key)
@@ -195,19 +195,15 @@ module Restfully
195
195
  # Build the resource after loading.
196
196
  def build
197
197
  metaclass = class << self; self; end
198
- # only build once
199
- # if @associations.empty?
200
- extend Collection if collection?
201
-
202
- response.links.each do |link|
203
- metaclass.send(:define_method, link.id.to_sym) do |*args|
204
- session.get(link.href, :head => {
205
- 'Accept' => link.type
206
- }).load(*args)
207
- end
208
-
198
+ extend Collection if collection?
199
+
200
+ response.links.each do |link|
201
+ metaclass.send(:define_method, link.id.to_sym) do |*args|
202
+ session.get(link.href, :head => {
203
+ 'Accept' => link.type
204
+ }).load(*args)
209
205
  end
210
- # end
206
+ end
211
207
  self
212
208
  end
213
209
 
@@ -43,7 +43,7 @@ module Restfully
43
43
  end
44
44
 
45
45
  # Read configuration from file:
46
- config_file = @config.delete(:configuration_file) || ENV['RESTFULLY_CONFIG']
46
+ config_file = ENV['RESTFULLY_CONFIG'] || @config.delete(:configuration_file)
47
47
  config_file = File.expand_path(config_file) if config_file
48
48
  if config_file && File.file?(config_file) && File.readable?(config_file)
49
49
  @logger.info "Using configuration file located at #{config_file}."
@@ -1,3 +1,3 @@
1
1
  module Restfully
2
- VERSION = "0.8.2"
2
+ VERSION = "0.8.3"
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: restfully
3
3
  version: !ruby/object:Gem::Version
4
- hash: 59
4
+ hash: 57
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 8
9
- - 2
10
- version: 0.8.2
9
+ - 3
10
+ version: 0.8.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Cyril Rohr
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-05-25 00:00:00 +02:00
18
+ date: 2011-06-15 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -265,7 +265,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
265
265
  requirements: []
266
266
 
267
267
  rubyforge_project:
268
- rubygems_version: 1.5.2
268
+ rubygems_version: 1.6.2
269
269
  signing_key:
270
270
  specification_version: 3
271
271
  summary: Consume RESTful APIs effortlessly