Class: Avm::Launcher::Ruby::Gem::Specification

Inherits:
Object
  • Object
show all
Defined in:
lib/avm/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.



20
21
22
# File 'lib/avm/launcher/ruby/gem/specification.rb', line 20

def initialize(gemspec_file)
  @gemspec_file = gemspec_file
end

Instance Attribute Details

#gemspec_fileObject (readonly)

Returns the value of attribute gemspec_file.



18
19
20
# File 'lib/avm/launcher/ruby/gem/specification.rb', line 18

def gemspec_file
  @gemspec_file
end

Class Method Details

.parse_version_file(file) ⇒ Object



11
12
13
14
15
# File 'lib/avm/launcher/ruby/gem/specification.rb', line 11

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



35
36
37
# File 'lib/avm/launcher/ruby/gem/specification.rb', line 35

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

#nameObject



31
32
33
# File 'lib/avm/launcher/ruby/gem/specification.rb', line 31

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

#to_sObject



39
40
41
# File 'lib/avm/launcher/ruby/gem/specification.rb', line 39

def to_s
  full_name
end

#versionObject



24
25
26
27
28
29
# File 'lib/avm/launcher/ruby/gem/specification.rb', line 24

def version
  v = self.class.parse_version_file(version_file)
  return v if v.present?

  raise "Version not found on file \"#{version_file}\""
end