Method: R10K::Module::Forge#status

Defined in:
lib/r10k/module/forge.rb

#statusSymbol

Determine the status of the forge module.

Returns:

  • (Symbol)

    :absent If the directory doesn’t exist

  • (Symbol)

    :mismatched If the module is not a forge module, or isn’t the right forge module

  • (Symbol)

    :mismatched If the module was previously a git checkout

  • (Symbol)

    :outdated If the installed module is older than expected

  • (Symbol)

    :insync If the module is in the desired state



111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# File 'lib/r10k/module/forge.rb', line 111

def status
  if not self.exist?
    # The module is not installed
    return :absent
  elsif not File.exist?(@path + 'metadata.json')
    # The directory exists but doesn't have a metadata file; it probably
    # isn't a forge module.
    return :mismatched
  end

  if File.directory?(@path + '.git')
    return :mismatched
  end

  # The module is present and has a metadata file, read the metadata to
  # determine the state of the module.
   = .read(@path + 'metadata.json')

  if not @title.tr('/','-') == .full_module_name.tr('/','-')

    # 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 != .version)
    return :outdated
  end

  return :insync
end