Class: DevelopWithPassion::Expander::Expansion
- Defined in:
- lib/developwithpassion_expander/expansion.rb
Instance Attribute Summary collapse
-
#copies ⇒ Object
Returns the value of attribute copies.
-
#files_to_merge ⇒ Object
Returns the value of attribute files_to_merge.
-
#globber ⇒ Object
Returns the value of attribute globber.
Instance Method Summary collapse
- #before(&block) ⇒ Object
- #cleanup(&block) ⇒ Object
- #copy_to(target, &block) ⇒ Object
- #expand_items ⇒ Object
- #hash_process(target, hash, factory, &block) ⇒ Object
-
#initialize ⇒ Expansion
constructor
A new instance of Expansion.
- #look_for_templates_in(path) ⇒ Object
- #merge_items ⇒ Object
- #merge_to(target, &block) ⇒ Object
- #run ⇒ Object
Constructor Details
#initialize ⇒ Expansion
Returns a new instance of Expansion.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/developwithpassion_expander/expansion.rb', line 6 def initialize initialize_hashes :files_to_merge,:copies @globber = lambda{|path| return glob(path)} array :cleanup_items do|a| a.readable a.process_using :run_cleanup,:call end array :setup_items do|a| a.readable a.process_using :run_setup_items,:call end array :executable_files do|a| a.mutator :register_executable a.process_using :mark_files_executable,ShellActionAgainstFile.new("chmod +x") end array :files_with_line_endings_to_fix do|a| a.mutator :fix_line_endings_for a.process_using :fix_line_endings,ShellActionAgainstFile.new("d2u") end array :folders_to_purge do|a| a.mutator :register_folder_to_purge a.process_using :purge_targets,ShellActionAgainstFile.new("rm -rf") end end |
Instance Attribute Details
#copies ⇒ Object
Returns the value of attribute copies.
4 5 6 |
# File 'lib/developwithpassion_expander/expansion.rb', line 4 def copies @copies end |
#files_to_merge ⇒ Object
Returns the value of attribute files_to_merge.
4 5 6 |
# File 'lib/developwithpassion_expander/expansion.rb', line 4 def files_to_merge @files_to_merge end |
#globber ⇒ Object
Returns the value of attribute globber.
4 5 6 |
# File 'lib/developwithpassion_expander/expansion.rb', line 4 def globber @globber end |
Instance Method Details
#before(&block) ⇒ Object
53 54 55 |
# File 'lib/developwithpassion_expander/expansion.rb', line 53 def before(&block) @setup_items << block end |
#cleanup(&block) ⇒ Object
49 50 51 |
# File 'lib/developwithpassion_expander/expansion.rb', line 49 def cleanup(&block) @cleanup_items << block end |
#copy_to(target, &block) ⇒ Object
37 38 39 |
# File 'lib/developwithpassion_expander/expansion.rb', line 37 def copy_to target,&block hash_process(target,@copies,lambda{|key| return Copy.new(CopyToTarget.new(key))},&block) end |
#expand_items ⇒ Object
73 74 75 |
# File 'lib/developwithpassion_expander/expansion.rb', line 73 def @copies.process_all_values_using{|copy| copy.run} end |
#hash_process(target, hash, factory, &block) ⇒ Object
68 69 70 71 72 |
# File 'lib/developwithpassion_expander/expansion.rb', line 68 def hash_process(target,hash,factory,&block) symbol = target.to_sym hash[symbol] = factory.call(target) unless hash.has_key?(symbol) hash[symbol].instance_eval(&block) end |
#look_for_templates_in(path) ⇒ Object
45 46 47 |
# File 'lib/developwithpassion_expander/expansion.rb', line 45 def look_for_templates_in(path) @globber.call(path).process_all_items_using(TemplateVisitor.instance) end |
#merge_items ⇒ Object
76 77 78 |
# File 'lib/developwithpassion_expander/expansion.rb', line 76 def merge_items @files_to_merge.process_all_values_using{|merge| merge.run} end |
#merge_to(target, &block) ⇒ Object
41 42 43 |
# File 'lib/developwithpassion_expander/expansion.rb', line 41 def merge_to target,&block hash_process(target,@files_to_merge,lambda{|key| return FileMerge.new(key)},&block) end |
#run ⇒ Object
57 58 59 60 61 62 63 64 65 |
# File 'lib/developwithpassion_expander/expansion.rb', line 57 def run run_setup_items purge_targets merge_items run_cleanup fix_line_endings mark_files_executable end |