Class: Capistrano::Env::Config
- Inherits:
-
Object
- Object
- Capistrano::Env::Config
- Defined in:
- lib/capistrano/env/config.rb
Instance Attribute Summary collapse
-
#filemode ⇒ Object
Returns the value of attribute filemode.
-
#formatter ⇒ Object
Returns the value of attribute formatter.
Instance Method Summary collapse
- #add(name_or_regexp, val = nil, &block) ⇒ Object
- #capenv_content ⇒ Object
- #capenv_file ⇒ Object
- #capenv_filemode ⇒ Object
- #envs ⇒ Object
- #formatter_class ⇒ Object
-
#initialize ⇒ Config
constructor
A new instance of Config.
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
9 10 11 12 |
# File 'lib/capistrano/env/config.rb', line 9 def initialize @values = {} @keys = [] end |
Instance Attribute Details
#filemode ⇒ Object
Returns the value of attribute filemode.
7 8 9 |
# File 'lib/capistrano/env/config.rb', line 7 def filemode @filemode end |
#formatter ⇒ Object
Returns the value of attribute formatter.
6 7 8 |
# File 'lib/capistrano/env/config.rb', line 6 def formatter @formatter end |
Instance Method Details
#add(name_or_regexp, val = nil, &block) ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/capistrano/env/config.rb', line 27 def add(name_or_regexp, val = nil, &block) if val && name_or_regexp.is_a?(String) @values[name_or_regexp] = val else @keys << [name_or_regexp, block] end end |
#capenv_content ⇒ Object
56 57 58 |
# File 'lib/capistrano/env/config.rb', line 56 def capenv_content formatter_class.format(envs) end |
#capenv_file ⇒ Object
52 53 54 |
# File 'lib/capistrano/env/config.rb', line 52 def capenv_file formatter_class.filename end |
#capenv_filemode ⇒ Object
60 61 62 |
# File 'lib/capistrano/env/config.rb', line 60 def capenv_filemode filemode end |
#envs ⇒ Object
42 43 44 45 46 47 48 49 50 |
# File 'lib/capistrano/env/config.rb', line 42 def envs result = {} @keys.each do |key, block| key_values = key.is_a?(Regexp) ? ENV.select { |x| x =~ key } : ENV.select { |x| x == key } key_values = Hash[key_values.map { |k, v| [block.call(k), v] }] if block result.merge!(key_values) end result.merge(@values) end |
#formatter_class ⇒ Object
35 36 37 38 39 40 |
# File 'lib/capistrano/env/config.rb', line 35 def formatter_class @formatter_class ||= begin require "capistrano/env/formatter/#{formatter}_formatter" Capistrano::Env::Formatter.const_get "#{formatter.capitalize}Formatter" end end |