Sha256: b0500e634a329a14e470ed901f9b5b90084e237cf440800ecf10818393ff55ab

Contents?: true

Size: 819 Bytes

Versions: 3

Compression:

Stored size: 819 Bytes

Contents

# frozen_string_literal: true

module Thinreports
  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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
thinreports-0.12.1 lib/thinreports/layout/version.rb
thinreports-0.12.0 lib/thinreports/layout/version.rb
thinreports-0.11.0 lib/thinreports/layout/version.rb