Class: ParseGemspec::Specification

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/parse_gemspec/specification.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(spec) ⇒ Specification

Returns a new instance of Specification.



14
15
16
# File 'lib/parse_gemspec/specification.rb', line 14

def initialize(spec)
  @spec = spec
end

Class Method Details

.load(file) ⇒ Object



7
8
9
10
11
12
# File 'lib/parse_gemspec/specification.rb', line 7

def self.load(file)
  fail GemspecFileNotFoundError, "file: #{file}" unless File.file?(file)
  spec = Gem::Specification.load(file)
  fail ParseGemspecError, "file: #{file}" unless spec
  new(spec)
end

Instance Method Details

#to_hash_objectObject

rubocop:disable Metrics/MethodLength



22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/parse_gemspec/specification.rb', line 22

def to_hash_object # rubocop:disable Metrics/MethodLength
  {
    name: name,
    version: version,
    authors: authors,
    description: description,
    email: email,
    homepage: homepage,
    licenses: licenses,
    metadata: ,
    summary: summary
  }
end

#versionObject



18
19
20
# File 'lib/parse_gemspec/specification.rb', line 18

def version
  @spec.version.version
end