Class: GemBench::GemfileLineTokenizer
- Inherits:
-
Object
- Object
- GemBench::GemfileLineTokenizer
- Defined in:
- lib/gem_bench/gemfile_line_tokenizer.rb
Constant Summary collapse
- GEM_REGEX =
run against gem lines like: “gem ‘aftership’, # Ruby SDK of AfterShip API.”
/\A\s*gem\s+([^#]*).*\Z/.freeze
- GEM_NAME_REGEX =
run against gem lines like: “gem ‘aftership’, # Ruby SDK of AfterShip API.”
/\A\s*gem\s+['"]{1}(?<name>[^'"]*)['"].*\Z/.freeze
- VERSION_CONSTRAINT =
/['"]{1}([^'"]*)['"]/.freeze
- GEMFILE_HASH_CONFIG_KEY_REGEX_PROC =
->(key) { /\A\s*[^#]*(?<key1>#{key}: *)['"]{1}(?<value1>[^'"]*)['"]|(?<key2>['"]#{key}['"] *=> *)['"]{1}(?<value2>[^'"]*)['"]|(?<key3>:#{key} *=> *)['"]{1}(?<value3>[^'"]*)['"]/ }
- VERSION_PATH =
GEMFILE_HASH_CONFIG_KEY_REGEX_PROC.call('path').freeze
- VERSION_GIT =
GEMFILE_HASH_CONFIG_KEY_REGEX_PROC.call('git').freeze
- VERSION_GITHUB =
GEMFILE_HASH_CONFIG_KEY_REGEX_PROC.call('github').freeze
- VERSION_GIT_REF =
GEMFILE_HASH_CONFIG_KEY_REGEX_PROC.call('ref').freeze
- VERSION_GIT_TAG =
GEMFILE_HASH_CONFIG_KEY_REGEX_PROC.call('tag').freeze
- VERSION_GIT_BRANCH =
GEMFILE_HASH_CONFIG_KEY_REGEX_PROC.call('branch').freeze
- VALID_VERSION_TYPES =
%i( constraint git_ref git_tag )
Instance Attribute Summary collapse
-
#all_lines ⇒ Object
readonly
Returns the value of attribute all_lines.
-
#index ⇒ Object
readonly
Returns the value of attribute index.
-
#is_gem ⇒ Object
readonly
Returns the value of attribute is_gem.
-
#line ⇒ Object
readonly
branch is only valid if the branch is not master.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#parse_success ⇒ Object
readonly
Returns the value of attribute parse_success.
-
#relevant_lines ⇒ Object
readonly
Returns the value of attribute relevant_lines.
-
#tokens ⇒ Object
readonly
Returns the value of attribute tokens.
-
#valid ⇒ Object
readonly
Returns the value of attribute valid.
-
#version ⇒ Object
readonly
version will be a string if it is a normal constraint like ‘~> 1.2.3’ version will be a hash if it is an alternative constraint like: git: “blah/blah”, ref: “shasha”.
-
#version_type ⇒ Object
readonly
Returns the value of attribute version_type.
Instance Method Summary collapse
-
#initialize(all_lines, line, index) ⇒ GemfileLineTokenizer
constructor
A new instance of GemfileLineTokenizer.
Constructor Details
#initialize(all_lines, line, index) ⇒ GemfileLineTokenizer
Returns a new instance of GemfileLineTokenizer.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/gem_bench/gemfile_line_tokenizer.rb', line 33 def initialize(all_lines, line, index) @line = line.strip @is_gem = self.line.match(GEM_REGEX) if self.is_gem @all_lines = all_lines @index = index @tokens = self.line.split(',') determine_name if self.name determine_relevant_lines determine_version @parse_success = true @valid = VALID_VERSION_TYPES.include?(self.version_type) else noop end else noop end end |
Instance Attribute Details
#all_lines ⇒ Object (readonly)
Returns the value of attribute all_lines.
22 23 24 |
# File 'lib/gem_bench/gemfile_line_tokenizer.rb', line 22 def all_lines @all_lines end |
#index ⇒ Object (readonly)
Returns the value of attribute index.
23 24 25 |
# File 'lib/gem_bench/gemfile_line_tokenizer.rb', line 23 def index @index end |
#is_gem ⇒ Object (readonly)
Returns the value of attribute is_gem.
21 22 23 |
# File 'lib/gem_bench/gemfile_line_tokenizer.rb', line 21 def is_gem @is_gem end |
#line ⇒ Object (readonly)
branch is only valid if the branch is not master
19 20 21 |
# File 'lib/gem_bench/gemfile_line_tokenizer.rb', line 19 def line @line end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
30 31 32 |
# File 'lib/gem_bench/gemfile_line_tokenizer.rb', line 30 def name @name end |
#parse_success ⇒ Object (readonly)
Returns the value of attribute parse_success.
31 32 33 |
# File 'lib/gem_bench/gemfile_line_tokenizer.rb', line 31 def parse_success @parse_success end |
#relevant_lines ⇒ Object (readonly)
Returns the value of attribute relevant_lines.
20 21 22 |
# File 'lib/gem_bench/gemfile_line_tokenizer.rb', line 20 def relevant_lines @relevant_lines end |
#tokens ⇒ Object (readonly)
Returns the value of attribute tokens.
24 25 26 |
# File 'lib/gem_bench/gemfile_line_tokenizer.rb', line 24 def tokens @tokens end |
#valid ⇒ Object (readonly)
Returns the value of attribute valid.
32 33 34 |
# File 'lib/gem_bench/gemfile_line_tokenizer.rb', line 32 def valid @valid end |
#version ⇒ Object (readonly)
version will be a string if it is a normal constraint like ‘~> 1.2.3’ version will be a hash if it is an alternative constraint like: git: “blah/blah”, ref: “shasha”
28 29 30 |
# File 'lib/gem_bench/gemfile_line_tokenizer.rb', line 28 def version @version end |
#version_type ⇒ Object (readonly)
Returns the value of attribute version_type.
29 30 31 |
# File 'lib/gem_bench/gemfile_line_tokenizer.rb', line 29 def version_type @version_type end |