etre-client 0.8.1 → 0.8.2
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.
- checksums.yaml +4 -4
- data/README.md +12 -1
- data/lib/etre-client/client.rb +3 -18
- data/lib/etre-client/version.rb +1 -1
- data/spec/client_spec.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 44d824a5e5b29f32d0523730882e2a021688e0f6
|
4
|
+
data.tar.gz: 673709db37ec3eb8d1c3f80a5381a3d488be2230
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bc1b87620cbd76905693db58a98575a8eafd8deba25f0821adea0a21b2aa491dff2a42c9815544c6cde91caf21f4c0ff94c4ad6bc1ac435e2d90fd1f6f822591
|
7
|
+
data.tar.gz: ee959e545e5ca61da91215a41af8b00e1c8ab8df0a94ed29ce8660cf524fae70ca43984af84c2918ec459e890ef4279d6938cce2b27ce7904439fdf83a8991df
|
data/README.md
CHANGED
@@ -21,7 +21,18 @@ require 'etre-client'
|
|
21
21
|
|
22
22
|
Create a new client
|
23
23
|
```
|
24
|
-
|
24
|
+
# Create a standard client.
|
25
|
+
e = Etre::Client.new(entity_type: "node", url: "http://127.0.0.1:8080")
|
26
|
+
|
27
|
+
# Create a client with advanced HTTP options. Can put whatever you want in here.
|
28
|
+
options = {
|
29
|
+
:ssl_client_cert => OpenSSL::X509::Certificate.new(File.read("path_to_ssl_cert")),
|
30
|
+
:ssl_client_key => OpenSSL::PKey::RSA.new(File.read("path_to_ssl_key")),
|
31
|
+
:ssl_ca_file => "path_to_ssl_ca",
|
32
|
+
:verify_ssl => OpenSSL::SSL::VERIFY_PEER,
|
33
|
+
:cookies => {:foo => "bar"},
|
34
|
+
}
|
35
|
+
e = Etre::Client.new(entity_type: "node", url: "http://127.0.0.1:8080", options: options)
|
25
36
|
```
|
26
37
|
|
27
38
|
Insert entities
|
data/lib/etre-client/client.rb
CHANGED
@@ -10,14 +10,10 @@ module Etre
|
|
10
10
|
META_LABEL_ID = "_id"
|
11
11
|
META_LABEL_TYPE = "_type"
|
12
12
|
|
13
|
-
def initialize(entity_type:, url:,
|
13
|
+
def initialize(entity_type:, url:, options: {})
|
14
14
|
@entity_type = entity_type
|
15
15
|
@url = url
|
16
|
-
|
17
|
-
@ssl_cert = ssl_cert
|
18
|
-
@ssl_key = ssl_key
|
19
|
-
@ssl_ca = ssl_ca
|
20
|
-
@insecure = insecure
|
16
|
+
@options = options
|
21
17
|
end
|
22
18
|
|
23
19
|
# query returns an array of entities that satisfy a query.
|
@@ -282,23 +278,12 @@ module Etre
|
|
282
278
|
end
|
283
279
|
|
284
280
|
def resource_for_route(route)
|
285
|
-
opts = {}
|
286
|
-
opts.merge!(ssl_options) unless @insecure
|
287
281
|
RestClient::Resource.new(
|
288
282
|
@url + API_ROOT + route,
|
289
|
-
|
283
|
+
@options
|
290
284
|
)
|
291
285
|
end
|
292
286
|
|
293
|
-
def ssl_options
|
294
|
-
{
|
295
|
-
:ssl_client_cert => OpenSSL::X509::Certificate.new(File.read(@ssl_cert)),
|
296
|
-
:ssl_client_key => OpenSSL::PKey::RSA.new(File.read(@ssl_key)),
|
297
|
-
:ssl_ca_file => @ssl_ca,
|
298
|
-
:verify_ssl => OpenSSL::SSL::VERIFY_PEER,
|
299
|
-
}
|
300
|
-
end
|
301
|
-
|
302
287
|
def parse_response(response)
|
303
288
|
JSON.parse(response)
|
304
289
|
end
|
data/lib/etre-client/version.rb
CHANGED
data/spec/client_spec.rb
CHANGED
@@ -2,7 +2,7 @@ require 'etre-client'
|
|
2
2
|
require 'ostruct'
|
3
3
|
|
4
4
|
describe Etre::Client do
|
5
|
-
let(:etre_client) { Etre::Client.new(entity_type: "node", url: "http://localhost:3000"
|
5
|
+
let(:etre_client) { Etre::Client.new(entity_type: "node", url: "http://localhost:3000") }
|
6
6
|
let(:get_headers) { {:accept => "application/json"} }
|
7
7
|
let(:post_headers) { get_headers.merge({:content_type => "application/json"}) }
|
8
8
|
let(:put_headers) { post_headers }
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: etre-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Finch
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-02-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|