Module: Escualo::Env
- Defined in:
- lib/escualo/env.rb
Class Method Summary collapse
- .clean(session, options) ⇒ Object
- .clean_command ⇒ Object
- .environment_variables(environment) ⇒ Object
- .get(session, variable) ⇒ Object
- .list(session) ⇒ Object
- .locale ⇒ Object
- .locale_export ⇒ Object
- .locale_variables ⇒ Object
- .present?(session, variable) ⇒ Boolean
- .set(session, variables) ⇒ Object
- .set_builtins(session, options) ⇒ Object
- .set_command(key, value) ⇒ Object
- .setup(session) ⇒ Object
- .unset(session, variable_names) ⇒ Object
- .unset_command(name) ⇒ Object
Class Method Details
.clean(session, options) ⇒ Object
17 18 19 20 21 |
# File 'lib/escualo/env.rb', line 17 def self.clean(session, ) session.clean_environment_variables! set_builtins session, end |
.clean_command ⇒ Object
45 46 47 |
# File 'lib/escualo/env.rb', line 45 def self.clean_command 'rm ~/.escualo/vars/*' end |
.environment_variables(environment) ⇒ Object
65 66 67 68 69 |
# File 'lib/escualo/env.rb', line 65 def self.environment_variables(environment) %w{RAILS_ENV NODE_ENV RACK_ENV}.map do |it| [it, environment] end.to_h end |
.get(session, variable) ⇒ Object
29 30 31 |
# File 'lib/escualo/env.rb', line 29 def self.get(session, variable) session.ask("cat ~/.escualo/vars/#{variable}") end |
.list(session) ⇒ Object
13 14 15 |
# File 'lib/escualo/env.rb', line 13 def self.list(session) session.ask('cat ~/.escualo/vars/*').gsub('export ', '') end |
.locale ⇒ Object
61 62 63 |
# File 'lib/escualo/env.rb', line 61 def self.locale 'en_US.UTF-8' end |
.locale_export ⇒ Object
71 72 73 |
# File 'lib/escualo/env.rb', line 71 def self.locale_export locale_variables.map { |key, value| "#{key}=#{value}" }.join(' ') end |
.locale_variables ⇒ Object
53 54 55 56 57 58 59 |
# File 'lib/escualo/env.rb', line 53 def self.locale_variables %w{LANG LANGUAGE LC_ALL LC_NAME LC_IDENTIFICATION LC_PAPER LC_ADDRESS LC_TIME LC_NUMERIC LC_MONETARY LC_TELEPHONE LC_MEASUREMENT}.map do |it| [it, locale] end.to_h end |
.present?(session, variable) ⇒ Boolean
23 24 25 26 27 |
# File 'lib/escualo/env.rb', line 23 def self.present?(session, variable) get(session, variable).present? rescue false end |
.set(session, variables) ⇒ Object
33 34 35 |
# File 'lib/escualo/env.rb', line 33 def self.set(session, variables) session.set_environment_variables! variables end |
.set_builtins(session, options) ⇒ Object
7 8 9 10 11 |
# File 'lib/escualo/env.rb', line 7 def self.set_builtins(session, ) set session, ESCUALO_BASE_VERSION: Escualo::BASE_VERSION set session, Escualo::Env.locale_variables set session, Escualo::Env.environment_variables(.env) end |
.set_command(key, value) ⇒ Object
49 50 51 |
# File 'lib/escualo/env.rb', line 49 def self.set_command(key, value) "echo export #{key}=#{value} > ~/.escualo/vars/#{key}" end |
.setup(session) ⇒ Object
3 4 5 |
# File 'lib/escualo/env.rb', line 3 def self.setup(session) session.setup_environment_variables! end |
.unset(session, variable_names) ⇒ Object
37 38 39 |
# File 'lib/escualo/env.rb', line 37 def self.unset(session, variable_names) session.unset_environment_variables! variable_names end |
.unset_command(name) ⇒ Object
41 42 43 |
# File 'lib/escualo/env.rb', line 41 def self.unset_command(name) "rm ~/.escualo/vars/#{name}" end |