Class: Yolice::YoLicense

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeYoLicense

Returns a new instance of YoLicense.



19
20
21
22
23
24
# File 'lib/yolice.rb', line 19

def initialize
  get_raw_licenses
  @licenses = []
  @features = {}
  @license_features = OpenStruct.new.marshal_load(load_license_config)
end

Instance Attribute Details

#featuresObject (readonly)

Returns the value of attribute features.



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

def features
  @features
end

#license_featuresObject (readonly)

Returns the value of attribute license_features.



14
15
16
# File 'lib/yolice.rb', line 14

def license_features
  @license_features
end

#licensesObject (readonly)

Returns the value of attribute licenses.



15
16
17
# File 'lib/yolice.rb', line 15

def licenses
  @licenses
end

#raw_licensesObject (readonly)

Returns the value of attribute raw_licenses.



16
17
18
# File 'lib/yolice.rb', line 16

def raw_licenses
  @raw_licenses
end

Instance Method Details

#col_featuresObject



33
34
35
36
37
38
39
40
41
42
# File 'lib/yolice.rb', line 33

def col_features
  @licenses.each do |l|
    @license_features["licenses"][l].each do |f|
      unless @features.include? f["feature"] && @features[f["feature"]] == "forbidden"
        @features[f["feature"]] = f["permission"]
      end
    end
  end
  self
end

#match_licensesObject



26
27
28
29
30
31
# File 'lib/yolice.rb', line 26

def match_licenses
  @raw_licenses.each do |gem_license|
    @licenses << fetch_most_likely(compare_to_licenses(gem_license))
  end
  self
end


44
45
46
47
48
49
50
# File 'lib/yolice.rb', line 44

def print_explanations
  puts "Here is your license situation: "
  puts "=" * 20
  @features.each do |f|
    puts "#{@license_features["features"][f[0]]["name"]} - #{@license_features["features"][f[0]][f[1]]}".send f[1]
  end
end