Class: Hackmac::KextSource
- Inherits:
-
Object
- Object
- Hackmac::KextSource
- Includes:
- Tins::StringVersion
- Defined in:
- lib/hackmac/kext_source.rb
Constant Summary collapse
- GITHUB_API_URL =
'https://api.github.com/repos/%s/releases'
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
-
#initialize(github, auth: nil) ⇒ KextSource
constructor
A new instance of KextSource.
- #inspect ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(github, auth: nil) ⇒ KextSource
Returns a new instance of KextSource.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/hackmac/kext_source.rb', line 11 def initialize(github, auth: nil) account, repo = github.split(?/) @name = repo releases = URI.open( GITHUB_API_URL % github, http_basic_authentication: auth) { |o| JSON.parse(o.read, object_class: JSON::GenericObject) } if version = releases.map { |r| next unless r.tag_name.include?(?.) version = r.tag_name.delete '^.0-9' begin Version.new(version) rescue ArgumentError end }.compact.max then @version = version end end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
32 33 34 |
# File 'lib/hackmac/kext_source.rb', line 32 def name @name end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
34 35 36 |
# File 'lib/hackmac/kext_source.rb', line 34 def version @version end |
Instance Method Details
#inspect ⇒ Object
36 37 38 |
# File 'lib/hackmac/kext_source.rb', line 36 def inspect "#<#{self.class}: #{to_s}>" end |
#to_s ⇒ Object
40 41 42 |
# File 'lib/hackmac/kext_source.rb', line 40 def to_s "#{name} #{version}" end |