Class: Papers::DependencySpecification

Inherits:
Object
  • Object
show all
Defined in:
lib/papers/dependency_specification.rb

Direct Known Subclasses

BowerComponent, Gem, Javascript

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ DependencySpecification

Returns a new instance of DependencySpecification.



5
6
7
8
9
10
# File 'lib/papers/dependency_specification.rb', line 5

def initialize(options)
  @name        = options[:name]
  @license     = options[:license]
  @license_url = options[:license_url]
  @project_url = options[:project_url]
end

Instance Attribute Details

#licenseObject

Returns the value of attribute license.



3
4
5
# File 'lib/papers/dependency_specification.rb', line 3

def license
  @license
end

#license_urlObject

Returns the value of attribute license_url.



3
4
5
# File 'lib/papers/dependency_specification.rb', line 3

def license_url
  @license_url
end

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/papers/dependency_specification.rb', line 3

def name
  @name
end

#project_urlObject

Returns the value of attribute project_url.



3
4
5
# File 'lib/papers/dependency_specification.rb', line 3

def project_url
  @project_url
end

Class Method Details

.all_from_manifest(manifest) ⇒ Object



23
24
25
26
27
28
29
30
# File 'lib/papers/dependency_specification.rb', line 23

def self.all_from_manifest(manifest)
  (manifest[manifest_key] || []).map do |name, info|
    license_url = info['license_url']
    license = info['license']
    project_url = info['project_url']
    self.new(name: name, license: license, license_url: license_url, project_url: project_url)
  end.sort { |a, b| a.name.downcase <=> b.name.downcase }
end

.missing_from_manifest(manifest) ⇒ Object



32
33
34
# File 'lib/papers/dependency_specification.rb', line 32

def self.missing_from_manifest(manifest)
  introspected.to_set - all_from_manifest(manifest).map(&:name).to_set
end

.unknown_in_manifest(manifest) ⇒ Object



36
37
38
# File 'lib/papers/dependency_specification.rb', line 36

def self.unknown_in_manifest(manifest)
  all_from_manifest(manifest).map(&:name).to_set - introspected.to_set
end

Instance Method Details

#acceptable_license?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/papers/dependency_specification.rb', line 17

def acceptable_license?
  Papers.config.license_whitelist.include?(license)
end

#name_without_versionObject



12
13
14
15
# File 'lib/papers/dependency_specification.rb', line 12

def name_without_version
  return @name unless @name.include?('-')
  @name.split('-')[0..-2].join('-')
end