class TerraspaceBundler::Lockfile
Public Class Methods
write()
click to toggle source
# File lib/terraspace_bundler/lockfile.rb, line 63 def write Yamler.write(@@mods) if @@mods end
Public Instance Methods
changed?(mod)
click to toggle source
mod built from Terrafile
# File lib/terraspace_bundler/lockfile.rb, line 36 def changed?(mod) # missing module case found = mods.find { |locked_mod| locked_mod.name == mod.name } unless found logger.debug "Replacing mod: #{mod.name}. Not found in Terrafile.lock" return true end comparer = VersionComparer.new(found, mod) comparer.run logger.debug("REASON: #{comparer.reason}") if comparer.reason comparer.changed? end
mods()
click to toggle source
# File lib/terraspace_bundler/lockfile.rb, line 17 def mods return @@mods if @@mods lockfile = TB.config.lockfile mods = File.exist?(lockfile) ? YAML.load_file(lockfile) : [] @@mods = mods.map do |name, props| new_mod(name, props) end end
new_mod(name, props)
click to toggle source
# File lib/terraspace_bundler/lockfile.rb, line 26 def new_mod(name, props) Mod.new(props.merge(name: name)) end
prune(removed_mods)
click to toggle source
# File lib/terraspace_bundler/lockfile.rb, line 57 def prune(removed_mods) removals = removed_mods.map(&:name) @@mods.delete_if { |m| removals.include?(m.name) } end
replace!(mod)
click to toggle source
# File lib/terraspace_bundler/lockfile.rb, line 50 def replace!(mod) # mods are immediately fresh from writing to @@mods directly @@mods.delete_if { |m| m.name == mod.name } @@mods << mod @@mods.sort_by!(&:name) end
sync(mod)
click to toggle source
update (if version mismatch) or create (if missing)
# File lib/terraspace_bundler/lockfile.rb, line 31 def sync(mod) replace!(mod) if changed?(mod) end