pubcontrol 0.0.7 → 0.1.0

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/pubcontrol.rb +8 -7
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 67e4fad9401ad2181ad2ce6417b64d9ae868c8d2
4
- data.tar.gz: 58d897a158410232d0489a84b94a785cb1477f53
3
+ metadata.gz: dbd47fd89088205b3512a8e7151106a5a8f8f354
4
+ data.tar.gz: f153e4eafe41d8a515906166af3497eef031f5cf
5
5
  SHA512:
6
- metadata.gz: df49cc27d6047cb7f60096a757661e28adcae4ca2c37c31e8bc8b2118fcfa4fbeebe186f9dce52e5f864ba9453ab5382379753fa7a0a2092c8ce09bf58fe2382
7
- data.tar.gz: 7f5511a18f5aadde6617fea8f2c56ad6c31e4fe010d6c96dba47be4e331e7bffe51037e21a035ad1122f74888daa80b4b0d7fc6de0fedca577f539144ce58a6b
6
+ metadata.gz: 91a2183465bf8bdbbea03106e5ca39ff8a1b4ed8aa32010e6855e90704a6f3cff45d5a2f53d378c03e212b184541c1e2431c9c47586811e30cadfd61f15434ea
7
+ data.tar.gz: ea516a7277f83ef0cc41c2c998a979efa34919e4f5617b1765ba1450fe45622dc2356b584800fa6264b97c8c66c6042a557f30b5c886086776aa5e89d0f50e36
data/lib/pubcontrol.rb CHANGED
@@ -18,7 +18,7 @@ require_relative 'pubcontrolset.rb'
18
18
  class PubControl
19
19
  attr_accessor :req_queue
20
20
 
21
- def initialize(uri)
21
+ def initialize(uri, use_ssl=true)
22
22
  @uri = uri
23
23
  @lock = Mutex.new
24
24
  @thread = nil
@@ -29,6 +29,7 @@ class PubControl
29
29
  @auth_basic_pass = nil
30
30
  @auth_jwt_claim = nil
31
31
  @auth_jwt_key = nil
32
+ @use_ssl = use_ssl
32
33
  end
33
34
 
34
35
  def set_auth_basic(username, password)
@@ -54,7 +55,7 @@ class PubControl
54
55
  uri = @uri
55
56
  auth = gen_auth_header
56
57
  end
57
- PubControl.pubcall(uri, auth, [export])
58
+ PubControl.pubcall(uri, auth, [export], @use_ssl)
58
59
  end
59
60
 
60
61
  def publish_async(channel, item, callback=nil)
@@ -102,12 +103,12 @@ class PubControl
102
103
  end
103
104
  @thread_mutex.unlock
104
105
  if reqs.length > 0
105
- PubControl.pubbatch(reqs)
106
+ PubControl.pubbatch(reqs, @use_ssl)
106
107
  end
107
108
  end
108
109
  end
109
110
 
110
- def self.pubcall(uri, auth_header, items)
111
+ def self.pubcall(uri, auth_header, items, use_ssl)
111
112
  uri = URI(uri + '/publish/')
112
113
  content = Hash.new
113
114
  content['items'] = items
@@ -119,7 +120,7 @@ class PubControl
119
120
  request['Authorization'] = auth_header
120
121
  end
121
122
  request['Content-Type'] = 'application/json'
122
- response = Net::HTTP.start(uri.host, use_ssl: true) do |http|
123
+ response = Net::HTTP.start(uri.host, use_ssl: use_ssl) do |http|
123
124
  http.request(request)
124
125
  end
125
126
  # REVIEW: HTTPSuccess does not include 3xx status codes.
@@ -129,7 +130,7 @@ class PubControl
129
130
  end
130
131
  end
131
132
 
132
- def self.pubbatch(reqs)
133
+ def self.pubbatch(reqs, use_ssl)
133
134
  raise 'reqs length == 0' unless reqs.length > 0
134
135
  uri = reqs[0][0]
135
136
  auth_header = reqs[0][1]
@@ -140,7 +141,7 @@ class PubControl
140
141
  callbacks.push(req[3])
141
142
  end
142
143
  begin
143
- PubControl.pubcall(uri, auth_header, items)
144
+ PubControl.pubcall(uri, auth_header, items, use_ssl)
144
145
  result = [true, '']
145
146
  rescue => e
146
147
  result = [false, e.message]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pubcontrol
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Konstantin Bokarius