berkshelf/berkshelf — pull request #1182 by mjcdiggity (2014-05-02 05:19:28+00:00)
Title: Fix Berkshelf::Graph#update

__tl;dr:__ `Berkshelf::Graph#update` should use `cookbook.cookbook_name`

Ran into an issue when using Berkshelf classes in a ruby script:

``` ruby
berksfile = Berkshelf::Berksfile.from_options
berksfile.install
berksfile.upload
```
Which resulted in:
``` ruby
Berkshelf::DependencyNotFound (Berkshelf::DependencyNotFound)
```

Upon some debugging, I came across this difference between `lockfile.graph.locks` output before and update `lockfile.graph.update(cookbooks)`, which is run by `Berkshelf::Installer#run` (only tomcat cookbook in Berksfile):
```
Before update:
{"java"=>#= 0.0.0), locked_version: #, groups: [:default], location: default>, "openssl"=>#= 0.0.0), locked_version: #, groups: [:default], location: default>, "tomcat"=>#= 0.0.0), locked_version: #, groups: [:default], location: default>}

After update:
{"java-1.22.0"=>#= 0.0.0), locked_version: #, groups: [:default], location: default>, "openssl-1.1.0"=>#= 0.0.0), locked_version: #, groups: [:default], location: default>, "tomcat-0.15.12"=>#= 0.0.0), locked_version: #, groups: [:default], location: default>}
```

As you can see, after update the key is the cookbook_name-version, which appears to be a result of this in Berkshelf::Graph#update (lockfile.rb line 724):
``` ruby
cookbooks.each do |cookbook|
@graph[cookbook.cookbook_name.to_s] = GraphItem.new(
cookbook.name,
cookbook.version,
cookbook.dependencies,
)
end
```

Using `cookbook.name` results in cookbook_name-version, which breaks dependency look ups when another command is run against that graph in memory after update, which is why it does not show up when running commands individually via the cli. After updating `cookbook.name => cookbook.cookbook_name`, the problem went away, and `lockfile.graph.locks` appeared the same before and after update.