launchbox 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 23898e444cc4bcebd9e27fc54f868d89581e1408
4
+ data.tar.gz: a563b1e2109c98414817aef970bfb5fa043cab3a
5
+ SHA512:
6
+ metadata.gz: d8221b70cbcb7bd684da8faef61f6752239daf625e5347ea23c400f76d3469ba6b55798d8c2e97c6dce59ae46bdfb4604658ed51ae89430958d16b99518f1feb
7
+ data.tar.gz: 40bc47ca18de037dc7577f77f558250215578c2e767e5717f55b139caef66cbde6f4bf0836b267d8da69f4bbeb612fbdc165eb2c51ce3a47a043ca3576879e51
@@ -0,0 +1,16 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ InstalledFiles
7
+ _yardoc
8
+ coverage
9
+ doc/
10
+ lib/bundler/man
11
+ pkg
12
+ rdoc
13
+ spec/reports
14
+ test/tmp
15
+ test/version_tmp
16
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in launchbox.gemspec
4
+ gemspec
@@ -0,0 +1,29 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ launchbox (0.0.1)
5
+ json
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ diff-lcs (1.2.5)
11
+ json (1.8.1)
12
+ rake (10.1.1)
13
+ rspec (2.14.1)
14
+ rspec-core (~> 2.14.0)
15
+ rspec-expectations (~> 2.14.0)
16
+ rspec-mocks (~> 2.14.0)
17
+ rspec-core (2.14.7)
18
+ rspec-expectations (2.14.5)
19
+ diff-lcs (>= 1.1.3, < 2.0)
20
+ rspec-mocks (2.14.5)
21
+
22
+ PLATFORMS
23
+ ruby
24
+
25
+ DEPENDENCIES
26
+ bundler (~> 1.3)
27
+ launchbox!
28
+ rake
29
+ rspec (~> 2.6)
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Ben Pellow
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,29 @@
1
+ # Launchbox
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'launchbox'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install launchbox
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'launchbox/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "launchbox"
8
+ spec.version = Launchbox::VERSION
9
+ spec.authors = ["Addonlist"]
10
+ spec.email = ["engineering@addonlist.com"]
11
+ spec.description = %q{Connect your app to Launchbox for all your service integrations in one place.}
12
+ spec.summary = %q{After configuring your app with launchbox email and token environment variables (ENV['LAUNCHBOX_USER_EMAIL'] and ENV['LAUNCHBOX_USER_TOKEN']), the gem will pull your services config and set them up for immediate use.}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency "json"
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.3"
24
+ spec.add_development_dependency "rake"
25
+ spec.add_development_dependency "rspec", "~> 2.6"
26
+ end
@@ -0,0 +1,16 @@
1
+ #lib/generators/launchbox/install_generator.rb
2
+ require 'rails/generators'
3
+ require 'rails/generators/named_base'
4
+
5
+ # creates an initializer and runs Launchbox::Config.init()"
6
+ module Launchbox
7
+ module Generators
8
+ class InstallGenerator < Rails::Generators::Base
9
+ desc "Launchbox install generator"
10
+
11
+ def create_initializer_file
12
+ create_file "config/initializers/launchbox.rb", "# Launchbox initializer content\nLaunchbox::Config.init()"
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,6 @@
1
+ require "launchbox/version"
2
+ require "launchbox/config"
3
+
4
+ module Launchbox
5
+ # Your code goes here...
6
+ end
@@ -0,0 +1,46 @@
1
+ require 'net/http'
2
+ require 'json'
3
+
4
+ BASE_CONFIG_URL = "https://launchbox.herokuapp.com/api/v1/config"
5
+
6
+ module Launchbox
7
+ class Config
8
+ def self.init
9
+ puts "Initializing Launchbox::Config"
10
+
11
+ puts "checking ENV['LAUNCHBOX_USER_EMAIL'] and ENV['LAUNCHBOX_USER_TOKEN']"
12
+
13
+ if ENV['LAUNCHBOX_USER_EMAIL'] == nil
14
+ return false, "Error: ENV['LAUNCHBOX_USER_EMAIL'] must be defined"
15
+ elsif ENV['LAUNCHBOX_USER_TOKEN'] == nil
16
+ return false, "Error: ENV['LAUNCHBOX_USER_TOKEN'] must be defined"
17
+ end
18
+
19
+ # contact server and look for config
20
+ configUrl = "#{BASE_CONFIG_URL}?user_email=#{ENV['LAUNCHBOX_USER_EMAIL']}&user_token=#{ENV['LAUNCHBOX_USER_TOKEN']}"
21
+
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)
29
+
30
+ # FIXME: LAUNCHBOX_APP_ID -- json[0] is hardcoding the first app.
31
+ app = json[0]
32
+ # set environment variables for each service
33
+ app.each do |service|
34
+ service['env_vars'].each do |key, value|
35
+ ENV[key] = value
36
+ end
37
+ end
38
+ return true, "Success"
39
+ elsif response.code == "401"
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
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,3 @@
1
+ module Launchbox
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,14 @@
1
+ require 'launchbox'
2
+
3
+ describe Launchbox::Config do
4
+ it "initializes with errors when environment variables aren't set" do
5
+ Launchbox::Config.init()[0].should eql(false)
6
+ end
7
+
8
+ # it "initializes without errors with valid environment variables" do
9
+ # ENV['LAUNCHBOX_USER_EMAIL'] = 'ben@addonlist.com'
10
+ # ENV['LAUNCHBOX_USER_TOKEN'] = 'iXZfkrcSqcZW9pPvK6bv'
11
+
12
+ # Launchbox::Config.init()[0].should eql(true)
13
+ # end
14
+ end
metadata ADDED
@@ -0,0 +1,116 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: launchbox
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Addonlist
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-02-05 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: json
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '1.3'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '1.3'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '2.6'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: '2.6'
69
+ description: Connect your app to Launchbox for all your service integrations in one
70
+ place.
71
+ email:
72
+ - engineering@addonlist.com
73
+ executables: []
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - .gitignore
78
+ - Gemfile
79
+ - Gemfile.lock
80
+ - LICENSE.txt
81
+ - README.md
82
+ - Rakefile
83
+ - launchbox.gemspec
84
+ - lib/generators/launchbox/install_generator.rb
85
+ - lib/launchbox.rb
86
+ - lib/launchbox/config.rb
87
+ - lib/launchbox/version.rb
88
+ - spec/launchbox_spec.rb
89
+ homepage: ''
90
+ licenses:
91
+ - MIT
92
+ metadata: {}
93
+ post_install_message:
94
+ rdoc_options: []
95
+ require_paths:
96
+ - lib
97
+ required_ruby_version: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ required_rubygems_version: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - '>='
105
+ - !ruby/object:Gem::Version
106
+ version: '0'
107
+ requirements: []
108
+ rubyforge_project:
109
+ rubygems_version: 2.0.3
110
+ signing_key:
111
+ specification_version: 4
112
+ summary: After configuring your app with launchbox email and token environment variables
113
+ (ENV['LAUNCHBOX_USER_EMAIL'] and ENV['LAUNCHBOX_USER_TOKEN']), the gem will pull
114
+ your services config and set them up for immediate use.
115
+ test_files:
116
+ - spec/launchbox_spec.rb