Class: LicenseScout::Reporter::Result

Inherits:
Object
  • Object
show all
Defined in:
lib/license_scout/reporter.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(dependency, reason, did_succeed) ⇒ Result

Returns a new instance of Result.



40
41
42
43
44
# File 'lib/license_scout/reporter.rb', line 40

def initialize(dependency, reason, did_succeed)
  @dependency = dependency
  @reason = reason
  @did_succeed = did_succeed
end

Instance Attribute Details

#dependencyObject (readonly)

Returns the value of attribute dependency.



37
38
39
# File 'lib/license_scout/reporter.rb', line 37

def dependency
  @dependency
end

#reasonObject (readonly)

Returns the value of attribute reason.



38
39
40
# File 'lib/license_scout/reporter.rb', line 38

def reason
  @reason
end

Class Method Details

.failure(dependency, reason) ⇒ Object



32
33
34
# File 'lib/license_scout/reporter.rb', line 32

def failure(dependency, reason)
  new(dependency, reason, false)
end

.success(dependency) ⇒ Object



28
29
30
# File 'lib/license_scout/reporter.rb', line 28

def success(dependency)
  new(dependency, nil, true)
end

Instance Method Details

#<=>(other) ⇒ Object



46
47
48
# File 'lib/license_scout/reporter.rb', line 46

def <=>(other)
  dependency.path <=> other.dependency.path
end

#dependency_stringObject



54
55
56
# File 'lib/license_scout/reporter.rb', line 54

def dependency_string
  dependency.uid
end

#license_stringObject



58
59
60
# File 'lib/license_scout/reporter.rb', line 58

def license_string
  dependency.license.records.map(&:id).compact.uniq.join(", ")
end

#reason_stringObject



62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/license_scout/reporter.rb', line 62

def reason_string
  case reason
  when :not_allowed
    "Not Allowed"
  when :flagged
    "Flagged"
  when :undetermined
    "Undetermined"
  when :missing
    "Missing"
  else
    "OK"
  end
end

#succeeded?Boolean

Returns:

  • (Boolean)


50
51
52
# File 'lib/license_scout/reporter.rb', line 50

def succeeded?
  @did_succeed
end