Class: EPC::Command::BaseCommand

Inherits:
Object
  • Object
show all
Includes:
Error, PersistentAttributes
Defined in:
lib/epc/command/base_command.rb

Direct Known Subclasses

ArchiveProjectCommand, ArchiveSolutionCommand, AttachLibraryCommand, AttachLibrarysetCommand, AttachRuntimeCommand, BindServiceCommand, BuildCommand, CopyDeploymentCommand, CreateCommand, CreateConfigCommand, CreateDependencyCommand, CreateDeploymentCommand, CreateGroupCommand, CreateLibraryCommand, CreateLibrarylanguageCommand, CreateLibrarysetCommand, CreateObjectroleCommand, CreateProjectCommand, CreateRoleCommand, CreateServiceversionCommand, CreateSolutionCommand, CreateUserCommand, DefineServiceCommand, DeleteConfigCommand, DeleteDependencyCommand, DeleteGroupCommand, DeleteLibraryCommand, DeleteLibrarylanguageCommand, DeleteLibrarysetCommand, DeleteProjectCommand, DeleteRoleCommand, DeleteServiceversionCommand, DeleteSolutionCommand, DeleteUserCommand, DeployCommand, DetachLibraryCommand, DetachLibrarysetCommand, InfoCommand, ListApprovalsCommand, ListAttachedlibrariesCommand, ListBoundservicesCommand, ListConfigCommand, ListDependenciesCommand, ListDeploymentsCommand, ListGroupsCommand, ListLibrariesCommand, ListLibrarylanguagesCommand, ListLibrarysetsCommand, ListObjectrolesCommand, ListObjecttypesCommand, ListPermissiongroupsCommand, ListProjectsCommand, ListProjecttypesCommand, ListRolepermissionsCommand, ListRolesCommand, ListRuntimesCommand, ListServicedefinitionsCommand, ListServicetypesCommand, ListServiceversionsCommand, ListSolutionsCommand, ListStagesCommand, ListUsersCommand, ListVersionsCommand, LoginCommand, LogoutCommand, PullCommand, PushCommand, RefreshSolutionCommand, RenewCommand, RequestPasswordchangeCommand, ShowDeploymentCommand, ShowGroupCommand, ShowLibrarysetCommand, ShowProjectCommand, ShowProjecttypeCommand, ShowRoleCommand, ShowSolutionCommand, ShowUserCommand, SubmitDeploymentCommand, TargetCommand, UnarchiveProjectCommand, UnarchiveSolutionCommand, UnbindServiceCommand, UndefineServiceCommand, UndeployCommand, UpdateConfigCommand, UpdateDeploymentprojectCommand, UpdateGroupCommand, UpdateLibrarylanguageCommand, UpdateLibrarysetCommand, UpdateProjectCommand, UpdateRoleCommand, UpdateRolepermissionsCommand, UpdateSolutionCommand, UpdateUserCommand, VoteDeploymentCommand

Constant Summary collapse

SLEEP_TIME =
1
TICKER_TICKS =

Numerators are in secs

25/SLEEP_TIME
GIVEUP_TICKS =
120/SLEEP_TIME
@@retrieval_rules =
{
  :system_role => {
    :match_attribute => :name,
    :required_attribute => :id,
    :required_type => :numeric, 
    :source => EPC::Config::ROLES_PATH + "/system/true"
  },
  :user => {
    :match_attribute => :name,
    :required_attribute => :id,
    :required_type => :numeric,
    :source => EPC::Config::USERS_PATH
  },
  :user_group => {
    :match_attribute => :name,
    :required_attribute => :id,
    :required_type => :numeric,
    :source => EPC::Config::GROUPS_PATH
  },
  :library_set => {
    :match_attribute => :name,
    :required_attribute => :id,
    :required_type => :numeric,
    :source => EPC::Config::LIBRARY_SETS_PATH
   }
}
@@required_arguments =
{:count => 0}
@@required_options =
[]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from PersistentAttributes

#auth_token, #caller_id, #target_url

Constructor Details

#initialize(client, options = {}) ⇒ BaseCommand

Returns a new instance of BaseCommand.



86
87
88
89
90
91
92
# File 'lib/epc/command/base_command.rb', line 86

def initialize(client, options = {})
  @client = client
  @options = options.dup
  if @options[:skip_prompts].present?
    create_method(:ask) {|text, arr| return "Y"}
  end
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object



50
51
52
53
54
55
56
# File 'lib/epc/command/base_command.rb', line 50

def method_missing(method, *args, &block)
  if method.to_s =~ /^retrieve_(.+)_identifier$/ 
    retrieve_identifier_for($1, *args, &block)
  else
    super
  end
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



10
11
12
# File 'lib/epc/command/base_command.rb', line 10

def client
  @client
end

#optionsObject (readonly)

Returns the value of attribute options.



11
12
13
# File 'lib/epc/command/base_command.rb', line 11

def options
  @options
end

Class Method Details

.inherited(subklass) ⇒ Object



66
67
68
69
# File 'lib/epc/command/base_command.rb', line 66

def self.inherited(subklass)
  # Here login is required for all commands that inherit
  subklass.
end

.required_arguments_count(count, options_hash = {}) ⇒ Object



71
72
73
74
75
76
# File 'lib/epc/command/base_command.rb', line 71

def self.required_arguments_count(count, options_hash = {})
  opt = {
    :message => "Please specify all the mandatory arguments"
  }.merge(options_hash)
  @@required_arguments = {:count => count, :message => opt[:message]}
end

.required_options(*opts, opt_hash) ⇒ Object



78
79
80
81
82
83
84
# File 'lib/epc/command/base_command.rb', line 78

def self.required_options(*opts, opt_hash)
  options_hash = {
    :mode => :any?,
    :message => "You need to specify all required options"
  }.merge(opt_hash)
  @@required_options << {:name => opts, :mode => options_hash[:mode], :message => options_hash[:message]}
end

Instance Method Details

#go(*args) ⇒ Object



94
95
96
97
98
99
100
101
102
# File 'lib/epc/command/base_command.rb', line 94

def go(*args)
  if () && (!logged_in?)
    say("You must be logged in to run this command")
    return 1
  else
    check_requirements(*args)
    return translate_status_to_exit_code(execute(*args))
  end
end

#respond_to?(meth) ⇒ Boolean

Returns:

  • (Boolean)


58
59
60
61
62
63
64
# File 'lib/epc/command/base_command.rb', line 58

def respond_to?(meth)
  if meth.to_s =~ /^retrieve_.*_identifier$/
    true
  else
    super
  end
end