harpy 0.1.7 → 0.1.8

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -2,3 +2,4 @@
2
2
  .bundle
3
3
  Gemfile.lock
4
4
  pkg/*
5
+ *.rbc
data/.travis.yml ADDED
@@ -0,0 +1,9 @@
1
+ rvm:
2
+ - rbx
3
+ - rbx-2.0
4
+ - 1.8.7
5
+ - ree
6
+ - 1.9.2
7
+ - ruby-head
8
+ notifications:
9
+ disabled: true
data/README.md CHANGED
@@ -159,8 +159,10 @@ Usage
159
159
  })
160
160
  # => {FirstModel => [...], SecondModel => [...]}
161
161
 
162
- About
163
- -----
162
+ Build Status
163
+ ---------
164
+
165
+ [![Build Status](http://travis-ci.org/TalentBox/harpy.png)](http://travis-ci.org/TalentBox/harpy)
164
166
 
165
167
  License
166
168
  -------
@@ -0,0 +1,18 @@
1
+ module Harpy
2
+ class Collection
3
+ include Resource
4
+ def initialize(attrs = nil)
5
+ attrs = attrs || {}
6
+ @items = attrs.delete :items
7
+ super attrs
8
+ end
9
+ private
10
+ def method_missing(method, *args)
11
+ if @items.respond_to? method
12
+ @items.send method, *args
13
+ else
14
+ super
15
+ end
16
+ end
17
+ end
18
+ end
@@ -1,4 +1,3 @@
1
- require "harpy/client"
2
1
  require "active_support"
3
2
  require "active_support/core_ext/object/blank"
4
3
  require "active_support/core_ext/numeric/bytes"
@@ -65,7 +64,8 @@ module Harpy
65
64
  case response.code
66
65
  when 200
67
66
  parsed = Yajl::Parser.parse response.body
68
- parsed[resource_name].collect{|model| new model}
67
+ items = parsed[resource_name].collect{|model| new model}
68
+ Harpy::Collection.new parsed.merge(items: items)
69
69
  else
70
70
  Harpy.client.invalid_code response
71
71
  end
data/lib/harpy/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Harpy
2
- VERSION = "0.1.7"
2
+ VERSION = "0.1.8"
3
3
  end
data/lib/harpy.rb CHANGED
@@ -9,6 +9,7 @@ module Harpy
9
9
  class InvalidResponseCode < Exception; end
10
10
 
11
11
  autoload :Client, "harpy/client"
12
+ autoload :Collection, "harpy/collection"
12
13
  autoload :EntryPoint, "harpy/entry_point"
13
14
  autoload :Resource, "harpy/resource"
14
15
  autoload :BodyToBig, "harpy/resource"
@@ -326,10 +326,12 @@ describe "class including Harpy::Resource" do
326
326
  eos
327
327
  Harpy.client.should_receive(:get).with(url, :params => {"firstname" => "Anthony"}).and_return response
328
328
  companies = Harpy::Spec::Company.search "firstname" => "Anthony"
329
- companies.should have(1).item
329
+ companies.should be_kind_of Harpy::Collection
330
+ companies.size.should == 1
330
331
  companies.first.should be_kind_of Harpy::Spec::Company
331
332
  companies.first.firstname.should == "Anthony"
332
333
  companies.first.id.should == "1"
334
+ companies.url.should == url
333
335
  end
334
336
  it "delegates other response codes to client" do
335
337
  response = Typhoeus::Response.new :code => 500
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: harpy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,12 +10,11 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2011-08-04 00:00:00.000000000 +02:00
14
- default_executable:
13
+ date: 2011-08-22 00:00:00.000000000Z
15
14
  dependencies:
16
15
  - !ruby/object:Gem::Dependency
17
16
  name: typhoeus
18
- requirement: &2160282920 !ruby/object:Gem::Requirement
17
+ requirement: &2151753400 !ruby/object:Gem::Requirement
19
18
  none: false
20
19
  requirements:
21
20
  - - ~>
@@ -23,10 +22,10 @@ dependencies:
23
22
  version: 0.2.4
24
23
  type: :runtime
25
24
  prerelease: false
26
- version_requirements: *2160282920
25
+ version_requirements: *2151753400
27
26
  - !ruby/object:Gem::Dependency
28
27
  name: activesupport
29
- requirement: &2160282260 !ruby/object:Gem::Requirement
28
+ requirement: &2151750940 !ruby/object:Gem::Requirement
30
29
  none: false
31
30
  requirements:
32
31
  - - ! '>='
@@ -34,10 +33,10 @@ dependencies:
34
33
  version: 3.0.0
35
34
  type: :runtime
36
35
  prerelease: false
37
- version_requirements: *2160282260
36
+ version_requirements: *2151750940
38
37
  - !ruby/object:Gem::Dependency
39
38
  name: activemodel
40
- requirement: &2160281760 !ruby/object:Gem::Requirement
39
+ requirement: &2151755800 !ruby/object:Gem::Requirement
41
40
  none: false
42
41
  requirements:
43
42
  - - ! '>='
@@ -45,10 +44,10 @@ dependencies:
45
44
  version: 3.0.0
46
45
  type: :runtime
47
46
  prerelease: false
48
- version_requirements: *2160281760
47
+ version_requirements: *2151755800
49
48
  - !ruby/object:Gem::Dependency
50
49
  name: hash-deep-merge
51
- requirement: &2160281280 !ruby/object:Gem::Requirement
50
+ requirement: &2151797880 !ruby/object:Gem::Requirement
52
51
  none: false
53
52
  requirements:
54
53
  - - ~>
@@ -56,10 +55,10 @@ dependencies:
56
55
  version: 0.1.1
57
56
  type: :runtime
58
57
  prerelease: false
59
- version_requirements: *2160281280
58
+ version_requirements: *2151797880
60
59
  - !ruby/object:Gem::Dependency
61
60
  name: yajl-ruby
62
- requirement: &2160280500 !ruby/object:Gem::Requirement
61
+ requirement: &2151821160 !ruby/object:Gem::Requirement
63
62
  none: false
64
63
  requirements:
65
64
  - - ~>
@@ -67,10 +66,10 @@ dependencies:
67
66
  version: 0.8.2
68
67
  type: :runtime
69
68
  prerelease: false
70
- version_requirements: *2160280500
69
+ version_requirements: *2151821160
71
70
  - !ruby/object:Gem::Dependency
72
71
  name: rake
73
- requirement: &2160280000 !ruby/object:Gem::Requirement
72
+ requirement: &2151838760 !ruby/object:Gem::Requirement
74
73
  none: false
75
74
  requirements:
76
75
  - - ~>
@@ -78,10 +77,10 @@ dependencies:
78
77
  version: 0.8.7
79
78
  type: :development
80
79
  prerelease: false
81
- version_requirements: *2160280000
80
+ version_requirements: *2151838760
82
81
  - !ruby/object:Gem::Dependency
83
82
  name: rspec
84
- requirement: &2160279480 !ruby/object:Gem::Requirement
83
+ requirement: &2151848480 !ruby/object:Gem::Requirement
85
84
  none: false
86
85
  requirements:
87
86
  - - ~>
@@ -89,10 +88,10 @@ dependencies:
89
88
  version: 2.6.0
90
89
  type: :development
91
90
  prerelease: false
92
- version_requirements: *2160279480
91
+ version_requirements: *2151848480
93
92
  - !ruby/object:Gem::Dependency
94
93
  name: rocco
95
- requirement: &2160278960 !ruby/object:Gem::Requirement
94
+ requirement: &2151858660 !ruby/object:Gem::Requirement
96
95
  none: false
97
96
  requirements:
98
97
  - - ~>
@@ -100,7 +99,7 @@ dependencies:
100
99
  version: '0.7'
101
100
  type: :development
102
101
  prerelease: false
103
- version_requirements: *2160278960
102
+ version_requirements: *2151858660
104
103
  description: Client for REST API with HATEOAS
105
104
  email:
106
105
  - joseph.halter@thetalentbox.com
@@ -111,6 +110,7 @@ extra_rdoc_files: []
111
110
  files:
112
111
  - .gitignore
113
112
  - .rspec
113
+ - .travis.yml
114
114
  - Gemfile
115
115
  - LICENSE
116
116
  - README.md
@@ -118,6 +118,7 @@ files:
118
118
  - harpy.gemspec
119
119
  - lib/harpy.rb
120
120
  - lib/harpy/client.rb
121
+ - lib/harpy/collection.rb
121
122
  - lib/harpy/entry_point.rb
122
123
  - lib/harpy/resource.rb
123
124
  - lib/harpy/version.rb
@@ -126,7 +127,6 @@ files:
126
127
  - spec/harpy/resource_spec.rb
127
128
  - spec/harpy_spec.rb
128
129
  - spec/spec_helper.rb
129
- has_rdoc: true
130
130
  homepage: https://github.com/TalentBox/harpy
131
131
  licenses: []
132
132
  post_install_message:
@@ -147,7 +147,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
147
147
  version: '0'
148
148
  requirements: []
149
149
  rubyforge_project:
150
- rubygems_version: 1.6.2
150
+ rubygems_version: 1.8.6
151
151
  signing_key:
152
152
  specification_version: 3
153
153
  summary: Client for REST API