Class: EacLauncher::Ruby::Gem::Specification

Inherits:
Object
  • Object
show all
Defined in:
lib/eac_launcher/ruby/gem/specification.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(gemspec_file) ⇒ Specification

Returns a new instance of Specification.



15
16
17
# File 'lib/eac_launcher/ruby/gem/specification.rb', line 15

def initialize(gemspec_file)
  @gemspec_file = gemspec_file
end

Instance Attribute Details

#gemspec_fileObject (readonly)

Returns the value of attribute gemspec_file.



13
14
15
# File 'lib/eac_launcher/ruby/gem/specification.rb', line 13

def gemspec_file
  @gemspec_file
end

Class Method Details

.parse_version_file(file) ⇒ Object



6
7
8
9
10
# File 'lib/eac_launcher/ruby/gem/specification.rb', line 6

def parse_version_file(file)
  s = ::File.read(file)
  m = /VERSION\s*=\s*[\'\"]([^\'\"]+)[\'\"]/.match(s)
  m ? m[1] : nil
end

Instance Method Details

#full_nameObject



29
30
31
# File 'lib/eac_launcher/ruby/gem/specification.rb', line 29

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

#nameObject



25
26
27
# File 'lib/eac_launcher/ruby/gem/specification.rb', line 25

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

#versionObject



19
20
21
22
23
# File 'lib/eac_launcher/ruby/gem/specification.rb', line 19

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