dhclient 0.1.3 → 0.1.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d0bfbabc076af054bd0e3748aa50c2245fbfcf82
4
- data.tar.gz: d679d634b0bf824cf43aede28234f864f2c0f990
3
+ metadata.gz: ed13f6ec8264555cb6fbfeabb85abc204f097964
4
+ data.tar.gz: a157200eb7a44427f872652332864cd721487b36
5
5
  SHA512:
6
- metadata.gz: a5ab9880cbbc9e2ca8525c31ea5dc9579b5da442b00c8737f32781835474d279d1882a54cd56a256d819bc8be821fb741330fe93a0f63fa28ee19042b62f7f36
7
- data.tar.gz: c3f9fae65ae2d3e465aef743b1da5903a29c493153e5828626c55543ea4c344dd084d8f9df5e971a8ba3c89211a4bba1953bbec517ead81fa7a994028fd835b0
6
+ metadata.gz: bb1295b9808b685145819886e69b48d21afde00c18d7f7fc8b17263fa50370d04ca5795969ad169e919271cf505efe328aac8ce02ad8668dcc5d7c9e396774f3
7
+ data.tar.gz: 8b80e19482459bf6c37bb4487d08d2369b074dc7536fdcf23f57c8984f8eff5b6c3ef89d3ff76c0c4a3740d994db8a82d49a2d9f01e08c3f9d1d0e0a3ba489cf
data/bin/dhconsole CHANGED
@@ -6,6 +6,21 @@ require "dhclient"
6
6
  # You can add fixtures and/or initialization code here to make experimenting
7
7
  # with your gem easier. You can also use a different console, if you like.
8
8
 
9
+ def pretty_print(content, format=:json)
10
+ if format == :xml
11
+ require 'rexml/document'
12
+ formatter = REXML::Formatters::Pretty.new
13
+ formatter.compact = true
14
+ xml = REXML::Document.new content
15
+ formatter.write(xml, out)
16
+ elsif format == :json
17
+ out = JSON.parse(content)
18
+ else
19
+ out = "Unsupported format #{format}"
20
+ end
21
+ return out
22
+ end
23
+
9
24
  # (If you use this, don't forget to add pry to your Gemfile!)
10
25
  require "pry"
11
26
  Pry.start
@@ -13,37 +13,37 @@ module DHClient
13
13
  response.body
14
14
  end
15
15
 
16
- def status
17
- response = RestClient.get "#{@datahub_base_url}/status-counts"
16
+ def status(opts={})
17
+ response = RestClient.get "#{@datahub_base_url}/status-counts", {}, accept: opts[:format] ||:json
18
18
  response.body
19
19
  end
20
20
 
21
- def compositions(pool_name='GLOBAL')
22
- response = RestClient.get "#{@datahub_base_url}/pools/#{pool_name}/compositions"
21
+ def compositions(pool_name='GLOBAL', opts)
22
+ response = RestClient.get "#{@datahub_base_url}/pools/#{pool_name}/compositions", {}, accept: opts[:format] ||:json
23
23
  response.body
24
24
  end
25
25
 
26
- def publications(pool_name='GLOBAL')
27
- response = RestClient.get "#{@datahub_base_url}/pools/#{pool_name}/publications"
26
+ def publications(pool_name='GLOBAL', opts)
27
+ response = RestClient.get "#{@datahub_base_url}/pools/#{pool_name}/publications", {}, accept: opts[:format] ||:json
28
28
  response.body
29
29
  end
30
30
 
31
31
  #POST
32
32
 
33
- def load_data(file, feed_name='DEFAULT_FEED', raw_item_name)
33
+ def load_data(file, feed_name='DEFAULT_FEED', raw_item_name, opts)
34
34
  data = File.new(file, 'rb')
35
- http_post "#{@datahub_base_url}/data-feeds/#{feed_name}/items/#{raw_item_name}", data, content_type: 'application/octet-stream'
35
+ http_post "#{@datahub_base_url}/data-feeds/#{feed_name}/items/#{raw_item_name}", data, content_type: 'application/octet-stream', accept: opts[:format] ||:json
36
36
  end
37
37
 
38
- def start_composition(pool_name='GLOBAL')
39
- http_post "#{@datahub_base_url}/pools/#{pool_name}/compositions"
38
+ def start_composition(pool_name='GLOBAL', opts)
39
+ http_post "#{@datahub_base_url}/pools/#{pool_name}/compositions", {}, {accept: opts[:format]||:json}
40
40
  end
41
41
 
42
- def start_publication(pool_name='GLOBAL', target_system)
42
+ def start_publication(pool_name='GLOBAL', target_system, opts)
43
43
  json_payload = {targetSystemPublications: [
44
44
  {targetSystemName: target_system}
45
45
  ]}.to_json
46
- http_post "#{@datahub_base_url}/pools/#{pool_name}/publications", json_payload, {content_type: :json, accept: :json}
46
+ http_post "#{@datahub_base_url}/pools/#{pool_name}/publications", json_payload, {content_type: :json, accept: opts[:format]||:json}
47
47
  end
48
48
 
49
49
  private
@@ -1,3 +1,3 @@
1
1
  module DHClient
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dhclient
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Quirino Oliveira
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-03-30 00:00:00.000000000 Z
11
+ date: 2017-04-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: methadone