Sha256: 7439d09697a0bd81f37ff8c6ca760a9306f9c17a48c6969f7161b5f146845b7a

Contents?: true

Size: 634 Bytes

Versions: 7

Compression:

Stored size: 634 Bytes

Contents

#!/usr/bin/env ruby
require 'rubygems'
require 'json/ext'
require 'configliere'

Settings.use :commandline, :define
Settings.define :json_keys, :description => "A comma separated list of keys, in the order to be read from source."
# Settings.resolve!

module TSVtoJSON
  
  # def initialize
  #   keys unless Settings.keys.nil?
  # end
  
  def keys
    @keys ||= Settings.json_keys.split(",")
  end
  
  def into_json record, exclude=[]
    json_hash = Hash.new
    keys.each_with_index do |key, index|
      next if exclude.include?(key)
      json_hash[key] = record[index]
    end
    return JSON.generate(json_hash)
  end
  
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
imw-0.2.18 bin/tsv_to_json.rb
imw-0.2.17 bin/tsv_to_json.rb
imw-0.2.16 bin/tsv_to_json.rb
imw-0.2.15 bin/tsv_to_json.rb
imw-0.2.14 bin/tsv_to_json.rb
imw-0.2.13 bin/tsv_to_json.rb
imw-0.2.12 bin/tsv_to_json.rb