Class: Berkshelf::Lockfile::LockfileLegacy

Inherits:
Object
  • Object
show all
Defined in:
lib/berkshelf/lockfile.rb

Overview

TODO:

Remove this class in Berkshelf 3.0.0

Legacy support for old lockfiles

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(berksfile, content) ⇒ LockfileLegacy

Create a new legacy lockfile for processing

Parameters:

  • content (String)

    the content to parse out and convert to a hash



243
244
245
246
# File 'lib/berkshelf/lockfile.rb', line 243

def initialize(berksfile, content)
  @berksfile = berksfile
  instance_eval(content).to_hash
end

Instance Attribute Details

#berksfileBerkshelf::Berksfile (readonly)

Returns the berksfile.

Returns:



237
238
239
# File 'lib/berkshelf/lockfile.rb', line 237

def berksfile
  @berksfile
end

#nameString (readonly)

Returns the name of this cookbook.

Returns:

  • (String)

    the name of this cookbook



233
234
235
# File 'lib/berkshelf/lockfile.rb', line 233

def name
  @name
end

#optionsHash (readonly)

Returns the hash of options.

Returns:

  • (Hash)

    the hash of options



229
230
231
# File 'lib/berkshelf/lockfile.rb', line 229

def options
  @options
end

Class Method Details

.parse(berksfile, content) ⇒ Object

Read the old lockfile content and instance eval in context.

Parameters:

  • berksfile (Berkshelf::Berksfile)

    the associated berksfile

  • content (String)

    the string content read from a legacy lockfile



211
212
213
214
215
216
217
218
219
220
221
222
223
224
# File 'lib/berkshelf/lockfile.rb', line 211

def parse(berksfile, content)
  sources = {}.tap do |hash|
    content.split("\n").each do |line|
      next if line.empty?

      source = self.new(berksfile, line)
      hash[source.name] = source.options
    end
  end

  {
    sources: sources,
  }
end

Instance Method Details

#cookbook(name, options = {}) ⇒ Object

Method defined in legacy lockfiles (since we are using instance_eval).

Parameters:

  • name (String)

    the name of this cookbook

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :locked_version (String)

    the locked version of this cookbook



255
256
257
258
# File 'lib/berkshelf/lockfile.rb', line 255

def cookbook(name, options = {})
  @name = name
  @options = manipulate(options)
end