Sha256: 901aa2c12486f55d44ebf881f757cf9f2f338160c2c4bd65fb332a6cab2289fb

Contents?: true

Size: 1.09 KB

Versions: 11

Compression:

Stored size: 1.09 KB

Contents

module EacLauncher
  module Ruby
    module Gem
      class Specification
        class << self
          def parse_version_file(file)
            s = ::File.read(file)
            m = /VERSION\s*=\s*[\'\"]([^\'\"]+)[\'\"]/.match(s)
            m ? m[1] : nil
          end
        end

        attr_reader :gemspec_file

        def initialize(gemspec_file)
          @gemspec_file = gemspec_file
        end

        def version
          v = self.class.parse_version_file(version_file)
          return v if v.present?
          raise "Version not found on file \"#{version_file}\""
        end

        def name
          ::File.basename(gemspec_file).gsub(/\.gemspec\z/, '')
        end

        def full_name
          "#{name}-#{version}"
        end

        def to_s
          full_name
        end

        private

        def gem_root
          ::File.dirname(gemspec_file)
        end

        def version_file
          f = ::File.join(gem_root, 'lib', name, 'version.rb')
          return f if ::File.exist?(f)
          raise "Version file \"#{f}\" does not exist"
        end
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
eac_launcher-0.5.0 lib/eac_launcher/ruby/gem/specification.rb
eac_launcher-0.4.0 lib/eac_launcher/ruby/gem/specification.rb
eac_launcher-0.3.2 lib/eac_launcher/ruby/gem/specification.rb
eac_launcher-0.3.1 lib/eac_launcher/ruby/gem/specification.rb
eac_launcher-0.3.0 lib/eac_launcher/ruby/gem/specification.rb
eac_launcher-0.2.2 lib/eac_launcher/ruby/gem/specification.rb
eac_launcher-0.2.1 lib/eac_launcher/ruby/gem/specification.rb
eac_launcher-0.2.0 lib/eac_launcher/ruby/gem/specification.rb
eac_launcher-0.1.7 lib/eac_launcher/ruby/gem/specification.rb
eac_launcher-0.1.6 lib/eac_launcher/ruby/gem/specification.rb
eac_launcher-0.1.5 lib/eac_launcher/ruby/gem/specification.rb