addons 0.0.6 → 0.0.7

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: 71b37f0db365cf94d2d92be898f5e8b4bac03a36
4
- data.tar.gz: 5163d2afbcb9adcc199bf28697213fe792d0fd7d
3
+ metadata.gz: 25218880dbda86d57e92d3d3b28d9277f5d0c9fe
4
+ data.tar.gz: 823981158b3181c5af83c33a1e65eac0dc399afb
5
5
  SHA512:
6
- metadata.gz: f7326ded313128265cc34186fcfb20804c2626fc3bdf1fc59b72a33d541308232f26ca7c35c79a7a22ca235beff29c0dc59815a369637250f24db41029822fa2
7
- data.tar.gz: 015635e5ced16c5923b520a5eac9cbb7faa15129558e2df532e481d61eac484392a7b4166305bc554a61cfeca89d253d97246c06f607f145a3398a222d0d19b0
6
+ metadata.gz: 61be947dbbc6998af97107d13cf84fa039eb53cc8e4b45e7eb118506e4407d59bf8dd3dacf07eabb02e3976262039ecedd82858e900f7766421aca1c1d9cab30
7
+ data.tar.gz: 836137c58562b65929a3385b78c8519c07b6c89948039ccb4576a15eb38cc902f26b0cce1984803676096ed23eb758abffc3f689038e34ff3ccbb5a18e42b194
data/lib/addons/config.rb CHANGED
@@ -9,6 +9,21 @@ module Addons
9
9
  def self.init
10
10
  puts "Initializing Addons::Config"
11
11
 
12
+ if ENV['ADDONS_APP_ID'].nil? or ENV['ADDONS_APP_ID'] == ""
13
+ filename = Rails.root.join('config', 'application.yml')
14
+
15
+ File.open(filename, 'r') do |file|
16
+ # NOTE: read the ADDONS_APP_ID and ADDONS_APP_TOKEN from application.yml and set ENV vars.
17
+
18
+ file.each_line do |line|
19
+ matches = line.match(/(.*): (.*)/)
20
+
21
+ env_var, value = matches[1], matches[2]
22
+ ENV[env_var] = value
23
+ end
24
+ end
25
+ end
26
+
12
27
  puts "checking ENV['ADDONS_APP_ID'] and ENV['ADDONS_APP_TOKEN']"
13
28
 
14
29
  if ENV['ADDONS_APP_ID'] == nil
@@ -1,3 +1,3 @@
1
1
  module Addons
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
@@ -6,11 +6,40 @@ require 'rails/generators/named_base'
6
6
  module Addons
7
7
  module Generators
8
8
  class InstallGenerator < Rails::Generators::Base
9
+
10
+ class_option :appid, type: :string, required: true, :desc => "ADDONS_APP_ID"
11
+ class_option :apptoken, type: :string, required: true, :desc => "ADDONS_APP_TOKEN"
12
+
13
+ def initialize(*args, &block)
14
+ super
15
+
16
+ @addons_app_id = options[:appid]
17
+ @addons_app_token = options[:apptoken]
18
+
19
+ puts "ADDONS_APP_ID: #{@addons_app_id}"
20
+ puts "ADDONS_APP_TOKEN: #{@addons_app_token}"
21
+ end
22
+
9
23
  desc "Addons install generator"
10
24
 
11
25
  def create_initializer_file
12
26
  create_file "config/initializers/addons.rb", "# Addons initializer content\nAddons::Config.init()"
13
27
  end
28
+
29
+ def bootstrap_app_id_and_token
30
+ # write config/application.yml to load env vars on startup
31
+ filename = Rails.root.join('config', 'application.yml')
32
+
33
+ # NOTE: 'w' overwrites the previous file!
34
+ File.open(filename, 'w') do |file|
35
+ # add new vars to application.yml for the restart
36
+ file.puts "ADDONS_APP_ID: #{@addons_app_id}"
37
+ file.puts "ADDONS_APP_TOKEN: #{@addons_app_token}"
38
+ end
39
+
40
+ puts "created application.yml"
41
+ end
42
+
14
43
  end
15
44
  end
16
45
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: addons
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Addonlist
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-26 00:00:00.000000000 Z
11
+ date: 2014-03-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json