rubygems-tasks 0.1.0.pre1
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +2 -0
- data/.rspec +1 -0
- data/.yardopts +1 -0
- data/ChangeLog.md +4 -0
- data/LICENSE.txt +20 -0
- data/README.md +112 -0
- data/Rakefile +35 -0
- data/gemspec.yml +14 -0
- data/lib/rubygems/tasks.rb +9 -0
- data/lib/rubygems/tasks/build.rb +3 -0
- data/lib/rubygems/tasks/build/gem.rb +58 -0
- data/lib/rubygems/tasks/build/tar.rb +49 -0
- data/lib/rubygems/tasks/build/task.rb +54 -0
- data/lib/rubygems/tasks/build/zip.rb +47 -0
- data/lib/rubygems/tasks/console.rb +73 -0
- data/lib/rubygems/tasks/install.rb +47 -0
- data/lib/rubygems/tasks/printing.rb +80 -0
- data/lib/rubygems/tasks/project.rb +113 -0
- data/lib/rubygems/tasks/push.rb +63 -0
- data/lib/rubygems/tasks/release.rb +49 -0
- data/lib/rubygems/tasks/scm.rb +3 -0
- data/lib/rubygems/tasks/scm/push.rb +56 -0
- data/lib/rubygems/tasks/scm/status.rb +67 -0
- data/lib/rubygems/tasks/scm/tag.rb +120 -0
- data/lib/rubygems/tasks/sign.rb +2 -0
- data/lib/rubygems/tasks/sign/checksum.rb +111 -0
- data/lib/rubygems/tasks/sign/pgp.rb +48 -0
- data/lib/rubygems/tasks/sign/task.rb +56 -0
- data/lib/rubygems/tasks/task.rb +141 -0
- data/lib/rubygems/tasks/tasks.rb +149 -0
- data/rubygems-tasks.gemspec +127 -0
- data/spec/spec_helper.rb +2 -0
- metadata +99 -0
@@ -0,0 +1,120 @@
|
|
1
|
+
require 'rubygems/tasks/task'
|
2
|
+
|
3
|
+
module Gem
|
4
|
+
class Tasks
|
5
|
+
module SCM
|
6
|
+
#
|
7
|
+
# The `scm:tag` task.
|
8
|
+
#
|
9
|
+
class Tag < Task
|
10
|
+
|
11
|
+
# Default format for versions
|
12
|
+
DEFAULT_FORMAT = '%s'
|
13
|
+
|
14
|
+
# The format for version tags.
|
15
|
+
#
|
16
|
+
# @return [String, Proc]
|
17
|
+
# The format String or Proc.
|
18
|
+
#
|
19
|
+
attr_accessor :format
|
20
|
+
|
21
|
+
#
|
22
|
+
# Initializes the `scm:tag` task.
|
23
|
+
#
|
24
|
+
# @param [Hash] options
|
25
|
+
# Additional options.
|
26
|
+
#
|
27
|
+
# @option options [String, Proc] :format (DEFAULT_FORMAT)
|
28
|
+
# The format String or Proc for version tags.
|
29
|
+
#
|
30
|
+
def initialize(options={})
|
31
|
+
super()
|
32
|
+
|
33
|
+
@format = options.fetch(:format,DEFAULT_FORMAT)
|
34
|
+
|
35
|
+
yield self if block_given?
|
36
|
+
define
|
37
|
+
end
|
38
|
+
|
39
|
+
#
|
40
|
+
# Defines the `scm:tag` task.
|
41
|
+
#
|
42
|
+
def define
|
43
|
+
namespace :scm do
|
44
|
+
task :tag, [:name] do |t,args|
|
45
|
+
tag = if args.name
|
46
|
+
args.name
|
47
|
+
else
|
48
|
+
version_tag(@project.gemspecs.values.first.version)
|
49
|
+
end
|
50
|
+
|
51
|
+
status "Tagging #{tag} ..."
|
52
|
+
|
53
|
+
unless tag!(tag)
|
54
|
+
error "Could not create tag #{tag}"
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
#
|
61
|
+
# Formats the version into a version tag.
|
62
|
+
#
|
63
|
+
# @param [String] version
|
64
|
+
# The version to be formatted.
|
65
|
+
#
|
66
|
+
# @return [String]
|
67
|
+
# The tag for the version.
|
68
|
+
#
|
69
|
+
# @raise [TypeError]
|
70
|
+
# {#format} was not a String or a Proc.
|
71
|
+
#
|
72
|
+
def version_tag(version)
|
73
|
+
case @format
|
74
|
+
when String
|
75
|
+
(@format % version)
|
76
|
+
when Proc
|
77
|
+
@format[version]
|
78
|
+
else
|
79
|
+
raise(TypeError,"tag format must be a String or Proc")
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
#
|
84
|
+
# Creates a tag.
|
85
|
+
#
|
86
|
+
# @param [String] name
|
87
|
+
# The name of the tag.
|
88
|
+
#
|
89
|
+
# @return [Boolean]
|
90
|
+
# Specifies whether the tag was successfully created.
|
91
|
+
#
|
92
|
+
def tag!(name)
|
93
|
+
case @project.scm
|
94
|
+
when :git then run 'git', 'tag', name
|
95
|
+
when :hg then run 'hg', 'tag', name
|
96
|
+
when :svn
|
97
|
+
branch = File.basename(@project.root)
|
98
|
+
tags_dir = if branch == 'trunk'
|
99
|
+
# we are in trunk/
|
100
|
+
File.join('..','tags')
|
101
|
+
else
|
102
|
+
# must be within branches/$name/
|
103
|
+
File.join('..','..','tags')
|
104
|
+
end
|
105
|
+
|
106
|
+
tag_dir = File.join(tag_dirs,name)
|
107
|
+
|
108
|
+
mkdir_p tags_dir
|
109
|
+
cp_r '.', tag_dir
|
110
|
+
|
111
|
+
return run('svn', 'add', tag_dir)
|
112
|
+
else
|
113
|
+
true
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
@@ -0,0 +1,111 @@
|
|
1
|
+
require 'rubygems/tasks/sign/task'
|
2
|
+
|
3
|
+
require 'digest'
|
4
|
+
|
5
|
+
module Gem
|
6
|
+
class Tasks
|
7
|
+
module Sign
|
8
|
+
#
|
9
|
+
# The `sign:checksum` task.
|
10
|
+
#
|
11
|
+
class Checksum < Task
|
12
|
+
|
13
|
+
# Enables or disables MD5 checksums.
|
14
|
+
attr_writer :md5
|
15
|
+
|
16
|
+
# Enables or disables SHA1 checksums.
|
17
|
+
attr_writer :sha1
|
18
|
+
|
19
|
+
# Enables or disables SHA2 checksums.
|
20
|
+
attr_writer :sha2
|
21
|
+
|
22
|
+
# Enables or disables SHA512 checksums.
|
23
|
+
attr_writer :sha512
|
24
|
+
|
25
|
+
#
|
26
|
+
# Initializes the `sign:checksum` task.
|
27
|
+
#
|
28
|
+
# @param [Hash] options
|
29
|
+
# Digest options.
|
30
|
+
#
|
31
|
+
# @option options [Boolean] :md5 (true)
|
32
|
+
# Specifies whether MD5 checksums are enabled.
|
33
|
+
#
|
34
|
+
# @option options [Boolean] :sha1 (true)
|
35
|
+
# Specifies whether SHA1 checksums are enabled.
|
36
|
+
#
|
37
|
+
# @option options [Boolean] :sha2 (false)
|
38
|
+
# Specifies whether SHA2 checksums are enabled.
|
39
|
+
#
|
40
|
+
# @option options [Boolean] :sha512 (false)
|
41
|
+
# Specifies whether SHA512 checksums are enabled.
|
42
|
+
#
|
43
|
+
def initialize(options={})
|
44
|
+
super()
|
45
|
+
|
46
|
+
@md5 = options.fetch(:md5, true)
|
47
|
+
@sha1 = options.fetch(:sha1, true)
|
48
|
+
@sha2 = options.fetch(:sha2, false)
|
49
|
+
@sha512 = options.fetch(:sha512,false)
|
50
|
+
|
51
|
+
yield self if block_given?
|
52
|
+
define
|
53
|
+
end
|
54
|
+
|
55
|
+
#
|
56
|
+
# Specifies whether MD5 checksums are enabled.
|
57
|
+
#
|
58
|
+
# @return [Boolean]
|
59
|
+
#
|
60
|
+
def md5?; @md5; end
|
61
|
+
|
62
|
+
#
|
63
|
+
# Specifies whether SHA1 checksums are enabled.
|
64
|
+
#
|
65
|
+
# @return [Boolean]
|
66
|
+
#
|
67
|
+
def sha1?; @sha1; end
|
68
|
+
|
69
|
+
#
|
70
|
+
# Specifies whether SHA2 checksums are enabled.
|
71
|
+
#
|
72
|
+
# @return [Boolean]
|
73
|
+
#
|
74
|
+
def sha2?; @sha2; end
|
75
|
+
|
76
|
+
#
|
77
|
+
# Specifies whether SHA512 checksums are enabled.
|
78
|
+
#
|
79
|
+
# @return [Boolean]
|
80
|
+
#
|
81
|
+
def sha512?; @sha512; end
|
82
|
+
|
83
|
+
#
|
84
|
+
# Defines the `sign:checksum` tasks.
|
85
|
+
#
|
86
|
+
def define
|
87
|
+
sign_task :checksum
|
88
|
+
task :checksum => 'sign:checksum'
|
89
|
+
end
|
90
|
+
|
91
|
+
#
|
92
|
+
# Prints the checksums of a package.
|
93
|
+
#
|
94
|
+
# @param [String] path
|
95
|
+
# The path to the package.
|
96
|
+
#
|
97
|
+
def sign(path)
|
98
|
+
status "Checksums for #{File.basename(path)}:"
|
99
|
+
|
100
|
+
puts
|
101
|
+
puts " md5: #{Digest::MD5.file(path)}" if @md5
|
102
|
+
puts " sha1: #{Digest::SHA1.file(path)}" if @sha1
|
103
|
+
puts " sha2: #{Digest::SHA2.file(path)}" if @sha2
|
104
|
+
puts " sha512: #{Digest::SHA512.file(path)}" if @sha512
|
105
|
+
puts
|
106
|
+
end
|
107
|
+
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'rubygems/tasks/sign/task'
|
2
|
+
|
3
|
+
module Gem
|
4
|
+
class Tasks
|
5
|
+
module Sign
|
6
|
+
#
|
7
|
+
# The `sign:pgp` task.
|
8
|
+
#
|
9
|
+
class PGP < Task
|
10
|
+
|
11
|
+
#
|
12
|
+
# Initializes the `sign` task.
|
13
|
+
#
|
14
|
+
# @param [Hash] options
|
15
|
+
# Digest options.
|
16
|
+
#
|
17
|
+
def initialize(options={})
|
18
|
+
super()
|
19
|
+
|
20
|
+
yield self if block_given?
|
21
|
+
define
|
22
|
+
end
|
23
|
+
|
24
|
+
#
|
25
|
+
# Defines the `sign:pgp` task.
|
26
|
+
#
|
27
|
+
def define
|
28
|
+
sign_task :pgp
|
29
|
+
|
30
|
+
task :pgp => 'sign:pgp'
|
31
|
+
end
|
32
|
+
|
33
|
+
#
|
34
|
+
# PGP signs a package.
|
35
|
+
#
|
36
|
+
# @param [String] path
|
37
|
+
# The path to the package.
|
38
|
+
#
|
39
|
+
def sign(path)
|
40
|
+
status "Signing #{File.basename(path)} ..."
|
41
|
+
|
42
|
+
run 'gpg', '--sign', path
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'rubygems/tasks/task'
|
2
|
+
|
3
|
+
require 'digest'
|
4
|
+
|
5
|
+
module Gem
|
6
|
+
class Tasks
|
7
|
+
module Sign
|
8
|
+
class Task < Tasks::Task
|
9
|
+
|
10
|
+
#
|
11
|
+
# Signs a package.
|
12
|
+
#
|
13
|
+
# @param [String] path
|
14
|
+
# The path to the package.
|
15
|
+
#
|
16
|
+
# @abstract
|
17
|
+
#
|
18
|
+
def sign(path)
|
19
|
+
end
|
20
|
+
|
21
|
+
protected
|
22
|
+
|
23
|
+
#
|
24
|
+
# Defines signing tasks for the various packages.
|
25
|
+
#
|
26
|
+
# @param [Symbol] name
|
27
|
+
# The name for the `sign:` task.
|
28
|
+
#
|
29
|
+
def sign_task(name)
|
30
|
+
@project.builds.each do |build,packages|
|
31
|
+
packages.each do |format,path|
|
32
|
+
namespace :sign do
|
33
|
+
namespace name do
|
34
|
+
namespace build do
|
35
|
+
task format => path do
|
36
|
+
sign(path)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
multi_task "sign:#{name}:#{build}", packages.keys
|
44
|
+
|
45
|
+
task "sign:#{name}" => "sign:#{name}:#{build}"
|
46
|
+
task "sign:#{build}" => "sign:#{name}:#{build}"
|
47
|
+
|
48
|
+
desc "Signs all packages" unless task?(:sign)
|
49
|
+
task :sign => "sign:#{name}:#{build}"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,141 @@
|
|
1
|
+
require 'rubygems/tasks/project'
|
2
|
+
require 'rubygems/tasks/printing'
|
3
|
+
|
4
|
+
require 'rake/tasklib'
|
5
|
+
|
6
|
+
module Gem
|
7
|
+
class Tasks
|
8
|
+
class Task < Rake::TaskLib
|
9
|
+
|
10
|
+
include Printing
|
11
|
+
|
12
|
+
def initialize
|
13
|
+
@project = Project.directories[Dir.pwd]
|
14
|
+
end
|
15
|
+
|
16
|
+
#
|
17
|
+
# The task name for the class.
|
18
|
+
#
|
19
|
+
# @return [String]
|
20
|
+
# The task name for the class.
|
21
|
+
#
|
22
|
+
# @api public
|
23
|
+
#
|
24
|
+
def self.task_name
|
25
|
+
@task_name ||= name.split('::').last.downcase
|
26
|
+
end
|
27
|
+
|
28
|
+
protected
|
29
|
+
|
30
|
+
#
|
31
|
+
# Runs a command.
|
32
|
+
#
|
33
|
+
# @param [String] command
|
34
|
+
# The command to run.
|
35
|
+
#
|
36
|
+
# @param [Array<String>] arguments
|
37
|
+
# Additional arguments for the command.
|
38
|
+
#
|
39
|
+
# @return [Boolean]
|
40
|
+
# Specifies whether the command was successful.
|
41
|
+
#
|
42
|
+
# @api semipublic
|
43
|
+
#
|
44
|
+
def run(command,*arguments)
|
45
|
+
show_command = [command, *arguments].join(' ')
|
46
|
+
|
47
|
+
debug show_command
|
48
|
+
|
49
|
+
unless system(command,*arguments)
|
50
|
+
error "Command failed: #{show_command}"
|
51
|
+
abort
|
52
|
+
end
|
53
|
+
|
54
|
+
return true
|
55
|
+
end
|
56
|
+
|
57
|
+
#
|
58
|
+
# Runs a `gem` command.
|
59
|
+
#
|
60
|
+
# @param [String] command
|
61
|
+
# The `gem` command to run.
|
62
|
+
#
|
63
|
+
# @param [Array<String>] command
|
64
|
+
# Additional arguments for the command.
|
65
|
+
#
|
66
|
+
# @return [Boolean]
|
67
|
+
# Specifies whether the command was successful.
|
68
|
+
#
|
69
|
+
# @api semipublic
|
70
|
+
#
|
71
|
+
def gem(command,*arguments)
|
72
|
+
run 'gem', command, *arguments
|
73
|
+
end
|
74
|
+
|
75
|
+
#
|
76
|
+
# Runs a `bundle` command.
|
77
|
+
#
|
78
|
+
# @param [String] command
|
79
|
+
# The `bundle` command to run.
|
80
|
+
#
|
81
|
+
# @param [Array<String>] arguments
|
82
|
+
# Additional arguments for the command.
|
83
|
+
#
|
84
|
+
# @return [Boolean]
|
85
|
+
# Specifies whether the command was successful.
|
86
|
+
#
|
87
|
+
# @api semipublic
|
88
|
+
#
|
89
|
+
def bundle(command,*arguments)
|
90
|
+
run 'bundler', command, *arguments
|
91
|
+
end
|
92
|
+
|
93
|
+
#
|
94
|
+
# Determines if a task was defined.
|
95
|
+
#
|
96
|
+
# @param [Symbol, String] name
|
97
|
+
# The task name to search for.
|
98
|
+
#
|
99
|
+
# @return [Boolean]
|
100
|
+
# Specifies whether the task was defined.
|
101
|
+
#
|
102
|
+
# @api semipublic
|
103
|
+
#
|
104
|
+
def task?(name)
|
105
|
+
Rake::Task.task_defined?(name)
|
106
|
+
end
|
107
|
+
|
108
|
+
#
|
109
|
+
# Defines a task that will invoke one or all of the specifies tasks
|
110
|
+
# within the namespace.
|
111
|
+
#
|
112
|
+
# @param [String] namespace
|
113
|
+
# The namespace of the sub-tasks to call.
|
114
|
+
#
|
115
|
+
# @param [Array<Symbol>] names
|
116
|
+
# The names of the sub-tasks.
|
117
|
+
#
|
118
|
+
# @example
|
119
|
+
# gemspec_tasks 'pkg:tar'
|
120
|
+
#
|
121
|
+
# @api semipublic
|
122
|
+
#
|
123
|
+
def multi_task(prefix,names)
|
124
|
+
task prefix => names.map { |name| "#{prefix}:#{name}" }
|
125
|
+
end
|
126
|
+
|
127
|
+
#
|
128
|
+
# Defines a task that will execute tasks for each gemspec.
|
129
|
+
#
|
130
|
+
# @param [Symbol, String] name
|
131
|
+
# The name for the task.
|
132
|
+
#
|
133
|
+
# @api semipublic
|
134
|
+
#
|
135
|
+
def gemspec_tasks(name)
|
136
|
+
multi_task name, @project.gemspecs.keys
|
137
|
+
end
|
138
|
+
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|