rake-release 0.3.1 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9b765b7e4a6fa595d55c6eb83b41562b32624fce
4
- data.tar.gz: 672abe5d9a19fe73061a7bdd46148222b4677b17
3
+ metadata.gz: 4c15844cf0ddcb1c04e6e96c6e7619549327f389
4
+ data.tar.gz: 488040f7a8e55d54fcbdd8a02030e6ba5ae83589
5
5
  SHA512:
6
- metadata.gz: d1418a8e642439637a45a2d52514519d052bd190451962d4d94041b03529b34782a44c3914ee8a66d6ea8c40acc5e80fdc1c1ab3dcf78c790c0d9026ab13936d
7
- data.tar.gz: 427aec58e984d2ed8bbba388e806077e05fab3f6869ca4ef229b24c9976384e95b7effa2d0a45a23b419a20c261aabc2aee91995a749936e0cb2f88560a66524
6
+ metadata.gz: 31df5bf0235d6a9c58f69b29a79d2d0f37934a016c414932d622b4739405f5a468bed692912bed509b933b4a3edae1f40750f15be188c1b0a7506d76c29fcfaf
7
+ data.tar.gz: ff35df37fc36b62c1f6aec9ccf1200d544d954f4a5450f567e1e31b75cd9d3448ff4e970840320890bbd8aa32ed5106fa24be5075680f6f22b890c7e9de2af30
data/lib/rake/release.rb CHANGED
@@ -7,23 +7,15 @@ require 'pathname'
7
7
  module Rake
8
8
  module Release
9
9
  class << self
10
- def pwd
11
- @pwd ||= Pathname.new Bundler::SharedHelpers.pwd
12
- end
13
-
14
- def ui
15
- @ui ||= Bundler::UI::Shell.new
16
- end
17
-
18
10
  def autodetect!
19
- specs = Spec.scan pwd.join '{*/*/,*/,}*.gemspec'
11
+ specs = Spec.scan Task.pwd.join '{*/*/,*/,}*.gemspec'
20
12
  specs.uniq! {|spec| spec.name }
21
13
 
22
14
  if specs.size == 1
23
- Task.new specs.first
15
+ Rake::Release::Task.new specs.first
24
16
  else
25
17
  specs.each do |spec|
26
- Task.new spec, namespace: spec.name
18
+ Rake::Release::Task.new spec, namespace: spec.name
27
19
  end
28
20
  end
29
21
  end
@@ -16,9 +16,10 @@ module Rake
16
16
  attr_reader :gemspec_path
17
17
 
18
18
  attr_accessor :namespace
19
+ attr_accessor :push_host
19
20
 
20
21
  def initialize(path, namespace: nil)
21
- path = Release.pwd.join(path.to_s).expand_path
22
+ path = Task.pwd.join(path.to_s).expand_path
22
23
 
23
24
  if path.directory?
24
25
  @base = path
@@ -38,18 +39,21 @@ module Rake
38
39
  @gemspec = Bundler.load_gemspec @gemspec_path
39
40
 
40
41
  raise RuntimeError.new 'Cannot load gemspec' unless @gemspec
41
- end
42
42
 
43
- def push_host
44
- @push_host ||= begin
45
- if @gemspec.metadata['allowed_push_host'].to_s.empty?
46
- @push_host = URI 'https://rubygems.org'
47
- else
48
- @push_host = URI @gemspec.metadata['allowed_push_host']
49
- end
43
+ @push_host = URI 'https://rubygems.org'
44
+
45
+ unless @gemspec.metadata['allowed_push_host'].to_s.empty?
46
+ @push_host = URI @gemspec.metadata['allowed_push_host']
50
47
  end
51
48
  end
52
49
 
50
+ def push_host=(value)
51
+ @push_host = URI value
52
+ end
53
+
54
+ alias_method :host, :push_host
55
+ alias_method :host=, :push_host=
56
+
53
57
  def push_host_name
54
58
  push_host.host.to_s
55
59
  end
@@ -73,11 +77,11 @@ module Rake
73
77
  class << self
74
78
  def load(*args, &block)
75
79
  new(*args, &block)
76
- rescue
80
+ rescue RuntimeError
77
81
  nil
78
82
  end
79
83
 
80
- def scan(path = Release.pwd.join('*.gemspec'))
84
+ def scan(path = Task.pwd.join('*.gemspec'))
81
85
  Pathname
82
86
  .glob(path)
83
87
  .map {|path| Rake::Release::Spec.load path }
@@ -15,7 +15,7 @@ module Rake
15
15
  def initialize(spec = nil, **kwargs, &block)
16
16
  @spec = spec || Rake::Release::Spec.new(**kwargs, &block)
17
17
 
18
- namespace = @spec.namespace || kwargs[:namespace]
18
+ namespace = kwargs[:namespace] || @spec.namespace
19
19
 
20
20
  if namespace
21
21
  send(:namespace, namespace) { setup }
@@ -85,7 +85,7 @@ module Rake
85
85
  @spec.pkg_path.mkpath
86
86
  FileUtils.mv @spec.pkg_file_name, @spec.pkg_path.join(@spec.pkg_file_name)
87
87
 
88
- Release.ui.confirm "#{@spec.name} #{@spec.version} built to #{@spec.pkg_path}."
88
+ Task.ui.confirm "#{@spec.name} #{@spec.version} built to #{@spec.pkg_path}."
89
89
  end
90
90
 
91
91
  def install(local: false)
@@ -94,7 +94,7 @@ module Rake
94
94
 
95
95
  sh! *cmd
96
96
 
97
- Release.ui.confirm "#{@spec.name} (#{@spec.version}) installed."
97
+ Task.ui.confirm "#{@spec.name} (#{@spec.version}) installed."
98
98
  end
99
99
 
100
100
  def publish
@@ -105,7 +105,7 @@ module Rake
105
105
 
106
106
  sh! *cmd
107
107
 
108
- Release.ui.confirm "Pushed #{@spec.pkg_file_name} to #{@spec.push_host}"
108
+ Task.ui.confirm "Pushed #{@spec.pkg_file_name} to #{@spec.push_host}"
109
109
  end
110
110
 
111
111
  def git_clean
@@ -127,11 +127,11 @@ module Rake
127
127
  def tag_version
128
128
  sh! 'git', 'tag', '-a', '-m', "Version #{@spec.version}", @spec.version_tag
129
129
 
130
- Release.ui.confirm "Tagged #{@spec.version_tag}."
130
+ Task.ui.confirm "Tagged #{@spec.version_tag}."
131
131
 
132
132
  yield if block_given?
133
133
  rescue
134
- Release.ui.error "Untagging #{@spec.version_tag} due to error."
134
+ Task.ui.error "Untagging #{@spec.version_tag} due to error."
135
135
 
136
136
  sh! 'git', 'tag', '-d', @spec.version_tag
137
137
 
@@ -145,7 +145,7 @@ module Rake
145
145
  return false
146
146
  end
147
147
 
148
- Release.ui.confirm "Tag #{@spec.version_tag} has already been created."
148
+ Task.ui.confirm "Tag #{@spec.version_tag} has already been created."
149
149
 
150
150
  true
151
151
  end
@@ -160,7 +160,7 @@ module Rake
160
160
  sh! *cmd
161
161
  sh! *cmd, '--tags'
162
162
 
163
- Release.ui.confirm 'Pushed git commits and tags.'
163
+ Task.ui.confirm 'Pushed git commits and tags.'
164
164
  end
165
165
 
166
166
  def publish?
@@ -185,7 +185,7 @@ module Rake
185
185
  def sh(*cmd, chdir: @spec.base, raise_error: true, &block)
186
186
  cmd = cmd.flatten.map(&:to_s)
187
187
 
188
- Release.ui.debug cmd
188
+ Task.ui.debug cmd
189
189
 
190
190
  Open3.popen2(*cmd, chdir: chdir) do |stdin, out, t|
191
191
  stdin.close
@@ -197,15 +197,31 @@ module Rake
197
197
  end
198
198
 
199
199
  class << self
200
- def load_all(dir = Release.pwd)
201
- specs = Spec.scan dir
200
+ def load_all(dir = self.pwd)
201
+ specs = Spec.scan dir.join('**/*.gemspec')
202
+
203
+ if specs.size > 1
204
+ specs.each {|spec| spec.namespace = spec.name }
205
+ end
202
206
 
203
207
  if block_given?
204
208
  specs.each(&Proc.new)
205
209
  end
206
210
 
211
+ if specs.uniq {|s| s.namespace.to_s.strip }.size != specs.size
212
+ raise RuntimeError.new 'Non distinct release task namespaces'
213
+ end
214
+
207
215
  specs.each {|spec| Task.new spec }
208
216
  end
217
+
218
+ def pwd
219
+ @pwd ||= Pathname.new Bundler::SharedHelpers.pwd
220
+ end
221
+
222
+ def ui
223
+ @ui ||= Bundler::UI::Shell.new
224
+ end
209
225
  end
210
226
  end
211
227
  end
data/rake-release.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = 'rake-release'
5
- spec.version = '0.3.1'
5
+ spec.version = '0.4.0'
6
6
  spec.authors = ['Jan Graichen']
7
7
  spec.email = ['jgraichen@altimos.de']
8
8
  spec.licenses = ['MIT']
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rake-release
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan Graichen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-21 00:00:00.000000000 Z
11
+ date: 2016-04-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler