Module: Gitenv::Context
Instance Attribute Summary collapse
-
#absolute ⇒ Object
Returns the value of attribute absolute.
-
#from_paths ⇒ Object
Returns the value of attribute from_paths.
-
#to_paths ⇒ Object
Returns the value of attribute to_paths.
Instance Method Summary collapse
- #copy!(config) ⇒ Object
- #from(path, &block) ⇒ Object
- #from_path ⇒ Object
- #home ⇒ Object
- #repository ⇒ Object
- #to(path, &block) ⇒ Object
- #to_abs(path, &block) ⇒ Object
- #to_path ⇒ Object
Instance Attribute Details
#absolute ⇒ Object
Returns the value of attribute absolute.
5 6 7 |
# File 'lib/gitenv/context.rb', line 5 def absolute @absolute end |
#from_paths ⇒ Object
Returns the value of attribute from_paths.
5 6 7 |
# File 'lib/gitenv/context.rb', line 5 def from_paths @from_paths end |
#to_paths ⇒ Object
Returns the value of attribute to_paths.
5 6 7 |
# File 'lib/gitenv/context.rb', line 5 def to_paths @to_paths end |
Instance Method Details
#copy!(config) ⇒ Object
45 46 47 48 49 50 |
# File 'lib/gitenv/context.rb', line 45 def copy! config self.from_paths = config.from_paths ? config.from_paths.dup : [] self.to_paths = config.to_paths ? config.to_paths.dup : [] self.absolute = config.absolute @config = config end |
#from(path, &block) ⇒ Object
7 8 9 10 11 12 13 14 |
# File 'lib/gitenv/context.rb', line 7 def from path, &block (@from_paths ||= []) << path if block instance_eval &block @from_paths.pop end self end |
#from_path ⇒ Object
16 17 18 |
# File 'lib/gitenv/context.rb', line 16 def from_path @from_paths ? File.join(*([ @config.repository, @from_paths ].flatten)) : @config.repository end |
#home ⇒ Object
52 53 54 |
# File 'lib/gitenv/context.rb', line 52 def home @config.home end |
#repository ⇒ Object
56 57 58 |
# File 'lib/gitenv/context.rb', line 56 def repository @config.repository end |
#to(path, &block) ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/gitenv/context.rb', line 20 def to path, &block (@to_paths ||= []) << path if block instance_eval &block @to_paths.pop end self end |
#to_abs(path, &block) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/gitenv/context.rb', line 29 def to_abs path, &block previous = @to_paths @to_paths = [ path ] @absolute = true if block instance_eval &block @to_paths = previous @absolute = false end self end |
#to_path ⇒ Object
41 42 43 |
# File 'lib/gitenv/context.rb', line 41 def to_path @to_paths ? File.join(*(@absolute ? @to_paths : [ @config.home, @to_paths ]).flatten) : @config.home end |