Class: Overapp::Files
- Includes:
- Enumerable, FromHash
- Defined in:
- lib/overapp/files.rb
Class Method Summary collapse
Instance Method Summary collapse
- #add(ops) ⇒ Object
- #apply(on_top) ⇒ Object
- #each(&b) ⇒ Object
- #size ⇒ Object
- #write_to!(dir) ⇒ Object
Class Method Details
.load_command(cmd, ops) ⇒ Object
50 51 52 |
# File 'lib/overapp/files.rb', line 50 def load_command(cmd,ops) FromCommand.new(:command => cmd, :path => ops[:path]||".").files end |
Instance Method Details
#add(ops) ⇒ Object
16 17 18 |
# File 'lib/overapp/files.rb', line 16 def add(ops) files << file_class.new(:path => ops[:file], :full_body => ops[:body]) end |
#apply(on_top) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/overapp/files.rb', line 22 def apply(on_top) res = files.clone on_top.each do |top_file| existing = res.find { |x| x.path == top_file.path } if existing res -= [existing] new_file = top_file.combined(existing) res << new_file if new_file elsif top_file.has_note? raise MissingBaseFileError.new(:top_file => top_file, :base => self) else res << top_file end end self.class.new(:files => res) end |
#each(&b) ⇒ Object
38 39 40 |
# File 'lib/overapp/files.rb', line 38 def each(&b) files.each(&b) end |
#size ⇒ Object
19 20 21 |
# File 'lib/overapp/files.rb', line 19 def size files.size end |
#write_to!(dir) ⇒ Object
42 43 44 45 46 47 |
# File 'lib/overapp/files.rb', line 42 def write_to!(dir) each do |f| f.write_to! dir end self end |