Class: DTK::Client::ModuleRef

Inherits:
Object
  • Object
show all
Defined in:
lib/client/module_ref.rb

Direct Known Subclasses

Operation::Module::Install::ModuleRef

Defined Under Namespace

Modules: NamespaceModuleName

Constant Summary collapse

MASTER_VERSION =
'master'

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ ModuleRef

opts can have keys

:namespace
:module_name
:namespace_module_name
:version
:client_dir_path


30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/client/module_ref.rb', line 30

def initialize(opts = {})
  if opts[:namespace] and opts[:module_name]
    @namespace   = opts[:namespace]
    @module_name = opts[:module_name]
  elsif opts[:namespace_module_name]
    namespace, module_name =  NamespaceModuleName.parse(opts[:namespace_module_name])
    @namespace   = namespace
    @module_name = module_name
  else
    raise Error, "Either :module_name and :namespace must be given or :namespace_module_name"
  end
  @version         = opts[:version] 
  @client_dir_path = opts[:client_dir_path]
end

Instance Attribute Details

#client_dir_pathObject (readonly)

Returns the value of attribute client_dir_path.



21
22
23
# File 'lib/client/module_ref.rb', line 21

def client_dir_path
  @client_dir_path
end

#module_nameObject (readonly)

Returns the value of attribute module_name.



21
22
23
# File 'lib/client/module_ref.rb', line 21

def module_name
  @module_name
end

#namespaceObject (readonly)

Returns the value of attribute namespace.



21
22
23
# File 'lib/client/module_ref.rb', line 21

def namespace
  @namespace
end

#versionObject

Returns the value of attribute version.



21
22
23
# File 'lib/client/module_ref.rb', line 21

def version
  @version
end

Class Method Details

.pretty_print(module_name, namespace, version = nil) ⇒ Object



45
46
47
48
49
50
# File 'lib/client/module_ref.rb', line 45

def self.pretty_print(module_name, namespace, version = nil)
  # TODO: update ::DTK::Common::PrettyPrintForm to insert 'master' when version is nil 
  version = version.join(', ')  if version.is_a?(Array)

  ::DTK::Common::PrettyPrintForm.module_ref(module_name, :namespace => namespace, :version => version || 'master')
end

Instance Method Details

#exact_match?(module_ref) ⇒ Boolean

Returns:

  • (Boolean)


69
70
71
# File 'lib/client/module_ref.rb', line 69

def exact_match?(module_ref)
  same_module?(module_ref) and @namespace == module_ref.namespace and @version == module_ref.version
end

#is_master_version?Boolean

Returns:

  • (Boolean)


61
62
63
# File 'lib/client/module_ref.rb', line 61

def is_master_version?
  @version.nil? or @version == MASTER_VERSION
end

#pretty_printObject



51
52
53
# File 'lib/client/module_ref.rb', line 51

def pretty_print
  self.class.pretty_print(@module_name, @namespace, @version)
end

TODO: look at deprecating print_form



56
57
58
# File 'lib/client/module_ref.rb', line 56

def print_form
  NamespaceModuleName.print_form(@namespace, @module_name, :version => @version)
end

#same_module?(module_ref) ⇒ Boolean

Returns:

  • (Boolean)


65
66
67
# File 'lib/client/module_ref.rb', line 65

def same_module?(module_ref)
  @module_name == module_ref.module_name 
end