Class: Spud::BuildTools::SpudBuild::FileContext

Inherits:
Object
  • Object
show all
Defined in:
lib/build_tools/spud/file_context.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(spud) ⇒ FileContext

Returns a new instance of FileContext.



8
9
10
11
# File 'lib/build_tools/spud/file_context.rb', line 8

def initialize(spud)
  @spud = spud
  @rules = {}
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args, &block) ⇒ Object



20
21
22
23
# File 'lib/build_tools/spud/file_context.rb', line 20

def method_missing(method_name, *args, &block)
  method_name = method_name.to_s
  rule(method_name, *args, &block)
end

Instance Attribute Details

#rulesObject (readonly)

Returns the value of attribute rules.



6
7
8
# File 'lib/build_tools/spud/file_context.rb', line 6

def rules
  @rules
end

Instance Method Details

#rule(name, *args, &block) ⇒ Object



13
14
15
16
17
18
# File 'lib/build_tools/spud/file_context.rb', line 13

def rule(name, *args, &block)
  name = name.to_s
  files = args.select { |arg| arg.is_a?(String) }
  deps = args.select { |arg| arg.is_a?(Hash) }.reduce({}) { |hash, dep| hash.merge(dep) }
  @rules[name] = Rule.new(@spud, self, name, files, deps, block)
end