Sha256: 0ef8fba52bb8da354ed43c7a270b50bd519412eeac498b0d2d95a323922e1884

Contents?: true

Size: 864 Bytes

Versions: 10

Compression:

Stored size: 864 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 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 exists?
          filename && File.exist?(filename)
        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

10 entries across 10 versions & 1 rubygems

Version Path
gem-release-2.0.4 lib/gem/release/context/gemspec.rb
gem-release-2.0.3 lib/gem/release/context/gemspec.rb
gem-release-2.0.2 lib/gem/release/context/gemspec.rb
gem-release-2.0.1 lib/gem/release/context/gemspec.rb
gem-release-2.0.0.rc.3 lib/gem/release/context/gemspec.rb
gem-release-2.0.0.rc.2 lib/gem/release/context/gemspec.rb
gem-release-2.0.0.rc.1 lib/gem/release/context/gemspec.rb
gem-release-2.0.0.dev.5 lib/gem/release/context/gemspec.rb
gem-release-2.0.0.dev.4 lib/gem/release/context/gemspec.rb
gem-release-2.0.0.dev.3 lib/gem/release/context/gemspec.rb