launchbox 0.0.1 → 0.0.2

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: 23898e444cc4bcebd9e27fc54f868d89581e1408
4
- data.tar.gz: a563b1e2109c98414817aef970bfb5fa043cab3a
3
+ metadata.gz: 2abfea5840f853aa48a90aeac8266161586bb288
4
+ data.tar.gz: fcb37f6e7dabb9dc1b81cd7ee9b812b3ac9474e8
5
5
  SHA512:
6
- metadata.gz: d8221b70cbcb7bd684da8faef61f6752239daf625e5347ea23c400f76d3469ba6b55798d8c2e97c6dce59ae46bdfb4604658ed51ae89430958d16b99518f1feb
7
- data.tar.gz: 40bc47ca18de037dc7577f77f558250215578c2e767e5717f55b139caef66cbde6f4bf0836b267d8da69f4bbeb612fbdc165eb2c51ce3a47a043ca3576879e51
6
+ metadata.gz: b1909571380957ee25da7f6e33888cdd0b0a2bb0030e276e04f667fc73c16c18da0b690da78e70fbc6e47cf0cc644f9681e31baa653bc21c3932c065b3ac5b8a
7
+ data.tar.gz: 3d5fa5ff27aba50c25fc17395727680927c1e27b181425e9458a1c040d33d3ed2ebf7f5dfa75bef184defc70442cf7e7bb174f7bae215c3f71fba9659989f879
@@ -1,4 +1,5 @@
1
1
  require 'net/http'
2
+ require 'open-uri'
2
3
  require 'json'
3
4
 
4
5
  BASE_CONFIG_URL = "https://launchbox.herokuapp.com/api/v1/config"
@@ -19,28 +20,26 @@ module Launchbox
19
20
  # contact server and look for config
20
21
  configUrl = "#{BASE_CONFIG_URL}?user_email=#{ENV['LAUNCHBOX_USER_EMAIL']}&user_token=#{ENV['LAUNCHBOX_USER_TOKEN']}"
21
22
 
22
- uri = URI.parse(configUrl)
23
- request = Net::HTTP::Get.new(uri.to_s)
24
- response = Net::HTTP.start(uri.host, uri.port) { |http|
25
- http.request(request)
26
- }
27
- if response.code == "200"
28
- json = JSON.parse(response.body)
23
+ begin
24
+ response = URI.parse(configUrl).read
25
+
26
+ json = JSON.parse(response)
29
27
 
30
28
  # FIXME: LAUNCHBOX_APP_ID -- json[0] is hardcoding the first app.
31
29
  app = json[0]
32
30
  # set environment variables for each service
33
31
  app.each do |service|
34
32
  service['env_vars'].each do |key, value|
33
+ puts "setting environment variable #{key}"
35
34
  ENV[key] = value
36
35
  end
37
36
  end
38
37
  return true, "Success"
39
- elsif response.code == "401"
38
+
39
+ rescue OpenURI::HTTPError => ex
40
40
  return false, "Error: Unauthorized use of Launchbox. Be sure to set ENV['LAUNCHBOX_USER_EMAIL'] and ENV['LAUNCHBOX_USER_TOKEN']"
41
- else
42
- return false, "Error: Error getting Launchbox config"
43
41
  end
42
+
44
43
  end
45
44
  end
46
45
  end
@@ -1,3 +1,3 @@
1
1
  module Launchbox
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: launchbox
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Addonlist