Class: Gemsmith::Gem::Specification

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

Overview

A Gem::Specification with additional enhancements.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file_path) ⇒ Specification

Returns a new instance of Specification.



25
26
27
28
29
30
# File 'lib/gemsmith/gem/specification.rb', line 25

def initialize file_path
  @file_path = file_path
  @spec = self.class.specification.load file_path
  validate
  @version = Versionaire::Version @spec.version.to_s
end

Class Method Details

.default_gem_hostObject



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

def self.default_gem_host
  ::Gem::DEFAULT_HOST
end

.find(name, version) ⇒ Object



17
18
19
# File 'lib/gemsmith/gem/specification.rb', line 17

def self.find name, version
  specification.find_by_name name, version
end

.find_all(name, requirement: Gem::Requirement.new.to_s) ⇒ Object



21
22
23
# File 'lib/gemsmith/gem/specification.rb', line 21

def self.find_all name, requirement: Gem::Requirement.new.to_s
  specification.find_all_by_name name, requirement
end

.specificationObject



9
10
11
# File 'lib/gemsmith/gem/specification.rb', line 9

def self.specification
  ::Gem::Specification
end

Instance Method Details

#allowed_push_hostObject



48
49
50
# File 'lib/gemsmith/gem/specification.rb', line 48

def allowed_push_host
  spec..fetch("allowed_push_host") { self.class.default_gem_host }
end

#allowed_push_keyObject



44
45
46
# File 'lib/gemsmith/gem/specification.rb', line 44

def allowed_push_key
  spec..fetch("allowed_push_key") { "rubygems_api_key" }
end

#homepage_urlObject



40
41
42
# File 'lib/gemsmith/gem/specification.rb', line 40

def homepage_url
  String spec.homepage
end

#nameObject



32
33
34
# File 'lib/gemsmith/gem/specification.rb', line 32

def name
  spec.name
end

#package_file_nameObject



60
61
62
# File 'lib/gemsmith/gem/specification.rb', line 60

def package_file_name
  "#{name}-#{version_number}.gem"
end

#pathObject



36
37
38
# File 'lib/gemsmith/gem/specification.rb', line 36

def path
  spec.full_gem_path
end

#version_labelObject



56
57
58
# File 'lib/gemsmith/gem/specification.rb', line 56

def version_label
  version.label
end

#version_numberObject



52
53
54
# File 'lib/gemsmith/gem/specification.rb', line 52

def version_number
  version.to_s
end