Class: EPC::Command::BaseCommand
- Includes:
- Error, PersistentAttributes
- Defined in:
- lib/epc/command/base_command.rb
Direct Known Subclasses
ArchiveCommand, AttachtoCommand, BuildCommand, CopyCommand, CreateCommand, CreateConfigCommand, CreateGroupCommand, CreateLibraryCommand, CreateLibrarylanguageCommand, CreateLibrarysetCommand, CreateObjectroleCommand, CreateProjectCommand, CreateRoleCommand, CreateServicedefinitionCommand, CreateSolutionCommand, CreateUserCommand, DeleteCommand, DeleteLibraryCommand, DeleteProjectCommand, DeleteServicedefinitionCommand, DeployCommand, DetachfromCommand, GetUserPropertyCommand, InfoCommand, ListCommand, ListDeploymentsCommand, ListDeploymentstagesCommand, ListGroupsCommand, ListLibrariesCommand, ListLibrarylanguagesCommand, ListMetricsCommand, ListObjectrolesCommand, ListObjecttypesCommand, ListPermissiongroupsCommand, ListPermissionsCommand, ListPluginsCommand, ListProjectsCommand, ListProjecttypesCommand, ListRolesCommand, ListRuntimesCommand, ListServicedefinitionsCommand, ListServicetypesCommand, ListServiceversionsCommand, ListSolutionsCommand, ListUserpropertiesCommand, ListUsersCommand, LoginCommand, LogoutCommand, PullCommand, PushCommand, RefreshSolutionCommand, RenewCommand, RequestPasswordchangeCommand, SetUserPropertyCommand, ShowCommand, ShowGroupCommand, ShowInstancesCommand, ShowLibrarysetCommand, ShowMetricsCommand, ShowProjecttypeCommand, SubmitCommand, TargetCommand, UnarchiveCommand, UndeployCommand, UpdateCommand, UpdateDeploymentCommand, UpdateGroupCommand, UpdateLibrarysetCommand, UpdateProjectCommand, UpdateSolutionCommand, UpdateUserCommand, VoteCommand
Constant Summary collapse
- SLEEP_TIME =
1
- TICKER_TICKS =
Numerators are in secs
25/SLEEP_TIME
- GIVEUP_TICKS =
120/SLEEP_TIME
- @@required_options =
[]
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
- #klass_name ⇒ Object
-
#object_id ⇒ Object
Returns the value of attribute object_id.
-
#object_type ⇒ Object
Returns the value of attribute object_type.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#target_id ⇒ Object
Returns the value of attribute target_id.
-
#target_type ⇒ Object
Returns the value of attribute target_type.
Class Method Summary collapse
- .include_module(object_type) ⇒ Object
- .inherited(subklass) ⇒ Object
- .required_options(*opts, opt_hash) ⇒ Object
Instance Method Summary collapse
- #check_options ⇒ Object
- #context_params ⇒ Object
- #context_params=(params) ⇒ Object
- #go(*args) ⇒ Object
-
#initialize(client, options = {}) ⇒ BaseCommand
constructor
A new instance of BaseCommand.
- #say_err(statement) ⇒ Object
Methods included from PersistentAttributes
#auth_token, #caller_id, #target_url
Constructor Details
#initialize(client, options = {}) ⇒ BaseCommand
Returns a new instance of BaseCommand.
48 49 50 51 52 53 54 |
# File 'lib/epc/command/base_command.rb', line 48 def initialize(client, = {}) @client = client @options = .dup if @options[:skip_prompts].present? create_method(:ask) {|text, arr| return "Y"} end end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
11 12 13 |
# File 'lib/epc/command/base_command.rb', line 11 def client @client end |
#klass_name ⇒ Object
86 87 88 89 |
# File 'lib/epc/command/base_command.rb', line 86 def klass_name return self.class.name if @klass_name.blank? @klass_name end |
#object_id ⇒ Object
Returns the value of attribute object_id.
15 16 17 |
# File 'lib/epc/command/base_command.rb', line 15 def object_id @object_id end |
#object_type ⇒ Object
Returns the value of attribute object_type.
14 15 16 |
# File 'lib/epc/command/base_command.rb', line 14 def object_type @object_type end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
12 13 14 |
# File 'lib/epc/command/base_command.rb', line 12 def @options end |
#target_id ⇒ Object
Returns the value of attribute target_id.
17 18 19 |
# File 'lib/epc/command/base_command.rb', line 17 def target_id @target_id end |
#target_type ⇒ Object
Returns the value of attribute target_type.
16 17 18 |
# File 'lib/epc/command/base_command.rb', line 16 def target_type @target_type end |
Class Method Details
.include_module(object_type) ⇒ Object
41 42 43 44 45 46 |
# File 'lib/epc/command/base_command.rb', line 41 def self.include_module(object_type) mod = object_type.capitalize if EPC::Config.module_exists?(mod) self.send :include, eval("EPC::Command::#{mod}") end end |
.inherited(subklass) ⇒ Object
28 29 30 31 |
# File 'lib/epc/command/base_command.rb', line 28 def self.inherited(subklass) # Here login is required for all commands that inherit subklass.require_login end |
.required_options(*opts, opt_hash) ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/epc/command/base_command.rb', line 33 def self.(*opts, opt_hash) = { :mode => :any?, :message => "You need to specify all required options" }.merge(opt_hash) @@required_options << {:name => opts, :mode => [:mode], :message => [:message]} end |
Instance Method Details
#check_options ⇒ Object
71 72 73 74 75 76 |
# File 'lib/epc/command/base_command.rb', line 71 def @@required_options.each do |req_opt| raise FatalError, req_opt[:message] unless req_opt[:name].map{|opt| @options[opt].present?}.send(req_opt[:mode]) end end |
#context_params ⇒ Object
78 79 80 |
# File 'lib/epc/command/base_command.rb', line 78 def context_params return [object_type, object_id, target_type, target_id] end |
#context_params=(params) ⇒ Object
82 83 84 |
# File 'lib/epc/command/base_command.rb', line 82 def context_params=(params) @object_type, @object_id, @target_type, @target_id = params end |
#go(*args) ⇒ Object
56 57 58 59 60 61 62 63 64 |
# File 'lib/epc/command/base_command.rb', line 56 def go(*args) if (login_required?) && (!logged_in?) say("You must be logged in to run this command") return 1 else return translate_status_to_exit_code(execute(*args)) end end |