api_client 0.5.7 → 0.5.9

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: afef879f60d75b581ba06820fe2a817926984909
4
- data.tar.gz: 3fc80dfc8684c9a7002cb5ef90f309621951c652
3
+ metadata.gz: 43c461e0ff353c1755880974f8704c1bee7176b0
4
+ data.tar.gz: f271d02470638507b7e5ddcd1b3e1c537d6d19fc
5
5
  SHA512:
6
- metadata.gz: 572c68cf1e8c7da1d39afc7c15bce81b72a17f0f9046140492e327aa673f68bee195072d0a335dd3822981bb37dcc7ced9adc8e43fb9de04eb0c6b7b5a2ec3bf
7
- data.tar.gz: 77c85f3c1f0c1da5644e61dd1b452caca2335a1ce5bc7093c5d03de7ffc5ca6b2a274f98e2f3c0a5232d3f737d1370bad3b166472dd95e00189f2b40211fc1b5
6
+ metadata.gz: 3dc40c025d6ebfd1e6e7e35be9b36f4a57feb5bbfc8c0c491bc2e73094964d881136cc79bf42dac693a02916fb4e057081bb5618ad490fe1421e193342cccac7
7
+ data.tar.gz: f5b8195b7f425819af8662333a62534c62251fa023c371499530cd90517cdee74b5b1e178321d1ad66411df5565c4ff446db83d81a727bf0edace6c0baf96d82
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ language: ruby
2
+ script: bundle exec rspec spec
3
+ rvm:
4
+ - 1.8.7
5
+ - 1.9.3
6
+ - 2.0.0
7
+ - 2.1.2
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ # 0.5.9
2
+
3
+ * fix compatibility with ruby 1.8.x
4
+
5
+ # 0.5.8
6
+
7
+ * fix the problem with strict_attr_reader and Array#flatten
8
+
1
9
  # 0.5.7
2
10
 
3
11
  * fix compatibility with hashie 2.1.0 and strict_attr_reader
data/Gemfile CHANGED
@@ -4,9 +4,8 @@ source "http://rubygems.org"
4
4
  gemspec
5
5
 
6
6
  # Testing
7
- gem "rspec"
8
7
  gem "simplecov"
9
8
 
10
9
  # Soft dependencies
11
- gem "simple_oauth"
10
+ gem "simple_oauth", '0.2.0'
12
11
  gem 'multi_xml'
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- ApiClient
1
+ ApiClient [![Build Status](https://travis-ci.org/futuresimple/api_client.svg?branch=master)](https://travis-ci.org/futuresimple/api_client)
2
2
  =========
3
3
 
4
4
  ApiClient is an experimental builder for HTTP API clients. The goal is to provide a easy to use engine for constructing queries and map the responses to instances of Hashie::Mash subclasses.
data/api_client.gemspec CHANGED
@@ -7,7 +7,7 @@ Gem::Specification.new do |s|
7
7
  s.version = ApiClient::VERSION
8
8
  s.authors = ["Marcin Bunsch"]
9
9
  s.email = ["marcin@futuresimple.com"]
10
- s.homepage = ""
10
+ s.homepage = "https://github.com/futuresimple/api_client"
11
11
  s.summary = %q{API client builder}
12
12
  s.description = %q{API client builder}
13
13
 
@@ -47,6 +47,8 @@ Gem::Specification.new do |s|
47
47
  s.add_dependency(%q<multi_json>, [">= 1.6.1"])
48
48
  end
49
49
 
50
+ s.add_development_dependency "rspec", '2.14.1'
51
+
50
52
  s.files = `git ls-files`.split("\n")
51
53
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
52
54
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
@@ -60,13 +60,19 @@ module ApiClient
60
60
  def method_missing(method_name, *args, &blk)
61
61
  if respond_to?(method_name) || has_special_ending?(method_name)
62
62
  super
63
- elsif respond_to?(:strict_attr_reader?) && self.strict_attr_reader?
63
+ elsif use_strict_reader?(method_name)
64
64
  fetch(method_name)
65
65
  else
66
66
  super
67
67
  end
68
68
  end
69
69
 
70
+ def use_strict_reader?(method_name)
71
+ respond_to?(:strict_attr_reader?) &&
72
+ self.strict_attr_reader? &&
73
+ method_name != :to_ary
74
+ end
75
+
70
76
  def has_special_ending?(name)
71
77
  name.to_s =~ /[?=]$/
72
78
  end
@@ -76,7 +76,7 @@ module ApiClient
76
76
 
77
77
  def exec_request(method, path, data, headers)
78
78
  response = @handler.send(method, path, data, headers)
79
- request = {method: method, path: path, data: data}
79
+ request = { :method => method, :path => path, :data => data}
80
80
  handle_response(request, response)
81
81
  rescue Faraday::Error::ConnectionFailed => e
82
82
  raise ApiClient::Errors::ConnectionFailed.new(e.message, request, response)
@@ -2,7 +2,7 @@ module ApiClient
2
2
 
3
3
  module Errors
4
4
  class ApiClientError < StandardError
5
- def initialize(message=nil, request, response)
5
+ def initialize(message = nil, request = nil, response = nil)
6
6
  super(message)
7
7
  @request = request
8
8
  @response = response
@@ -1,3 +1,3 @@
1
1
  module ApiClient
2
- VERSION = "0.5.7"
2
+ VERSION = "0.5.9"
3
3
  end
@@ -23,6 +23,16 @@ describe ApiClient::Base do
23
23
  class StrictDescendant < StrictApi
24
24
  end
25
25
 
26
+ context "when used in an array" do
27
+
28
+ subject { [StrictApi.new] }
29
+
30
+ it "does not break Array#flatten" do
31
+ lambda { subject.flatten }.should_not raise_error
32
+ end
33
+
34
+ end
35
+
26
36
  describe "#inspect" do
27
37
 
28
38
  it "has a nice inspect" do
@@ -50,7 +60,10 @@ describe ApiClient::Base do
50
60
  describe "strict_read" do
51
61
  it "fails if the key is missing and strict_read is set" do
52
62
  api = StrictApi.new
53
- lambda { api.missing }.should raise_error(KeyError)
63
+ lambda { api.missing }.should raise_error do |error|
64
+ error_type = error.class.to_s
65
+ error_type.should match(/KeyError|IndexError/)
66
+ end
54
67
  end
55
68
 
56
69
  it "doesn't fail if strict_read is not set" do
@@ -77,12 +90,18 @@ describe ApiClient::Base do
77
90
 
78
91
  it "calling method which asks for missing attribute fails" do
79
92
  api = StrictApi.new
80
- lambda { api.accessor_of_x }.should raise_error(KeyError)
93
+ lambda { api.accessor_of_x }.should raise_error do |error|
94
+ error_type = error.class.to_s
95
+ error_type.should match(/KeyError|IndexError/)
96
+ end
81
97
  end
82
98
 
83
99
  it "passes strict api configuration to subclasses" do
84
100
  api = StrictDescendant.new
85
- lambda { api.missing }.should raise_error(KeyError)
101
+ lambda { api.missing }.should raise_error do |error|
102
+ error_type = error.class.to_s
103
+ error_type.should match(/KeyError|IndexError/)
104
+ end
86
105
  end
87
106
  end
88
107
  end
@@ -13,7 +13,7 @@ describe ApiClient::Connection::Middlewares::Request::Logger do
13
13
  }
14
14
  app.should_receive(:call).with(env)
15
15
  instance.call(env)
16
- logger.history.first.should == "GET http://api.twitter.com: 0.0000 seconds"
16
+ logger.history.first.include?("GET http://api.twitter.com").should be_true
17
17
  end
18
18
 
19
19
  end
metadata CHANGED
@@ -1,71 +1,85 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: api_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.7
4
+ version: 0.5.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcin Bunsch
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-14 00:00:00.000000000 Z
11
+ date: 2015-02-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: yajl-ruby
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: faraday
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: 0.8.1
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: 0.8.1
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: hashie
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: 2.0.5
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: 2.0.5
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: multi_json
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: 1.6.1
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: 1.6.1
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '='
74
+ - !ruby/object:Gem::Version
75
+ version: 2.14.1
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '='
81
+ - !ruby/object:Gem::Version
82
+ version: 2.14.1
69
83
  description: API client builder
70
84
  email:
71
85
  - marcin@futuresimple.com
@@ -73,8 +87,9 @@ executables: []
73
87
  extensions: []
74
88
  extra_rdoc_files: []
75
89
  files:
76
- - .gitignore
77
- - .rspec
90
+ - ".gitignore"
91
+ - ".rspec"
92
+ - ".travis.yml"
78
93
  - CHANGELOG.md
79
94
  - Gemfile
80
95
  - LICENSE
@@ -130,7 +145,7 @@ files:
130
145
  - spec/spec_helper.rb
131
146
  - spec/support/fake_logger.rb
132
147
  - spec/support/matchers.rb
133
- homepage: ''
148
+ homepage: https://github.com/futuresimple/api_client
134
149
  licenses: []
135
150
  metadata: {}
136
151
  post_install_message:
@@ -139,17 +154,17 @@ require_paths:
139
154
  - lib
140
155
  required_ruby_version: !ruby/object:Gem::Requirement
141
156
  requirements:
142
- - - '>='
157
+ - - ">="
143
158
  - !ruby/object:Gem::Version
144
159
  version: '0'
145
160
  required_rubygems_version: !ruby/object:Gem::Requirement
146
161
  requirements:
147
- - - '>='
162
+ - - ">="
148
163
  - !ruby/object:Gem::Version
149
164
  version: '0'
150
165
  requirements: []
151
166
  rubyforge_project: api_client
152
- rubygems_version: 2.0.5
167
+ rubygems_version: 2.2.2
153
168
  signing_key:
154
169
  specification_version: 3
155
170
  summary: API client builder