Sha256: 09957415405d5ecb38455b149d062b92f3cd41fa581cecdda612cf4cb6124972

Contents?: true

Size: 902 Bytes

Versions: 5

Compression:

Stored size: 902 Bytes

Contents

# frozen_string_literal: true

module Thinreports
  module BasicReport
    module Layout
      class Version
        COMPATIBLE_RULES = ['>= 0.8.0', '< 1.0.0'].freeze
        NEW_SCHEMA_FROM = '0.9.0'

        class << self
          def compatible_rules
            COMPATIBLE_RULES
          end
        end

        def initialize(schema_version)
          @schema_version = normalize_version(schema_version)
        end

        def compatible?
          self.class.compatible_rules.all? do |rule|
            op, ver = rule.split(' ')
            schema_version.send(op.to_sym, normalize_version(ver))
          end
        end

        def legacy?
          @schema_version < normalize_version(NEW_SCHEMA_FROM)
        end

        private

        attr_reader :schema_version

        def normalize_version(version)
          Gem::Version.create(version)
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
thinreports-0.14.2 lib/thinreports/basic_report/layout/version.rb
thinreports-0.14.1 lib/thinreports/basic_report/layout/version.rb
thinreports-0.14.0 lib/thinreports/basic_report/layout/version.rb
thinreports-0.13.1 lib/thinreports/basic_report/layout/version.rb
thinreports-0.13.0 lib/thinreports/basic_report/layout/version.rb