2017-04-20 21:30:59 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
|
|
module Mastodon
|
2017-04-27 15:22:19 +02:00
|
|
|
module Version
|
2026-03-18 21:02:52 +09:00
|
|
|
# sakyey-forked version
|
|
|
|
|
module Sakyey
|
|
|
|
|
MAJOR = 1
|
|
|
|
|
MINOR = 0
|
|
|
|
|
PATCH = 0
|
|
|
|
|
PRE = nil
|
|
|
|
|
|
|
|
|
|
def self.to_s
|
|
|
|
|
base = [MAJOR, MINOR, PATCH].join('.')
|
|
|
|
|
PRE ? "#{base}-#{PRE}" : base
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# Mastodon + glitch
|
2017-04-27 15:22:19 +02:00
|
|
|
module_function
|
|
|
|
|
|
|
|
|
|
def major
|
2022-10-28 00:26:02 +02:00
|
|
|
4
|
2017-04-27 15:22:19 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def minor
|
2025-07-02 10:00:43 +02:00
|
|
|
5
|
2017-04-27 15:22:19 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def patch
|
2026-02-24 14:55:18 +01:00
|
|
|
7
|
2017-04-27 15:22:19 +02:00
|
|
|
end
|
|
|
|
|
|
2023-08-25 18:26:44 +02:00
|
|
|
def default_prerelease
|
2025-11-06 12:39:07 +01:00
|
|
|
''
|
2017-04-27 15:22:19 +02:00
|
|
|
end
|
|
|
|
|
|
2023-08-25 18:26:44 +02:00
|
|
|
def prerelease
|
2025-01-10 10:52:43 -05:00
|
|
|
version_configuration[:prerelease].presence || default_prerelease
|
2023-08-25 18:26:44 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def build_metadata
|
2026-03-18 21:02:52 +09:00
|
|
|
# version_configuration[:metadata]
|
|
|
|
|
"sakyey.#{Sakyey}.glitch"
|
2017-07-24 16:21:08 +02:00
|
|
|
end
|
|
|
|
|
|
2017-04-27 15:22:19 +02:00
|
|
|
def to_a
|
2019-07-26 01:57:27 -04:00
|
|
|
[major, minor, patch].compact
|
2017-04-27 15:22:19 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def to_s
|
2023-08-25 18:26:44 +02:00
|
|
|
components = [to_a.join('.')]
|
|
|
|
|
components << "-#{prerelease}" if prerelease.present?
|
|
|
|
|
components << "+#{build_metadata}" if build_metadata.present?
|
|
|
|
|
components.join
|
2017-04-27 15:22:19 +02:00
|
|
|
end
|
2017-08-22 20:54:19 +00:00
|
|
|
|
2023-09-01 17:47:07 +02:00
|
|
|
def gem_version
|
|
|
|
|
@gem_version ||= Gem::Version.new(to_s.split('+')[0])
|
|
|
|
|
end
|
|
|
|
|
|
2024-09-16 14:10:02 +02:00
|
|
|
def api_versions
|
|
|
|
|
{
|
2025-09-24 10:58:08 +02:00
|
|
|
mastodon: 7,
|
2026-01-27 22:30:17 +01:00
|
|
|
glitch: 1,
|
2024-09-16 14:10:02 +02:00
|
|
|
}
|
|
|
|
|
end
|
|
|
|
|
|
2018-07-28 19:25:33 +02:00
|
|
|
def repository
|
2025-01-14 09:32:29 -05:00
|
|
|
source_configuration[:repository]
|
2018-07-28 19:25:33 +02:00
|
|
|
end
|
|
|
|
|
|
2017-08-22 20:54:19 +00:00
|
|
|
def source_base_url
|
2025-01-14 09:32:29 -05:00
|
|
|
source_configuration[:base_url] || "https://github.com/#{repository}"
|
2017-08-22 20:54:19 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# specify git tag or commit hash here
|
|
|
|
|
def source_tag
|
2025-01-14 09:32:29 -05:00
|
|
|
source_configuration[:tag]
|
2017-08-22 20:54:19 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def source_url
|
|
|
|
|
if source_tag
|
|
|
|
|
"#{source_base_url}/tree/#{source_tag}"
|
|
|
|
|
else
|
|
|
|
|
source_base_url
|
|
|
|
|
end
|
|
|
|
|
end
|
2018-05-18 08:47:22 +09:00
|
|
|
|
2024-11-18 09:41:09 +01:00
|
|
|
def source_commit
|
|
|
|
|
ENV.fetch('SOURCE_COMMIT', nil)
|
|
|
|
|
end
|
|
|
|
|
|
2018-05-18 08:47:22 +09:00
|
|
|
def user_agent
|
2025-06-05 08:09:05 -04:00
|
|
|
@user_agent ||= "Mastodon/#{Version} (#{HTTP::Request::USER_AGENT}; +http#{'s' if Rails.configuration.x.use_https}://#{Rails.configuration.x.web_domain}/)"
|
2018-05-18 08:47:22 +09:00
|
|
|
end
|
2025-01-10 10:52:43 -05:00
|
|
|
|
|
|
|
|
def version_configuration
|
2025-01-14 09:32:29 -05:00
|
|
|
mastodon_configuration.version
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def source_configuration
|
|
|
|
|
mastodon_configuration.source
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def mastodon_configuration
|
|
|
|
|
Rails.configuration.x.mastodon
|
2025-01-10 10:52:43 -05:00
|
|
|
end
|
2017-04-27 15:22:19 +02:00
|
|
|
end
|
2017-04-20 21:30:59 -04:00
|
|
|
end
|