class Samwise::Cli
Public Instance Methods
check_format()
click to toggle source
# File lib/samwise/cli.rb, line 28 def check_format wrap_sam("valid_format"){|c, u, j| u[j] = Samwise::Util.duns_is_properly_formatted?(duns: u['duns'])} end
excluded()
click to toggle source
# File lib/samwise/cli.rb, line 16 def excluded wrap_sam("excluded"){|c, u, j| u[j] = c.excluded?(duns: u['duns'])} end
format()
click to toggle source
# File lib/samwise/cli.rb, line 34 def format wrap_sam("formatted_duns") {|c, u, j| u[j] = Samwise::Util.format_duns(duns: u['duns'])} end
get_info()
click to toggle source
# File lib/samwise/cli.rb, line 22 def get_info wrap_sam("user_info"){|c, u, j| u[j] = c.get_duns_info(duns: u['duns'])} end
verify()
click to toggle source
# File lib/samwise/cli.rb, line 11 def verify wrap_sam("verified"){|c, u, j| u[j] = c.duns_is_in_sam?(duns: u['duns'])} end
Private Instance Methods
wrap_sam(jsonOutKey, &block)
click to toggle source
# File lib/samwise/cli.rb, line 40 def wrap_sam(jsonOutKey, &block) infile = ($stdin.tty?) ? File.read(options[:infile]) : $stdin.read #read in a json of users to be samwised duns_hash = JSON.parse(infile) #check what method called wrap_sam. Do not init samwise client for utils thor_method = caller_locations(1,1)[0].label client = Samwise::Client.new unless (thor_method == "check_format") || (jsonOutKey =="format") duns_hash['users'].each do |user| #abort process do improperly formated duns abort("please use a .json with a duns key") unless user.has_key?("duns") block.call(client, user, jsonOutKey) end puts duns_hash.to_json end