Class: SimpleResolver
- Inherits:
-
Object
- Object
- SimpleResolver
- Defined in:
- lib/tasks/simple_resolver.rb
Direct Known Subclasses
Instance Method Summary collapse
- #edit_warning ⇒ Object
- #execute ⇒ Object
- #files ⇒ Object
- #finish ⇒ Object
-
#initialize(template, output, files, base_dir = nil) ⇒ SimpleResolver
constructor
A new instance of SimpleResolver.
- #xml_edit_warning ⇒ Object
Constructor Details
#initialize(template, output, files, base_dir = nil) ⇒ SimpleResolver
Returns a new instance of SimpleResolver.
4 5 6 7 8 9 10 11 12 |
# File 'lib/tasks/simple_resolver.rb', line 4 def initialize(template, output, files, base_dir=nil) @template = template @output = output @files = files @base_dir = base_dir @ignored_files = [] execute finish end |
Instance Method Details
#edit_warning ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/tasks/simple_resolver.rb', line 51 def edit_warning return <<EOF /************************************* * DO NOT EDIT THIS FILE! * This file was auto-generated from * an ERB template which can be * found at: * #{@template} *************************************/ EOF end |
#execute ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/tasks/simple_resolver.rb', line 14 def execute template_file = File.open(@template, 'r') content = template_file.read result = ERB.new(content, nil, '>').result(binding) output_file = File.open(@output, 'w') output_file.write(result) template_file.close output_file.close end |
#files ⇒ Object
26 27 28 |
# File 'lib/tasks/simple_resolver.rb', line 26 def files return @files end |
#finish ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'lib/tasks/simple_resolver.rb', line 30 def finish if(@ignored_files.size > 0) Logger.puts '>> SimpleResolver ignored the following files because their names were invalid:' @ignored_files.each do |file| puts file end end end |
#xml_edit_warning ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/tasks/simple_resolver.rb', line 39 def xml_edit_warning return <<EOF <!-- DO NOT EDIT THIS FILE! This file was auto-generated from an ERB template which can be found at: #{@template} --> EOF end |