Module: Veye::Project

Defined in:
lib/veye/project.rb,
lib/veye/project/check.rb,
lib/veye/views/project.rb,
lib/veye/project/license.rb,
lib/veye/views/project/info_csv.rb,
lib/veye/views/project/info_json.rb,
lib/veye/views/project/info_table.rb,
lib/veye/views/project/info_pretty.rb,
lib/veye/views/project/licence_csv.rb,
lib/veye/views/project/licence_json.rb,
lib/veye/views/project/info_markdown.rb,
lib/veye/views/project/licence_table.rb,
lib/veye/views/project/dependency_csv.rb,
lib/veye/views/project/licence_pretty.rb,
lib/veye/views/project/dependency_json.rb,
lib/veye/views/project/dependency_table.rb,
lib/veye/views/project/dependency_pretty.rb,
lib/veye/views/project/dependency_markdown.rb

Overview

Project module includes commands for managing projects on VersionEye and presenting results on command line.

Defined Under Namespace

Classes: Check, DependencyCSV, DependencyJSON, DependencyMarkdown, DependencyPretty, DependencyTable, InfoCSV, InfoJSON, InfoMarkdown, InfoPretty, InfoTable, LicenceCSV, LicenceJSON, LicencePretty, LicenceTable, License

Class Method Summary collapse

Class Method Details

.calc_upgrade_heuristics(version_requested, version_current) ⇒ Object

estimates how difficult it would be to upgrade to current version



76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/veye/project.rb', line 76

def self.calc_upgrade_heuristics(version_requested, version_current)
  scores = @default_upgrade_heuristics
  
  semver_A = SemVer.parse(version_requested)
  semver_B = SemVer.parse(version_current)

  #if any of versions are not semver, then shortcut execution
  if ( semver_A.nil? or semver_B.nil? )
    #hack: float unknown outdated semvers top of up-to-date packages
    scores[:dv_score] = 0.01 if version_requested != version_current
    return scores
  end

  scores = {
    :is_semver  => true,
    :dv_major   => (semver_A.major - semver_B.major).abs,
    :dv_minor   => (semver_A.minor - semver_B.minor).abs,
    :dv_patch   => (semver_A.patch - semver_B.patch).abs
  }

  dv_score = Math.log10(scores[:dv_major] * 1e3 + scores[:dv_minor] * 1e2 + scores[:dv_patch] + 1)
  scores[:dv_score] = dv_score.round(3)

  scores[:difficulty] = humanize_dv_score(scores[:dv_score], scores[:is_semver])

  scores
end

.get_files(path) ⇒ Object

returns list of supported filenames in the working folder



62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/veye/project.rb', line 62

def self.get_files(path)
  files = Set.new
  Dir.foreach(path) do |filename|
    files << filename if supported?(filename)
  end

  if files.include?('Gemfile') and files.include?('Gemfile.lock')
    files.delete 'Gemfile'
  end

  files
end

.humanize_dv_score(the_score, is_semver) ⇒ Object



104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# File 'lib/veye/project.rb', line 104

def self.humanize_dv_score(the_score, is_semver)
  if is_semver == false
    'unknown'
  elsif the_score == 0
    'up-to-date'
  elsif the_score < 1
    'low'
  elsif the_score >= 1 and the_score < 3
    'medium'
  elsif the_score >= 3
    'high'
  else
    'unknown'
  end
end

.merge(api_key, parent_id, child_id) ⇒ Object

– project commands



32
33
34
35
36
37
38
39
40
# File 'lib/veye/project.rb', line 32

def self.merge(api_key, parent_id, child_id)
  if parent_id.to_s.empty? or child_id.to_s.empty?
    printf("%s\n", "parent_id or child_id was unspecified".color(:red))
    return
  end

  res = Veye::API::Project.merge(api_key, parent_id, child_id)
  printf("success: %s\n", res.data.fetch('success', false))
end

.supported?(filename) ⇒ Boolean

Returns:

  • (Boolean)


57
58
59
# File 'lib/veye/project.rb', line 57

def self.supported?(filename)
  @supported_files.any? {|ptrn| filename.to_s.downcase.match(/^#{ptrn}$/) }  
end

.supported_filesObject

– helper functions



53
54
55
# File 'lib/veye/project.rb', line 53

def self.supported_files
  @supported_files
end

.unmerge(api_key, parent_id, child_id) ⇒ Object



42
43
44
45
46
47
48
49
50
# File 'lib/veye/project.rb', line 42

def self.unmerge(api_key, parent_id, child_id)
  if parent_id.to_s.empty? or child_id.to_s.empty?
    printf("%s\n", "parent_id or child_id was unspecified".color(:red))
    return
  end

  res = Veye::API::Project.unmerge(api_key, parent_id, child_id)
  printf("success: %s\n", res.data.fetch('success', false) )
end