exportr 0.1.3 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE CHANGED
@@ -1,8 +1,18 @@
1
1
  Copyright (C) 2012 Richard Calahan, All Day Everyday
2
2
 
3
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software
4
- and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
3
+ Permission is hereby granted, free of charge, to any person obtaining a
4
+ copy of this software and associated documentation files (the "Software"),
5
+ to deal in the Software without restriction, including without limitation
6
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
7
+ and/or sell copies of the Software, and to permit persons to whom the Software
8
+ is furnished to do so, subject to the following conditions:
5
9
 
6
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
7
12
 
8
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
14
+ INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
15
+ PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
16
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
17
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
18
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -1,4 +1,3 @@
1
-
2
1
  # Exportr: Environment manager for Rails development
3
2
 
4
3
  ## Description
@@ -27,7 +26,6 @@ Run the generator.
27
26
 
28
27
  $ rails generate exportr
29
28
 
30
-
31
29
  The generator creates a yaml file in your config directory. It will store key:value pairs to be loaded as environment variables when your app launches. You can edit it manually, or use the command line utility.
32
30
 
33
31
  ### CLI
@@ -41,3 +39,9 @@ or
41
39
  $ exportr --remove KEY
42
40
 
43
41
  ### FYI
42
+
43
+ You'll need to restart your webserver for the changes to take effect.
44
+
45
+ ### License
46
+
47
+ Exportr is copyright 2012 by Richard Calahan and contributors at All Day Everyday. It is licensed under the MIT license. See the include LICENSE file for details.
@@ -1,7 +1,6 @@
1
- require 'optparse'
2
1
  require 'exportr/config'
3
- require 'exportr/error_messages'
4
2
  require 'exportr/helpers'
3
+ require 'optparse'
5
4
  require 'yaml'
6
5
 
7
6
  module Exportr
@@ -9,26 +8,30 @@ module Exportr
9
8
  module Command
10
9
 
11
10
  extend Exportr::Config
12
- extend Exportr::ErrorMessages
13
11
  extend Exportr::Helpers
14
12
 
13
+ def self.global_options
14
+ @global_options ||= []
15
+ end
16
+
17
+ def self.global_option name, *args
18
+ global_options << { :name => name, :args => args }
19
+ end
20
+
15
21
  global_option :add, '-a', '--add VAR', 'Add environment variable'
16
22
  global_option :remove, '-r', '--remove VAR', 'Remove environment variable'
17
23
 
18
24
  def self.run *argv
19
- error not_root unless at_root?
25
+ error NOT_ROOT unless at_root?
20
26
  parser.parse! argv
21
27
  end
22
28
 
23
29
  def self.add val
24
- vars = load_config
25
- vars.merge! val
26
- write_config vars
30
+ write_config load_config.merge(val)
27
31
  end
28
32
 
29
33
  def self.remove val
30
- vars = load_config
31
- write_config vars.reject { |k,v| k == val.to_a[0][0] }
34
+ write_config load_config.reject { |k,v| k == val.to_a[0][0] }
32
35
  end
33
36
 
34
37
  def self.parser
@@ -42,13 +45,13 @@ module Exportr
42
45
  end
43
46
 
44
47
  def self.read_config
45
- error no_config_file unless File.exists?(config_file)
46
- File.read config_file
48
+ error NO_CONFIG_FILE unless File.exists?(CONFIG_FILE)
49
+ File.read CONFIG_FILE
47
50
  end
48
51
 
49
52
  def self.write_config vars
50
53
  cm = comments
51
- File.open config_file, 'w+' do |f|
54
+ File.open CONFIG_FILE, 'w+' do |f|
52
55
  f.write cm << "\n" << dump_config(vars)
53
56
  end
54
57
  end
@@ -2,16 +2,19 @@ module Exportr
2
2
 
3
3
  module Config
4
4
 
5
- def global_options
6
- @global_options ||= []
7
- end
8
-
9
- def global_option name, *args
10
- global_options << { :name => name, :args => args }
11
- end
5
+ # Default config file location.
6
+ CONFIG_FILE = 'config/exportr.yml'
7
+
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.'
10
+
11
+ # Default error message if there is no config file present.
12
+ NO_CONFIG_FILE = 'You must run `rails generate exportr` first.'
12
13
 
13
- def config_file
14
- "config/exportr.yml"
14
+ def self.extended base
15
+ constants.each do |const|
16
+ base.const_set const, const_get(const)
17
+ end
15
18
  end
16
19
 
17
20
  end
@@ -2,8 +2,12 @@ module Exportr
2
2
 
3
3
  module Helpers
4
4
 
5
+ def log msg
6
+ STDOUT.puts msg
7
+ end
8
+
5
9
  def error msg
6
- puts "ERROR: " << msg
10
+ STDERR.puts "ERROR: #{msg}"
7
11
  exit 1
8
12
  end
9
13
 
@@ -1,3 +1,3 @@
1
1
  module Exportr
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.5"
3
3
  end
@@ -1,6 +1,7 @@
1
- # Loads export.yml and sets key=value to the local environment
1
+ require 'exportr/config'
2
2
 
3
- if File.exists? "#{Rails.root}/config/exportr.yml"
4
- config = YAML.load(File.open("#{Rails.root}/config/exportr.yml"))
3
+ # Loads export.yml and sets key=value to the local environment
4
+ if File.exists? "#{Rails.root}/#{Exportr::Config::CONFIG_FILE}"
5
+ config = YAML.load(File.open("#{Rails.root}/#{Exportr::Config::CONFIG_FILE}"))
5
6
  config.each_pair { |key,value| ENV[key] = value } if config
6
7
  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.1.3
4
+ version: 0.1.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -30,7 +30,6 @@ files:
30
30
  - lib/exportr.rb
31
31
  - lib/exportr/command.rb
32
32
  - lib/exportr/config.rb
33
- - lib/exportr/error_messages.rb
34
33
  - lib/exportr/helpers.rb
35
34
  - lib/exportr/version.rb
36
35
  - lib/generators/exportr/exportr_generator.rb
@@ -1,15 +0,0 @@
1
- module Exportr
2
-
3
- module ErrorMessages
4
-
5
- def not_root
6
- "You must run exportr from the root of your application."
7
- end
8
-
9
- def no_config_file
10
- "You must run `rails generate exportr` first. "
11
- end
12
-
13
- end
14
-
15
- end