rubygems-tasks 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog.md +34 -0
- data/README.md +2 -2
- data/gemspec.yml +1 -1
- data/lib/rubygems/tasks/build/gem.rb +3 -1
- data/lib/rubygems/tasks/build/tar.rb +2 -0
- data/lib/rubygems/tasks/build/task.rb +3 -1
- data/lib/rubygems/tasks/build/zip.rb +2 -0
- data/lib/rubygems/tasks/console.rb +6 -8
- data/lib/rubygems/tasks/install.rb +3 -1
- data/lib/rubygems/tasks/printing.rb +14 -0
- data/lib/rubygems/tasks/push.rb +6 -2
- data/lib/rubygems/tasks/scm/push.rb +5 -1
- data/lib/rubygems/tasks/scm/status.rb +29 -20
- data/lib/rubygems/tasks/scm/tag.rb +9 -1
- data/lib/rubygems/tasks/sign/checksum.rb +2 -0
- data/lib/rubygems/tasks/sign/pgp.rb +2 -0
- data/spec/console_spec.rb +6 -4
- data/spec/project_spec.rb +1 -1
- data/spec/scm/status_spec.rb +50 -0
- metadata +4 -2
data/ChangeLog.md
CHANGED
@@ -1,3 +1,37 @@
|
|
1
|
+
### 0.2.1 / 2012-04-29
|
2
|
+
|
3
|
+
* Overrode the `FileUtils.fu_output_message` to call
|
4
|
+
{Gem::Tasks::Printing#debug}.
|
5
|
+
* Added `@api semipublic` tags to mark the semi-public API.
|
6
|
+
* Fixed a spelling error.
|
7
|
+
|
8
|
+
#### console
|
9
|
+
|
10
|
+
* Infer the primary file to require from the gemspec name.
|
11
|
+
* No longer run `bundle console`, since it is not the same as running
|
12
|
+
`bundle exec irb -Ilib -rfoo/bar`.
|
13
|
+
|
14
|
+
#### scm:status
|
15
|
+
|
16
|
+
* Will display the human-readable status, if the repository is dirty.
|
17
|
+
* Hooks into the `validate` task.
|
18
|
+
|
19
|
+
#### scm:push
|
20
|
+
|
21
|
+
* Depends on the `validate` task.
|
22
|
+
|
23
|
+
#### scm:tag
|
24
|
+
|
25
|
+
* Depends on the `validate` task.
|
26
|
+
|
27
|
+
#### build:*
|
28
|
+
|
29
|
+
* All `build:*` tasks now depend on the `validate` task.
|
30
|
+
|
31
|
+
#### push
|
32
|
+
|
33
|
+
* Depends on the `validate` task.
|
34
|
+
|
1
35
|
### 0.2.0 / 2012-04-27
|
2
36
|
|
3
37
|
* Removed `Gem::Tasks::Task.task_name`.
|
data/README.md
CHANGED
@@ -68,7 +68,7 @@ Specifying an alternate Ruby Console to run:
|
|
68
68
|
Enable pushing gems to an in-house [RubyGems][2] server:
|
69
69
|
|
70
70
|
Gem::Tasks.new do |tasks|
|
71
|
-
tasks.push.host = 'gems.company.
|
71
|
+
tasks.push.host = 'gems.company.com'
|
72
72
|
end
|
73
73
|
|
74
74
|
Disable the `push` task:
|
@@ -85,9 +85,9 @@ Enable Checksums and PGP signatures for built packages:
|
|
85
85
|
|
86
86
|
Selectively defining tasks:
|
87
87
|
|
88
|
+
Gem::Build::Tar.new
|
88
89
|
Gem::SCM::Status.new
|
89
90
|
Gem::SCM::Tag.new(:format => 'REL-%s')
|
90
|
-
Gem::Build::Tar.new
|
91
91
|
Gem::Sign::Checksum.new
|
92
92
|
Gem::Console.new
|
93
93
|
|
data/gemspec.yml
CHANGED
@@ -46,10 +46,12 @@ module Gem
|
|
46
46
|
# @param [Gem::Specification] gemspec
|
47
47
|
# The gemspec to build the `.gem` package from.
|
48
48
|
#
|
49
|
+
# @api semipublic
|
50
|
+
#
|
49
51
|
def build(path,gemspec)
|
50
52
|
builder = ::Gem::Builder.new(gemspec)
|
51
53
|
|
52
|
-
|
54
|
+
mv builder.build, Project::PKG_DIR
|
53
55
|
end
|
54
56
|
|
55
57
|
end
|
@@ -33,6 +33,8 @@ module Gem
|
|
33
33
|
def build_task(name,extname=name)
|
34
34
|
directory Project::PKG_DIR
|
35
35
|
|
36
|
+
task :validate
|
37
|
+
|
36
38
|
@project.builds.each do |build,packages|
|
37
39
|
namespace :build do
|
38
40
|
namespace name do
|
@@ -40,7 +42,7 @@ module Gem
|
|
40
42
|
path = packages[extname]
|
41
43
|
|
42
44
|
# define file tasks, so the packages are not needless re-built
|
43
|
-
file(path => [Project::PKG_DIR, *gemspec.files]) do
|
45
|
+
file(path => [:validate, Project::PKG_DIR, *gemspec.files]) do
|
44
46
|
status "Building #{File.basename(path)} ..."
|
45
47
|
|
46
48
|
build(path,gemspec)
|
@@ -64,11 +64,13 @@ module Gem
|
|
64
64
|
# @return [Array<String>]
|
65
65
|
# The arguments for the console command.
|
66
66
|
#
|
67
|
+
# @api semipublic
|
68
|
+
#
|
67
69
|
def console(name=nil)
|
68
70
|
gemspec = @project.gemspec(name)
|
69
71
|
|
70
72
|
require_paths = gemspec.require_paths
|
71
|
-
require_file = gemspec.
|
73
|
+
require_file = gemspec.name.gsub('-',File::SEPARATOR)
|
72
74
|
|
73
75
|
arguments = [@command]
|
74
76
|
|
@@ -79,18 +81,14 @@ module Gem
|
|
79
81
|
arguments.push('-rrubygems') if RUBY_VERSION < '1.9'
|
80
82
|
|
81
83
|
# add an -r option to require the library
|
82
|
-
arguments.push('-r' + require_file
|
84
|
+
arguments.push('-r' + require_file)
|
83
85
|
|
84
86
|
# push on additional options
|
85
87
|
arguments.push(*@options)
|
86
88
|
|
87
89
|
if @project.bundler?
|
88
|
-
#
|
89
|
-
|
90
|
-
arguments = ['bundle', 'console']
|
91
|
-
else
|
92
|
-
arguments.unshift('bundle', 'exec')
|
93
|
-
end
|
90
|
+
# run under `bundle exec`
|
91
|
+
arguments.unshift('bundle', 'exec')
|
94
92
|
end
|
95
93
|
|
96
94
|
return run(*arguments)
|
@@ -49,7 +49,9 @@ module Gem
|
|
49
49
|
# The path to the `.gem` file.
|
50
50
|
#
|
51
51
|
# @return [Boolean]
|
52
|
-
# Specifies whether `gem install` was
|
52
|
+
# Specifies whether `gem install` was successful or not.
|
53
|
+
#
|
54
|
+
# @api semipublic
|
53
55
|
#
|
54
56
|
def install(path)
|
55
57
|
run 'gem', 'install', '-q', path
|
@@ -77,6 +77,20 @@ module Gem
|
|
77
77
|
$stderr.puts "#{ERROR_PREFIX} #{message}"
|
78
78
|
end
|
79
79
|
|
80
|
+
private
|
81
|
+
|
82
|
+
#
|
83
|
+
# The FileUtils output method.
|
84
|
+
#
|
85
|
+
# @param [String] message
|
86
|
+
# The FileUtils message to print.
|
87
|
+
#
|
88
|
+
# @since 0.2.1
|
89
|
+
#
|
90
|
+
def fu_output_message(message)
|
91
|
+
debug(message)
|
92
|
+
end
|
93
|
+
|
80
94
|
end
|
81
95
|
end
|
82
96
|
end
|
data/lib/rubygems/tasks/push.rb
CHANGED
@@ -32,11 +32,13 @@ module Gem
|
|
32
32
|
# Defines the `push` task.
|
33
33
|
#
|
34
34
|
def define
|
35
|
+
task :validate
|
36
|
+
|
35
37
|
namespace :push do
|
36
38
|
@project.builds.each do |build,packages|
|
37
39
|
path = packages[:gem]
|
38
40
|
|
39
|
-
task build => path do
|
41
|
+
task build => [:validate, path] do
|
40
42
|
if @host
|
41
43
|
status "Pushing #{File.basename(path)} to #{@host} ..."
|
42
44
|
else
|
@@ -61,7 +63,9 @@ module Gem
|
|
61
63
|
# The path to the `.gem` file.
|
62
64
|
#
|
63
65
|
# @return [Boolean]
|
64
|
-
# Specifies whether `gem push` was
|
66
|
+
# Specifies whether `gem push` was successful or not.
|
67
|
+
#
|
68
|
+
# @api semipublic
|
65
69
|
#
|
66
70
|
def push(path)
|
67
71
|
arguments = ['gem', 'push', path]
|
@@ -25,8 +25,10 @@ module Gem
|
|
25
25
|
# Defines the `scm:push` task.
|
26
26
|
#
|
27
27
|
def define
|
28
|
+
task :validate
|
29
|
+
|
28
30
|
namespace :scm do
|
29
|
-
task :push do
|
31
|
+
task :push => :validate do
|
30
32
|
status "Pushing commits ..."
|
31
33
|
|
32
34
|
unless push!
|
@@ -42,6 +44,8 @@ module Gem
|
|
42
44
|
# @return [Boolean]
|
43
45
|
# Specifies whether the commits were successfully pushed.
|
44
46
|
#
|
47
|
+
# @api semipublic
|
48
|
+
#
|
45
49
|
def push!
|
46
50
|
case @project.scm
|
47
51
|
when :git
|
@@ -27,41 +27,50 @@ module Gem
|
|
27
27
|
def define
|
28
28
|
namespace :scm do
|
29
29
|
task :status do
|
30
|
-
|
31
|
-
|
32
|
-
unless status.strip.empty?
|
30
|
+
if dirty?
|
33
31
|
error "Project has uncommitted changes!"
|
34
|
-
|
32
|
+
|
33
|
+
status
|
35
34
|
abort
|
36
35
|
end
|
37
36
|
end
|
38
37
|
end
|
39
38
|
|
40
|
-
#
|
41
|
-
task
|
42
|
-
|
43
|
-
# do not allow pushing commits when the repository is dirty
|
44
|
-
task 'scm:push' => 'scm:status'
|
39
|
+
# alias the `validate` task to scm:status
|
40
|
+
task :validate => 'scm:status'
|
41
|
+
end
|
45
42
|
|
46
|
-
|
47
|
-
|
43
|
+
#
|
44
|
+
# Checks the status of the project repository.
|
45
|
+
#
|
46
|
+
# @return [Boolean]
|
47
|
+
# Specifies whether the repository is dirty.
|
48
|
+
#
|
49
|
+
# @api semipublic
|
50
|
+
#
|
51
|
+
# @since 0.2.1
|
52
|
+
#
|
53
|
+
def dirty?
|
54
|
+
status = case @project.scm
|
55
|
+
when :git then `git status --porcelain --untracked-files=no`
|
56
|
+
when :hg then `hg status --quiet`
|
57
|
+
when :svn then `svn status --quiet`
|
58
|
+
else ''
|
59
|
+
end
|
48
60
|
|
49
|
-
|
50
|
-
task :push => 'scm:status'
|
61
|
+
return !status.chomp.empty?
|
51
62
|
end
|
52
63
|
|
53
64
|
#
|
54
|
-
#
|
65
|
+
# Displays the status of the project repository.
|
55
66
|
#
|
56
|
-
# @
|
57
|
-
# The status of the project repository.
|
67
|
+
# @api semipublic
|
58
68
|
#
|
59
69
|
def status
|
60
70
|
case @project.scm
|
61
|
-
when :git then
|
62
|
-
when :hg then
|
63
|
-
when :svn then
|
64
|
-
else ''
|
71
|
+
when :git then run 'git', 'status', '--untracked-files=no'
|
72
|
+
when :hg then run 'hg', 'status', '--quiet'
|
73
|
+
when :svn then run 'svn', 'status', '--quiet'
|
65
74
|
end
|
66
75
|
end
|
67
76
|
|
@@ -53,8 +53,10 @@ module Gem
|
|
53
53
|
# Defines the `scm:tag` task.
|
54
54
|
#
|
55
55
|
def define
|
56
|
+
task :validate
|
57
|
+
|
56
58
|
namespace :scm do
|
57
|
-
task :tag, [:name] do |t,args|
|
59
|
+
task :tag, [:name] => :validate do |t,args|
|
58
60
|
tag = if args.name
|
59
61
|
args.name
|
60
62
|
else
|
@@ -82,6 +84,8 @@ module Gem
|
|
82
84
|
# @raise [TypeError]
|
83
85
|
# {#format} was not a String or a Proc.
|
84
86
|
#
|
87
|
+
# @api semipublic
|
88
|
+
#
|
85
89
|
def version_tag(version)
|
86
90
|
case @format
|
87
91
|
when String
|
@@ -106,6 +110,8 @@ module Gem
|
|
106
110
|
# * Git: `git config user.signingkey`
|
107
111
|
# * Mercurial: `hg showconfig extensions hgext gpg`
|
108
112
|
#
|
113
|
+
# @api semipublic
|
114
|
+
#
|
109
115
|
# @since 0.2.0
|
110
116
|
#
|
111
117
|
def sign?
|
@@ -132,6 +138,8 @@ module Gem
|
|
132
138
|
# @return [Boolean]
|
133
139
|
# Specifies whether the tag was successfully created.
|
134
140
|
#
|
141
|
+
# @api semipublic
|
142
|
+
#
|
135
143
|
def tag!(name)
|
136
144
|
message = "Tagging #{name}"
|
137
145
|
|
data/spec/console_spec.rb
CHANGED
@@ -8,9 +8,9 @@ describe Gem::Tasks::Console do
|
|
8
8
|
include_context "rake"
|
9
9
|
|
10
10
|
if RUBY_VERSION < '1.9'
|
11
|
-
let(:default_options) { %w[-Ilib -rrubygems -rrubygems/tasks
|
11
|
+
let(:default_options) { %w[-Ilib -rrubygems -rrubygems/tasks] }
|
12
12
|
else
|
13
|
-
let(:default_options) { %w[-Ilib -rrubygems/tasks
|
13
|
+
let(:default_options) { %w[-Ilib -rrubygems/tasks] }
|
14
14
|
end
|
15
15
|
|
16
16
|
let(:custom_command) { 'ripl' }
|
@@ -24,9 +24,11 @@ describe Gem::Tasks::Console do
|
|
24
24
|
end
|
25
25
|
|
26
26
|
context "when project.bundler? == true" do
|
27
|
-
it "should use `bundle
|
27
|
+
it "should use `bundle exec`" do
|
28
28
|
subject.project.stub!(:bundler?).and_return(true)
|
29
|
-
subject.should_receive(:run).with(
|
29
|
+
subject.should_receive(:run).with(
|
30
|
+
'bundle', 'exec', 'irb', *default_options
|
31
|
+
)
|
30
32
|
|
31
33
|
subject.console
|
32
34
|
end
|
data/spec/project_spec.rb
CHANGED
@@ -110,7 +110,7 @@ describe Gem::Tasks::Project do
|
|
110
110
|
subject { rubygems_multi_project }
|
111
111
|
|
112
112
|
it "should group builds by gemspec name" do
|
113
|
-
subject.builds.keys.should
|
113
|
+
subject.builds.keys.should =~ subject.gemspecs.keys
|
114
114
|
end
|
115
115
|
|
116
116
|
it "should map a package format to a pkg/ path" do
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'rake_context'
|
3
|
+
|
4
|
+
require 'rubygems/tasks/scm/status'
|
5
|
+
|
6
|
+
describe Gem::Tasks::SCM::Status do
|
7
|
+
describe "#status" do
|
8
|
+
context "git" do
|
9
|
+
include_context "rake"
|
10
|
+
|
11
|
+
it "should run `git status --untracked-files=no`" do
|
12
|
+
subject.project.stub!(:scm).and_return(:git)
|
13
|
+
|
14
|
+
subject.should_receive(:run).with(
|
15
|
+
'git', 'status', '--untracked-files=no'
|
16
|
+
)
|
17
|
+
|
18
|
+
subject.status
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
context "hg" do
|
23
|
+
include_context "rake"
|
24
|
+
|
25
|
+
it "should run `hg status --quiet`" do
|
26
|
+
subject.project.stub!(:scm).and_return(:hg)
|
27
|
+
|
28
|
+
subject.should_receive(:run).with(
|
29
|
+
'hg', 'status', '--quiet'
|
30
|
+
)
|
31
|
+
|
32
|
+
subject.status
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
context "svn" do
|
37
|
+
include_context "rake"
|
38
|
+
|
39
|
+
it "should run `svn status --quiet`" do
|
40
|
+
subject.project.stub!(:scm).and_return(:svn)
|
41
|
+
|
42
|
+
subject.should_receive(:run).with(
|
43
|
+
'svn', 'status', '--quiet'
|
44
|
+
)
|
45
|
+
|
46
|
+
subject.status
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubygems-tasks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-04-
|
12
|
+
date: 2012-04-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
@@ -90,6 +90,7 @@ files:
|
|
90
90
|
- spec/push_spec.rb
|
91
91
|
- spec/rake_context.rb
|
92
92
|
- spec/scm/push_spec.rb
|
93
|
+
- spec/scm/status_spec.rb
|
93
94
|
- spec/scm/tag_spec.rb
|
94
95
|
- spec/spec_helper.rb
|
95
96
|
- spec/tasks_spec.rb
|
@@ -123,5 +124,6 @@ test_files:
|
|
123
124
|
- spec/project_spec.rb
|
124
125
|
- spec/push_spec.rb
|
125
126
|
- spec/scm/push_spec.rb
|
127
|
+
- spec/scm/status_spec.rb
|
126
128
|
- spec/scm/tag_spec.rb
|
127
129
|
- spec/tasks_spec.rb
|