class PMLCode::SparseUpdater
Private Instance Methods
generate_update_id(match)
click to toggle source
# File lib/pmlcode/updaters/sparse_updater.rb, line 28 def generate_update_id(match) "#{match[:chapter]}.#{match[:snapshot]}/#{match[:path]}" end
update(match, already_wrote)
click to toggle source
# File lib/pmlcode/updaters/sparse_updater.rb, line 9 def update(match, already_wrote) success = false content = nil Dir.chdir(@options.app) do content = `git show origin/#{match[:chapter]}.#{match[:snapshot]}:#{match[:path]}` success = $?.success? end if success unless already_wrote || @options.dry_run full_path = File.join(directory(match), match[:path]) FileUtils.mkdir_p(File.dirname(full_path)) File.open(full_path, 'w') do |f| f.write(content) end end content end end