Sha256: a7754481826e2edcd5d6dde36c429911ff6fbb6d4a9d0442d36ea810b30b33d9

Contents?: true

Size: 679 Bytes

Versions: 10

Compression:

Stored size: 679 Bytes

Contents

# concatenate input files:
# * assuming that each input file has a single header line
# * writing a single header line to the output (just use the header line from the first file)
# * trying that all the files have the same format (no validation)

class Masticate::Concat #< Masticate::Base
  def initialize(filenames)
    @filenames = filenames
  end

  def concat(opts)
    File.unlink(opts[:output]) if opts[:output] && File.exists?(opts[:output])
    redirect = ">>#{opts[:output]}" if opts[:output]
    
    file1, *rest = @filenames
    system "cat #{file1} #{redirect}"
    rest.each do |file|
      system "tail -n +2 #{file} | sed '/^$/d' #{redirect}"
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
masticate-0.6.2 lib/masticate/concat.rb
masticate-0.6.1 lib/masticate/concat.rb
masticate-0.6.0 lib/masticate/concat.rb
masticate-0.5.1 lib/masticate/concat.rb
masticate-0.5.0 lib/masticate/concat.rb
masticate-0.4.2 lib/masticate/concat.rb
masticate-0.4.1 lib/masticate/concat.rb
masticate-0.4.0 lib/masticate/concat.rb
masticate-0.3.2 lib/masticate/concat.rb
masticate-0.3.1 lib/masticate/concat.rb