Class: GemBench::StrictVersionGem
- Inherits:
-
Object
- Object
- GemBench::StrictVersionGem
- Defined in:
- lib/gem_bench/strict_version_gem.rb
Overview
Helps determine if a gem dependency is “valid” according to the strict rules of:
- every gem must have a version requirement of some sort
Instance Attribute Summary collapse
-
#index ⇒ Object
readonly
Returns the value of attribute index.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#relevant_lines ⇒ Object
readonly
Returns the value of attribute relevant_lines.
-
#tokenized_line ⇒ Object
readonly
Returns the value of attribute tokenized_line.
-
#valid ⇒ Object
readonly
Returns the value of attribute valid.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
-
#version_type ⇒ Object
readonly
Returns the value of attribute version_type.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name, version, version_type, valid, relevant_lines, index, tokenized_line = nil) ⇒ StrictVersionGem
constructor
A new instance of StrictVersionGem.
- #is_type?(type) ⇒ Boolean
- #to_s ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(name, version, version_type, valid, relevant_lines, index, tokenized_line = nil) ⇒ StrictVersionGem
Returns a new instance of StrictVersionGem.
24 25 26 27 28 29 30 31 32 |
# File 'lib/gem_bench/strict_version_gem.rb', line 24 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 |
Instance Attribute Details
#index ⇒ Object (readonly)
Returns the value of attribute index.
5 6 7 |
# File 'lib/gem_bench/strict_version_gem.rb', line 5 def index @index end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/gem_bench/strict_version_gem.rb', line 5 def name @name end |
#relevant_lines ⇒ Object (readonly)
Returns the value of attribute relevant_lines.
5 6 7 |
# File 'lib/gem_bench/strict_version_gem.rb', line 5 def relevant_lines @relevant_lines end |
#tokenized_line ⇒ Object (readonly)
Returns the value of attribute tokenized_line.
5 6 7 |
# File 'lib/gem_bench/strict_version_gem.rb', line 5 def tokenized_line @tokenized_line end |
#valid ⇒ Object (readonly)
Returns the value of attribute valid.
5 6 7 |
# File 'lib/gem_bench/strict_version_gem.rb', line 5 def valid @valid end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
5 6 7 |
# File 'lib/gem_bench/strict_version_gem.rb', line 5 def version @version end |
#version_type ⇒ Object (readonly)
Returns the value of attribute version_type.
5 6 7 |
# File 'lib/gem_bench/strict_version_gem.rb', line 5 def version_type @version_type end |
Class Method Details
.from_line(all_lines, line, index, opts = {}) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/gem_bench/strict_version_gem.rb', line 8 def from_line(all_lines, line, index, opts = {}) tokenized_line = GemfileLineTokenizer.new(all_lines, line, index) return unless tokenized_line.parse_success 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 |
Instance Method Details
#is_type?(type) ⇒ Boolean
38 39 40 |
# File 'lib/gem_bench/strict_version_gem.rb', line 38 def is_type?(type) version_type == type.to_sym end |
#to_s ⇒ Object
42 43 44 45 46 47 48 49 50 |
# File 'lib/gem_bench/strict_version_gem.rb', line 42 def to_s <<~EOS Gem: #{name} Line Number: #{index} Version: #{version.inspect} Relevant Gemfile Lines: #{relevant_lines.join("\n")} EOS end |
#valid? ⇒ Boolean
34 35 36 |
# File 'lib/gem_bench/strict_version_gem.rb', line 34 def valid? valid end |