phoseum-cli 0.0.4 → 0.0.5

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
  SHA256:
3
- metadata.gz: 9800b3e97fad5a30ebc7a0fddcc17794ea22f28c3320d5a046313ca3eb1193cc
4
- data.tar.gz: c3b421b14f8a1f88953d79e66c93bfc6c452bf87fc12ac83ee502e1d14c1deb2
3
+ metadata.gz: a37ca1ca918358760c52aeff733cb635c01843958a0f45c9d7ba36354abd6bc3
4
+ data.tar.gz: b3bf79b10605c1925fc8e2bcf71841de774e56a457e7518a16c86dfdad2af8ab
5
5
  SHA512:
6
- metadata.gz: b56525518afece528044cc963d4d1c5b00d9cf9af241940968f0b9adc7b9974b499670e5810852e17000260500fb0770e3616fbe5f786ee62bff31fc5252eb9a
7
- data.tar.gz: 490ea67df9103c47c3355d34e99142bea70e5415c070e1d182c777a4020ce8ea7de8d84faa8d691af50bf18a225ae6a0b3785d785c0a7fa7b30824eb9df32339
6
+ metadata.gz: 274832a0b5d037a2363162702d02c450e2d25869d6b50ab9b91c89949902643413c321621e6ed654572dd2356ebe1444f8030869fab3b7aa356351c722ac3aba
7
+ data.tar.gz: fc7a1bc69fb62ed22d9763380262c65a37d195d0854a88f94052a8aad559ea019d8d88662659abe630caaff62a83be76aa9c5f622f8b0ff958a2b42436f2ce4d
@@ -32,6 +32,10 @@ def option_parser(opts)
32
32
  options[:login] = l
33
33
  end
34
34
 
35
+ opts.on("-m", "--multiple", "Ignore repeated images, keep multiple") do |m|
36
+ options[:multiple] = m
37
+ end
38
+
35
39
  opts.on("-v", "--verbose", "Run verbosely (DEBUG mode)") do |v|
36
40
  options[:verbose] = v
37
41
  end
@@ -111,15 +115,57 @@ def client_checks
111
115
  puts "I could not find the DEFAULT_SECRET from Phoseum config, Variable is empty.".red
112
116
  exit 1
113
117
  end
114
-
115
118
  if !$config['SERVERURL']
116
119
  puts "I could not find the SERVERURL from Phoseum config, this client is then useless.".red
117
120
  exit 1
118
121
  end
119
-
120
122
  if !$config['PORT']
121
123
  puts "I could not find the PORT from Phoseum config, this client is then useless.".red
122
124
  exit 1
123
125
  end
126
+ end
127
+
128
+ def clean_html(msg)
129
+ msg.gsub!(/<\/?[^>]*>/, ' ')
130
+ msg.gsub!(/\n\n+/, '\n')
131
+ msg.gsub!(/^\n|\n$/, ' ')
132
+ return msg
133
+ end
124
134
 
135
+ def search_image(sign)
136
+ headers = {}
137
+ if $config['TOKEN']
138
+ headers={ "bearer" => "#{$config['TOKEN']}" }
139
+ else
140
+ if token = user_login()
141
+ headers = { "bearer" => token }
142
+ else
143
+ puts "Login Failed".red
144
+ exit 1
145
+ end
146
+ end
147
+ some_uri="?signature=#{sign}"
148
+ base = URI.parse("#{$config['SERVERURL']}#{some_uri}")
149
+ request = Net::HTTP::Get.new(base,headers)
150
+ response = Net::HTTP.start(base.hostname, $config['PORT'],
151
+ :timeout => $config['CALL_TIMEOUT'],
152
+ :use_ssl => base.scheme == "https",
153
+ :verify_mode => OpenSSL::SSL::VERIFY_PEER,
154
+ :ca_file => $config['CA_TRUST']
155
+ ) do |http|
156
+ http.request(request)
157
+ end
158
+ begin
159
+ list = JSON.parse(response.body)
160
+ if list['warning']
161
+ return list['warning']
162
+ end
163
+ if list['success']
164
+ return false
165
+ end
166
+ rescue
167
+ puts "\nThe server sent out an Error:".red
168
+ puts clean_html(response.body)
169
+ exit 1
170
+ end
125
171
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: phoseum-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julio C Hegedus