lib/cookbook-reader/parser.rb in cookbook-reader-0.1.1 vs lib/cookbook-reader/parser.rb in cookbook-reader-0.1.2

- old
+ new

@@ -15,12 +15,16 @@ def display_data @top_list.each do |element| puts "Cookbook: #{element['name']}\n" puts " Dependancies:" - element['depends'].each do |name, version| - puts " #{name}, #{version}\n" + if element['depends'] + element['depends'].each do |name, version| + puts " #{name}, #{version}\n" + end + else + puts " None\n" end puts "\n" end end @@ -30,11 +34,12 @@ @depends_list = {} File.open(filename) do |fp| fp.each do |line| key, value = line.chomp.split(" ") - key.strip! - value.strip! + next if key.nil? || value.nil? + key.strip! unless key.nil? + value.strip! unless value.nil? key = key.chomp('"').reverse.chomp('"').reverse value = value.chomp('"').reverse.chomp('"').reverse if key =~ /depends/ @hash[key] = add_dependencies(line)