lib/overapp/files.rb in overapp-0.4.2 vs lib/overapp/files.rb in overapp-0.5.0
- old
+ new
@@ -1,11 +1,11 @@
module Overapp
class MissingBaseFileError < RuntimeError
include FromHash
attr_accessor :top_file, :base
def message
- res = "Cannot overlay onto missing file #{top_file.path}\nBase File Count: #{base.files.size}\n"
+ res = "Cannot overlay onto missing file #{top_file.path}\nBase File Count: #{base.files.size}\n#{top_file.params_obj.note_params.inspect}"
res += base.map { |x| x.path }.join("\n")
res
end
end
class Files
@@ -17,22 +17,26 @@
files << file_class.new(:path => ops[:file], :full_body => ops[:body])
end
def size
files.size
end
- def apply(on_top)
+ def apply(on_top,ops={})
res = files.clone
on_top.each do |top_file|
+ if ops[:vars] && ops[:vars].size > 0
+ #raise ops[:vars].inspect
+ top_file.vars = ops[:vars]
+ end
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
+ res << top_file.parsed
end
end
self.class.new(:files => res)
end
def each(&b)
@@ -44,12 +48,13 @@
f.write_to! dir
end
self
end
- class << self
- def load_command(cmd,ops)
- FromCommand.new(:command => cmd, :path => ops[:path]||".").files
+ def with_tmp(&b)
+ Overapp::TmpDir.with do |dir|
+ write_to! dir
+ b[dir]
end
end
end
end
\ No newline at end of file