berkshelf 2.0.18 → 3.0.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (128) hide show
  1. data/.ruby-version +1 -1
  2. data/.travis.yml +4 -1
  3. data/CHANGELOG.md +2 -26
  4. data/Gemfile +12 -2
  5. data/README.md +9 -1
  6. data/berkshelf.gemspec +9 -18
  7. data/bin/berks +3 -13
  8. data/features/apply_command.feature +11 -9
  9. data/features/berksfile.feature +8 -10
  10. data/features/config.feature +1 -2
  11. data/features/configure_command.feature +13 -14
  12. data/features/contingent_command.feature +13 -1
  13. data/features/cookbook_command.feature +2 -4
  14. data/features/groups_install.feature +10 -2
  15. data/features/help.feature +1 -1
  16. data/features/init_command.feature +5 -7
  17. data/features/install_command.feature +157 -228
  18. data/features/json_formatter.feature +27 -15
  19. data/features/licenses.feature +18 -12
  20. data/features/list_command.feature +6 -1
  21. data/features/lockfile.feature +116 -72
  22. data/features/outdated_command.feature +3 -47
  23. data/features/package_command.feature +10 -7
  24. data/features/shelf/show.feature +2 -2
  25. data/features/shelf/uninstall.feature +2 -2
  26. data/features/show_command.feature +10 -3
  27. data/features/step_definitions/chef/config_steps.rb +12 -0
  28. data/features/step_definitions/chef_server_steps.rb +16 -16
  29. data/features/step_definitions/cli_steps.rb +3 -79
  30. data/features/step_definitions/config_steps.rb +43 -0
  31. data/features/step_definitions/environment_steps.rb +7 -0
  32. data/features/step_definitions/filesystem_steps.rb +12 -57
  33. data/features/step_definitions/gem_steps.rb +1 -2
  34. data/features/step_definitions/json_steps.rb +3 -1
  35. data/features/step_definitions/lockfile_steps.rb +4 -0
  36. data/features/step_definitions/utility_steps.rb +0 -19
  37. data/features/support/aruba.rb +12 -0
  38. data/features/support/env.rb +52 -57
  39. data/features/update_command.feature +37 -23
  40. data/features/upload_command.feature +96 -160
  41. data/generator_files/Berksfile.erb +2 -1
  42. data/generator_files/Vagrantfile.erb +3 -0
  43. data/generator_files/default_test.rb.erb +1 -1
  44. data/generator_files/helpers.rb.erb +1 -1
  45. data/lib/berkshelf.rb +43 -24
  46. data/lib/berkshelf/api_client.rb +67 -0
  47. data/lib/berkshelf/api_client/remote_cookbook.rb +42 -0
  48. data/lib/berkshelf/berksfile.rb +232 -420
  49. data/lib/berkshelf/cached_cookbook.rb +22 -10
  50. data/lib/berkshelf/chef/config.rb +1 -0
  51. data/lib/berkshelf/cli.rb +66 -68
  52. data/lib/berkshelf/commands/shelf.rb +1 -1
  53. data/lib/berkshelf/community_rest.rb +10 -17
  54. data/lib/berkshelf/config.rb +23 -27
  55. data/lib/berkshelf/cookbook_generator.rb +3 -4
  56. data/lib/berkshelf/cookbook_store.rb +74 -17
  57. data/lib/berkshelf/core_ext/file.rb +2 -2
  58. data/lib/berkshelf/core_ext/pathname.rb +7 -5
  59. data/lib/berkshelf/{cookbook_source.rb → dependency.rb} +47 -67
  60. data/lib/berkshelf/downloader.rb +49 -106
  61. data/lib/berkshelf/errors.rb +64 -71
  62. data/lib/berkshelf/formatters.rb +11 -9
  63. data/lib/berkshelf/formatters/human_readable.rb +9 -9
  64. data/lib/berkshelf/formatters/json.rb +14 -4
  65. data/lib/berkshelf/init_generator.rb +3 -3
  66. data/lib/berkshelf/installer.rb +136 -0
  67. data/lib/berkshelf/location.rb +91 -131
  68. data/lib/berkshelf/locations/git_location.rb +9 -11
  69. data/lib/berkshelf/locations/github_location.rb +1 -1
  70. data/lib/berkshelf/locations/path_location.rb +10 -27
  71. data/lib/berkshelf/lockfile.rb +92 -70
  72. data/lib/berkshelf/logger.rb +4 -7
  73. data/lib/berkshelf/mixin/config.rb +21 -4
  74. data/lib/berkshelf/resolver.rb +60 -150
  75. data/lib/berkshelf/resolver/graph.rb +44 -0
  76. data/lib/berkshelf/source.rb +55 -0
  77. data/lib/berkshelf/source_uri.rb +38 -0
  78. data/lib/berkshelf/version.rb +1 -1
  79. data/spec/config/knife.rb +1 -1
  80. data/spec/fixtures/cassettes/Berkshelf_Resolver/_initialize/adds_the_dependencies_of_the_dependency_as_dependencies.yml +3694 -0
  81. data/spec/fixtures/cookbooks/example_cookbook/Berksfile.lock +1 -1
  82. data/spec/fixtures/lockfiles/default.lock +1 -1
  83. data/spec/spec_helper.rb +20 -121
  84. data/spec/support/chef_api.rb +3 -4
  85. data/spec/support/chef_server.rb +20 -11
  86. data/spec/support/git.rb +127 -0
  87. data/spec/support/kitchen.rb +12 -0
  88. data/spec/support/path_helpers.rb +69 -0
  89. data/spec/unit/berkshelf/api_client/remote_cookbook_spec.rb +23 -0
  90. data/spec/unit/berkshelf/api_client_spec.rb +57 -0
  91. data/spec/unit/berkshelf/berksfile_spec.rb +206 -324
  92. data/spec/unit/berkshelf/cached_cookbook_spec.rb +73 -38
  93. data/spec/unit/berkshelf/community_rest_spec.rb +30 -71
  94. data/spec/unit/berkshelf/config_spec.rb +3 -14
  95. data/spec/unit/berkshelf/cookbook_generator_spec.rb +1 -2
  96. data/spec/unit/berkshelf/cookbook_store_spec.rb +12 -7
  97. data/spec/unit/berkshelf/dependency_spec.rb +285 -0
  98. data/spec/unit/berkshelf/downloader_spec.rb +4 -183
  99. data/spec/unit/berkshelf/formatters/null_spec.rb +1 -1
  100. data/spec/unit/berkshelf/formatters_spec.rb +4 -2
  101. data/spec/unit/berkshelf/git_spec.rb +15 -15
  102. data/spec/unit/berkshelf/installer_spec.rb +39 -0
  103. data/spec/unit/berkshelf/location_spec.rb +87 -114
  104. data/spec/unit/berkshelf/locations/git_location_spec.rb +41 -53
  105. data/spec/unit/berkshelf/locations/path_location_spec.rb +13 -23
  106. data/spec/unit/berkshelf/lockfile_spec.rb +38 -40
  107. data/spec/unit/berkshelf/resolver/graph_spec.rb +44 -0
  108. data/spec/unit/berkshelf/resolver_spec.rb +34 -83
  109. data/spec/unit/berkshelf/source_spec.rb +23 -0
  110. data/spec/unit/berkshelf/source_uri_spec.rb +29 -0
  111. metadata +149 -188
  112. checksums.yaml +0 -7
  113. data/features/default_locations.feature +0 -127
  114. data/features/step_definitions/berksfile_steps.rb +0 -8
  115. data/features/step_definitions/configure_cli_steps.rb +0 -19
  116. data/features/vendor_install.feature +0 -19
  117. data/lib/berkshelf/core_ext/openuri.rb +0 -36
  118. data/lib/berkshelf/core_ext/rbzip2.rb +0 -8
  119. data/lib/berkshelf/locations/chef_api_location.rb +0 -228
  120. data/lib/berkshelf/locations/site_location.rb +0 -92
  121. data/lib/berkshelf/test.rb +0 -35
  122. data/spec/knife.rb.sample +0 -12
  123. data/spec/support/test_generators.rb +0 -27
  124. data/spec/unit/berkshelf/cli_spec.rb +0 -16
  125. data/spec/unit/berkshelf/cookbook_source_spec.rb +0 -358
  126. data/spec/unit/berkshelf/core_ext/pathname_spec.rb +0 -46
  127. data/spec/unit/berkshelf/locations/chef_api_location_spec.rb +0 -139
  128. data/spec/unit/berkshelf/locations/site_location_spec.rb +0 -19
@@ -1,5 +1,5 @@
1
1
  module Berkshelf
2
- class GitLocation
2
+ class GitLocation < Location::Base
3
3
  class << self
4
4
  # Create a temporary directory for the cloned repository within Berkshelf's
5
5
  # temporary directory
@@ -11,8 +11,6 @@ module Berkshelf
11
11
  end
12
12
  end
13
13
 
14
- include Location
15
-
16
14
  set_location_key :git
17
15
  set_valid_options :ref, :branch, :tag, :rel
18
16
 
@@ -24,7 +22,6 @@ module Berkshelf
24
22
 
25
23
  alias_method :tag, :branch
26
24
 
27
- # @param [#to_s] name
28
25
  # @param [Solve::Constraint] version_constraint
29
26
  # @param [Hash] options
30
27
  #
@@ -38,9 +35,8 @@ module Berkshelf
38
35
  # same as tag
39
36
  # @option options [String] :rel
40
37
  # the path within the repository to find the cookbook
41
- def initialize(name, version_constraint, options = {})
42
- @name = name
43
- @version_constraint = version_constraint
38
+ def initialize(dependency, options = {})
39
+ super
44
40
  @uri = options[:git]
45
41
  @branch = options[:branch] || options[:tag] || 'master'
46
42
  @ref = options[:ref]
@@ -52,7 +48,9 @@ module Berkshelf
52
48
  # @param [#to_s] destination
53
49
  #
54
50
  # @return [Berkshelf::CachedCookbook]
55
- def download(destination)
51
+ def do_download
52
+ destination = Berkshelf::CookbookStore.instance.storage_path
53
+
56
54
  if cached?(destination)
57
55
  @ref ||= Berkshelf::Git.rev_parse(revision_path(destination))
58
56
  return local_revision(destination)
@@ -63,14 +61,14 @@ module Berkshelf
63
61
 
64
62
  tmp_path = rel ? File.join(clone, rel) : clone
65
63
  unless File.chef_cookbook?(tmp_path)
66
- msg = "Cookbook '#{name}' not found at git: #{uri}"
64
+ msg = "Cookbook '#{dependency.name}' not found at git: #{uri}"
67
65
  msg << " with branch '#{branch}'" if branch
68
66
  msg << " with ref '#{ref}'" if ref
69
67
  msg << " at path '#{rel}'" if rel
70
68
  raise CookbookNotFound, msg
71
69
  end
72
70
 
73
- cb_path = File.join(destination, "#{name}-#{ref}")
71
+ cb_path = File.join(destination, "#{dependency.name}-#{ref}")
74
72
  FileUtils.rm_rf(cb_path)
75
73
  FileUtils.mv(tmp_path, cb_path)
76
74
 
@@ -123,7 +121,7 @@ module Berkshelf
123
121
 
124
122
  def revision_path(destination)
125
123
  return unless ref
126
- File.join(destination, "#{name}-#{ref}")
124
+ File.join(destination, "#{dependency.name}-#{ref}")
127
125
  end
128
126
  end
129
127
  end
@@ -17,7 +17,7 @@ module Berkshelf
17
17
  # the GitHub repo identifier to clone
18
18
  # @option options [#to_sym] :protocol
19
19
  # the protocol with which to communicate with GitHub
20
- def initialize(name, version_constraint, options = {})
20
+ def initialize(dependency, options = {})
21
21
  @repo_identifier = options.delete(:github)
22
22
  @protocol = (options.delete(:protocol) || DEFAULT_PROTOCOL).to_sym
23
23
  options[:git] = github_url
@@ -1,5 +1,5 @@
1
1
  module Berkshelf
2
- class PathLocation
2
+ class PathLocation < Location::Base
3
3
  class << self
4
4
  # Expand and return a string representation of the given path if it is
5
5
  # absolute or a path in the users home directory.
@@ -19,15 +19,12 @@ module Berkshelf
19
19
  end
20
20
  end
21
21
 
22
- include Location
23
-
24
22
  set_location_key :path
25
23
  set_valid_options :path, :metadata
26
24
 
27
25
  attr_accessor :path
28
- attr_reader :name
29
26
 
30
- # @param [#to_s] name
27
+ # @param [#to_s] dependency
31
28
  # @param [Solve::Constraint] version_constraint
32
29
  # @param [Hash] options
33
30
  #
@@ -35,19 +32,14 @@ module Berkshelf
35
32
  # a filepath to the cookbook on your local disk
36
33
  # @option options [Boolean] :metadata
37
34
  # true if this is a metadata source
38
- def initialize(name, version_constraint, options = {})
39
- @name = name
40
- @version_constraint = version_constraint
41
- @path = options[:path].to_s
42
- @metadata = options[:metadata]
35
+ def initialize(dependency, options = {})
36
+ super
37
+ @path = options[:path].to_s
38
+ @metadata = options[:metadata]
43
39
  end
44
40
 
45
- # The cookbook associated with this path location.
46
- #
47
- # @return [Berkshelf::CachedCookbook]
48
- # the cached cookbook for this location
49
- def cookbook
50
- @cookbook ||= CachedCookbook.from_path(path, name: name)
41
+ def do_download
42
+ CachedCookbook.from_path(path, name: name)
51
43
  end
52
44
 
53
45
  # Returns true if the location is a metadata location. By default, no
@@ -80,23 +72,14 @@ module Berkshelf
80
72
  super.merge(value: self.path)
81
73
  end
82
74
 
83
- # The string representation of this PathLocation. If the path
84
- # is the default cookbook store, just leave it out, because
85
- # it's probably just cached.
86
- #
87
- # @example
88
- # loc.to_s #=> artifact (1.4.0)
75
+ # The string representation of this PathLocation
89
76
  #
90
77
  # @example
91
78
  # loc.to_s #=> artifact (1.4.0) at path: '/Users/Seth/Dev/artifact'
92
79
  #
93
80
  # @return [String]
94
81
  def to_s
95
- if path.to_s.include?(Berkshelf.berkshelf_path.to_s)
96
- "#{self.class.location_key}"
97
- else
98
- "#{self.class.location_key}: '#{path}'"
99
- end
82
+ "#{self.class.location_key}: '#{File.expand_path(path)}'"
100
83
  end
101
84
  end
102
85
  end
@@ -1,10 +1,10 @@
1
+ require_relative 'dependency'
2
+
1
3
  module Berkshelf
2
4
  # The object representation of the Berkshelf lockfile. The lockfile is useful
3
5
  # when working in teams where the same cookbook versions are desired across
4
6
  # multiple workstations.
5
7
  class Lockfile
6
- require_relative 'cookbook_source'
7
-
8
8
  # @return [Pathname]
9
9
  # the path to this Lockfile
10
10
  attr_reader :filepath
@@ -20,9 +20,9 @@ module Berkshelf
20
20
  # @param berksfile [Berkshelf::Berksfile]
21
21
  # the Berksfile associated with this Lockfile
22
22
  def initialize(berksfile)
23
- @berksfile = berksfile
24
- @filepath = File.expand_path("#{berksfile.filepath}.lock")
25
- @sources = {}
23
+ @berksfile = berksfile
24
+ @filepath = File.expand_path("#{berksfile.filepath}.lock")
25
+ @dependencies = {}
26
26
 
27
27
  load! if File.exists?(@filepath)
28
28
  end
@@ -30,14 +30,14 @@ module Berkshelf
30
30
  # Load the lockfile from file system.
31
31
  def load!
32
32
  contents = File.read(filepath).strip
33
- hash = parse(contents)
33
+ hash = parse(contents)
34
34
 
35
- hash[:sources].each do |name, options|
35
+ hash[:dependencies].each do |name, options|
36
36
  # Dynamically calculate paths relative to the Berksfile if a path is given
37
37
  options[:path] &&= File.expand_path(options[:path], File.dirname(filepath))
38
38
 
39
39
  begin
40
- add(CookbookSource.new(berksfile, name.to_s, options))
40
+ add(Berkshelf::Dependency.new(berksfile, name.to_s, options))
41
41
  rescue Berkshelf::CookbookNotFound
42
42
  # It's possible that a source is locked that contains a path location, and
43
43
  # that path location was renamed or no longer exists. When loading the
@@ -49,71 +49,70 @@ module Berkshelf
49
49
 
50
50
  # The list of sources constrained in this lockfile.
51
51
  #
52
- # @return [Array<Berkshelf::CookbookSource>]
53
- # the list of sources in this lockfile
54
- def sources
55
- @sources.values
52
+ # @return [Array<Berkshelf::Dependency>]
53
+ # the list of dependencies in this lockfile
54
+ def dependencies
55
+ @dependencies.values
56
56
  end
57
57
 
58
- # Find the given source in this lockfile. This method accepts a source
58
+ # Find the given dependency in this lockfile. This method accepts a dependency
59
59
  # attribute which may either be the name of a cookbook (String) or an
60
- # actual cookbook source.
60
+ # actual cookbook dependency.
61
61
  #
62
- # @param [String, Berkshelf::CookbookSource] source
63
- # the cookbook source/name to find
64
- # @return [CookbookSource, nil]
65
- # the cookbook source from this lockfile or nil if one was not found
66
- def find(source)
67
- @sources[cookbook_name(source).to_s]
62
+ # @param [String, Berkshelf::Dependency] dependency
63
+ # the cookbook dependency/name to find
64
+ # @return [Berkshelf::Dependency, nil]
65
+ # the cookbook dependency from this lockfile or nil if one was not found
66
+ def find(dependency)
67
+ @dependencies[cookbook_name(dependency).to_s]
68
68
  end
69
69
 
70
- # Determine if this lockfile contains the given source.
70
+ # Determine if this lockfile contains the given dependency.
71
71
  #
72
- # @param [String, Berkshelf::CookbookSource] source
73
- # the cookbook source/name to determine existence of
72
+ # @param [String, Berkshelf::Dependency] dependency
73
+ # the cookbook dependency/name to determine existence of
74
74
  # @return [Boolean]
75
- # true if the source exists, false otherwise
76
- def has_source?(source)
77
- !find(source).nil?
75
+ # true if the dependency exists, false otherwise
76
+ def has_dependency?(dependency)
77
+ !find(dependency).nil?
78
78
  end
79
79
 
80
- # Replace the current list of sources with `sources`. This method does
80
+ # Replace the current list of dependencies with `dependencies`. This method does
81
81
  # not write out the lockfile - it only changes the state of the object.
82
82
  #
83
- # @param [Array<Berkshelf::CookbookSource>] sources
84
- # the list of sources to update
85
- # @option options [String] :sha
86
- # the sha of the Berksfile updating the sources
87
- def update(sources)
88
- reset_sources!
89
- sources.each { |source| append(source) }
83
+ # @param [Array<Berkshelf::Dependency>] dependencies
84
+ # the list of dependencies to update
85
+ def update(dependencies)
86
+ reset_dependencies!
87
+
88
+ dependencies.each { |dependency| append(dependency) }
90
89
  save
91
90
  end
92
91
 
93
- # Add the given source to the `sources` list, if it doesn't already exist.
92
+ # Add the given dependency to the `dependencies` list, if it doesn't already exist.
94
93
  #
95
- # @param [Berkshelf::CookbookSource] source
96
- # the source to append to the sources list
97
- def add(source)
98
- @sources[cookbook_name(source)] = source
94
+ # @param [Berkshelf::Dependency] dependency
95
+ # the dependency to append to the dependencies list
96
+ def add(dependency)
97
+ @dependencies[cookbook_name(dependency)] = dependency
99
98
  end
100
99
  alias_method :append, :add
101
100
 
102
- # Remove the given source from this lockfile. This method accepts a source
101
+ # Remove the given dependency from this lockfile. This method accepts a dependency
103
102
  # attribute which may either be the name of a cookbook (String) or an
104
- # actual cookbook source.
103
+ # actual cookbook dependency.
105
104
  #
106
- # @param [String, Berkshelf::CookbookSource] source
107
- # the cookbook source/name to remove
105
+ # @param [String, Berkshelf::Dependency] dependency
106
+ # the cookbook dependency/name to remove
108
107
  #
109
108
  # @raise [Berkshelf::CookbookNotFound]
110
- # if the provided source does not exist
111
- def remove(source)
112
- unless has_source?(source)
113
- raise Berkshelf::CookbookNotFound, "'#{cookbook_name(source)}' does not exist in this lockfile!"
109
+ # if the provided dependency does not exist
110
+ def remove(dependency)
111
+ unless has_dependency?(dependency)
112
+ raise Berkshelf::CookbookNotFound, "'#{cookbook_name(dependency)}' does not exist in this lockfile!"
114
113
  end
115
114
 
116
- @sources.delete(cookbook_name(source))
115
+ @dependencies.delete(cookbook_name(dependency))
117
116
  end
118
117
  alias_method :unlock, :remove
119
118
 
@@ -126,17 +125,17 @@ module Berkshelf
126
125
  # @return [String]
127
126
  # the detailed string representation of the lockfile
128
127
  def inspect
129
- "#<Berkshelf::Lockfile #{Pathname.new(filepath).basename}, sources: #{sources.inspect}>"
128
+ "#<Berkshelf::Lockfile #{Pathname.new(filepath).basename}, dependencies: #{dependencies.inspect}>"
130
129
  end
131
130
 
132
131
  # Write the current lockfile to a hash
133
132
  #
134
133
  # @return [Hash]
135
134
  # the hash representation of this lockfile
136
- # * :sources [Array<Berkshelf::CookbookSource>] the list of sources
135
+ # * :dependencies [Array<Berkshelf::Dependency>] the list of dependencies
137
136
  def to_hash
138
137
  {
139
- sources: @sources
138
+ dependencies: @dependencies
140
139
  }
141
140
  end
142
141
 
@@ -159,12 +158,23 @@ module Berkshelf
159
158
  # @return [Hash]
160
159
  def parse(contents)
161
160
  # Ruby's JSON.parse cannot handle an empty string/file
162
- return { sha: nil, sources: [] } if contents.strip.empty?
161
+ return { dependencies: [] } if contents.strip.empty?
162
+
163
+ hash = JSON.parse(contents, symbolize_names: true)
163
164
 
164
- JSON.parse(contents, symbolize_names: true)
165
+ # Legacy support for 2.0 lockfiles
166
+ # @todo Remove in 4.0
167
+ if hash[:sources]
168
+ LockfileLegacy.warn!
169
+ hash[:dependencies] = hash.delete(:sources)
170
+ end
171
+
172
+ return hash
165
173
  rescue Exception => e
174
+ # Legacy support for 1.0 lockfiles
175
+ # @todo Remove in 4.0
166
176
  if e.class == JSON::ParserError && contents =~ /^cookbook ["'](.+)["']/
167
- Berkshelf.ui.warn 'You are using the old lockfile format. Attempting to convert...'
177
+ LockfileLegacy.warn!
168
178
  return LockfileLegacy.parse(berksfile, contents)
169
179
  else
170
180
  raise Berkshelf::LockfileParserError.new(filepath, e)
@@ -178,29 +188,26 @@ module Berkshelf
178
188
  end
179
189
  end
180
190
 
181
- # Clear the sources array
182
- def reset_sources!
183
- @sources = {}
191
+ def reset_dependencies!
192
+ @dependencies = {}
184
193
  end
185
194
 
186
195
  # Return the name of this cookbook (because it's the key in our
187
196
  # table).
188
197
  #
189
- # @param [Berkshelf::CookbookSource, #to_s] source
190
- # the source to find the name from
198
+ # @param [Berkshelf::Dependency, #to_s] dependency
199
+ # the dependency to find the name from
191
200
  #
192
201
  # @return [String]
193
202
  # the name of the cookbook
194
- def cookbook_name(source)
195
- source.is_a?(CookbookSource) ? source.name : source.to_s
203
+ def cookbook_name(dependency)
204
+ dependency.is_a?(Berkshelf::Dependency) ? dependency.name : dependency.to_s
196
205
  end
197
206
 
198
207
  # Legacy support for old lockfiles
199
208
  #
200
209
  # @todo Remove this class in Berkshelf 3.0.0
201
210
  class LockfileLegacy
202
- require 'pathname'
203
-
204
211
  class << self
205
212
  # Read the old lockfile content and instance eval in context.
206
213
  #
@@ -209,19 +216,34 @@ module Berkshelf
209
216
  # @param [String] content
210
217
  # the string content read from a legacy lockfile
211
218
  def parse(berksfile, content)
212
- sources = {}.tap do |hash|
219
+ dependencies = {}.tap do |hash|
213
220
  content.split("\n").each do |line|
214
221
  next if line.empty?
215
-
216
- source = self.new(berksfile, line)
222
+ source = new(berksfile, line)
217
223
  hash[source.name] = source.options
218
224
  end
219
225
  end
220
226
 
221
227
  {
222
- sources: sources,
228
+ dependencies: dependencies,
223
229
  }
224
230
  end
231
+
232
+ # Warn the user they he/she is using an old Lockfile format.
233
+ #
234
+ # This automatically outputs to the {Berkshelf.ui}; nothing is
235
+ # returned.
236
+ #
237
+ # @return [nil]
238
+ def warn!
239
+ Berkshelf.ui.warn(warning_message)
240
+ end
241
+
242
+ private
243
+ # @return [String]
244
+ def warning_message
245
+ 'You are using the old lockfile format. Attempting to convert...'
246
+ end
225
247
  end
226
248
 
227
249
  # @return [Hash]
@@ -245,19 +267,19 @@ module Berkshelf
245
267
  instance_eval(content).to_hash
246
268
  end
247
269
 
248
- # Method defined in legacy lockfiles (since we are using
249
- # instance_eval).
270
+ # Method defined in legacy lockfiles (since we are using instance_eval).
250
271
  #
251
272
  # @param [String] name
252
273
  # the name of this cookbook
253
274
  # @option options [String] :locked_version
254
275
  # the locked version of this cookbook
255
276
  def cookbook(name, options = {})
256
- @name = name
277
+ @name = name
257
278
  @options = manipulate(options)
258
279
  end
259
280
 
260
281
  private
282
+
261
283
  # Perform various manipulations on the hash.
262
284
  #
263
285
  # @param [Hash] options