lhc 3.7.3 → 3.8.0

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: 09f1c0d9fa0645fc1048d98e3c2794a88f65e13c
4
- data.tar.gz: aaf5c617b27eb91fcb9a4927c93c35c7cd6c74ef
3
+ metadata.gz: b11d4708f7d94c14f063078c8c7d2d19ef0b17b3
4
+ data.tar.gz: 6af6b618ffbf68766bcbe1fa0aa1a90320794d1f
5
5
  SHA512:
6
- metadata.gz: d75504269905d157286034ce95f0dc298271f3150a82233554e1098a3c110a0a69e31f43ff93928645ce91f1e2c4d77442cdb3403467217c64c72e8cfe9ac46b
7
- data.tar.gz: c871bf741a099b249677586bf5ede1fad6dcdf879cb97d694085b18d2906e7be80e3b4a016b63dc1fb8235a2edd1a48bea1b2569854ace0770470418cc6c907c
6
+ metadata.gz: 9d592f45c4492bf54a9a91be316bee2023612cb21680e996812db68d9a47b3cf11c37933c4a17ef40f7c0cee919947d6f0a30fc1a27877aa6fd0c99a7e382a2f
7
+ data.tar.gz: 00b53d02f8a57a918873f110b733d7084989e2c92057d0ca66ca0a693163cbe8d8351173f3b84c703f0bd931006dc2046d0c3dc7b56cc83cbbc4bf5025e1898c
data/README.md CHANGED
@@ -57,6 +57,12 @@ The response data can be access with dot-notation and square-bracket notation. Y
57
57
  response.data[:name] # 'local.ch'
58
58
  ```
59
59
 
60
+ You can also access response data directly through the response object (with square bracket notation only):
61
+
62
+ ```ruby
63
+ LHC.json.get(url: 'http://datastore/entry/1')[:name]
64
+ ```
65
+
60
66
  ## Parallel requests
61
67
 
62
68
  If you pass an array of requests to `LHC.request`, it will perform those requests in parallel.
data/lib/lhc/response.rb CHANGED
@@ -17,6 +17,10 @@ class LHC::Response
17
17
  @data ||= LHC::Response::Data.new(self)
18
18
  end
19
19
 
20
+ def [](key)
21
+ data[key]
22
+ end
23
+
20
24
  def effective_url
21
25
  raw.effective_url
22
26
  end
data/lib/lhc/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module LHC
2
- VERSION ||= "3.7.3"
2
+ VERSION ||= "3.8.0"
3
3
  end
@@ -0,0 +1,23 @@
1
+ require 'rails_helper'
2
+
3
+ describe LHC do
4
+ context 'data accessor (hash with indifferent access)' do
5
+ before(:each) do
6
+ stub_request(:get, "http://local.ch/")
7
+ .with(headers: { 'Accept' => 'application/json', 'Content-Type' => 'application/json' })
8
+ .to_return(body: { 'MyProp' => 'MyValue' }.to_json)
9
+ end
10
+
11
+ it 'makes data accessible with square bracket accessor (string)' do
12
+ expect(
13
+ LHC.json.get('http://local.ch')['MyProp']
14
+ ).to eq 'MyValue'
15
+ end
16
+
17
+ it 'makes data accessible with square bracket accessor (symbol)' do
18
+ expect(
19
+ LHC.json.get('http://local.ch')[:MyProp]
20
+ ).to eq 'MyValue'
21
+ end
22
+ end
23
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lhc
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.7.3
4
+ version: 3.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - local.ch
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-03 00:00:00.000000000 Z
11
+ date: 2016-11-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: typhoeus
@@ -259,6 +259,7 @@ files:
259
259
  - spec/request/url_patterns_spec.rb
260
260
  - spec/response/body_spec.rb
261
261
  - spec/response/code_spec.rb
262
+ - spec/response/data_accessor_spec.rb
262
263
  - spec/response/data_spec.rb
263
264
  - spec/response/effective_url_spec.rb
264
265
  - spec/response/headers_spec.rb
@@ -371,6 +372,7 @@ test_files:
371
372
  - spec/request/url_patterns_spec.rb
372
373
  - spec/response/body_spec.rb
373
374
  - spec/response/code_spec.rb
375
+ - spec/response/data_accessor_spec.rb
374
376
  - spec/response/data_spec.rb
375
377
  - spec/response/effective_url_spec.rb
376
378
  - spec/response/headers_spec.rb