[DRE-commits] [librarian-puppet] 51/153: Issue #250 Fix error when module has no dependencies in metadata.json

Stig Sandbeck Mathisen ssm at debian.org
Wed Jun 1 20:30:40 UTC 2016


This is an automated email from the git hooks/post-receive script.

ssm pushed a commit to branch master
in repository librarian-puppet.

commit a028cc5189d788762f68fd961a569a4b4fc16a61
Author: Carlos Sanchez <csanchez at maestrodev.com>
Date:   Fri Aug 22 09:20:13 2014 +0200

    Issue #250 Fix error when module has no dependencies in metadata.json
---
 Changelog.md                         |  8 ++++++++
 features/install.feature             | 10 ----------
 features/install/git.feature         | 20 +++++++++++++++++++
 lib/librarian/puppet/source/local.rb | 37 ++++++++++++++++++------------------
 4 files changed, 47 insertions(+), 28 deletions(-)

diff --git a/Changelog.md b/Changelog.md
index bed7a2d..2033e16 100644
--- a/Changelog.md
+++ b/Changelog.md
@@ -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`
diff --git a/features/install.feature b/features/install.feature
index 876bba1..77fe34d 100644
--- a/features/install.feature
+++ b/features/install.feature
@@ -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
diff --git a/features/install/git.feature b/features/install/git.feature
index 84d45cf..c47edf4 100644
--- a/features/install/git.feature
+++ b/features/install/git.feature
@@ -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:
     """
diff --git a/lib/librarian/puppet/source/local.rb b/lib/librarian/puppet/source/local.rb
index 81e1082..78c3bbd 100644
--- a/lib/librarian/puppet/source/local.rb
+++ b/lib/librarian/puppet/source/local.rb
@@ -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

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ruby-extras/librarian-puppet.git



More information about the Pkg-ruby-extras-commits mailing list