exportr 0.2.2 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -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 VAR', 'Add environment variable'
22
- global_option :remove, '-r', '--remove VAR', 'Remove environment variable'
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
@@ -6,8 +6,8 @@ module Exportr
6
6
 
7
7
  extend Exportr::Config
8
8
 
9
- def log msg
10
- STDOUT.puts " | #{msg}"
9
+ def log msg=nil
10
+ STDOUT.puts msg ? " | #{msg}" : ""
11
11
  end
12
12
 
13
13
  def error msg
@@ -1,12 +1,14 @@
1
- require "exportr/config"
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? "#{Rails.root}/#{Exportr::Config::CONFIG_FILE}"
9
- config = YAML.load(File.open("#{Rails.root}/#{Exportr::Config::CONFIG_FILE}"))
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
@@ -1,3 +1,3 @@
1
1
  module Exportr
2
- VERSION = "0.2.2"
2
+ VERSION = "0.2.4"
3
3
  end
@@ -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 at app initialization to set app specific environment variables
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'
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.2
4
+ version: 0.2.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: