Class: Yolice::YoLicense
- Inherits:
-
Object
- Object
- Yolice::YoLicense
- Defined in:
- lib/yolice.rb
Instance Attribute Summary collapse
-
#features ⇒ Object
readonly
Returns the value of attribute features.
-
#license_features ⇒ Object
readonly
Returns the value of attribute license_features.
-
#licenses ⇒ Object
readonly
Returns the value of attribute licenses.
-
#raw_licenses ⇒ Object
readonly
Returns the value of attribute raw_licenses.
Instance Method Summary collapse
- #col_features ⇒ Object
-
#initialize ⇒ YoLicense
constructor
A new instance of YoLicense.
- #match_licenses ⇒ Object
- #print_explanations ⇒ Object
Constructor Details
#initialize ⇒ YoLicense
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
#features ⇒ Object (readonly)
Returns the value of attribute features.
17 18 19 |
# File 'lib/yolice.rb', line 17 def features @features end |
#license_features ⇒ Object (readonly)
Returns the value of attribute license_features.
14 15 16 |
# File 'lib/yolice.rb', line 14 def license_features @license_features end |
#licenses ⇒ Object (readonly)
Returns the value of attribute licenses.
15 16 17 |
# File 'lib/yolice.rb', line 15 def licenses @licenses end |
#raw_licenses ⇒ Object (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_features ⇒ Object
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_licenses ⇒ Object
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 |
#print_explanations ⇒ Object
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 |