Commit a028cc51 authored by Carlos Sanchez's avatar Carlos Sanchez

Issue #250 Fix error when module has no dependencies in metadata.json

parent c8f3e7d0
......@@ -2,6 +2,10 @@
## From 1.1.x Librarian-Puppet requires Ruby >= 1.9, uses Puppet Forge API v3. For Ruby 1.8 use 1.0.x
### 1.3.3
* [Issue #250](https://github.com/rodjek/librarian-puppet/issues/250) Fix error when module has no dependencies in `metadata.json`
### 1.3.2
* [Issue #246](https://github.com/rodjek/librarian-puppet/issues/246) Do not fail if modules have no `Modulefile` nor `metadata.json`
......@@ -46,6 +50,10 @@
## 1.0.x: Works on Ruby 1.8, using Puppet Forge API v1
### 1.0.10
* [Issue #250](https://github.com/rodjek/librarian-puppet/issues/250) Fix error when module has no dependencies in `metadata.json`
### 1.0.9
* [Issue #246](https://github.com/rodjek/librarian-puppet/issues/246) Do not fail if modules have no `Modulefile` nor `metadata.json`
......
......@@ -40,13 +40,3 @@ Feature: cli/install
"""
Unable to parse .*/bad_modulefile/Modulefile, ignoring: Missing version
"""
Scenario: Running install with no Modulefile nor metadata.json
Given a file named "Puppetfile" with:
"""
forge "http://forge.puppetlabs.com"
mod 'puppetlabs/stdlib', :git => 'https://github.com/puppetlabs/puppetlabs-stdlib.git', :ref => '3.0.0'
"""
When I run `librarian-puppet install`
Then the exit status should be 0
......@@ -100,6 +100,26 @@ Feature: cli/install/git
And the file "modules/with_puppetfile/Modulefile" should match /name *'librarian-with_puppetfile_and_modulefile'/
And the file "modules/test/Modulefile" should match /name *'maestrodev-test'/
Scenario: Running install with no Modulefile nor metadata.json
Given a file named "Puppetfile" with:
"""
forge "http://forge.puppetlabs.com"
mod 'puppetlabs/stdlib', :git => 'https://github.com/puppetlabs/puppetlabs-stdlib.git', :ref => '3.0.0'
"""
When I run `librarian-puppet install`
Then the exit status should be 0
Scenario: Running install with metadata.json without dependencies
Given a file named "Puppetfile" with:
"""
forge "http://forge.puppetlabs.com"
mod 'puppetlabs/sqlite', :git => 'https://github.com/puppetlabs/puppetlabs-sqlite.git', :ref => '84a0a6'
"""
When I run `librarian-puppet install`
Then the exit status should be 0
Scenario: Install a module using modulefile syntax
Given a file named "Puppetfile" with:
"""
......
......@@ -103,24 +103,25 @@ module Librarian
end
def parsed_metadata
@metadata ||= if metadata?
JSON.parse(File.read(metadata))
elsif modulefile?
# translate Modulefile to metadata.json
evaluated = evaluate_modulefile(modulefile)
{
'version' => evaluated.version,
'dependencies' => evaluated.dependencies.map do |dependency|
{
'name' => dependency.instance_variable_get(:@full_module_name),
'version_requirement' => dependency.instance_variable_get(:@version_requirement)
}
end
}
else
{
'dependencies' => []
}
if @metadata.nil?
@metadata = if metadata?
JSON.parse(File.read(metadata))
elsif modulefile?
# translate Modulefile to metadata.json
evaluated = evaluate_modulefile(modulefile)
{
'version' => evaluated.version,
'dependencies' => evaluated.dependencies.map do |dependency|
{
'name' => dependency.instance_variable_get(:@full_module_name),
'version_requirement' => dependency.instance_variable_get(:@version_requirement)
}
end
}
else
{}
end
@metadata['dependencies'] ||= []
end
@metadata
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment