Skip to content

Commit

Permalink
fix rubocop/reek detections
Browse files Browse the repository at this point in the history
  • Loading branch information
masa21kik committed Jun 8, 2014
1 parent 63a4027 commit 32a2336
Showing 1 changed file with 23 additions and 22 deletions.
45 changes: 23 additions & 22 deletions bin/json_cli
Original file line number Diff line number Diff line change
Expand Up @@ -3,51 +3,52 @@ require 'json_cli'
require 'thor'

module JsonCli
# CLI class
class CLI < Thor
class_option :output, :aliases => :o, :default => '/dev/stdout'
class_option :output, aliases: :o, default: '/dev/stdout'

desc "left_join RIGHT_FILE [LEFT_FILE]", "left outer join of json files"
option :join_key, :required => true, :aliases => :k
def left_join(right_file, left_file = nil)
left_io = left_file.nil? ? STDIN : File.open(left_file, 'r')
desc 'left_join RIGHT_FILE [LEFT_FILE]', 'left outer join of json files'
option :join_key, required: true, aliases: :k
def left_join(right_file, left_file = '/dev/stdin')
left_io = File.open(left_file, 'r')
right_io = File.open(right_file, 'r')
JsonCli::JoinJson.left_join(left_io, right_io, opts)
[left_io, right_io, opts[:out]].each(&:close)
end

desc "right_join RIGHT_FILE [LEFT_FILE]", "right outer join of json files"
option :join_key, :required => true, :aliases => :k
def right_join(right_file, left_file = nil)
left_io = left_file.nil? ? STDIN : File.open(left_file, 'r')
desc 'right_join RIGHT_FILE [LEFT_FILE]', 'right outer join of json files'
option :join_key, required: true, aliases: :k
def right_join(right_file, left_file = '/dev/stdin')
left_io = File.open(left_file, 'r')
right_io = File.open(right_file, 'r')
JsonCli::JoinJson.right_join(left_io, right_io, opts)
[left_io, right_io, opts[:out]].each(&:close)
end

desc "inner_join RIGHT_FILE [LEFT_FILE]", "inner join of json files"
option :join_key, :required => true, :aliases => :k
def inner_join(right_file, left_file = nil)
left_io = left_file.nil? ? STDIN : File.open(left_file, 'r')
desc 'inner_join RIGHT_FILE [LEFT_FILE]', 'inner join of json files'
option :join_key, required: true, aliases: :k
def inner_join(right_file, left_file = '/dev/stdin')
left_io = File.open(left_file, 'r')
right_io = File.open(right_file, 'r')
JsonCli::JoinJson.inner_join(left_io, right_io, opts)
[left_io, right_io, opts[:out]].each(&:close)
end

desc "unwind_array [JSON_FILE]", "unwind array of json file"
option :unwind_key, :required => true, :aliases => :k
def unwind_array(json_file = nil)
io = json_file.nil? ? STDIN : File.open(json_file, 'r')
desc 'unwind_array [JSON_FILE]', 'unwind array of json file'
option :unwind_key, required: true, aliases: :k
def unwind_array(json_file = '/dev/stdin')
io = File.open(json_file, 'r')
JsonCli::UnwindJson.unwind_array(io, opts)
[io, opts[:out]].each(&:close)
end

desc "unwind_hash [JSON_FILE]", "unwind hash of json file"
option :unwind_key, :required => true, :aliases => :k
option :flatten, :type => :boolean, :aliases => :f
desc 'unwind_hash [JSON_FILE]', 'unwind hash of json file'
option :unwind_key, required: true, aliases: :k
option :flatten, type: :boolean, aliases: :f
option :key_label
option :value_label
def unwind_hash(json_file = nil)
io = json_file.nil? ? STDIN : File.open(json_file, 'r')
def unwind_hash(json_file = '/dev/stdin')
io = File.open(json_file, 'r')
JsonCli::UnwindJson.unwind_hash(io, opts)
[io, opts[:out]].each(&:close)
end
Expand Down

0 comments on commit 32a2336

Please sign in to comment.