Sha256: a5a01c18a843218966902bc942d284013e666c4eb6123c3376761eb76e5e5e08

Contents?: true

Size: 1.05 KB

Versions: 171

Compression:

Stored size: 1.05 KB

Contents

# frozen_string_literal: true

require 'avm/eac_generic_base0/sources/base'
require 'eac_ruby_utils/core_ext'

module Avm
  module EacRubyBase1
    module Sources
      class Base < ::Avm::EacGenericBase0::Sources::Base
        module Rubygems
          GEMSPEC_EXTNAME = '.gemspec'

          def gem_name
            gem_name_by_gemspec || gem_name_by_path
          end

          def gem_name_by_gemspec
            gemspec_path.if_present { |v| v.basename(GEMSPEC_EXTNAME).to_path }
          end

          def gem_name_by_path
            fullname = path.basename.to_s
            /\A(.+)(?:-\d+(?:\.\d+)*)\z/.if_match(fullname, false) { |m| m[1] }.if_present(fullname)
          end

          def gem_namespace_parts
            gem_name.split('-')
          end

          # @return [Gem::Specification]
          def gemspec
            ::Gem::Specification.load(gemspec_path.to_path)
          end

          # @return [Pathname]
          def gemspec_path
            path.glob("*#{GEMSPEC_EXTNAME}").first
          end
        end
      end
    end
  end
end

Version data entries

171 entries across 171 versions & 2 rubygems

Version Path
avm-eac_ruby_base1-0.35.1 lib/avm/eac_ruby_base1/sources/base/rubygems.rb
eac_tools-0.96.1 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/base/rubygems.rb
avm-eac_ruby_base1-0.35.0 lib/avm/eac_ruby_base1/sources/base/rubygems.rb
eac_tools-0.95.0 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/base/rubygems.rb
avm-eac_ruby_base1-0.34.1 lib/avm/eac_ruby_base1/sources/base/rubygems.rb
eac_tools-0.91.1 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/base/rubygems.rb
avm-eac_ruby_base1-0.34.0 lib/avm/eac_ruby_base1/sources/base/rubygems.rb
eac_tools-0.91.0 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/base/rubygems.rb
avm-eac_ruby_base1-0.33.1 lib/avm/eac_ruby_base1/sources/base/rubygems.rb
eac_tools-0.83.0 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/base/rubygems.rb
eac_tools-0.82.0 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/base/rubygems.rb
eac_tools-0.81.0 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/base/rubygems.rb
avm-eac_ruby_base1-0.33.0 lib/avm/eac_ruby_base1/sources/base/rubygems.rb
eac_tools-0.80.0 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/base/rubygems.rb
eac_tools-0.79.0 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/base/rubygems.rb
avm-eac_ruby_base1-0.32.1 lib/avm/eac_ruby_base1/sources/base/rubygems.rb
eac_tools-0.78.0 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/base/rubygems.rb
avm-eac_ruby_base1-0.32.0 lib/avm/eac_ruby_base1/sources/base/rubygems.rb
eac_tools-0.77.1 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/base/rubygems.rb
eac_tools-0.77.0 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/base/rubygems.rb