megam_api 0.14 → 0.15
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/megam/api/version.rb +1 -1
- data/lib/megam/api.rb +22 -5
- data/test/test_accounts.rb +1 -1
- metadata +2 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f70bad4104531f59a86d0a85bf96c1f855c0c96e
|
4
|
+
data.tar.gz: 1ec8eb2603e2f632b47352f05be0407786d9f53c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8c01a6c03db68969107623032db64ee3c37d1ec706ea83478137a041ecb7844cdaf614bc4e28b76984533686b5fc6079667a51ac02489f8190ecacee88b0a978
|
7
|
+
data.tar.gz: 71f7dc9c679c313976733140c50c049fb21577c98c4354fb3711dd549bc24154c447b201adc00ed4565da885b0f2c4889fc02a87560f566ee4a66f5f392d3100
|
data/lib/megam/api/version.rb
CHANGED
data/lib/megam/api.rb
CHANGED
@@ -4,6 +4,7 @@ require "excon"
|
|
4
4
|
require "uri"
|
5
5
|
require "zlib"
|
6
6
|
require 'openssl'
|
7
|
+
require 'yaml' #COMMON YML
|
7
8
|
|
8
9
|
# open it up when needed. This will be needed when a new customer onboarded via pug.
|
9
10
|
require "securerandom"
|
@@ -98,7 +99,6 @@ module Megam
|
|
98
99
|
:nonblock => false,
|
99
100
|
:scheme => 'https'
|
100
101
|
}
|
101
|
-
|
102
102
|
API_VERSION1 = "/v1"
|
103
103
|
|
104
104
|
def text
|
@@ -118,6 +118,11 @@ module Megam
|
|
118
118
|
# 3. Upon merge of the options, the api_key, email as available in the @options is deleted.
|
119
119
|
def initialize(options={})
|
120
120
|
@options = OPTIONS.merge(options)
|
121
|
+
if File.exist?("#{ENV['MEGAM_HOME']}/nilavu.yml")
|
122
|
+
@common = YAML.load_file("#{ENV['MEGAM_HOME']}/nilavu.yml") #COMMON YML
|
123
|
+
@options[:host] = "#{@common["api"]["host"]}"
|
124
|
+
@options[:scheme] = "#{@common["api"]["scheme"]}"
|
125
|
+
end
|
121
126
|
@api_key = @options.delete(:api_key) || ENV['MEGAM_API_KEY']
|
122
127
|
@email = @options.delete(:email)
|
123
128
|
raise ArgumentError, "You must specify [:email, :api_key]" if @email.nil? || @api_key.nil?
|
@@ -188,7 +193,7 @@ module Megam
|
|
188
193
|
private
|
189
194
|
|
190
195
|
def just_color_debug(path)
|
191
|
-
text.msg "--> #{text.color(
|
196
|
+
text.msg "--> #{text.color('(#{path})', :cyan,:bold)}" # Why " inside "
|
192
197
|
end
|
193
198
|
|
194
199
|
#Make a lazy connection.
|
@@ -199,16 +204,22 @@ module Megam
|
|
199
204
|
'X-Megam-HMAC' => encoded_api_header[:hmac],
|
200
205
|
'X-Megam-Date' => encoded_api_header[:date],
|
201
206
|
}).merge(@options[:headers])
|
207
|
+
#COMMON YML
|
208
|
+
if @options[:scheme] == "https"
|
209
|
+
puts "=====> if https =======>"
|
210
|
+
Excon.defaults[:ssl_ca_file] = File.expand_path(File.join("#{ENV['MEGAM_HOME']}", "#{@common["api"]["pub_key"]}")) || File.expand_path(File.join(File.dirname(__FILE__), "..", "certs", "cacert.pem")) #COMMON YML
|
202
211
|
|
203
|
-
|
204
|
-
|
205
|
-
|
212
|
+
if !File.exist?(File.expand_path(File.join("#{ENV['MEGAM_HOME']}", "#{@common["api"]["pub_key"]}")))
|
213
|
+
text.warn("Certificate file does not exist. SSL_VERIFY_PEER set as false")
|
214
|
+
Excon.defaults[:ssl_verify_peer] = false
|
215
|
+
elsif !File.exist?(File.expand_path(File.join(File.dirname(__FILE__), "..", "certs", "cacert.pem")))
|
206
216
|
text.warn("Certificate file does not exist. SSL_VERIFY_PEER set as false")
|
207
217
|
Excon.defaults[:ssl_verify_peer] = false
|
208
218
|
else
|
209
219
|
Megam::Log.debug("Certificate found")
|
210
220
|
Excon.defaults[:ssl_verify_peer] = true
|
211
221
|
end
|
222
|
+
end
|
212
223
|
|
213
224
|
Megam::Log.debug("HTTP Request Data:")
|
214
225
|
Megam::Log.debug("> HTTP #{@options[:scheme]}://#{@options[:host]}")
|
@@ -216,7 +227,13 @@ module Megam
|
|
216
227
|
Megam::Log.debug("> #{key}: #{value}")
|
217
228
|
end
|
218
229
|
Megam::Log.debug("End HTTP Request Data.")
|
230
|
+
if @options[:scheme] == "https"
|
219
231
|
@connection = Excon.new("#{@options[:scheme]}://#{@options[:host]}",@options)
|
232
|
+
else
|
233
|
+
Excon.defaults[:ssl_verify_peer] = false
|
234
|
+
@connection = Excon.new("#{@options[:scheme]}://#{@options[:host]}:9000",@options)
|
235
|
+
end
|
236
|
+
@connection
|
220
237
|
end
|
221
238
|
|
222
239
|
## encode header as per rules.
|
data/test/test_accounts.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: megam_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.15'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kishorekumar Neelamegam, Thomas Alrin, Subash Sethurajan, Rajthilak
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-07-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: excon
|
@@ -234,4 +234,3 @@ signing_key:
|
|
234
234
|
specification_version: 4
|
235
235
|
summary: Ruby Client for the Megam Cloud
|
236
236
|
test_files: []
|
237
|
-
has_rdoc:
|