Class: ENVied::Cli

Inherits:
Thor
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/envied/cli.rb

Instance Method Summary collapse

Instance Method Details

#checkObject



72
73
74
75
76
77
# File 'lib/envied/cli.rb', line 72

def check
  ENVied.require(*options[:groups])
  unless options[:quiet]
    puts "All variables for group(s) #{options[:groups]} are present and valid"
  end
end

#extractObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/envied/cli.rb', line 26

def extract
  globs = options[:globs]
  globs << "{test,spec}/*" if options[:tests]
  var_occurrences = ENVied::EnvVarExtractor.new(globs: globs).extract

  puts "Found %d occurrences of %d variables:" % [var_occurrences.values.flatten.size, var_occurrences.size]
  var_occurrences.sort.each do |var, occs|
    puts var
    occs.sort_by{|i| i[:path].size }.each do |occ|
      puts "* %s:%s" % occ.values_at(:path, :line)
    end
    puts
  end
end

#initObject



42
43
44
45
46
47
48
# File 'lib/envied/cli.rb', line 42

def init
  puts "Writing Envfile to #{File.expand_path('Envfile')}"
  template("Envfile.tt")

  puts "Add the following snippet (or similar) to your app's initialization:"
  puts "ENVied.require(*ENV['ENVIED_GROUPS'] || [:default, ENV['RACK_ENV']])"
end

#versionObject



11
12
13
# File 'lib/envied/cli.rb', line 11

def version
  puts ENVied::VERSION
end