Class: R10K::Module::Definition

Inherits:
Base
  • Object
show all
Defined in:
lib/r10k/module/definition.rb

Constant Summary

Constants included from Logging

Logging::LOG_LEVELS, Logging::SYSLOG_LEVELS_MAP

Instance Attribute Summary collapse

Attributes inherited from Base

#dirname, #environment, #name, #origin, #owner, #path, #spec_deletable, #title

Instance Method Summary collapse

Methods inherited from Base

#accept, #cachedir, #delete_spec_dir, #full_path, #maybe_delete_spec_dir, #should_sync?

Methods included from Logging

add_outputters, debug_formatter, default_formatter, default_outputter, #logger, #logger_name, parse_level

Constructor Details

#initialize(name, dirname:, args:, implementation:, environment: nil) ⇒ Definition

Returns a new instance of Definition.



7
8
9
10
11
12
13
14
# File 'lib/r10k/module/definition.rb', line 7

def initialize(name, dirname:, args:, implementation:, environment: nil)
  @original_name  = name
  @original_args  = args.dup
  @implementation = implementation
  @version        = implementation.statically_defined_version(name, args)

  super(name, dirname, args, environment)
end

Instance Attribute Details

#versionObject (readonly)

Returns the value of attribute version.



5
6
7
# File 'lib/r10k/module/definition.rb', line 5

def version
  @version
end

Instance Method Details

#propertiesObject



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/r10k/module/definition.rb', line 36

def properties
  type = nil

  if @args[:type]
    type = @args[:type]
  elsif @args[:ref] || @args[:commit] || @args[:branch] || @args[:tag]
    type = 'git'
  elsif @args[:svn]
    # This logic is clear and included for completeness sake, though at
    # this time module definitions do not support SVN versions.
    type = 'svn'
  else
    type = 'forge'
  end

  {
    expected: version,
    # We can't get the value for `actual` here because that requires the
    # implementation (and potentially expensive operations by the
    # implementation). Some consumers will check this value, if it exists
    # and if not, fall back to the expected version. That is the correct
    # behavior when assuming modules are unchanged, and why `actual` is set
    # to `nil` here.
    actual: nil,
    type: type
  }
end

#statusObject



32
33
34
# File 'lib/r10k/module/definition.rb', line 32

def status
  :insync
end

#sync(args = {}) ⇒ Object

syncing is a noop for module definitions Returns false to inidicate the module was not updated



27
28
29
30
# File 'lib/r10k/module/definition.rb', line 27

def sync(args = {})
  logger.debug1(_("Not updating module %{name}, assuming content unchanged") % {name: name})
  false
end

#to_implementationObject



16
17
18
19
20
21
22
23
# File 'lib/r10k/module/definition.rb', line 16

def to_implementation
  mod = @implementation.new(@title, @dirname, @original_args, @environment)

  mod.origin = origin
  mod.spec_deletable = spec_deletable

  mod
end