Skip to content

Commit c015a0c

Browse files
authored
🔨 Galtzo FLOSS Rakefile v1.0.0
1 parent cb9e6c1 commit c015a0c

File tree

1 file changed

+81
-17
lines changed

1 file changed

+81
-17
lines changed

‎Rakefile‎

Lines changed: 81 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,36 @@
11
# frozen_string_literal: true
22

3+
# Galtzo FLOSS Rakefile v1.0 - 2025-08-12
4+
#
5+
# MIT License (see License.txt)
6+
#
7+
# Copyright (c) 2025 Peter H. Boling (galtzo.com)
8+
#
9+
# Expected to work in any project that uses Bundler.
10+
# Sets up tasks for rspec, minitest, rubocop, reek, yard, and stone_checksums.
11+
# rake build # Build my_gem-1.0.0.gem into the pkg directory
12+
# rake build:checksum # Generate SHA512 checksum of my_gem-1.0.0.gem into the checksums directory
13+
# rake build:generate_checksums # Generate both SHA256 & SHA512 checksums into the checksums directory, and git commit them
14+
# rake bundle:audit:check # Checks the Gemfile.lock for insecure dependencies
15+
# rake bundle:audit:update # Updates the bundler-audit vulnerability database
16+
# rake clean # Remove any temporary products
17+
# rake clobber # Remove any generated files
18+
# rake coverage # Run specs w/ coverage and open results in browser
19+
# rake install # Build and install my_gem-1.0.0.gem into system gems
20+
# rake install:local # Build and install my_gem-1.0.0.gem into system gems without network access
21+
# rake reek # Check for code smells
22+
# rake reek:update # Run reek and store the output into the REEK file
23+
# rake release[remote] # Create tag v1.0.0 and build and push my_gem-1.0.0.gem to rubygems.org
24+
# rake rubocop # alias rubocop task to rubocop_gradual
25+
# rake rubocop_gradual # Run RuboCop Gradual
26+
# rake rubocop_gradual:autocorrect # Run RuboCop Gradual with autocorrect (only when it's safe)
27+
# rake rubocop_gradual:autocorrect_all # Run RuboCop Gradual with autocorrect (safe and unsafe)
28+
# rake rubocop_gradual:check # Run RuboCop Gradual to check the lock file
29+
# rake rubocop_gradual:force_update # Run RuboCop Gradual to force update the lock file
30+
# rake spec # Run RSpec code examples
31+
# rake test # Run tests / run spec task with test task
32+
# rake yard # Generate YARD Documentation
33+
334
require "bundler/gem_tasks"
435

536
defaults = []
@@ -39,6 +70,7 @@ rescue LoadError
3970
end
4071
end
4172

73+
# Setup RSpec
4274
begin
4375
require "rspec/core/rake_task"
4476

@@ -52,6 +84,20 @@ rescue LoadError
5284
end
5385
end
5486

87+
# Setup MiniTest
88+
begin
89+
require "rake/testtask"
90+
91+
Rake::TestTask.new(:test) do |t|
92+
t.test_files = FileList["tests/**/test_*.rb"]
93+
end
94+
rescue LoadError
95+
desc("test task stub")
96+
task(:test) do
97+
warn("NOTE: minitest isn't installed, or is disabled for #{RUBY_VERSION} in the current environment")
98+
end
99+
end
100+
55101
desc "run spec task with test task"
56102
task test: :spec
57103

@@ -69,6 +115,40 @@ rescue LoadError
69115
end
70116
end
71117

118+
# Setup Reek
119+
begin
120+
require "reek/rake/task"
121+
122+
Reek::Rake::Task.new do |t|
123+
t.fail_on_error = true
124+
t.verbose = false
125+
t.source_files = "{lib,spec,tests}/**/*.rb"
126+
end
127+
128+
# Store current Reek output into REEK file
129+
require "open3"
130+
desc("Run reek and store the output into the REEK file")
131+
task("reek:update") do
132+
# Run via Bundler if available to ensure the right gem version is used
133+
cmd = [Gem.bindir ? File.join(Gem.bindir, "bundle") : "bundle", "exec", "reek"]
134+
135+
output, status = Open3.capture2e(*cmd)
136+
137+
File.write("REEK", output)
138+
139+
# Mirror the failure semantics of the standard reek task
140+
unless status.success?
141+
abort("reek:update failed (reek reported smells). Output written to REEK")
142+
end
143+
end
144+
defaults << "reek:update" unless is_ci
145+
rescue LoadError
146+
desc("(stub) reek is unavailable")
147+
task(:reek) do
148+
warn("NOTE: reek isn't installed, or is disabled for #{RUBY_VERSION} in the current environment")
149+
end
150+
end
151+
72152
# Setup Yard
73153
begin
74154
require "yard"
@@ -82,6 +162,7 @@ begin
82162
"*.cff",
83163
"*.md",
84164
"*.txt",
165+
"REEK",
85166
]
86167
end
87168
defaults << "yard"
@@ -92,23 +173,6 @@ rescue LoadError
92173
end
93174
end
94175

95-
# Setup Reek
96-
begin
97-
require "reek/rake/task"
98-
99-
Reek::Rake::Task.new do |t|
100-
t.fail_on_error = true
101-
t.verbose = false
102-
t.source_files = "{lib,spec}/**/*.rb"
103-
end
104-
defaults << "reek" unless is_ci
105-
rescue LoadError
106-
desc("(stub) reek is unavailable")
107-
task(:reek) do
108-
warn("NOTE: reek isn't installed, or is disabled for #{RUBY_VERSION} in the current environment")
109-
end
110-
end
111-
112176
### RELEASE TASKS
113177
# Setup stone_checksums
114178
begin

0 commit comments

Comments
 (0)