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.
- checksums.yaml +4 -4
- data/lib/pubcontrol.rb +8 -7
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dbd47fd89088205b3512a8e7151106a5a8f8f354
|
4
|
+
data.tar.gz: f153e4eafe41d8a515906166af3497eef031f5cf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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:
|
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]
|