Class: R10K::Module::Forge
- Includes:
- Logging
- Defined in:
- lib/r10k/module/forge.rb
Constant Summary
Constants included from Logging
Instance Attribute Summary collapse
-
#author ⇒ Object
readonly
Returns the value of attribute author.
-
#full_name ⇒ Object
readonly
Returns the value of attribute full_name.
Attributes inherited from Base
Class Method Summary collapse
Instance Method Summary collapse
-
#current_version ⇒ R10K::SemVer
(also: #version)
The version of the currently installed module.
- #exist? ⇒ Boolean
-
#expected_version ⇒ R10K::SemVer
The expected version that the module.
-
#initialize(full_name, basedir, args) ⇒ Forge
constructor
A new instance of Forge.
- #insync? ⇒ Boolean
- #owner ⇒ Object deprecated Deprecated.
-
#status ⇒ Symbol
Determine the status of the forge module.
- #sync(options = {}) ⇒ Object
Methods included from Logging
formatter, included, level, level=, levels, #logger, #logger_name, outputter, parse_level
Methods inherited from Base
Constructor Details
#initialize(full_name, basedir, args) ⇒ Forge
Returns a new instance of Forge.
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/r10k/module/forge.rb', line 36 def initialize(full_name, basedir, args) @full_name = full_name @basedir = basedir @author, @name = full_name.split('/') @full_path = Pathname.new(File.join(@basedir, @name)) @metadata = R10K::Module::Metadata.new(@full_path + 'metadata.json') if args.is_a? String @expected_version = R10K::SemVer.new(args) elsif args.is_a? Symbol and args == :latest @expected_version = args end end |
Instance Attribute Details
#author ⇒ Object (readonly)
Returns the value of attribute author.
24 25 26 |
# File 'lib/r10k/module/forge.rb', line 24 def @author end |
#full_name ⇒ Object (readonly)
Returns the value of attribute full_name.
34 35 36 |
# File 'lib/r10k/module/forge.rb', line 34 def full_name @full_name end |
Class Method Details
.implement?(name, args) ⇒ Boolean
16 17 18 |
# File 'lib/r10k/module/forge.rb', line 16 def self.implement?(name, args) !!(name.match %r[\w+/\w+]) end |
Instance Method Details
#current_version ⇒ R10K::SemVer Also known as: version
Returns The version of the currently installed module.
74 75 76 |
# File 'lib/r10k/module/forge.rb', line 74 def current_version @metadata.version end |
#exist? ⇒ Boolean
80 81 82 |
# File 'lib/r10k/module/forge.rb', line 80 def exist? @full_path.exist? end |
#expected_version ⇒ R10K::SemVer
Returns The expected version that the module.
65 66 67 68 69 70 |
# File 'lib/r10k/module/forge.rb', line 65 def expected_version if @expected_version == :latest set_version_from_forge end @expected_version end |
#insync? ⇒ Boolean
84 85 86 |
# File 'lib/r10k/module/forge.rb', line 84 def insync? status == :insync end |
#owner ⇒ Object
Deprecated.
27 28 29 30 |
# File 'lib/r10k/module/forge.rb', line 27 def owner logger.warn "#{self.inspect}#owner is deprecated; use #author instead" @author end |
#status ⇒ Symbol
Determine the status of the forge module.
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
# File 'lib/r10k/module/forge.rb', line 95 def status if not self.exist? # The module is not installed return :absent elsif not @metadata.exist? # The directory exists but doesn't have a metadata file; it probably # isn't a forge module. return :mismatched end # The module is present and has a metadata file, read the metadata to # determine the state of the module. @metadata.read if not @author == @metadata. # This is a forge module but the installed module is a different author # than the expected author. return :mismatched end if expected_version && (expected_version != @metadata.version) return :outdated end return :insync end |
#sync(options = {}) ⇒ Object
53 54 55 56 57 58 59 60 61 62 |
# File 'lib/r10k/module/forge.rb', line 53 def sync( = {}) case status when :absent install when :outdated upgrade when :mismatched reinstall end end |