Class: Dressmaker::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/dressmaker/configuration.rb,
lib/dressmaker/configuration/rule.rb,
lib/dressmaker/configuration/matcher.rb,
lib/dressmaker/configuration/file_rule.rb,
lib/dressmaker/configuration/delegators.rb,
lib/dressmaker/configuration/file_matcher.rb,
lib/dressmaker/configuration/directory_rule.rb,
lib/dressmaker/configuration/directory_matcher.rb

Defined Under Namespace

Classes: Delegators, DirectoryMatcher, DirectoryRule, FileMatcher, FileRule, Matcher, Rule

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Configuration

Returns a new instance of Configuration.



21
22
23
24
# File 'lib/dressmaker/configuration.rb', line 21

def initialize(options)
  @options = options
  @rules = []
end

Instance Attribute Details

#description_holderObject

Returns the value of attribute description_holder.



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

def description_holder
  @description_holder
end

#optionsObject (readonly)

Returns the value of attribute options.



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

def options
  @options
end

#rulesObject (readonly)

Returns the value of attribute rules.



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

def rules
  @rules
end

Class Method Details

.load(file, options) ⇒ Object



15
16
17
18
19
# File 'lib/dressmaker/configuration.rb', line 15

def self.load(file, options)
  configuration = new(options)
  configuration.instance_eval(File.read(file))
  configuration
end

Instance Method Details

#directoryObject



26
27
28
# File 'lib/dressmaker/configuration.rb', line 26

def directory
  DirectoryMatcher.new(self)
end

#filesObject



30
31
32
# File 'lib/dressmaker/configuration.rb', line 30

def files
  FileMatcher.new(self)
end

#process!(target) ⇒ Object



34
35
36
37
38
39
40
41
# File 'lib/dressmaker/configuration.rb', line 34

def process!(target)
  rules.each do |rule|
    Dir.glob("#{target}/**/*") do |file|
      rel_file = file[target.size, file.size]
      rule.inform && rule.execute!(file) if rule.matches?(target, rel_file)
    end
  end
end