version.rb 1013 Bytes
Newer Older
1 2 3
# frozen_string_literal: true

module Mastodon
4 5 6 7
  module Version
    module_function

    def major
8
      2
9 10 11
    end

    def minor
12
      9
13 14 15
    end

    def patch
16
      0
17 18 19
    end

    def pre
20
      nil
21 22
    end

Eugen Rochko's avatar
Eugen Rochko committed
23
    def flags
24
      'rc1'
Eugen Rochko's avatar
Eugen Rochko committed
25 26
    end

27 28 29 30 31
    def to_a
      [major, minor, patch, pre].compact
    end

    def to_s
Eugen Rochko's avatar
Eugen Rochko committed
32
      [to_a.join('.'), flags].join
33
    end
34

35
    def repository
36
      ENV.fetch('GITHUB_REPOSITORY') { 'tootsuite/mastodon' }
37 38
    end

39
    def source_base_url
40
      ENV.fetch('SOURCE_BASE_URL') { "https://github.com/#{repository}" }
41 42 43 44
    end

    # specify git tag or commit hash here
    def source_tag
45
      ENV.fetch('SOURCE_TAG') { nil }
46 47 48 49 50 51 52 53 54
    end

    def source_url
      if source_tag
        "#{source_base_url}/tree/#{source_tag}"
      else
        source_base_url
      end
    end
55 56 57 58

    def user_agent
      @user_agent ||= "#{HTTP::Request::USER_AGENT} (Mastodon/#{Version}; +http#{Rails.configuration.x.use_https ? 's' : ''}://#{Rails.configuration.x.web_domain}/)"
    end
59
  end
60
end