Class: EPC::Command::ShowLibrarysetCommand
- Inherits:
-
BaseCommand
- Object
- BaseCommand
- EPC::Command::ShowLibrarysetCommand
- Defined in:
- lib/epc/command/show_libraryset_command.rb
Constant Summary
Constants inherited from BaseCommand
BaseCommand::GIVEUP_TICKS, BaseCommand::SLEEP_TIME, BaseCommand::TICKER_TICKS
Instance Attribute Summary
Attributes inherited from BaseCommand
Instance Method Summary collapse
Methods inherited from BaseCommand
#go, inherited, #initialize, #method_missing, required_arguments_count, required_options, #respond_to?
Methods included from PersistentAttributes
#auth_token, #caller_id, #target_url
Constructor Details
This class inherits a constructor from EPC::Command::BaseCommand
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class EPC::Command::BaseCommand
Instance Method Details
#execute(library_set = nil) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/epc/command/show_libraryset_command.rb', line 5 def execute(library_set = nil) if library_set.nil? say("You must specify a library-set") say(EPC::Help::COMMAND_USAGES[:show_libraryset]) return 1 end if numeric?(library_set) library_set_id = library_set.to_i else library_set_id = get_resource_id(EPC::Config::LIBRARY_SETS_PATH, :name, library_set) end if library_set_id.nil? || library_set_id == 0 say("Library set could not be determined") return 1 end status, response, headers = client.get(EPC::Config::LIBRARY_SETS_PATH + "/#{library_set_id}") if status.failure? say("Request failed: [#{response[:message]}]") else if [:json].nil? response[:language] = response[:library_language][:name] rescue nil response[:created_by] = "#{response[:created_by][:name]}(#{response[:created_by][:id]})" rescue nil response[:created_at] = Time.parse(response[:created_at]).strftime("%m/%d/%Y %I:%M%p") rescue nil response[:updated_at] = Time.parse(response[:updated_at]).strftime("%m/%d/%Y %I:%M%p") rescue nil set_table = EPC::TabularOutputter.new([response], [:id, :name, :language, :created_by, :created_at, :updated_at]) say(set_table.print) libraries = response[:libraries] unless libraries.empty? say("\n") libraries.each do |lib| lib[:language] = lib[:library_language][:name] rescue nil lib[:version] = lib[:library_version] rescue nil end libraries_table = EPC::TabularOutputter.new(libraries, [:id, :name, :language, :version, :group]) say(libraries_table.print) end else say(response[:libraries].to_json) end end return status end |