diff --git a/Gemfile b/Gemfile index adaf808..84c4af5 100644 --- a/Gemfile +++ b/Gemfile @@ -2,12 +2,15 @@ source 'https://rubygems.org' -LOCAL_GEM_PATH = ENV.fetch('LOCAL_GEMS', '..') +AVAILABLE_LOCAL_GEMS = %w[ffi].freeze +LOCAL_GEM_PATH = ENV.fetch('LOCAL_GEM_PATH', '..') +LOCAL_GEMS = ENV.fetch('LOCAL_GEMS', AVAILABLE_LOCAL_GEMS.join(';')).split(/[,;]|\s+/) + def local_gem(gem_name, **options) options[:path] = "#{LOCAL_GEM_PATH}/#{gem_name}" if Dir.exist?("#{LOCAL_GEM_PATH}/#{gem_name}") gem gem_name, **options end -%w[ffi].each { |g| local_gem g } +(AVAILABLE_LOCAL_GEMS & LOCAL_GEMS).each { |g| local_gem(g) } gemspec diff --git a/lib/ffi/libfuse/gem_helper.rb b/lib/ffi/libfuse/gem_helper.rb index f731850..bdc916e 100644 --- a/lib/ffi/libfuse/gem_helper.rb +++ b/lib/ffi/libfuse/gem_helper.rb @@ -5,13 +5,6 @@ module FFI module Libfuse # @!visibility private class GemHelper - SEMVER_TAG_REGEX = /^v\d+\.\d+\.\d+/.freeze - - # branches the format is refs/heads/, - # tags it is refs/tags/. - # for pull requests it is refs/pull//merge, - GIT_REF_TYPES = { 'heads' => :branch, 'tags' => :tag, 'pull' => :pull }.freeze - class << self # set when install'd. attr_accessor :instance @@ -33,7 +26,7 @@ def git_ref(env: ENV) return [ref, nil] unless ref&.start_with?('refs/') _refs, ref_type, ref_name = ref.split('/', 3) - [ref_name, GIT_REF_TYPES[ref_type]] + [ref_name, { 'heads' => :branch, 'tags' => :tag, 'pull' => :pull }[ref_type]] end def gem_version(main_branch:, version:, env: ENV) @@ -44,7 +37,7 @@ def gem_version(main_branch:, version:, env: ENV) when :branch ref_name == main_branch ? [version] : [version, ref_name] when :tag - SEMVER_TAG_REGEX.match?(ref_name) ? [ref_name[1..]] : [version, ref_name] + /^v\d+\.\d+\.\d+/.match?(ref_name) ? [ref_name[1..]] : [version, ref_name] when :pull pr_number, merge, _rest = ref_name.split('/') # GITHUB_BASE_REF The name of the base ref or target branch of the pull request in a workflow run