module Jekyll::Filters

Constants

PREFIX

Public Instance Methods

android_sdk_level_to_version(input) click to toggle source

Convert an Android SDK level into an Android version.

input - Android SDK Level.

Returns the Android version.

# File lib/jekyll/FDroidFilters.rb, line 25
def android_sdk_level_to_version(input)
  sdkLevel = @@AndroidSdkLevelToVersionRelation[input]
  if not sdkLevel.nil?
    return sdkLevel
  end
  return '?'
end
file_size_human_readable(input) click to toggle source

Convert a file size to a human-readable String. Source: codereview.stackexchange.com/q/9107

input - File size in Bytes.

Returns human-readable String.

# File lib/jekyll/FDroidFilters.rb, line 72
def file_size_human_readable(input)
  input = input.to_f
  i = PREFIX.length - 1
  while input > 512 && i > 0
    i -= 1
    input /= 1024
  end
  return ((input > 9 || input.modulo(1) < 0.1 ? '%d' : '%.1f') % input) + ' ' + PREFIX[i]
end
get_license_name(input) click to toggle source

Convert a SPDX license identifier to its full name.

input - SPDX license identifier.

Returns full license name.

# File lib/jekyll/FDroidFilters.rb, line 88
def get_license_name(input)
  if input.nil? or input.empty?
    return 'Unknown'
  end
  spdxLicense = @@SpdxLicenseNameToGnuUrlRelation[input]
  if input.end_with? "+"
    spdxLicense = @@SpdxLicenseNameToGnuUrlRelation[input.chomp('+')]
  end
  if not spdxLicense.nil?
    if input.end_with? "+"
      return spdxLicense['name'] + ' or later version'
    end
    return spdxLicense['name']
  end
  return input
end
get_license_url(input) click to toggle source

Convert a SPDX license identifier to its URL on GNU.org.

input - SPDX license identifier.

Returns URL on GNU.org.

# File lib/jekyll/FDroidFilters.rb, line 110
def get_license_url(input)
  if input.nil? or input.empty?
    return ''
  end
  if input.end_with? "+"
    input = input.chomp('+')
  end
  spdxLicense = @@SpdxLicenseNameToGnuUrlRelation[input]
  if not spdxLicense.nil?
    return spdxLicense['url']
  end
  return 'https://spdx.org/licenses/' + input + '.html'
end