exportr 0.2.2 → 0.2.4
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.
data/lib/exportr/command.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'exportr/config'
|
2
2
|
require 'exportr/helpers'
|
3
|
+
require 'exportr/version'
|
3
4
|
require 'optparse'
|
4
5
|
require 'yaml'
|
5
6
|
|
@@ -18,10 +19,11 @@ module Exportr
|
|
18
19
|
global_options << { :name => name, :args => args }
|
19
20
|
end
|
20
21
|
|
21
|
-
global_option :add, '-a', '--add
|
22
|
-
global_option :remove, '-r', '--remove
|
22
|
+
global_option :add, '-a', '--add KEY=VALUE', 'Add environment variable'
|
23
|
+
global_option :remove, '-r', '--remove KEY', 'Remove environment variable'
|
23
24
|
global_option :clear, '-c', '--clear', 'Clear out all environment variables'
|
24
25
|
global_option :list, '-l', '--list', 'List all environment variables'
|
26
|
+
global_option :version, '-v', '--version', 'Get exportr version number'
|
25
27
|
|
26
28
|
def self.run *argv
|
27
29
|
error NOT_RAILS unless in_rails_application?
|
@@ -29,26 +31,37 @@ module Exportr
|
|
29
31
|
end
|
30
32
|
|
31
33
|
def self.add val
|
34
|
+
log
|
32
35
|
log "Adding #{val.to_a[0][0]}=#{val.to_a[0][1]} to your environment..."
|
33
36
|
write_config load_config.merge(val)
|
34
37
|
end
|
35
38
|
|
36
39
|
def self.remove val
|
40
|
+
log
|
37
41
|
log "Removing #{val.to_a[0][0]} from your environment..."
|
38
42
|
write_config load_config.reject { |k,v| k == val.to_a[0][0] }
|
39
43
|
end
|
40
44
|
|
41
45
|
def self.clear val=nil
|
46
|
+
log
|
42
47
|
log "Clearing environment variables..."
|
43
48
|
write_config Hash.new
|
44
49
|
end
|
45
50
|
|
46
51
|
def self.list val=nil
|
52
|
+
log
|
47
53
|
log "Exportr Environment Variables"
|
48
54
|
log "--------------------------------------------------"
|
49
55
|
vars = load_config.to_a
|
50
56
|
vars.each { |var| log "#{var[0]}=#{var[1]}" }
|
51
57
|
log("none.") unless vars.any?
|
58
|
+
log
|
59
|
+
end
|
60
|
+
|
61
|
+
def self.version val=nil
|
62
|
+
log
|
63
|
+
log "Version #{Exportr::VERSION}"
|
64
|
+
log
|
52
65
|
end
|
53
66
|
|
54
67
|
def self.parser
|
@@ -70,6 +83,7 @@ module Exportr
|
|
70
83
|
f.write cm << "\n" << dump_config(vars)
|
71
84
|
end
|
72
85
|
log "Done."
|
86
|
+
log
|
73
87
|
end
|
74
88
|
|
75
89
|
def self.load_config
|
data/lib/exportr/helpers.rb
CHANGED
data/lib/exportr/railtie.rb
CHANGED
@@ -1,12 +1,14 @@
|
|
1
|
-
require
|
1
|
+
require 'exportr/helpers'
|
2
2
|
|
3
3
|
module Exportr
|
4
4
|
|
5
5
|
class Railtie < Rails::Railtie
|
6
6
|
|
7
|
+
extend Exportr::Helpers
|
8
|
+
|
7
9
|
config.before_initialize do
|
8
|
-
if File.exists?
|
9
|
-
config = YAML.load(File.open(
|
10
|
+
if File.exists? config_file
|
11
|
+
config = YAML.load(File.open(config_file)
|
10
12
|
config.each_pair { |key,value| ENV[key] = value } if config
|
11
13
|
end
|
12
14
|
end
|
data/lib/exportr/version.rb
CHANGED
@@ -4,21 +4,11 @@ class ExportrGenerator < Rails::Generators::Base
|
|
4
4
|
|
5
5
|
def generate_initializer
|
6
6
|
copy_file 'exportr.yml', 'config/exportr.yml'
|
7
|
-
|
8
|
-
# Decrecation warning
|
9
|
-
if File.exists?("#{Rails.root}/config/initializers/exportr.rb")
|
10
|
-
puts
|
11
|
-
puts 'Deprecation Warning: Exportr no longer uses config/initialzers/exportr.rb to load environment variables.'
|
12
|
-
puts 'Please remove before restarting your server.'
|
13
|
-
puts
|
14
|
-
end
|
15
|
-
|
16
7
|
end
|
17
8
|
|
18
9
|
def mod_gitignore
|
19
10
|
return if File.read("#{Rails.root}/.gitignore").match(/config\/exportr.yml/)
|
20
11
|
File.open("#{Rails.root}/.gitignore", 'a+') do |f|
|
21
|
-
f.puts
|
22
12
|
f.puts
|
23
13
|
f.puts '# Ignoring local env export'
|
24
14
|
f.puts 'config/exportr.yml'
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# This file is loaded
|
1
|
+
# This file is loaded before app initialization to set app specific environment variables
|
2
2
|
# set environment variables in the format [KEY]: [VALUE], each separated by a newline
|
3
3
|
#
|
4
4
|
# FACEBOOK_APP_KEY: '234443366312034'
|