Class: Rake::Release::Spec

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/rake/release/spec.rb

Constant Summary collapse

EMPTY_STR =
''

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path = nil, namespace: nil, sign_tag: false) {|_self| ... } ⇒ Spec

Returns a new instance of Spec.

Yields:

  • (_self)

Yield Parameters:



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/rake/release/spec.rb', line 25

def initialize(path = nil, namespace: nil, sign_tag: false)
  path = Task.pwd.join(path.to_s).expand_path

  if path.directory?
    @base = path

    gemspecs = Dir[@base.join('*.gemspec')]

    raise 'Unable to determine gemspec file.' if gemspecs.size != 1

    @gemspec_path = Pathname.new gemspecs.first
  else
    @base = path.parent
    @gemspec_path = path
  end

  @gemspec = Bundler.load_gemspec @gemspec_path

  raise 'Cannot load gemspec' unless @gemspec

  @push_host = URI 'https://rubygems.org'

  unless @gemspec.['allowed_push_host'].to_s.empty?
    @push_host = URI @gemspec.['allowed_push_host']
  end

  @sign_tag = sign_tag
  @namespace = namespace
  @version_tag = "v#{version}"

  yield self if block_given?
end

Instance Attribute Details

#baseObject (readonly)

Returns the value of attribute base.



16
17
18
# File 'lib/rake/release/spec.rb', line 16

def base
  @base
end

#gemspecObject (readonly)

Returns the value of attribute gemspec.



17
18
19
# File 'lib/rake/release/spec.rb', line 17

def gemspec
  @gemspec
end

#gemspec_pathObject (readonly)

Returns the value of attribute gemspec_path.



18
19
20
# File 'lib/rake/release/spec.rb', line 18

def gemspec_path
  @gemspec_path
end

#namespaceObject

Returns the value of attribute namespace.



22
23
24
# File 'lib/rake/release/spec.rb', line 22

def namespace
  @namespace
end

#push_hostObject Also known as: host

Returns the value of attribute push_host.



19
20
21
# File 'lib/rake/release/spec.rb', line 19

def push_host
  @push_host
end

#sign_tagObject

Returns the value of attribute sign_tag.



21
22
23
# File 'lib/rake/release/spec.rb', line 21

def sign_tag
  @sign_tag
end

#version_tagObject

Returns the value of attribute version_tag.



23
24
25
# File 'lib/rake/release/spec.rb', line 23

def version_tag
  @version_tag
end

Class Method Details

.load(*args, &block) ⇒ Object



82
83
84
85
86
# File 'lib/rake/release/spec.rb', line 82

def load(*args, &block)
  new(*args, &block)
rescue RuntimeError
  nil
end

.scan(path = Task.pwd.join('*.gemspec')) ⇒ Object



88
89
90
91
92
93
# File 'lib/rake/release/spec.rb', line 88

def scan(path = Task.pwd.join('*.gemspec'))
  Pathname
    .glob(path)
    .map {|m| Rake::Release::Spec.load(m) }
    .reject(&:nil?)
end

Instance Method Details

#pkg_file_nameObject



73
74
75
# File 'lib/rake/release/spec.rb', line 73

def pkg_file_name
  @pkg_file_name ||= "#{name}-#{version}.gem"
end

#pkg_file_pathObject



77
78
79
# File 'lib/rake/release/spec.rb', line 77

def pkg_file_path
  @pkg_file_path ||= pkg_path.join pkg_file_name
end

#pkg_pathObject



69
70
71
# File 'lib/rake/release/spec.rb', line 69

def pkg_path
  @pkg_path ||= base.join 'pkg'
end

#push_host_nameObject



65
66
67
# File 'lib/rake/release/spec.rb', line 65

def push_host_name
  push_host.host.to_s
end