Class: Valise::Stack::ExtensionsDecorator

Inherits:
Valise::Stack show all
Defined in:
lib/valise/stack/extensions-decorator.rb

Instance Attribute Summary collapse

Attributes inherited from Valise::Stack

#segments

Instance Method Summary collapse

Methods inherited from Valise::Stack

#below, #depth_of, #dump_load, #exts, #find, #item_for, #merge_diff, #not_above, #reverse

Methods included from ItemEnum

#absent, #present, #writable

Methods included from Unpath

#clean_pathname, #containing_workspace, #current_directory, #file_from_backtrace, #from_here, #make_pathname, #starting_directory, #up_to, #up_until

Constructor Details

#initialize(stack) ⇒ ExtensionsDecorator

Returns a new instance of ExtensionsDecorator.



6
7
8
9
10
11
12
# File 'lib/valise/stack/extensions-decorator.rb', line 6

def initialize(stack)
  @stack = stack
  @extensions = []
  @stacks = Hash.new do |h,segments|
    h[segments] = @stack.valise.get(segments)
  end
end

Instance Attribute Details

#extensionsObject

Returns the value of attribute extensions.



14
15
16
# File 'lib/valise/stack/extensions-decorator.rb', line 14

def extensions
  @extensions
end

Instance Method Details

#diffed(item, value) ⇒ Object



34
35
36
# File 'lib/valise/stack/extensions-decorator.rb', line 34

def diffed(item, value)
  item.stack.diffed(item, value)
end

#eachObject



42
43
44
45
46
47
48
49
50
51
# File 'lib/valise/stack/extensions-decorator.rb', line 42

def each
  return enum_for(:each) unless block_given?
  @stack.each do |item|
    @extensions.each do |ext|
      dir, file = *item.segments.split
      ext_stack = @stacks[dir + (file.to_s + ext)]
      yield(ext_stack.item_for(item.root))
    end
  end
end

#inspectObject



16
17
18
# File 'lib/valise/stack/extensions-decorator.rb', line 16

def inspect
  @stack.inspect + "x#{extensions.inspect}"
end

#merged(item) ⇒ Object



30
31
32
# File 'lib/valise/stack/extensions-decorator.rb', line 30

def merged(item)
  item.stack.merged(item)
end

#reget(root) ⇒ Object



24
25
26
27
28
# File 'lib/valise/stack/extensions-decorator.rb', line 24

def reget(root)
  decorated = self.new(super)
  decorated.extensions = self.extensions
  decorated
end

#rel_pathObject



38
39
40
# File 'lib/valise/stack/extensions-decorator.rb', line 38

def rel_path
  @stack.rel_path
end

#valiseObject



20
21
22
# File 'lib/valise/stack/extensions-decorator.rb', line 20

def valise
  @stack.valise
end