Sha256: 4d3ca72b31ebd29a712283961a37f30520782f2fe0a9928b0fd2a81b7e662da4

Contents?: true

Size: 690 Bytes

Versions: 6

Compression:

Stored size: 690 Bytes

Contents

require "yaml"

class Lono::Bundler::Lockfile
  class Yamler
    def initialize(components)
      @components = components.sort_by(&:name)
    end

    def dump
      YAML.dump(data)
    end

    def data
      @components.map do |component|
        item(component)
      end
    end

    def item(component)
      props = component.props.dup # passthrough: name, url, version, ref, tag, branch etc
      props[:sha] ||= component.latest_sha
      props.delete_if { |k,v| v.nil? }
      props.deep_stringify_keys
    end

    def write
      IO.write(LB.config.lockfile, dump)
    end

    class << self
      def write(components)
        new(components).write
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
lono-8.0.0.pre.rc6 lib/lono/bundler/lockfile/yamler.rb
lono-8.0.0.pre.rc5 lib/lono/bundler/lockfile/yamler.rb
lono-8.0.0.pre.rc4 lib/lono/bundler/lockfile/yamler.rb
lono-8.0.0.pre.rc3 lib/lono/bundler/lockfile/yamler.rb
lono-8.0.0.pre.rc2 lib/lono/bundler/lockfile/yamler.rb
lono-8.0.0.pre.rc1 lib/lono/bundler/lockfile/yamler.rb