lib/papers/manifest_updater.rb in papers-2.4.3 vs lib/papers/manifest_updater.rb in papers-2.4.4
- old
+ new
@@ -25,22 +25,22 @@
original_content = File.read(@manifest_path)
result = YAML.load(original_content)
update_gems(result)
- update_javascript(result, "javascripts", get_installed_javascripts)
- update_javascript(result, "bower_components", get_installed_bower_components)
- update_javascript(result, "npm_packages", get_installed_npm_packages)
+ update_javascript(result, 'javascripts', get_installed_javascripts)
+ update_javascript(result, 'bower_components', get_installed_bower_components)
+ update_javascript(result, 'npm_packages', get_installed_npm_packages)
manifest_content = build_header + YAML.dump(result)
# strip trailing whitespace, ensure file ends with a newline
manifest_content.gsub(/\s*$/, '') + "\n"
end
def update_gems(result)
- result_gems = result["gems"]
+ result_gems = result['gems']
return unless result_gems
manifest_names = manifest_names(result_gems)
gemspecs.each do |gemspec|
if manifest_gem_key = manifest_names[gemspec.name]
@@ -70,16 +70,19 @@
result[key] = installed
end
def update_gem(result_gems, gemspec, manifest_gem_key)
manifest_gem = result_gems.delete(manifest_gem_key)
- if gemspec.license && gemspec.license != manifest_gem["license"]
+ if gemspec.license && gemspec.license != manifest_gem['license']
new_licenses = gemspec.licenses || []
new_licenses << gemspec.license
new_licenses.uniq!
- manifest_gem["license"] = "License Change! Was '#{manifest_gem["license"]}', is now #{new_licenses}"
+ # license key could be an array to_s to protect against that
+ unless manifest_gem['license'].to_s.match(/^License Change! Was '.+', is now .+$/)
+ manifest_gem['license'] = "License Change! Was '#{manifest_gem['license']}', is now #{new_licenses}"
+ end
end
name = gem_name_and_version(gemspec)
name = gemspec.name if gemspec.name == manifest_gem_key
result_gems[name] = manifest_gem
@@ -97,10 +100,10 @@
end
end
end
def name_from_key(key)
- key.include?("-") ? key.rpartition("-").first : key
+ key.include?('-') ? key.rpartition('-').first : key
end
def manifest_names(result_gems)
result_gems.reduce({}) do |hash, (key, _)|
hash[name_from_key(key)] = key