addons 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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c118692550919048d67af86cb78cf3c8825e1206
4
+ data.tar.gz: e2601cab1fc450c983c9ef8cb9175b711699a0b8
5
+ SHA512:
6
+ metadata.gz: 0970425003c415253f784cfc6522e1c252e634d75becff752bc0616b823cae4dd969d1d06348be76a85d88b99d6bcadaca424f6cdbe03cd92f40c101fdcb5692
7
+ data.tar.gz: a3f0a2691783553dec8069ef0903c4eb9c1a55a80b3c433da61f3d465f25c14dd5b8e22f9f4e97e4bdf33c29035b20e7bb4514a325767e9394d3e5b92ea67ee7
data/.gitignore ADDED
@@ -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 addons.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,103 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ addons (0.0.5)
5
+ figaro
6
+ json
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ actionmailer (4.0.1)
12
+ actionpack (= 4.0.1)
13
+ mail (~> 2.5.4)
14
+ actionpack (4.0.1)
15
+ activesupport (= 4.0.1)
16
+ builder (~> 3.1.0)
17
+ erubis (~> 2.7.0)
18
+ rack (~> 1.5.2)
19
+ rack-test (~> 0.6.2)
20
+ activemodel (4.0.1)
21
+ activesupport (= 4.0.1)
22
+ builder (~> 3.1.0)
23
+ activerecord (4.0.1)
24
+ activemodel (= 4.0.1)
25
+ activerecord-deprecated_finders (~> 1.0.2)
26
+ activesupport (= 4.0.1)
27
+ arel (~> 4.0.0)
28
+ activerecord-deprecated_finders (1.0.3)
29
+ activesupport (4.0.1)
30
+ i18n (~> 0.6, >= 0.6.4)
31
+ minitest (~> 4.2)
32
+ multi_json (~> 1.3)
33
+ thread_safe (~> 0.1)
34
+ tzinfo (~> 0.3.37)
35
+ arel (4.0.2)
36
+ atomic (1.1.14)
37
+ builder (3.1.4)
38
+ diff-lcs (1.2.5)
39
+ erubis (2.7.0)
40
+ figaro (0.7.0)
41
+ bundler (~> 1.0)
42
+ rails (>= 3, < 5)
43
+ hike (1.2.3)
44
+ i18n (0.6.9)
45
+ json (1.8.1)
46
+ mail (2.5.4)
47
+ mime-types (~> 1.16)
48
+ treetop (~> 1.4.8)
49
+ mime-types (1.25.1)
50
+ minitest (4.7.5)
51
+ multi_json (1.8.4)
52
+ polyglot (0.3.3)
53
+ rack (1.5.2)
54
+ rack-test (0.6.2)
55
+ rack (>= 1.0)
56
+ rails (4.0.1)
57
+ actionmailer (= 4.0.1)
58
+ actionpack (= 4.0.1)
59
+ activerecord (= 4.0.1)
60
+ activesupport (= 4.0.1)
61
+ bundler (>= 1.3.0, < 2.0)
62
+ railties (= 4.0.1)
63
+ sprockets-rails (~> 2.0.0)
64
+ railties (4.0.1)
65
+ actionpack (= 4.0.1)
66
+ activesupport (= 4.0.1)
67
+ rake (>= 0.8.7)
68
+ thor (>= 0.18.1, < 2.0)
69
+ rake (10.1.1)
70
+ rspec (2.14.1)
71
+ rspec-core (~> 2.14.0)
72
+ rspec-expectations (~> 2.14.0)
73
+ rspec-mocks (~> 2.14.0)
74
+ rspec-core (2.14.7)
75
+ rspec-expectations (2.14.5)
76
+ diff-lcs (>= 1.1.3, < 2.0)
77
+ rspec-mocks (2.14.5)
78
+ sprockets (2.10.1)
79
+ hike (~> 1.2)
80
+ multi_json (~> 1.0)
81
+ rack (~> 1.0)
82
+ tilt (~> 1.1, != 1.3.0)
83
+ sprockets-rails (2.0.1)
84
+ actionpack (>= 3.0)
85
+ activesupport (>= 3.0)
86
+ sprockets (~> 2.8)
87
+ thor (0.18.1)
88
+ thread_safe (0.1.3)
89
+ atomic
90
+ tilt (1.4.1)
91
+ treetop (1.4.15)
92
+ polyglot
93
+ polyglot (>= 0.3.1)
94
+ tzinfo (0.3.38)
95
+
96
+ PLATFORMS
97
+ ruby
98
+
99
+ DEPENDENCIES
100
+ addons!
101
+ bundler (~> 1.3)
102
+ rake
103
+ rspec (~> 2.6)
data/LICENSE.txt ADDED
@@ -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.
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # Addons
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'addons'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install addons
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
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/addons.gemspec ADDED
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'addons/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "addons"
8
+ spec.version = Addons::VERSION
9
+ spec.authors = ["Addonlist"]
10
+ spec.email = ["engineering@addonlist.com"]
11
+ spec.description = %q{Connect your app to Addons for all your service integrations in one place.}
12
+ spec.summary = %q{After configuring your app with addons 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
+ spec.add_dependency "figaro"
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.3"
25
+ spec.add_development_dependency "rake"
26
+ spec.add_development_dependency "rspec", "~> 2.6"
27
+ end
@@ -0,0 +1,74 @@
1
+ require 'net/http'
2
+ require 'open-uri'
3
+ require 'json'
4
+
5
+ BASE_CONFIG_URL = "https://launchbox.herokuapp.com/api/v1/config"
6
+
7
+ module Addons
8
+ class Config
9
+ def self.init
10
+ puts "Initializing Addons::Config"
11
+
12
+ puts "checking ENV['LAUNCHBOX_USER_EMAIL'] and ENV['LAUNCHBOX_USER_TOKEN']"
13
+
14
+ if ENV['LAUNCHBOX_USER_EMAIL'] == nil
15
+ return false, "Error: ENV['LAUNCHBOX_USER_EMAIL'] must be defined"
16
+ elsif ENV['LAUNCHBOX_USER_TOKEN'] == nil
17
+ return false, "Error: ENV['LAUNCHBOX_USER_TOKEN'] must be defined"
18
+ end
19
+
20
+ # contact server and look for config
21
+ configUrl = "#{BASE_CONFIG_URL}?user_email=#{ENV['LAUNCHBOX_USER_EMAIL']}&user_token=#{ENV['LAUNCHBOX_USER_TOKEN']}"
22
+
23
+ begin
24
+ response = URI.parse(configUrl).read
25
+
26
+ json = JSON.parse(response)
27
+
28
+ # FIXME: LAUNCHBOX_APP_ID -- json[0] is hardcoding the first app.
29
+ app = json[0]
30
+
31
+ # gitignore config/application.yml so we aren't storing sensitive info in .git
32
+ # TODO: replace figaro with figaro-addons and application.yml with addons.yml
33
+ gitignore = Rails.root.join('.gitignore')
34
+ if File.readlines(gitignore).grep(/config\/application.yml/).size == 0
35
+ File.open(gitignore, 'a') do |file|
36
+ file.puts 'config/application.yml'
37
+ end
38
+ end
39
+
40
+ figaro = Rails.root.join('Gemfile')
41
+ if File.readlines(figaro).grep(/gem 'figaro'/).size == 0
42
+ File.open(figaro, 'a') do |file|
43
+ file.puts ""
44
+ file.puts "gem 'figaro' # Addons dependency"
45
+ end
46
+ end
47
+
48
+ # write config/application.yml to load env vars on startup
49
+ filename = Rails.root.join('config', 'application.yml')
50
+
51
+ # NOTE: 'w' overwrites the previous file!
52
+ File.open(filename, 'w') do |file|
53
+ # set environment variables for each service
54
+ app.each do |service|
55
+ service['env_vars'].each do |key, value|
56
+ puts "setting environment variable #{key}"
57
+
58
+ # add new vars to application.yml for the restart
59
+ file.puts "#{key}: #{value}"
60
+
61
+ # add new vars to this instance
62
+ ENV[key] = value
63
+ end
64
+ end
65
+ end
66
+ return true, "Success"
67
+
68
+ rescue OpenURI::HTTPError => ex
69
+ return false, "Error: Unauthorized use of Addons. Be sure to set ENV['LAUNCHBOX_USER_EMAIL'] and ENV['LAUNCHBOX_USER_TOKEN']"
70
+ end
71
+
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,3 @@
1
+ module Addons
2
+ VERSION = "0.0.5"
3
+ end
data/lib/addons.rb ADDED
@@ -0,0 +1,6 @@
1
+ require "addons/version"
2
+ require "addons/config"
3
+
4
+ module Addons
5
+ # Your code goes here...
6
+ end
@@ -0,0 +1,16 @@
1
+ #lib/generators/addons/install_generator.rb
2
+ require 'rails/generators'
3
+ require 'rails/generators/named_base'
4
+
5
+ # creates an initializer and runs Addons::Config.init()"
6
+ module Addons
7
+ module Generators
8
+ class InstallGenerator < Rails::Generators::Base
9
+ desc "Addons install generator"
10
+
11
+ def create_initializer_file
12
+ create_file "config/initializers/addons.rb", "# Addons initializer content\nAddons::Config.init()"
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,14 @@
1
+ require 'addons'
2
+
3
+ describe Addons::Config do
4
+ it "initializes with errors when environment variables aren't set" do
5
+ Addons::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
+ # Addons::Config.init()[0].should eql(true)
13
+ # end
14
+ end
metadata ADDED
@@ -0,0 +1,129 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: addons
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.5
5
+ platform: ruby
6
+ authors:
7
+ - Addonlist
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-02-23 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: figaro
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '1.3'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '1.3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ~>
74
+ - !ruby/object:Gem::Version
75
+ version: '2.6'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ~>
81
+ - !ruby/object:Gem::Version
82
+ version: '2.6'
83
+ description: Connect your app to Addons for all your service integrations in one place.
84
+ email:
85
+ - engineering@addonlist.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - .gitignore
91
+ - Gemfile
92
+ - Gemfile.lock
93
+ - LICENSE.txt
94
+ - README.md
95
+ - Rakefile
96
+ - addons.gemspec
97
+ - lib/addons.rb
98
+ - lib/addons/config.rb
99
+ - lib/addons/version.rb
100
+ - lib/generators/addons/install_generator.rb
101
+ - spec/addons_spec.rb
102
+ homepage: ''
103
+ licenses:
104
+ - MIT
105
+ metadata: {}
106
+ post_install_message:
107
+ rdoc_options: []
108
+ require_paths:
109
+ - lib
110
+ required_ruby_version: !ruby/object:Gem::Requirement
111
+ requirements:
112
+ - - '>='
113
+ - !ruby/object:Gem::Version
114
+ version: '0'
115
+ required_rubygems_version: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - '>='
118
+ - !ruby/object:Gem::Version
119
+ version: '0'
120
+ requirements: []
121
+ rubyforge_project:
122
+ rubygems_version: 2.0.3
123
+ signing_key:
124
+ specification_version: 4
125
+ summary: After configuring your app with addons email and token environment variables
126
+ (ENV['LAUNCHBOX_USER_EMAIL'] and ENV['LAUNCHBOX_USER_TOKEN']), the gem will pull
127
+ your services config and set them up for immediate use.
128
+ test_files:
129
+ - spec/addons_spec.rb