Sha256: 0449ab50fd010f8cddfe965b7adaf983cdc2833b5d3592cb86809e7d3eac2c80

Contents?: true

Size: 1.34 KB

Versions: 4

Compression:

Stored size: 1.34 KB

Contents

module GemBench
  class StrictVersionGem
    attr_reader :name
    attr_reader :version
    attr_reader :version_type
    attr_reader :valid
    attr_reader :relevant_lines
    attr_reader :index
    attr_reader :tokenized_line

    class << self
      def from_line(all_lines, line, index, opts = {})
        tokenized_line = GemfileLineTokenizer.new(all_lines, line, index)
        return nil unless tokenized_line.is_gem
        new(
            tokenized_line.name,
            tokenized_line.version,
            tokenized_line.version_type,
            tokenized_line.valid,
            tokenized_line.relevant_lines,
            tokenized_line.index,
            opts[:debug] == true ? tokenized_line : nil
        )
      end
    end

    def initialize(name, version, version_type, valid, relevant_lines, index, tokenized_line = nil)
      @name = name
      @version = version
      @version_type = version_type ? version_type.to_sym : :unknown
      @valid = valid
      @relevant_lines = relevant_lines
      @index = index
      @tokenized_line = tokenized_line # for debugging
    end

    def valid?
      valid
    end

    def is_type?(type)
      version_type == type.to_sym
    end

    def to_s
      <<-EOS
Gem: #{name}
Line Number: #{index}
Version: #{version.inspect}
Relevant Gemfile Lines:
#{relevant_lines.join("\n")}
      EOS
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
gem_bench-1.0.5 lib/gem_bench/strict_version_gem.rb
gem_bench-1.0.4 lib/gem_bench/strict_version_gem.rb
gem_bench-1.0.3 lib/gem_bench/strict_version_gem.rb
gem_bench-1.0.2 lib/gem_bench/strict_version_gem.rb