api_client 0.5.18 → 0.5.19

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
- SHA256:
3
- metadata.gz: e7980882966d6be9d46eb6ccefda12d73f298c304e70978e9f02551306f043e4
4
- data.tar.gz: 06e03619e8809b5cbfed6d0adb0141aba5534a5e799720894c9b1b89f746b6e6
2
+ SHA1:
3
+ metadata.gz: 8eeb2b5ca77044aee74791f6fe2602caf0ec55fa
4
+ data.tar.gz: fc1580088fa93289ccff7c1c0f02aeb2ebd520da
5
5
  SHA512:
6
- metadata.gz: 2d2603112847dcacdc6a1d81e60ad08c52c4dfe078b1ae08f2dd5965c9f25fc4d03aab868e4731f9d8daf191e5952877e2e32b89987bb0f30c19cf4ae1e6d616
7
- data.tar.gz: 8259db14092fb9999e9a71be673e5875991f22729ff3664a562e1a5ad593ac33c959abc4afc257d963d841293c7b5baabfd0c29e3c68e49f26e787dfebb7a01f
6
+ metadata.gz: 34872ccc6e39ca70e0e00be9f80f387562beee0c26ac1e59ce14f936b379449ad262b141bd2be5f3589bff82c3489b20d62c1612078f66678dabe83f172acadc
7
+ data.tar.gz: 535cb5860e13acbe078d742430b182312e459663b8760c523b4ba23e9c8f0e9f53c10c2c2853d5f7f171d06cde06a491278bac86fdf1b7527042939e8aa334be
data/.gitignore CHANGED
@@ -6,3 +6,4 @@ bin
6
6
  coverage
7
7
  examples/config.rb
8
8
  *.sw[a-z]
9
+ .idea/*
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ # 0.5.19
2
+
3
+ * introduced PATCH requests.
4
+ * brought back ruby < 2.1 compatibility. Process::CLOCK_MONOTONIC is not present until ruby 2.2. There was a breaking change since 0.5.16.
5
+
1
6
  # 0.5.18
2
7
 
3
8
  * pass along the caller to each `connection` hook
@@ -11,7 +11,7 @@ module ApiClient
11
11
  extend ApiClient::Mixins::Delegation
12
12
  extend ApiClient::Mixins::Configuration
13
13
 
14
- delegate :fetch, :get, :put, :post, :delete, :headers, :endpoint, :options, :adapter, :params, :raw, :to => :scope
14
+ delegate :fetch, :get, :put, :post, :patch, :delete, :headers, :endpoint, :options, :adapter, :params, :raw, :to => :scope
15
15
 
16
16
  dsl_accessor :format, :namespace
17
17
 
@@ -38,6 +38,17 @@ module ApiClient
38
38
  def post(path, data = {}, headers = {})
39
39
  end
40
40
 
41
+ #### ApiClient::Connection::Abstract#patch
42
+ # Performs a PATCH request
43
+ # Accepts three parameters:
44
+ #
45
+ # * path - the path request should go to
46
+ # * data - (optional) data sent in the request
47
+ # * headers - (optional) headers sent along in the request
48
+ #
49
+ def patch(path, data = {}, headers = {})
50
+ end
51
+
41
52
  #### ApiClient::Connection::Abstract#put
42
53
  # Performs a PUT request
43
54
  # Accepts three parameters:
@@ -43,6 +43,19 @@ module ApiClient
43
43
  exec_request(:post, path, data, headers)
44
44
  end
45
45
 
46
+ #### ApiClient::Connection::Abstract#patch
47
+ # Performs a PATCH request
48
+ # Accepts three parameters:
49
+ #
50
+ # * path - the path request should go to
51
+ # * data - (optional) data sent in the request
52
+ # * headers - (optional) headers sent along in the request
53
+ #
54
+ # This method automatically adds the application token header
55
+ def patch(path, data = {}, headers = {})
56
+ exec_request(:patch, path, data, headers)
57
+ end
58
+
46
59
  #### ApiClient::Connection::Abstract#put
47
60
  # Performs a PUT request
48
61
  # Accepts three parameters:
@@ -7,9 +7,9 @@ class ApiClient::Connection::Middlewares::Request::Logger < Faraday::Middleware
7
7
 
8
8
  gather_request_debug_lines(env, debug_lines) if should_log_details
9
9
 
10
- start = current_stamp_millisec
10
+ start = CurrentTimestamp.milis
11
11
  response = @app.call(env)
12
- taken_sec = (current_stamp_millisec - start) / 1000.0
12
+ taken_sec = (CurrentTimestamp.milis - start) / 1000.0
13
13
 
14
14
  gather_response_debug_lines(response, taken_sec, debug_lines) if response && should_log_details
15
15
 
@@ -46,7 +46,19 @@ class ApiClient::Connection::Middlewares::Request::Logger < Faraday::Middleware
46
46
  debug_lines
47
47
  end
48
48
 
49
- def current_stamp_millisec
50
- Process.clock_gettime(Process::CLOCK_MONOTONIC, :millisecond)
49
+ class CurrentTimestamp
50
+ class << self
51
+ version = RUBY_VERSION.split('.').map(&:to_i)
52
+
53
+ if (version[0] < 2) || (version[0] == 2 && version[1] < 2)
54
+ def milis
55
+ (Time.now.to_f * 1000).to_i
56
+ end
57
+ else
58
+ def milis
59
+ Process.clock_gettime(Process::CLOCK_MONOTONIC, :millisecond)
60
+ end
61
+ end
62
+ end
51
63
  end
52
64
  end
@@ -97,6 +97,10 @@ module ApiClient
97
97
  request(:post, path, options)
98
98
  end
99
99
 
100
+ def patch(path, options = {})
101
+ request(:patch, path, options)
102
+ end
103
+
100
104
  def put(path, options = {})
101
105
  request(:put, path, options)
102
106
  end
@@ -1,3 +1,3 @@
1
1
  module ApiClient
2
- VERSION = "0.5.18"
2
+ VERSION = "0.5.19"
3
3
  end
@@ -5,7 +5,7 @@ describe ApiClient::Base do
5
5
  it "delegates methods to scope" do
6
6
  scope = double
7
7
  ApiClient::Base.stub(:scope).and_return(scope)
8
- [:fetch, :get, :put, :post, :delete, :headers, :endpoint, :options, :adapter, :params, :raw].each do |method|
8
+ [:fetch, :get, :put, :post, :patch, :delete, :headers, :endpoint, :options, :adapter, :params, :raw].each do |method|
9
9
  scope.should_receive(method)
10
10
  ApiClient::Base.send(method)
11
11
  end
@@ -58,6 +58,14 @@ describe ApiClient::Connection::Basic do
58
58
  @instance.post "/home", @params, @headers
59
59
  end
60
60
 
61
+ it "can perform PATCH requests" do
62
+ @instance.handler.
63
+ should_receive(:run_request).
64
+ with(:patch, '/home', @params, @headers).
65
+ and_return(@response)
66
+ @instance.patch "/home", @params, @headers
67
+ end
68
+
61
69
  it "can perform PUT requests" do
62
70
  @instance.handler.
63
71
  should_receive(:run_request).
@@ -147,6 +147,11 @@ describe ApiClient::Scope do
147
147
  result.should == {"a"=> "1"}
148
148
  end
149
149
 
150
+ it "makes a PATCH request" do
151
+ result = test_request :patch
152
+ result.should == {"a"=> "1"}
153
+ end
154
+
150
155
  it "makes a PUT request" do
151
156
  result = test_request :put
152
157
  result.should == {"a"=> "1"}
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: api_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.18
4
+ version: 0.5.19
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcin Bunsch
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-10-11 00:00:00.000000000 Z
11
+ date: 2019-05-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -165,7 +165,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
165
165
  version: '0'
166
166
  requirements: []
167
167
  rubyforge_project: api_client
168
- rubygems_version: 2.7.7
168
+ rubygems_version: 2.4.5.5
169
169
  signing_key:
170
170
  specification_version: 3
171
171
  summary: API client builder