class TerraspaceBundler::Lockfile::Yamler
Public Class Methods
new(mods)
click to toggle source
# File lib/terraspace_bundler/lockfile/yamler.rb, line 5 def initialize(mods) @mods = mods.sort_by(&:name) end
write(mods)
click to toggle source
# File lib/terraspace_bundler/lockfile/yamler.rb, line 32 def write(mods) new(mods).write end
Public Instance Methods
data()
click to toggle source
# File lib/terraspace_bundler/lockfile/yamler.rb, line 13 def data @mods.inject({}) do |acc, mod| acc.merge(item(mod)) end end
dump()
click to toggle source
# File lib/terraspace_bundler/lockfile/yamler.rb, line 9 def dump YAML.dump(data.deep_stringify_keys) end
item(mod)
click to toggle source
# File lib/terraspace_bundler/lockfile/yamler.rb, line 19 def item(mod) props = mod.props.dup # passthrough: name, url, version, ref, tag, branch etc props.delete(:name) # different structure in Terrafile.lock YAML props[:sha] ||= mod.latest_sha props.delete_if { |k,v| v.nil? } { mod.name => props } end
write()
click to toggle source
# File lib/terraspace_bundler/lockfile/yamler.rb, line 27 def write IO.write(TB.config.lockfile, dump) end