Class: Mergit

Inherits:
Object
  • Object
show all
Defined in:
lib/mergit.rb,
lib/mergit/errors.rb,
lib/mergit/version.rb,
lib/mergit/processor.rb

Defined Under Namespace

Classes: MergitError, Processor, RequirementNotFound

Constant Summary collapse

ATTRIBUTES =
{
  :search_path => [Dir.pwd],
  :replacements => {},
}.freeze
VERSION =
"0.1.0"

Instance Method Summary collapse

Constructor Details

#initialize(options = nil) ⇒ Mergit

Returns a new instance of Mergit.



15
16
17
18
19
20
21
# File 'lib/mergit.rb', line 15

def initialize options=nil
  final_options = options ? ATTRIBUTES.merge(options) : ATTRIBUTES

  ATTRIBUTES.each_key do |attr|
    instance_variable_set("@#{attr}", final_options[attr])
  end
end

Instance Method Details

#process(string) ⇒ Object



31
32
33
# File 'lib/mergit.rb', line 31

def process string
  create_string_processor(string).output
end

#process_file(filename) ⇒ Object



23
24
25
26
27
28
29
# File 'lib/mergit.rb', line 23

def process_file filename
  if File.file? filename
    create_file_processor(filename).output
  else
    raise MergitError.new "No such file: #{filename}"
  end
end