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
eac_tools-0.48.1 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/base/rubygems.rb
eac_tools-0.48.0 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/base/rubygems.rb
avm-eac_ruby_base1-0.27.3 lib/avm/eac_ruby_base1/sources/base/rubygems.rb
eac_tools-0.47.2 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/base/rubygems.rb
avm-eac_ruby_base1-0.27.2 lib/avm/eac_ruby_base1/sources/base/rubygems.rb
eac_tools-0.47.1 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/base/rubygems.rb
eac_tools-0.47.0 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/base/rubygems.rb
eac_tools-0.46.0 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/base/rubygems.rb
eac_tools-0.45.2 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/base/rubygems.rb
eac_tools-0.45.1 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/base/rubygems.rb
avm-eac_ruby_base1-0.27.1 lib/avm/eac_ruby_base1/sources/base/rubygems.rb
eac_tools-0.45.0 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/base/rubygems.rb
eac_tools-0.44.0 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/base/rubygems.rb
eac_tools-0.43.0 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/base/rubygems.rb
avm-eac_ruby_base1-0.27.0 lib/avm/eac_ruby_base1/sources/base/rubygems.rb
eac_tools-0.42.0 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/base/rubygems.rb
eac_tools-0.41.0 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/base/rubygems.rb
avm-eac_ruby_base1-0.26.2 lib/avm/eac_ruby_base1/sources/base/rubygems.rb
eac_tools-0.40.0 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/base/rubygems.rb
eac_tools-0.39.0 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/base/rubygems.rb