|
35 | 35 | # frozen_string_literal: true |
36 | 36 |
|
37 | 37 | require 'rubygems' |
| 38 | +require 'bundler' |
38 | 39 |
|
39 | | -# @todo: Check if Bundler needs to be `require`d. |
40 | 40 | GEM_SPEC = Bundler.load_gemspec(File.join(__dir__, 'rubytree.gemspec')) |
41 | 41 |
|
42 | 42 | PKG_NAME = GEM_SPEC.name |
43 | 43 | PKG_VER = GEM_SPEC.version |
44 | 44 | GEM_NAME = "#{PKG_NAME}-#{PKG_VER}.gem" |
45 | 45 |
|
46 | 46 | desc 'Default Task (Run the tests)' |
47 | | -task :default do |
48 | | - if ENV['COVERAGE'] |
49 | | - Rake::Task['test:coverage'].invoke |
50 | | - else |
51 | | - Rake::Task['test:unit'].invoke |
52 | | - Rake::Task['spec'].invoke |
53 | | - end |
54 | | -end |
| 47 | +task :default => 'test:all' |
55 | 48 |
|
56 | 49 | desc 'Display the current gem version' |
57 | 50 | task :version do |
|
71 | 64 |
|
72 | 65 | namespace :doc do # ................................ Documentation |
73 | 66 | begin |
74 | | - gem 'rdoc', '>= 6.4.0' # To get around a stupid bug in Ruby 1.9.2 Rake. |
75 | 67 | require 'rdoc/task' |
76 | 68 | Rake::RDocTask.new do |rdoc| |
77 | 69 | rdoc.rdoc_dir = 'rdoc' |
@@ -153,31 +145,18 @@ rescue LoadError |
153 | 145 | end |
154 | 146 |
|
155 | 147 | # ................................ Gem related |
156 | | -namespace :gem do |
157 | | - require 'rubygems/package_task' |
158 | | - Gem::PackageTask.new(GEM_SPEC) do |pkg| |
159 | | - pkg.need_zip = true |
160 | | - pkg.need_tar = true |
161 | | - end |
162 | | - |
163 | | - desc 'Push the gem into the Rubygems and Github repositories' |
164 | | - task push: :gem do |
165 | | - github_repo = 'https://rubygems.pkg.github.com/evolve75' |
166 | | - |
167 | | - # This pushes to the standard RubyGems registry |
168 | | - sh "gem push pkg/#{GEM_NAME}" |
169 | | - |
170 | | - # For github, the credentials key is assumed to be github |
171 | | - # See: https://docs.github.com/en/packages/working-with-a-github-packages-registry/ |
172 | | - sh "gem push --key github --host #{github_repo} pkg/#{GEM_NAME}" |
173 | | - end |
174 | | -end |
| 148 | +require 'bundler/gem_helper' |
| 149 | +Bundler::GemHelper.install_tasks |
175 | 150 |
|
176 | 151 | # ................................ Ruby linting |
177 | | -require 'rubocop/rake_task' |
| 152 | +begin |
| 153 | + require 'rubocop/rake_task' |
178 | 154 |
|
179 | | -RuboCop::RakeTask.new(:rubocop) do |t| |
180 | | - t.options = ['--display-cop-names'] |
181 | | - t.requires << 'rubocop-rake' |
182 | | - t.requires << 'rubocop-rspec' |
| 155 | + RuboCop::RakeTask.new(:rubocop) do |t| |
| 156 | + t.options = ['--display-cop-names'] |
| 157 | + t.requires << 'rubocop-rake' |
| 158 | + t.requires << 'rubocop-rspec' |
| 159 | + end |
| 160 | +rescue LoadError |
| 161 | + # RuboCop not available. |
183 | 162 | end |
0 commit comments