rubygems-tasks 0.2.5 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +31 -0
  3. data/.gitignore +4 -2
  4. data/ChangeLog.md +20 -0
  5. data/Gemfile +12 -0
  6. data/LICENSE.txt +1 -1
  7. data/README.md +114 -80
  8. data/Rakefile +6 -20
  9. data/gemspec.yml +13 -5
  10. data/lib/rubygems/tasks/build/gem.rb +5 -6
  11. data/lib/rubygems/tasks/build/tar.rb +5 -6
  12. data/lib/rubygems/tasks/build/task.rb +4 -2
  13. data/lib/rubygems/tasks/build/zip.rb +5 -6
  14. data/lib/rubygems/tasks/build.rb +61 -3
  15. data/lib/rubygems/tasks/console.rb +13 -10
  16. data/lib/rubygems/tasks/install.rb +4 -5
  17. data/lib/rubygems/tasks/printing.rb +2 -0
  18. data/lib/rubygems/tasks/project.rb +3 -1
  19. data/lib/rubygems/tasks/push.rb +20 -7
  20. data/lib/rubygems/tasks/release.rb +4 -5
  21. data/lib/rubygems/tasks/scm/push.rb +5 -6
  22. data/lib/rubygems/tasks/scm/status.rb +5 -6
  23. data/lib/rubygems/tasks/scm/tag.rb +9 -12
  24. data/lib/rubygems/tasks/scm.rb +52 -3
  25. data/lib/rubygems/tasks/sign/checksum.rb +21 -14
  26. data/lib/rubygems/tasks/sign/pgp.rb +5 -6
  27. data/lib/rubygems/tasks/sign/task.rb +4 -2
  28. data/lib/rubygems/tasks/sign.rb +42 -2
  29. data/lib/rubygems/tasks/task.rb +11 -3
  30. data/lib/rubygems/tasks.rb +67 -66
  31. data/rubygems-tasks.gemspec +1 -0
  32. data/spec/build_spec.rb +72 -0
  33. data/spec/console_spec.rb +45 -18
  34. data/spec/install_spec.rb +5 -1
  35. data/spec/project_spec.rb +19 -19
  36. data/spec/push_spec.rb +15 -3
  37. data/spec/scm/push_spec.rb +6 -6
  38. data/spec/scm/status_spec.rb +8 -12
  39. data/spec/scm/tag_spec.rb +18 -28
  40. data/spec/scm_spec.rb +72 -0
  41. data/spec/sign/pgp_spec.rb +1 -1
  42. data/spec/sign_spec.rb +52 -0
  43. data/spec/tasks_spec.rb +18 -191
  44. metadata +32 -26
@@ -1,4 +1,6 @@
1
- require 'rubygems/tasks/task'
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'task'
2
4
 
3
5
  module Gem
4
6
  class Tasks
@@ -8,21 +10,31 @@ module Gem
8
10
  class Push < Task
9
11
 
10
12
  # The rubygems host to push gems to.
13
+ #
14
+ # @return [String, nil]
11
15
  attr_accessor :host
12
16
 
17
+ # The rubygems API key.
13
18
  #
14
- # Initializes the `push` task.
19
+ # @return [String, nil]
15
20
  #
16
- # @param [Hash] options
17
- # Additional options.
21
+ # @since 0.3.0
22
+ attr_accessor :key
23
+
18
24
  #
19
- # @option options [String] :host
25
+ # Initializes the `push` task.
26
+ #
27
+ # @param [String, nil] host
20
28
  # The rubygems host to push gems to.
21
29
  #
22
- def initialize(options={})
30
+ # @param [String, nil] key
31
+ # An optional rubygems API key.
32
+ #
33
+ def initialize(host: nil, key: nil)
23
34
  super()
24
35
 
25
- @host = options[:host]
36
+ @host = host
37
+ @key = key
26
38
 
27
39
  yield self if block_given?
28
40
  define
@@ -69,6 +81,7 @@ module Gem
69
81
  #
70
82
  def push(path)
71
83
  arguments = ['gem', 'push', path]
84
+ arguments.push('--key', @key) if @key
72
85
  arguments.push('--host', @host) if @host
73
86
 
74
87
  return run(*arguments)
@@ -1,4 +1,6 @@
1
- require 'rubygems/tasks/task'
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'task'
2
4
 
3
5
  module Gem
4
6
  class Tasks
@@ -10,10 +12,7 @@ module Gem
10
12
  #
11
13
  # Initializes the `release` task.
12
14
  #
13
- # @param [Hash] options
14
- # Additional options for the `release` task.
15
- #
16
- def initialize(options={})
15
+ def initialize
17
16
  super()
18
17
 
19
18
  yield self if block_given?
@@ -1,8 +1,10 @@
1
- require 'rubygems/tasks/task'
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../task'
2
4
 
3
5
  module Gem
4
6
  class Tasks
5
- module SCM
7
+ class SCM
6
8
  #
7
9
  # The `scm:push` task.
8
10
  #
@@ -11,10 +13,7 @@ module Gem
11
13
  #
12
14
  # Initializes the `scm:push` task.
13
15
  #
14
- # @param [Hash] options
15
- # Additional options.
16
- #
17
- def initialize(options={})
16
+ def initialize
18
17
  super()
19
18
 
20
19
  yield self if block_given?
@@ -1,8 +1,10 @@
1
- require 'rubygems/tasks/task'
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../task'
2
4
 
3
5
  module Gem
4
6
  class Tasks
5
- module SCM
7
+ class SCM
6
8
  #
7
9
  # The `scm:status` task.
8
10
  #
@@ -11,10 +13,7 @@ module Gem
11
13
  #
12
14
  # Initializes the `status` task.
13
15
  #
14
- # @param [Hash] options
15
- # Additional options.
16
- #
17
- def initialize(options={})
16
+ def initialize
18
17
  super()
19
18
 
20
19
  yield self if block_given?
@@ -1,8 +1,10 @@
1
- require 'rubygems/tasks/task'
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../task'
2
4
 
3
5
  module Gem
4
6
  class Tasks
5
- module SCM
7
+ class SCM
6
8
  #
7
9
  # The `scm:tag` task.
8
10
  #
@@ -15,7 +17,6 @@ module Gem
15
17
  #
16
18
  # @return [String, Proc]
17
19
  # The format String or Proc.
18
- #
19
20
  attr_accessor :format
20
21
 
21
22
  # Enables or disables PGP signing of tags.
@@ -24,26 +25,22 @@ module Gem
24
25
  # The new value.
25
26
  #
26
27
  # @since 0.2.0
27
- #
28
28
  attr_writer :sign
29
29
 
30
30
  #
31
31
  # Initializes the `scm:tag` task.
32
32
  #
33
- # @param [Hash] options
34
- # Additional options.
35
- #
36
- # @option options [String, Proc] :format (DEFAULT_FORMAT)
33
+ # @param [String, Proc] format
37
34
  # The format String or Proc for version tags.
38
35
  #
39
- # @option options [Boolean] :sign
36
+ # @param [Boolean] sign
40
37
  # Enables PGP signing of tags.
41
38
  #
42
- def initialize(options={})
39
+ def initialize(format: DEFAULT_FORMAT, sign: nil)
43
40
  super()
44
41
 
45
- @format = options.fetch(:format,DEFAULT_FORMAT)
46
- @sign = options[:sign]
42
+ @format = format
43
+ @sign = sign
47
44
 
48
45
  yield self if block_given?
49
46
  define
@@ -1,3 +1,52 @@
1
- require 'rubygems/tasks/scm/status'
2
- require 'rubygems/tasks/scm/tag'
3
- require 'rubygems/tasks/scm/push'
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'scm/status'
4
+ require_relative 'scm/tag'
5
+ require_relative 'scm/push'
6
+
7
+ module Gem
8
+ class Tasks
9
+ class SCM
10
+
11
+ # The {Status scm:status} task.
12
+ #
13
+ # @return [Status, nil]
14
+ #
15
+ # @since 0.3.0
16
+ attr_reader :status
17
+
18
+ # The {Tag scm:tag} task.
19
+ #
20
+ # @return [Tag, nil]
21
+ #
22
+ # @since 0.3.0
23
+ attr_reader :tag
24
+
25
+ # The {Push scm:push} task.
26
+ #
27
+ # @return [Push, nil]
28
+ #
29
+ # @since 0.3.0
30
+ attr_reader :push
31
+
32
+ #
33
+ # Initializes the `scm:*` tasks.
34
+ #
35
+ # @param [Boolean] status
36
+ # Enables or disables the {SCM::Status scm:status} task.
37
+ #
38
+ # @param [Boolean] tag
39
+ # Enables or disables the {SCM::Tag scm:tag} task.
40
+ #
41
+ # @param [Boolean] push
42
+ # Enables or disables the {SCM::Push scm:push} task.
43
+ #
44
+ def initialize(status: true, tag: true, push: true)
45
+ @status = (Status.new if status)
46
+ @tag = (Tag.new if tag)
47
+ @push = (Push.new if push)
48
+ end
49
+
50
+ end
51
+ end
52
+ end
@@ -1,52 +1,59 @@
1
- require 'rubygems/tasks/sign/task'
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'task'
2
4
 
3
5
  require 'digest'
4
6
 
5
7
  module Gem
6
8
  class Tasks
7
- module Sign
9
+ class Sign
8
10
  #
9
11
  # The `sign:checksum` task.
10
12
  #
11
13
  class Checksum < Task
12
14
 
13
15
  # Enables or disables MD5 checksums.
16
+ #
17
+ # @return [Boolean]
14
18
  attr_writer :md5
15
19
 
16
20
  # Enables or disables SHA1 checksums.
21
+ #
22
+ # @return [Boolean]
17
23
  attr_writer :sha1
18
24
 
19
25
  # Enables or disables SHA2 checksums.
26
+ #
27
+ # @return [Boolean]
20
28
  attr_writer :sha2
21
29
 
22
30
  # Enables or disables SHA512 checksums.
31
+ #
32
+ # @return [Boolean]
23
33
  attr_writer :sha512
24
34
 
25
35
  #
26
36
  # Initializes the `sign:checksum` task.
27
37
  #
28
- # @param [Hash] options
29
- # Digest options.
30
- #
31
- # @option options [Boolean] :md5 (true)
38
+ # @param [Boolean] md5
32
39
  # Specifies whether MD5 checksums are enabled.
33
40
  #
34
- # @option options [Boolean] :sha1 (true)
41
+ # @param [Boolean] sha1
35
42
  # Specifies whether SHA1 checksums are enabled.
36
43
  #
37
- # @option options [Boolean] :sha2 (false)
44
+ # @param [Boolean] sha2
38
45
  # Specifies whether SHA2 checksums are enabled.
39
46
  #
40
- # @option options [Boolean] :sha512 (false)
47
+ # @param [Boolean] sha512
41
48
  # Specifies whether SHA512 checksums are enabled.
42
49
  #
43
- def initialize(options={})
50
+ def initialize(md5: true, sha1: true, sha2: false, sha512: false)
44
51
  super()
45
52
 
46
- @md5 = options.fetch(:md5, true)
47
- @sha1 = options.fetch(:sha1, true)
48
- @sha2 = options.fetch(:sha2, false)
49
- @sha512 = options.fetch(:sha512,false)
53
+ @md5 = md5
54
+ @sha1 = sha1
55
+ @sha2 = sha2
56
+ @sha512 = sha512
50
57
 
51
58
  yield self if block_given?
52
59
  define
@@ -1,8 +1,10 @@
1
- require 'rubygems/tasks/sign/task'
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'task'
2
4
 
3
5
  module Gem
4
6
  class Tasks
5
- module Sign
7
+ class Sign
6
8
  #
7
9
  # The `sign:pgp` task.
8
10
  #
@@ -11,10 +13,7 @@ module Gem
11
13
  #
12
14
  # Initializes the `sign` task.
13
15
  #
14
- # @param [Hash] options
15
- # Digest options.
16
- #
17
- def initialize(options={})
16
+ def initialize
18
17
  super()
19
18
 
20
19
  yield self if block_given?
@@ -1,10 +1,12 @@
1
- require 'rubygems/tasks/task'
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../task'
2
4
 
3
5
  require 'digest'
4
6
 
5
7
  module Gem
6
8
  class Tasks
7
- module Sign
9
+ class Sign
8
10
  class Task < Tasks::Task
9
11
 
10
12
  #
@@ -1,2 +1,42 @@
1
- require 'rubygems/tasks/sign/checksum'
2
- require 'rubygems/tasks/sign/pgp'
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'sign/checksum'
4
+ require_relative 'sign/pgp'
5
+
6
+ module Gem
7
+ class Tasks
8
+ class Sign
9
+
10
+ # The {Checksum sign:checksum} task.
11
+ #
12
+ # @return [Checksum, nil]
13
+ #
14
+ # @since 0.3.0
15
+ attr_reader :checksum
16
+
17
+ # The {PGP sign:pgp} task.
18
+ #
19
+ # @return [PGP, nil]
20
+ #
21
+ # @since 0.3.0
22
+ attr_reader :pgp
23
+
24
+ #
25
+ # Initializes the `scm:*` tasks.
26
+ #
27
+ # @param [Boolean] checksum
28
+ # Enables or disables the {Checksum sign:checksum} task.
29
+ #
30
+ # @param [Boolean] pgp
31
+ # Enables or disables the {PGP sign:pgp} task.
32
+ #
33
+ # @since 0.3.0
34
+ #
35
+ def initialize(checksum: nil, pgp: nil)
36
+ @checksum = (Checksum.new if checksum)
37
+ @pgp = (PGP.new if pgp)
38
+ end
39
+
40
+ end
41
+ end
42
+ end
@@ -1,5 +1,7 @@
1
- require 'rubygems/tasks/project'
2
- require 'rubygems/tasks/printing'
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'project'
4
+ require_relative 'printing'
3
5
 
4
6
  require 'rake/tasklib'
5
7
 
@@ -67,7 +69,13 @@ module Gem
67
69
  # @api semipublic
68
70
  #
69
71
  def gem(command,*arguments)
70
- run 'gem', command, *arguments
72
+ if defined?(Bundler)
73
+ Bundler.with_original_env do
74
+ run 'gem', command, *arguments
75
+ end
76
+ else
77
+ run 'gem', command, *arguments
78
+ end
71
79
  end
72
80
 
73
81
  #
@@ -1,13 +1,14 @@
1
- require 'rubygems/tasks/console'
2
- require 'rubygems/tasks/build'
3
- require 'rubygems/tasks/install'
4
- require 'rubygems/tasks/scm'
5
- require 'rubygems/tasks/push'
6
- require 'rubygems/tasks/release'
7
- require 'rubygems/tasks/sign'
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'tasks/console'
4
+ require_relative 'tasks/build'
5
+ require_relative 'tasks/install'
6
+ require_relative 'tasks/scm'
7
+ require_relative 'tasks/push'
8
+ require_relative 'tasks/release'
9
+ require_relative 'tasks/sign'
8
10
 
9
11
  require 'rake/tasklib'
10
- require 'ostruct'
11
12
 
12
13
  module Gem
13
14
  #
@@ -28,28 +29,19 @@ module Gem
28
29
  #
29
30
  class Tasks
30
31
 
32
+ # The {Build build:\*} tasks.
31
33
  #
32
- # The `build` tasks.
33
- #
34
- # @return [OpenStruct]
35
- # The collection of `build` tasks.
36
- #
34
+ # @return [Build]
37
35
  attr_reader :build
38
36
 
37
+ # The {SCM scm:\*} tasks.
39
38
  #
40
- # The `scm` tasks.
41
- #
42
- # @return [OpenStruct]
43
- # The collection of `scm` tasks.
44
- #
39
+ # @return [SCM]
45
40
  attr_reader :scm
46
41
 
42
+ # The {Sign sign:\*} tasks.
47
43
  #
48
- # The `sign` tasks.
49
- #
50
- # @return [OpenStruct]
51
- # The collection of `sign` tasks.
52
- #
44
+ # @return [Sign]
53
45
  attr_reader :sign
54
46
 
55
47
  # The {Console console} task.
@@ -67,30 +59,54 @@ module Gem
67
59
  #
68
60
  # Initializes the project tasks.
69
61
  #
70
- # @param [Hash{Symbol => Hash}] options
71
- # Enables or disables individual tasks.
62
+ # @param [Hash{Symbol => Boolean}] build
63
+ # Enables or disables the `build` tasks. Additional keyword arguments
64
+ # can be passed to the individual build tasks via a Hash.
65
+ #
66
+ # @option build [Boolean] :gem (true)
67
+ # Enables or disables the {Build::Gem build:gem} task.
68
+ #
69
+ # @option build [Boolean] :tar
70
+ # Enables or disables the {Build::Tar build:tar} task.
71
+ #
72
+ # @option build [Boolean] :zip
73
+ # Enables or disables the {Build::Zip build:zip} task.
74
+ #
75
+ # @param [Hash{Symbol => Boolean}] scm
76
+ # Enables or disables the `scm` tasks. Additional keyword arguments
77
+ # can be passed to the individual scm tasks via a Hash.
72
78
  #
73
- # @option options [Hash{Symbol => Boolean}] :build
74
- # Enables or disables the `build` tasks.
79
+ # @option scm [Boolean] :status (true)
80
+ # Enables or disables the {SCM::Status scm:status} task.
75
81
  #
76
- # @option options [Hash{Symbol => Boolean}] :scm
77
- # Enables or disables the `scm` tasks.
82
+ # @option scm [Boolean] :tag (true)
83
+ # Enables or disables the {SCM::Tag scm:tag} task.
78
84
  #
79
- # @option options [Boolean] :console (true)
85
+ # @option scm [Boolean] :push (true)
86
+ # Enables or disables the {SCM::Push scm:push} task.
87
+ #
88
+ # @param [Hash{Symbol => Boolean}] sign
89
+ # Enables or disables the `sign` tasks. Additional keyword arguments
90
+ # can be passed to the individual sign tasks via a Hash.
91
+ #
92
+ # @option sign [Boolean] :checksum
93
+ # Enables or disables the {Sign::Checksum sign:checksum} task.
94
+ #
95
+ # @option sign [Boolean] :pgp
96
+ # Enables or disables the {Sign::PGP sign:pgp} task.
97
+ #
98
+ # @param [Boolean] console
80
99
  # Enables or disables the {Console console} task.
81
100
  #
82
- # @option options [Boolean] :install (true)
101
+ # @param [Boolean] install
83
102
  # Enables or disables the {Install install} task.
84
103
  #
85
- # @option options [Boolean] :push (true)
104
+ # @param [Boolean] push
86
105
  # Enables or disables the {Push push} task.
87
106
  #
88
- # @option options [Boolean] :release (true)
107
+ # @param [Boolean] release
89
108
  # Enables or disables the {Release release} task.
90
109
  #
91
- # @option options [Hash{Symbol => Boolean}] :sign
92
- # Enables or disables the `sign` tasks.
93
- #
94
110
  # @yield [tasks]
95
111
  # If a block is given, it will be passed the newly created tasks,
96
112
  # before they are fully defined.
@@ -109,36 +125,21 @@ module Gem
109
125
  # tasks.scm.tag.format = "release-%s"
110
126
  # end
111
127
  #
112
- def initialize(options={})
113
- build_options = options.fetch(:build,{})
114
- scm_options = options.fetch(:scm,{})
115
- sign_options = options.fetch(:sign,{})
116
-
117
- @scm = OpenStruct.new
118
- @build = OpenStruct.new
119
- @sign = OpenStruct.new
120
-
121
- if build_options
122
- @build.gem = (Build::Gem.new if build_options.fetch(:gem,true))
123
- @build.tar = (Build::Tar.new if build_options[:tar])
124
- @build.zip = (Build::Zip.new if build_options[:zip])
125
- end
126
-
127
- if scm_options
128
- @scm.status = (SCM::Status.new if scm_options.fetch(:status,true))
129
- @scm.tag = (SCM::Tag.new if scm_options.fetch(:tag,true))
130
- @scm.push = (SCM::Push.new if scm_options.fetch(:push,true))
131
- end
132
-
133
- if sign_options
134
- @sign.checksum = (Sign::Checksum.new if sign_options[:checksum])
135
- @sign.pgp = (Sign::PGP.new if sign_options[:pgp])
136
- end
137
-
138
- @console = (Console.new if options.fetch(:console,true))
139
- @install = (Install.new if options.fetch(:install,true))
140
- @push = (Push.new if options.fetch(:push,true))
141
- @release = (Release.new if options.fetch(:release,true))
128
+ def initialize(build: {},
129
+ scm: {},
130
+ sign: {},
131
+ console: true,
132
+ install: true,
133
+ push: true,
134
+ release: true)
135
+ @scm = SCM.new(**scm)
136
+ @build = Build.new(**build)
137
+ @sign = Sign.new(**sign)
138
+
139
+ @console = (Console.new if console)
140
+ @install = (Install.new if install)
141
+ @push = (Push.new if push)
142
+ @release = (Release.new if release)
142
143
 
143
144
  yield self if block_given?
144
145
  end
@@ -20,6 +20,7 @@ Gem::Specification.new do |gem|
20
20
  gem.authors = Array(gemspec['authors'])
21
21
  gem.email = gemspec['email']
22
22
  gem.homepage = gemspec['homepage']
23
+ gem.metadata = gemspec['metadata'] if gemspec['metadata']
23
24
 
24
25
  glob = lambda { |patterns| gem.files & Dir[*patterns] }
25
26
 
@@ -0,0 +1,72 @@
1
+ require 'spec_helper'
2
+ require 'rake_context'
3
+
4
+ require 'rubygems/tasks/build'
5
+
6
+ describe Gem::Tasks::Build do
7
+ include_context "rake"
8
+
9
+ describe "#initialize" do
10
+ context "when given no keyword arguments" do
11
+ it "must initialize #gem by default" do
12
+ expect(subject.gem).to be_a(Gem::Tasks::Build::Gem)
13
+ end
14
+
15
+ it "must not initialize #tar by default" do
16
+ expect(subject.tar).to be(nil)
17
+ end
18
+
19
+ it "must not initialize #zip by default" do
20
+ expect(subject.zip).to be(nil)
21
+ end
22
+ end
23
+
24
+ context "when given `gem: true`" do
25
+ subject { described_class.new(gem: true) }
26
+
27
+ it "must initialize #gem" do
28
+ expect(subject.gem).to be_a(Gem::Tasks::Build::Gem)
29
+ end
30
+ end
31
+
32
+ context "when given `gem: false`" do
33
+ subject { described_class.new(gem: false) }
34
+
35
+ it "must not initialize #gem" do
36
+ expect(subject.gem).to be(nil)
37
+ end
38
+ end
39
+
40
+ context "when given `tar: true`" do
41
+ subject { described_class.new(tar: true) }
42
+
43
+ it "must initialize #tar" do
44
+ expect(subject.tar).to be_a(Gem::Tasks::Build::Tar)
45
+ end
46
+ end
47
+
48
+ context "when given `tar: false`" do
49
+ subject { described_class.new(tar: false) }
50
+
51
+ it "must not initialize #tar" do
52
+ expect(subject.tar).to be(nil)
53
+ end
54
+ end
55
+
56
+ context "when given `zip: true`" do
57
+ subject { described_class.new(zip: true) }
58
+
59
+ it "must initialize #zip" do
60
+ expect(subject.zip).to be_a(Gem::Tasks::Build::Zip)
61
+ end
62
+ end
63
+
64
+ context "when given `zip: false`" do
65
+ subject { described_class.new(zip: false) }
66
+
67
+ it "must not initialize #zip" do
68
+ expect(subject.zip).to be(nil)
69
+ end
70
+ end
71
+ end
72
+ end