exportr 0.2.1 → 0.2.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.
- data/lib/exportr/command.rb +5 -5
- data/lib/exportr/config.rb +1 -1
- data/lib/exportr/helpers.rb +22 -3
- data/lib/exportr/version.rb +1 -1
- metadata +2 -2
data/lib/exportr/command.rb
CHANGED
@@ -7,8 +7,8 @@ module Exportr
|
|
7
7
|
|
8
8
|
module Command
|
9
9
|
|
10
|
-
extend Exportr::Config
|
11
10
|
extend Exportr::Helpers
|
11
|
+
extend Exportr::Config
|
12
12
|
|
13
13
|
def self.global_options
|
14
14
|
@global_options ||= []
|
@@ -24,7 +24,7 @@ module Exportr
|
|
24
24
|
global_option :list, '-l', '--list', 'List all environment variables'
|
25
25
|
|
26
26
|
def self.run *argv
|
27
|
-
error
|
27
|
+
error NOT_RAILS unless in_rails_application?
|
28
28
|
parser.parse! argv
|
29
29
|
end
|
30
30
|
|
@@ -60,13 +60,13 @@ module Exportr
|
|
60
60
|
end
|
61
61
|
|
62
62
|
def self.read_config
|
63
|
-
error NO_CONFIG_FILE unless File.exists?(
|
64
|
-
File.read
|
63
|
+
error NO_CONFIG_FILE unless File.exists?(config_file)
|
64
|
+
File.read config_file
|
65
65
|
end
|
66
66
|
|
67
67
|
def self.write_config vars
|
68
68
|
cm = comments
|
69
|
-
File.open
|
69
|
+
File.open config_file, 'w+' do |f|
|
70
70
|
f.write cm << "\n" << dump_config(vars)
|
71
71
|
end
|
72
72
|
log "Done."
|
data/lib/exportr/config.rb
CHANGED
@@ -6,7 +6,7 @@ module Exportr
|
|
6
6
|
CONFIG_FILE = 'config/exportr.yml'
|
7
7
|
|
8
8
|
# Default error message if CLI is run from anywhere but the root
|
9
|
-
|
9
|
+
NOT_RAILS = 'Could not detect rails application.'
|
10
10
|
|
11
11
|
# Default error message if there is no config file present.
|
12
12
|
NO_CONFIG_FILE = 'You must run `rails generate exportr` first.'
|
data/lib/exportr/helpers.rb
CHANGED
@@ -1,7 +1,11 @@
|
|
1
|
+
require 'exportr/config'
|
2
|
+
|
1
3
|
module Exportr
|
2
4
|
|
3
5
|
module Helpers
|
4
|
-
|
6
|
+
|
7
|
+
extend Exportr::Config
|
8
|
+
|
5
9
|
def log msg
|
6
10
|
STDOUT.puts " | #{msg}"
|
7
11
|
end
|
@@ -11,8 +15,23 @@ module Exportr
|
|
11
15
|
exit 1
|
12
16
|
end
|
13
17
|
|
14
|
-
def
|
15
|
-
!!
|
18
|
+
def in_rails_application?
|
19
|
+
!!rails_root
|
20
|
+
end
|
21
|
+
|
22
|
+
def rails_root
|
23
|
+
begin
|
24
|
+
return Dir.pwd if File.exists?('script/rails')
|
25
|
+
raise
|
26
|
+
rescue
|
27
|
+
Dir.chdir '..'
|
28
|
+
retry unless Dir.pwd == '/'
|
29
|
+
return false
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def config_file
|
34
|
+
File.expand_path(CONFIG_FILE, rails_root)
|
16
35
|
end
|
17
36
|
|
18
37
|
end
|
data/lib/exportr/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: exportr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-04-
|
12
|
+
date: 2012-04-11 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Helps manage rails application specific environment variables for multiple
|
15
15
|
apps in development.
|