class Papers::LicenseValidator
Attributes
errors[R]
Public Class Methods
new()
click to toggle source
# File lib/papers/license_validator.rb, line 13 def initialize @errors = [] end
Public Instance Methods
manifest()
click to toggle source
# File lib/papers/license_validator.rb, line 28 def manifest @manifest ||= YAML.load_file(Papers.config.manifest_file) end
pretty_bower_component_list()
click to toggle source
# File lib/papers/license_validator.rb, line 40 def pretty_bower_component_list BowerComponent.all_from_manifest(manifest).map(&:pretty_hash) end
pretty_gem_list()
click to toggle source
# File lib/papers/license_validator.rb, line 32 def pretty_gem_list Gem.all_from_manifest(manifest).map(&:pretty_hash) end
pretty_js_list()
click to toggle source
# File lib/papers/license_validator.rb, line 36 def pretty_js_list Javascript.all_from_manifest(manifest).map(&:pretty_hash) end
pretty_npm_package_list()
click to toggle source
# File lib/papers/license_validator.rb, line 44 def pretty_npm_package_list NpmPackage.all_from_manifest(manifest).map(&:pretty_hash) end
valid?()
click to toggle source
# File lib/papers/license_validator.rb, line 17 def valid? @errors = [] validate_spec_type(Gem) if Papers.config.validate_gems? validate_spec_type(Javascript) if Papers.config.validate_javascript? validate_spec_type(BowerComponent) if Papers.config.validate_bower_components? validate_spec_type(NpmPackage) if Papers.config.validate_npm_packages? @errors.empty? end
Private Instance Methods
validate_spec_type(spec_type)
click to toggle source
# File lib/papers/license_validator.rb, line 50 def validate_spec_type(spec_type) asset_type_name = spec_type.asset_type_name spec_type.missing_from_manifest(manifest).each do |name| errors << "#{asset_type_name} #{name} is included in the application, but not in the manifest" end spec_type.unknown_in_manifest(manifest).each do |name| errors << "#{asset_type_name} #{name} is included in the manifest, but not in the application" end spec_type.all_from_manifest(manifest).each do |spec| unless spec.acceptable_license? errors << "#{asset_type_name} #{spec.name} is licensed under #{spec.license}, which is not whitelisted" end end end