Class: Gitenv::Context
- Inherits:
-
Object
- Object
- Gitenv::Context
- Defined in:
- lib/gitenv/context.rb
Instance Attribute Summary collapse
-
#ignores ⇒ Object
Returns the value of attribute ignores.
Instance Method Summary collapse
- #dup ⇒ Object
- #from(path = nil, &block) ⇒ Object
-
#initialize(config, options = {}) ⇒ Context
constructor
A new instance of Context.
- #to(path = nil, &block) ⇒ Object
Constructor Details
#initialize(config, options = {}) ⇒ Context
Returns a new instance of Context.
7 8 9 10 11 12 13 14 15 |
# File 'lib/gitenv/context.rb', line 7 def initialize(config, = {}) @config = config @from = [:from] @to ||= File.('~') @ignores = [:ignores] || [] @ignores << '.DS_Store' if @ignores.empty? and RbConfig::CONFIG['host_os'] =~ /darwin/ end |
Instance Attribute Details
#ignores ⇒ Object
Returns the value of attribute ignores.
5 6 7 |
# File 'lib/gitenv/context.rb', line 5 def ignores @ignores end |
Instance Method Details
#dup ⇒ Object
45 46 47 |
# File 'lib/gitenv/context.rb', line 45 def dup Context.new @config, from: @from, to: @to, ignores: @ignores.dup end |
#from(path = nil, &block) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/gitenv/context.rb', line 17 def from(path = nil, &block) return @from if path.nil? old = @from @from = @from ? File.(path, @from) : File.(path) if block @config.instance_eval(&block) @from = old end self end |
#to(path = nil, &block) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/gitenv/context.rb', line 31 def to(path = nil, &block) return @to if path.nil? old = @to @to = @to ? File.(path, @to) : File.(path) if block @config.instance_eval(&block) @to = old end self end |