Class: RepositoryDependency

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/repository_dependency.rb

Instance Method Summary collapse

Instance Method Details

#compatible_license?Boolean

Returns:

  • (Boolean)

23
24
25
26
27
28
29
30
31
32
33
34
# File 'app/models/repository_dependency.rb', line 23

def compatible_license?
  return nil unless project
  return nil if project.normalized_licenses.empty?
  return nil if manifest.github_repository.license.blank?
  project.normalized_licenses.any? do |license|
    begin
      License::Compatibility.forward_compatiblity(license, manifest.github_repository.license)
    rescue
      true
    end
  end
end

#find_project_idObject


15
16
17
# File 'app/models/repository_dependency.rb', line 15

def find_project_id
  Project.platform(platform).where('lower(name) = ?', project_name.try(:downcase).try(:strip)).limit(1).pluck(:id).first
end

#github_repositoryObject


11
12
13
# File 'app/models/repository_dependency.rb', line 11

def github_repository
  manifest.try(:github_repository)
end

#incompatible_license?Boolean

Returns:

  • (Boolean)

19
20
21
# File 'app/models/repository_dependency.rb', line 19

def incompatible_license?
  compatible_license? == false
end

#outdated?Boolean

Returns:

  • (Boolean)

63
64
65
66
67
68
# File 'app/models/repository_dependency.rb', line 63

def outdated?
  return nil unless valid_requirements? && project && project.latest_stable_release_number
  !SemanticRange.satisfies(project.latest_stable_release_number, requirements)
rescue
  nil
end

#platformObject


36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'app/models/repository_dependency.rb', line 36

def platform
  plat = read_attribute(:platform)
  case plat
  when 'rubygemslockfile', 'gemspec'
    'Rubygems'
  when 'cocoapodslockfile'
    'CocoaPods'
  when 'nugetlockfile', 'nuspec'
    'NuGet'
  when 'packagistlockfile'
    'Packagist'
  when 'npmshrinkwrap'
    'NPM'
  else
    plat
  end
end

#update_project_idObject


54
55
56
57
# File 'app/models/repository_dependency.rb', line 54

def update_project_id
  proj_id = find_project_id
  update_attribute(:project_id, proj_id) if proj_id.present?
end

#valid_requirements?Boolean

Returns:

  • (Boolean)

59
60
61
# File 'app/models/repository_dependency.rb', line 59

def valid_requirements?
  !!SemanticRange.valid_range(requirements)
end