Module: Orchparty::Plugin::Env
- Defined in:
- lib/orchparty/plugins/env.rb
Class Method Summary collapse
- .define_flags(c) ⇒ Object
- .desc ⇒ Object
- .env_output(application, options) ⇒ Object
- .generate(ast, options) ⇒ Object
Class Method Details
.define_flags(c) ⇒ Object
11 12 13 14 15 |
# File 'lib/orchparty/plugins/env.rb', line 11 def self.define_flags(c) c.flag %i[output o], desc: 'Set the output file' c.flag %i[service s], desc: 'Set the service to generate environment variables from.' c.flag %i[seperator sep], desc: 'How to join the environment variables', default_value: '\\n' end |
.desc ⇒ Object
7 8 9 |
# File 'lib/orchparty/plugins/env.rb', line 7 def self.desc 'generate environment variables' end |
.env_output(application, options) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/orchparty/plugins/env.rb', line 26 def self.env_output(application, ) services = if [:service] [application.services[[:service]]] else application.services.values end [:sep] = "\n" if [:sep] == '\\n' envs = services.map(&:environment).compact.inject({}) { |a, v| a.merge(v) } envs.map { |k, v| "#{k}=#{v.is_a?(String) ? v.shellescape : v}" }.join([:sep]) end |
.generate(ast, options) ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/orchparty/plugins/env.rb', line 17 def self.generate(ast, ) output = env_output(ast, ) if [:output] File.write([:output], output) else print output end end |