Sha256: 564b0b92e130e18df84d3dd483066e29978168df3e345fadb56bbc55db589256

Contents?: true

Size: 1014 Bytes

Versions: 11

Compression:

Stored size: 1014 Bytes

Contents

module Gem
  module Release
    class Context
      class Gemspec < Struct.new(:name)
        attr_reader :filename

        def initialize(*)
          super
          @filename = name && "#{name}.gemspec" || filenames.first
        end

        def exists?
          filename && File.exist?(filename)
        end

        def gem_name
          gemspec.name if gemspec
        end

        def version
          gemspec.version.to_s if gemspec
        end

        def gem_filename
          gemspec.file_name if gemspec
        end

        def metadata
          gemspec && gemspec.metadata || {}
        end

        def homepage
          gemspec.homepage if gemspec
        end

        private

          def gemspec
            return @gemspec if instance_variable_defined?(:@gemspec)
            @gemspec = exists? ? ::Gem::Specification.load(filename) : nil
          end

          def filenames
            Dir['*.gemspec'].map { |path| File.basename(path) }
          end
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
gem-release-2.2.4 lib/gem/release/context/gemspec.rb
gem-release-2.2.3 lib/gem/release/context/gemspec.rb
gem-release-2.2.3.alpha4 lib/gem/release/context/gemspec.rb
gem-release-2.2.3.alpha3 lib/gem/release/context/gemspec.rb
gem-release-2.2.3.alpha2 lib/gem/release/context/gemspec.rb
gem-release-2.2.3.alpha1 lib/gem/release/context/gemspec.rb
gem-release-2.2.2 lib/gem/release/context/gemspec.rb
gem-release-2.2.1 lib/gem/release/context/gemspec.rb
gem-release-2.2.0 lib/gem/release/context/gemspec.rb
gem-release-2.1.1 lib/gem/release/context/gemspec.rb
gem-release-2.1.0 lib/gem/release/context/gemspec.rb