Skip to content

Commit

Permalink
Allow github macro as an alternative to git within Gemfile for strict…
Browse files Browse the repository at this point in the history
… version constraint analysis
  • Loading branch information
pboling committed Jun 5, 2017
1 parent fd57bb7 commit db64266
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
Version 1.0.5 - JUN.05.2017
* Allow github macro as an alternative to git within Gemfile for strict version constraint analysis

Version 1.0.3 - JUN.02.2017
* fixed accidental removal of loaded_gems in 1.0.2
* better documentation
Expand Down
14 changes: 13 additions & 1 deletion lib/gem_bench/gemfile_line_tokenizer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ class GemfileLineTokenizer
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
Expand Down Expand Up @@ -71,7 +72,7 @@ def determine_relevant_lines
def determine_version
version_path ||
(
version_git && (
(version_git || version_github) && (
check_for_version_of_type_git_ref ||
check_for_version_of_type_git_tag ||
check_for_version_of_type_git_branch
Expand Down Expand Up @@ -118,6 +119,17 @@ def version_git
)
end

def version_github
@version = {}
line = relevant_lines.detect { |next_line| (next_line.match(VERSION_GITHUB)) }
return false unless line
enhance_version(
line.match(VERSION_GITHUB),
:github,
:github
)
end

def check_for_version_of_type_git_ref
line = relevant_lines.detect { |next_line| (next_line.match(VERSION_GIT_REF)) }
return false unless line
Expand Down

0 comments on commit db64266

Please sign in to comment.