π§ͺ Spiker
Spiker helps you spin up quick, testable Ruby experiments, aka spikes. Whether you're validating an idea, poking at a new API, or just noodling with some code, Spiker gives you a clean, red-green workflow in seconds.
Itβs like rails new
for code spikes.
π Install
Get Spiker the same way you get any other Ruby gem:
gem install spiker
π οΈ Use It
Navigate to wherever you keep your brilliant ideas:
cd ~/spikes
Then create your first Spiker-flavored spike:
spiker simple my_rad_idea
cd my_rad_idea
Start coding. Run tests. Celebrate small wins. π
𧬠Spike Types
Spiker gives you different formats depending on your mood:
simple
All code and tests in one file. Perfect for one-off ideas or sharing snippets with others.
spiker simple my_rad_idea
Generates:
my_rad_idea/
βββ app.rb
βββ Gemfile
βββ Guardfile
βββ .env
βββ Dockerfile*
βββ docker-compose.yml*
βββ Makefile*
* Skippable via --skip-docker
, --skip-bundle
, etc.
The app.rb
file includes your class, a few tests, and support for .env
values:
require 'minitest'
require 'minitest/autorun'
require 'minitest/reporters'
Minitest::Reporters.use!
class MyRadIdeaTest < Minitest::Test
def test_name
assert_equal "Fred", MySpike.new(name: "Fred").name
end
def test_default_env_value
assert_equal "test", ENV["TEST_VALUE"]
end
end
# your brilliance goes here
class MyRadIdea
attr_accessor :name
def initialize(name:)
@name = name
end
end
Start Guard and hack away:
bundle exec guard
given
Like simple
, but with support for Minitest::Spec
and Given/When/Then
style tests. Inspired by the late, great Jim Weirich.
spiker given my_given_spike
multi
When you need more structure β say you're testing something big, or just like folders.
spiker multi cool_tool
cd cool_tool
You get:
cool_tool/
βββ lib/cool_tool.rb
βββ test/
β βββ test_helper.rb
β βββ cool_tool_test.rb
βββ Guardfile
βββ Gemfile
βββ Rakefile
βββ README.md
...etc
Minitest is still the test framework. Rake is wired up. Guard watches your files. You're all set.
rspec
Like multi
, but for people who write describe
instead of def test_thing
. πΉ
spiker rspec spike_it
cd spike_it
Youβll get:
spike_it/
βββ lib/spike_it.rb
βββ spec/
β βββ spec_helper.rb
β βββ spike_it_spec.rb
βββ Guardfile
βββ Gemfile
βββ Rakefile
Just add ideas and run bundle exec guard
or rake
or... rspec
.
βοΈ Options
Want fewer moving parts?
spiker simple my_spike --skip-docker --skip-bundle --skip-git
Run spiker help
or spiker help [COMMAND]
to see all your options.
π‘ Why Use Spiker?
- β Fast: From idea to testable code in seconds and no boring boilerplate by hand
- β Familiar: Minitest, RSpec, Guard, Rake β tools you already know... or want to know
- β Simple: No weird configs or meta-generators
- β Docker-Ready: Write code in your favorite editor, run your code in Docker? Intriguing...
- β Flexible: Choose the spike format that fits your flow
πͺ Development
Spiker is a straightforward "generator"-style Ruby gem. It uses Thor to handle the bulk of the generator heavy lifting, so it will be straightforward to adapt to your needs. If you want to make a new style of "spike", you'll work in:
lib/spiker.rb
lib/spiker/cli.rb
lib/spiker/generators/<YOUR_GENERATOR_HERE>
lib/spiker/templates/<YOUR_GENERATOR_TEMPLATES_HERE>
Adapting an existing spike just requires attention to the last two items above.
To get rolling, check out the repo and run bundle exec bin/setup
to install dependencies.
Then, run rake test
to run the tests.
You can also run bundle exec bin/console
for an interactive prompt that will allow you to experiment.
To install your updated version of the gem onto your local machine, run bundle exec rake install
.
To see what else you can do, there's always bundle exec rake -T
π§Ό Fine Print
Spiker is open source, MIT-licensed, and built for fun and function.
Use it. Fork it. Spike responsibly.