exportr 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -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 NOT_ROOT unless at_root?
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?(CONFIG_FILE)
64
- File.read CONFIG_FILE
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 CONFIG_FILE, 'w+' do |f|
69
+ File.open config_file, 'w+' do |f|
70
70
  f.write cm << "\n" << dump_config(vars)
71
71
  end
72
72
  log "Done."
@@ -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
- NOT_ROOT = 'You must run exportr from the root of your application.'
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.'
@@ -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 at_root?
15
- !!Dir.new(Dir.pwd).collect.detect { |f| f == 'Gemfile' }
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
@@ -1,3 +1,3 @@
1
1
  module Exportr
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
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.1
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-10 00:00:00.000000000 Z
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.