rubygems-tasks 0.2.4 → 0.2.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +7 -0
  2. data/.github/workflows/ruby.yml +27 -0
  3. data/.gitignore +4 -3
  4. data/.travis.yml +9 -0
  5. data/ChangeLog.md +13 -0
  6. data/Gemfile +10 -0
  7. data/LICENSE.txt +1 -1
  8. data/README.md +23 -12
  9. data/Rakefile +7 -66
  10. data/gemspec.yml +16 -4
  11. data/lib/rubygems/tasks/build/gem.rb +0 -2
  12. data/lib/rubygems/tasks/build/tar.rb +0 -2
  13. data/lib/rubygems/tasks/build/task.rb +9 -14
  14. data/lib/rubygems/tasks/console.rb +1 -4
  15. data/lib/rubygems/tasks/install.rb +1 -1
  16. data/lib/rubygems/tasks/project.rb +3 -3
  17. data/lib/rubygems/tasks/push.rb +2 -2
  18. data/lib/rubygems/tasks/sign/checksum.rb +3 -2
  19. data/lib/rubygems/tasks/sign/pgp.rb +1 -1
  20. data/lib/rubygems/tasks/sign/task.rb +13 -17
  21. data/lib/rubygems/tasks/task.rb +14 -8
  22. data/lib/rubygems/tasks.rb +140 -2
  23. data/rubygems-tasks.gemspec +39 -87
  24. data/spec/console_spec.rb +43 -20
  25. data/spec/install_spec.rb +5 -1
  26. data/spec/project_spec.rb +30 -27
  27. data/spec/projects/bundler-project/.gitignore +17 -0
  28. data/spec/projects/bundler-project/Gemfile +4 -0
  29. data/spec/projects/bundler-project/LICENSE +22 -0
  30. data/spec/projects/bundler-project/README.md +29 -0
  31. data/spec/projects/bundler-project/Rakefile +2 -0
  32. data/spec/projects/bundler-project/bundler-project.gemspec +19 -0
  33. data/spec/projects/bundler-project/lib/bundler-project/version.rb +5 -0
  34. data/spec/projects/bundler-project/lib/bundler-project.rb +7 -0
  35. data/spec/projects/rubygems-multi-project/.gitignore +17 -0
  36. data/spec/projects/rubygems-multi-project/LICENSE.txt +22 -0
  37. data/spec/projects/rubygems-multi-project/README.md +21 -0
  38. data/spec/projects/rubygems-multi-project/lib/rubygems/project/version.rb +5 -0
  39. data/spec/projects/rubygems-multi-project/rubygems-project-lite.gemspec +19 -0
  40. data/spec/projects/rubygems-multi-project/rubygems-project.gemspec +19 -0
  41. data/spec/projects/rubygems-project/.gitignore +17 -0
  42. data/spec/projects/rubygems-project/LICENSE.txt +22 -0
  43. data/spec/projects/rubygems-project/README.md +21 -0
  44. data/spec/projects/rubygems-project/lib/rubygems/project/version.rb +5 -0
  45. data/spec/projects/rubygems-project/rubygems-project.gemspec +19 -0
  46. data/spec/push_spec.rb +2 -2
  47. data/spec/rake_context.rb +1 -3
  48. data/spec/scm/push_spec.rb +7 -7
  49. data/spec/scm/status_spec.rb +6 -6
  50. data/spec/scm/tag_spec.rb +18 -18
  51. data/spec/sign/pgp_spec.rb +1 -1
  52. data/spec/spec_helper.rb +25 -8
  53. data/spec/tasks_spec.rb +171 -55
  54. metadata +99 -87
  55. data/lib/rubygems/tasks/tasks.rb +0 -147
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: be886af586a0508f6dbe548247677067920db2f38b4590c4cd54f3b96b0449ee
4
+ data.tar.gz: 7d3c7deb140448cfebfba8ebbf184eccfe4bc167823f2088192c5e4f0f69acc3
5
+ SHA512:
6
+ metadata.gz: a5906ece048555085e8ec9b5959f262c3d642ee28d8001f8f42221ce53a1c76e39ce41a5e18cdafae1c8ed67fa1ef97b009a28f66b0223c117efba4d78e44f7c
7
+ data.tar.gz: '038f3abd105da7c5705632c4e65dc3d268567da424bb5e74411b667b93a940a3ff563a801e2ddee32959d7514e4ba821b39e8db0797fce7819814cd8498b2b9a'
@@ -0,0 +1,27 @@
1
+ name: CI
2
+
3
+ on: [ push, pull_request ]
4
+
5
+ jobs:
6
+ tests:
7
+ runs-on: ubuntu-latest
8
+ strategy:
9
+ fail-fast: false
10
+ matrix:
11
+ ruby:
12
+ - 3.0
13
+ - 3.1
14
+ - 3.2
15
+ - jruby
16
+ - truffleruby
17
+ name: Ruby ${{ matrix.ruby }}
18
+ steps:
19
+ - uses: actions/checkout@v2
20
+ - name: Set up Ruby
21
+ uses: ruby/setup-ruby@v1
22
+ with:
23
+ ruby-version: ${{ matrix.ruby }}
24
+ - name: Install dependencies
25
+ run: bundle install --jobs 4 --retry 3
26
+ - name: Run tests
27
+ run: bundle exec rake test
data/.gitignore CHANGED
@@ -1,3 +1,4 @@
1
- doc/
2
- pkg/
3
- data/projects/
1
+ /Gemfile.lock
2
+ /doc/
3
+ /pkg/
4
+ /vendor/bundle
data/.travis.yml ADDED
@@ -0,0 +1,9 @@
1
+ language: ruby
2
+ before_install:
3
+ - sudo apt-get install git subversion mercurial
4
+ - gem install rspec -v "~> 3.0"
5
+ rvm:
6
+ - 2.5
7
+ - 2.6
8
+ - 2.7
9
+ - jruby
data/ChangeLog.md CHANGED
@@ -1,3 +1,16 @@
1
+ ### 0.2.6 / 2023-09-07
2
+
3
+ * Fixed `rake install` so that it runs `gem install -q pkg/...` outside of the
4
+ Bundler environment, if currently running under Bundler.
5
+
6
+ ### 0.2.5 / 2020-03-02
7
+
8
+ * Require Ruby >= 2.0.0.
9
+ * Added irb as a dependencies.
10
+ * Fixed issue where `file` tasks were defined in namespaces resulting in task
11
+ names such as `namespace:path/to/file` instead of simply `path/to/file`.
12
+ * Set gemspec license to MIT.
13
+
1
14
  ### 0.2.4 / 2013-04-8
2
15
 
3
16
  * Use the new `Gem::Package` class when running under Ruby 2.0.0.
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ group :development do
6
+ gem 'rake'
7
+ gem 'rspec', '~> 3.0'
8
+ gem 'kramdown'
9
+ gem 'yard', '~> 0.9'
10
+ end
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2011-2013 Hal Brodigan
1
+ Copyright (c) 2011-2020 Hal Brodigan
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # rubygems-tasks
2
2
 
3
+ [![CI](https://github.com/postmodern/rubygems-tasks/actions/workflows/ruby.yml/badge.svg)](https://github.com/postmodern/rubygems-tasks/actions/workflows/ruby.yml)
4
+ [![Code Climate](https://codeclimate.com/github/postmodern/rubygems-tasks.svg)](https://codeclimate.com/github/postmodern/rubygems-tasks)
5
+
3
6
  * [Source](https://github.com/postmodern/rubygems-tasks)
4
7
  * [Issues](https://github.com/postmodern/rubygems-tasks/issues)
5
8
  * [Email](mailto:postmodern.mod3 at gmail.com)
@@ -33,7 +36,7 @@ This is what rubygems-tasks seeks to provide.
33
36
  * Provides tasks to build, install and push gems to [rubygems.org].
34
37
  * Loads all project metadata from the `.gemspec` file.
35
38
  * Supports loading multiple `.gemspec` files.
36
- * Supports pushing gems to alternate [Gemcutter] servers.
39
+ * Supports pushing gems to alternate [gem server]s.
37
40
  * Supports optionally building `.tar.gz` and `.zip` archives.
38
41
  * `build:tar`
39
42
  * `build:zip`
@@ -55,6 +58,11 @@ This is what rubygems-tasks seeks to provide.
55
58
  * **Does not** inject dependencies into gems.
56
59
  * **Zero** dependencies.
57
60
 
61
+ ## Requirements
62
+
63
+ * [ruby] >= 2.0.0
64
+ * [rake]
65
+
58
66
  ## Install
59
67
 
60
68
  $ gem install rubygems-tasks
@@ -67,7 +75,7 @@ Specifying an alternate Ruby Console to run:
67
75
  tasks.console.command = 'pry'
68
76
  end
69
77
 
70
- Enable pushing gems to an in-house [Gemcutter] server:
78
+ Enable pushing gems to an in-house [gem server]:
71
79
 
72
80
  Gem::Tasks.new do |tasks|
73
81
  tasks.push.host = 'gems.company.com'
@@ -75,23 +83,23 @@ Enable pushing gems to an in-house [Gemcutter] server:
75
83
 
76
84
  Disable the `push` task:
77
85
 
78
- Gem::Tasks.new(:push => false)
86
+ Gem::Tasks.new(push: false)
79
87
 
80
88
  Enable building `.tar.gz` and `.zip` archives:
81
89
 
82
- Gem::Tasks.new(:build => {:tar => true, :zip => true})
90
+ Gem::Tasks.new(build: {tar: true, zip: true})
83
91
 
84
92
  Enable Checksums and PGP signatures for built packages:
85
93
 
86
- Gem::Tasks.new(:sign => {:checksum => true, :pgp => true})
94
+ Gem::Tasks.new(sign: {checksum: true, pgp: true})
87
95
 
88
96
  Selectively defining tasks:
89
97
 
90
- Gem::Build::Tar.new
91
- Gem::SCM::Status.new
92
- Gem::SCM::Tag.new(:format => 'REL-%s')
93
- Gem::Sign::Checksum.new
94
- Gem::Console.new
98
+ Gem::Tasks::Build::Tar.new
99
+ Gem::Tasks::SCM::Status.new
100
+ Gem::Tasks::SCM::Tag.new(format: 'REL-%s')
101
+ Gem::Tasks::Sign::Checksum.new
102
+ Gem::Tasks::Console.new
95
103
 
96
104
  ## Synopsis
97
105
 
@@ -102,7 +110,7 @@ Selectively defining tasks:
102
110
 
103
111
  ## Copyright
104
112
 
105
- Copyright (c) 2011-2013 Hal Brodigan
113
+ Copyright (c) 2011-2020 Hal Brodigan
106
114
 
107
115
  See {file:LICENSE.txt} for details.
108
116
 
@@ -114,4 +122,7 @@ See {file:LICENSE.txt} for details.
114
122
  [Hoe]: https://github.com/seattlerb/hoe#readme
115
123
 
116
124
  [rubygems.org]: https://rubygems.org/
117
- [Gemcutter]: https://github.com/rubygems/rubygems.org#readme
125
+ [gem server]: https://github.com/rubygems/rubygems.org#readme
126
+
127
+ [ruby]: https://www.ruby-lang.org/
128
+ [rake]: https://rubygems.org/gems/rake
data/Rakefile CHANGED
@@ -1,4 +1,5 @@
1
1
  require 'rubygems'
2
+
2
3
  require 'rake'
3
4
 
4
5
  lib_dir = File.expand_path('lib',File.dirname(__FILE__))
@@ -6,74 +7,14 @@ $LOAD_PATH << lib_dir unless $LOAD_PATH.include?(lib_dir)
6
7
 
7
8
  require 'rubygems/tasks'
8
9
  Gem::Tasks.new(
9
- :build => {:gem => true, :tar => true},
10
- :sign => {:checksum => true, :pgp => true}
10
+ build: {gem: true, tar: true},
11
+ sign: {checksum: true, pgp: true}
11
12
  )
12
13
 
13
- begin
14
- gem 'rspec', '~> 2.4'
15
- require 'rspec/core/rake_task'
16
-
17
- RSpec::Core::RakeTask.new
18
- rescue LoadError
19
- task :spec do
20
- abort "Please run `gem install rspec` to install RSpec."
21
- end
22
- end
14
+ require 'rspec/core/rake_task'
15
+ RSpec::Core::RakeTask.new
23
16
  task :test => :spec
24
17
  task :default => :spec
25
18
 
26
- begin
27
- gem 'yard', '~> 0.7'
28
- require 'yard'
29
-
30
- YARD::Rake::YardocTask.new
31
- rescue LoadError => e
32
- task :yard do
33
- abort 'Please run `gem install yard` to install YARD.'
34
- end
35
- end
36
-
37
- require 'net/https'
38
- require 'uri'
39
-
40
- DOWNLOAD_URI = 'http://cloud.github.com/downloads/postmodern/rubygems-tasks/'
41
- PROJECTS_DIR = File.join('data','projects')
42
- PROJECTS = %w[rubygems-project rubygems-multi-project bundler-project]
43
-
44
- directory PROJECTS_DIR
45
-
46
- PROJECTS.each do |project|
47
- project_file = "#{project}.tar.gz"
48
- project_path = File.join(PROJECTS_DIR,project_file)
49
- project_dir = File.join(PROJECTS_DIR,project)
50
-
51
- file project_path => PROJECTS_DIR do
52
- Net::HTTP.get_response(URI(DOWNLOAD_URI + project_file)) do |response|
53
- size, total = 0, response.header['Content-Length'].to_i
54
-
55
- puts ">>> Downloading to #{project_file} to #{project_path} ..."
56
-
57
- File.open(project_path,"wb") do |file|
58
- response.read_body do |chunk|
59
- file.write(chunk)
60
-
61
- size += chunk.size
62
- printf "\r>>> [%d / %d] %d%% ...", size, total, ((size * 100) / total)
63
- end
64
- end
65
-
66
- puts
67
- end
68
- end
69
-
70
- task project_dir => project_path do
71
- unless File.directory?(project_dir)
72
- sh 'tar', 'xzf', project_path, '-C', PROJECTS_DIR
73
- end
74
- end
75
-
76
- task 'data:projects' => project_dir
77
- end
78
-
79
- task :spec => 'data:projects'
19
+ require 'yard'
20
+ YARD::Rake::YardocTask.new
data/gemspec.yml CHANGED
@@ -1,14 +1,26 @@
1
1
  name: rubygems-tasks
2
- version: 0.2.4
2
+ version: 0.2.6
3
3
  summary: Rake tasks for managing and releasing Ruby Gems.
4
- description:
4
+ description: |
5
5
  Agnostic and unobtrusive Rake tasks for managing and releasing Ruby Gems.
6
6
 
7
7
  authors: Postmodern
8
+ license: MIT
8
9
  email: postmodern.mod3@gmail.com
9
10
  homepage: https://github.com/postmodern/rubygems-tasks#readme
10
11
  has_yard: true
11
12
 
13
+ metadata:
14
+ documentation_uri: https://rubydoc.info/gems/rubygems-tasks
15
+ source_code_uri: https://github.com/postmodern/rubygems-tasks
16
+ bug_tracker_uri: https://github.com/postmodern/rubygems-tasks/issues
17
+ changelog_uri: https://github.com/postmodern/rubygems-tasks/blob/master/ChangeLog.md
18
+
19
+ required_ruby_version: ">= 2.0.0"
20
+
21
+ dependencies:
22
+ rake: ">= 10.0.0"
23
+ irb: ~> 1.0
24
+
12
25
  development_dependencies:
13
- rspec: ~> 2.4
14
- yard: ~> 0.7
26
+ bundler: ~> 2.0
@@ -1,7 +1,5 @@
1
1
  require 'rubygems/tasks/build/task'
2
2
 
3
- require 'fileutils'
4
-
5
3
  if Gem::VERSION > '2.' then require 'rubygems/package'
6
4
  else require 'rubygems/builder'
7
5
  end
@@ -1,7 +1,5 @@
1
1
  require 'rubygems/tasks/build/task'
2
2
 
3
- require 'set'
4
-
5
3
  module Gem
6
4
  class Tasks
7
5
  module Build
@@ -34,25 +34,20 @@ module Gem
34
34
  task :validate
35
35
 
36
36
  @project.builds.each do |build,packages|
37
- namespace :build do
38
- namespace name do
39
- gemspec = @project.gemspecs[build]
40
- path = packages[extname]
37
+ gemspec = @project.gemspecs[build]
38
+ path = packages[extname]
41
39
 
42
- # define file tasks, so the packages are not needless re-built
43
- file(path => [Project::PKG_DIR, *gemspec.files]) do
44
- invoke :validate
40
+ # define file tasks, so the packages are not needless re-built
41
+ file(path => [Project::PKG_DIR, *gemspec.files]) do
42
+ invoke :validate
45
43
 
46
- status "Building #{File.basename(path)} ..."
44
+ status "Building #{File.basename(path)} ..."
47
45
 
48
- build(path,gemspec)
49
- end
50
-
51
- task build => path
52
- end
46
+ build(path,gemspec)
53
47
  end
54
48
 
55
- task "build:#{build}" => "build:#{name}:#{build}"
49
+ task "build:#{name}:#{build}" => path
50
+ task "build:#{build}" => "build:#{name}:#{build}"
56
51
  end
57
52
 
58
53
  gemspec_tasks "build:#{name}"
@@ -77,11 +77,8 @@ module Gem
77
77
  # add -I options for lib/ or ext/ directories
78
78
  arguments.push(*require_paths.map { |dir| "-I#{dir}" })
79
79
 
80
- # add a -rrubygems to explicitly load rubygems on Ruby 1.8
81
- arguments.push('-rrubygems') if RUBY_VERSION < '1.9'
82
-
83
80
  # add an -r option to require the library
84
- arguments.push('-r' + require_file)
81
+ arguments.push("-r#{require_file}")
85
82
 
86
83
  # push on additional options
87
84
  arguments.push(*@options)
@@ -54,7 +54,7 @@ module Gem
54
54
  # @api semipublic
55
55
  #
56
56
  def install(path)
57
- run 'gem', 'install', '-q', path
57
+ gem 'install', '-q', path
58
58
  end
59
59
 
60
60
  end
@@ -9,9 +9,9 @@ module Gem
9
9
 
10
10
  # Supported SCMs and their control directories.
11
11
  SCM_DIRS = {
12
- :git => '.git',
13
- :hg => '.hg',
14
- :svn => '.svn'
12
+ git: '.git',
13
+ hg: '.hg',
14
+ svn: '.svn'
15
15
  }
16
16
 
17
17
  # The `pkg/` directory.
@@ -7,7 +7,7 @@ module Gem
7
7
  #
8
8
  class Push < Task
9
9
 
10
- # The Gemcutter host to push gems to.
10
+ # The rubygems host to push gems to.
11
11
  attr_accessor :host
12
12
 
13
13
  #
@@ -17,7 +17,7 @@ module Gem
17
17
  # Additional options.
18
18
  #
19
19
  # @option options [String] :host
20
- # The Gemcutter host to push gems to.
20
+ # The rubygems host to push gems to.
21
21
  #
22
22
  def initialize(options={})
23
23
  super()
@@ -84,8 +84,9 @@ module Gem
84
84
  # Defines the `sign:checksum` tasks.
85
85
  #
86
86
  def define
87
- sign_task :checksum
88
- task :checksum => 'sign:checksum'
87
+ super(:checksum)
88
+
89
+ task :checksum => 'sign:checksum'
89
90
  end
90
91
 
91
92
  #
@@ -25,7 +25,7 @@ module Gem
25
25
  # Defines the `sign:pgp` task.
26
26
  #
27
27
  def define
28
- sign_task :pgp
28
+ super(:pgp)
29
29
 
30
30
  task :pgp => 'sign:pgp'
31
31
  end
@@ -7,28 +7,13 @@ module Gem
7
7
  module Sign
8
8
  class Task < Tasks::Task
9
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
10
  #
24
11
  # Defines signing tasks for the various packages.
25
12
  #
26
13
  # @param [Symbol] name
27
14
  # The name for the `sign:` task.
28
15
  #
29
- # @api semipublic
30
- #
31
- def sign_task(name)
16
+ def define(name)
32
17
  @project.builds.each do |build,packages|
33
18
  packages.each do |format,path|
34
19
  namespace :sign do
@@ -42,7 +27,7 @@ module Gem
42
27
  end
43
28
  end
44
29
 
45
- multi_task "sign:#{name}:#{build}", packages.keys
30
+ namespaced_tasks "sign:#{name}:#{build}", packages.keys
46
31
 
47
32
  task "sign:#{name}" => "sign:#{name}:#{build}"
48
33
  task "sign:#{build}" => "sign:#{name}:#{build}"
@@ -52,6 +37,17 @@ module Gem
52
37
  end
53
38
  end
54
39
 
40
+ #
41
+ # Signs a package.
42
+ #
43
+ # @param [String] path
44
+ # The path to the package.
45
+ #
46
+ # @abstract
47
+ #
48
+ def sign(path)
49
+ end
50
+
55
51
  end
56
52
  end
57
53
  end
@@ -67,7 +67,13 @@ module Gem
67
67
  # @api semipublic
68
68
  #
69
69
  def gem(command,*arguments)
70
- run 'gem', command, *arguments
70
+ if defined?(Bundler)
71
+ Bundler.with_original_env do
72
+ run 'gem', command, *arguments
73
+ end
74
+ else
75
+ run 'gem', command, *arguments
76
+ end
71
77
  end
72
78
 
73
79
  #
@@ -124,28 +130,28 @@ module Gem
124
130
  # @param [String] prefix
125
131
  # The namespace of the sub-tasks to call.
126
132
  #
127
- # @param [Array<Symbol>] names
133
+ # @param [Array<Symbol>] subtasks
128
134
  # The names of the sub-tasks.
129
135
  #
130
136
  # @example
131
- # gemspec_tasks 'pkg:tar'
137
+ # namespaced_tasks 'pkg:tar', @project.gemspecs.keys
132
138
  #
133
139
  # @api semipublic
134
140
  #
135
- def multi_task(prefix,names)
136
- task prefix => names.map { |name| "#{prefix}:#{name}" }
141
+ def namespaced_tasks(prefix,subtasks)
142
+ task prefix => subtasks.map { |subtask| "#{prefix}:#{subtask}" }
137
143
  end
138
144
 
139
145
  #
140
146
  # Defines a task that will execute tasks for each gemspec.
141
147
  #
142
- # @param [Symbol, String] name
148
+ # @param [Symbol, String] prefix
143
149
  # The name for the task.
144
150
  #
145
151
  # @api semipublic
146
152
  #
147
- def gemspec_tasks(name)
148
- multi_task name, @project.gemspecs.keys
153
+ def gemspec_tasks(prefix)
154
+ namespaced_tasks prefix, @project.gemspecs.keys
149
155
  end
150
156
 
151
157
  end