Class: Tailor::Configuration::FileSet

Inherits:
Hash
  • Object
show all
Includes:
Logger::Mixin
Defined in:
lib/tailor/configuration/file_set.rb

Constant Summary collapse

DEFAULT_GLOB =
'lib/**/*.rb'

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Logger::Mixin

included

Constructor Details

#initialize(file_expression = nil, style = nil) ⇒ FileSet

Returns a new instance of FileSet.

Parameters:

  • style (Hash) (defaults to: nil)

    Style options to merge into the default Style settings.

  • file_expression (String, Array) (defaults to: nil)


18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/tailor/configuration/file_set.rb', line 18

def initialize(file_expression=nil, style=nil)
  @style = if style
    Style.new.to_hash.merge(style)
  else
    Style.new.to_hash
  end

  self[:style] = @style

  file_expression ||= DEFAULT_GLOB
  @file_list = build_file_list(file_expression)
  self[:file_list] = @file_list
end

Instance Attribute Details

#file_listObject

Returns the value of attribute file_list.



13
14
15
# File 'lib/tailor/configuration/file_set.rb', line 13

def file_list
  @file_list
end

#styleObject (readonly)

Returns the value of attribute style.



12
13
14
# File 'lib/tailor/configuration/file_set.rb', line 12

def style
  @style
end

Instance Method Details

#[](key) ⇒ Object



41
42
43
44
45
46
47
48
49
# File 'lib/tailor/configuration/file_set.rb', line 41

def [](key)
  if key == :style
    @style.to_hash
  elsif key == :file_list
    @file_list
  else
    raise Tailor::RuntimeError, "Invalid key requested: #{key}"
  end
end

#update_file_list(file_expression) ⇒ Object



32
33
34
35
# File 'lib/tailor/configuration/file_set.rb', line 32

def update_file_list(file_expression)
  new_list = build_file_list(file_expression)
  @file_list.concat(new_list).uniq!
end

#update_style(new_style) ⇒ Object



37
38
39
# File 'lib/tailor/configuration/file_set.rb', line 37

def update_style(new_style)
  @style.to_hash.merge!(new_style)
end