Class: PandocBinary::Release

Inherits:
Struct
  • Object
show all
Extended by:
RawDataParsable, TimeAttributeParsable
Defined in:
lib/pandoc_binary.rb

Defined Under Namespace

Classes: Asset

Constant Summary collapse

URI_BASE =
"https://api.github.com/repos/jgm/pandoc/releases/tags/%{version}"

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from RawDataParsable

from_raw_data

Methods included from TimeAttributeParsable

define_time_attribute

Instance Attribute Details

#assetsObject

Returns the value of attribute assets

Returns:

  • (Object)

    the current value of assets



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

def assets
  @assets
end

#published_atObject

Returns the value of attribute published_at

Returns:

  • (Object)

    the current value of published_at



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

def published_at
  @published_at
end

#tag_nameObject

Returns the value of attribute tag_name

Returns:

  • (Object)

    the current value of tag_name



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

def tag_name
  @tag_name
end

Class Method Details

.fetch_by_version(version) ⇒ Object



75
76
77
78
79
80
# File 'lib/pandoc_binary.rb', line 75

def fetch_by_version(version)
  uri = URI(URI_BASE % {version: version})
  json = Net::HTTP.get(uri)
  raw_release = JSON.parse(json, symbolize_names: true)
  return from_raw_data(raw_release)
end

.from_raw_data(raw_data) ⇒ Object



67
68
69
70
71
72
73
# File 'lib/pandoc_binary.rb', line 67

def from_raw_data(raw_data)
  result = super
  result.assets = raw_data[:assets].map { |raw_asset|
    Asset.from_raw_data(raw_asset)
  }
  return result
end

Instance Method Details

#asset_by_architecture(architecture) ⇒ Object



90
91
92
93
94
95
# File 'lib/pandoc_binary.rb', line 90

def asset_by_architecture(architecture)
  return assets.find { |asset|
    asset.name.end_with?(architecture.archive_suffix) &&
      asset.name.index(architecture.name)
  }
end