spiker 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f6183b45c44cffdac7e55a8cc487634185d550b98b88802d331e66b4d19e5159
4
- data.tar.gz: c96d176df0f11614308af344020b8a3b546e291fcb0dc94b7c97724867a9a6e5
3
+ metadata.gz: d65d9dc195dfb1282b040fbfcac1139d9cc4c44f8bae2441deef02901ad0e38a
4
+ data.tar.gz: add551461d8e80b7626e5c96e738ed79b93ee360b3c2d7f809f07e90390a20f6
5
5
  SHA512:
6
- metadata.gz: 61065d34c4b29b1f541ec91274d326536f3952f2e94ed4efad1863bcf81b2eb2b335d140eb9eb2b38ed866ead8bcb213e7b6eff536dc7e71dfe8f9e41507c8a0
7
- data.tar.gz: fc2d21d8670e09eb8acd314ae5e75c6caf57f6b880e02cc4becebfab2c6d439bb937da3abf464cc22b8a6d34fcad2fdd380a115ebe14706d9d890f168ab89d0e
6
+ metadata.gz: f90ec88cf889ab847482622d47e040b5c6ba64b664e261b21c3076963a5f669d027f3cbc494349d48fcc7c44902cec6878a60e50181e67690f6facacf3abfef4
7
+ data.tar.gz: 0ec1b5564017f569255ffbec1286b85a5edf793c98e9a23fa4cd08d1c1b4bbda6b20ad2cb09ee648bc91be32c284f947748e2293002ed90fe079b26674eaa100
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- spiker (0.1.4)
4
+ spiker (0.1.5)
5
5
  thor (~> 0.19)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -24,7 +24,7 @@ Then, create a new spike:
24
24
  Using the "simple" formula, Spiker will create an `app.rb` file, a `Gemfile`, a `Guardfile` and an `.env` file for configuration, to be read by the `dotenv` gem. The `app.rb` file will contain boilerplate for both Minitest and a Ruby class in the same file:
25
25
 
26
26
  ```ruby
27
- require 'dotenv'
27
+ require 'dotenv/load'
28
28
  require 'minitest'
29
29
  require 'minitest/autorun'
30
30
  require 'minitest/reporters'
data/lib/spiker/cli.rb CHANGED
@@ -3,12 +3,15 @@
3
3
  require "thor"
4
4
  require_relative "version"
5
5
  require_relative "generators/simple"
6
+ require_relative "generators/given"
6
7
  require_relative "generators/multi"
7
8
 
8
9
  module Spiker
9
- # Accept options "single" and "multi"
10
- # for single-file spikes or multi-file spikes
11
- # and a name for the spike directory. That is all
10
+ # Accept options "simple", "given", or "multi".
11
+ # Both Simple and Given create "single file" spikes
12
+ # with the tests and spike code in a single file.
13
+ # The Multi option creates a more traditionally structured
14
+ # spike directory with tests, code, README, etc. That is all.
12
15
  class CLI < Thor
13
16
  desc "version", "Show version"
14
17
  def version
@@ -21,6 +24,12 @@ module Spiker
21
24
  Spiker::Generators::Simple.start([name])
22
25
  end
23
26
 
27
+ desc "given NAME", "Spike in a single file using Given syntax"
28
+ method_option :name, type: :string, aliases: "-n", desc: "Name of the spike"
29
+ def given(name)
30
+ Spiker::Generators::GivenOption.start([name])
31
+ end
32
+
24
33
  desc "multi NAME", "Spike over multiple files"
25
34
  method_option :name, type: :string, aliases: "-n", desc: "Name of the spike"
26
35
  def multiple(name)
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "thor/group"
4
+ require_relative "../../spiker"
5
+
6
+ module Spiker
7
+ module Generators
8
+ # Generates a single spike file, with supporting infrastructure.
9
+ # For simpler spikes that don't need a ton of organization.
10
+ class GivenOption < Thor::Group
11
+ include Thor::Actions
12
+
13
+ argument :name, type: :string
14
+
15
+ def self.source_root
16
+ "#{File.dirname(__FILE__)}/templates/given"
17
+ end
18
+
19
+ def create_spike_directory
20
+ empty_directory(name)
21
+ end
22
+
23
+ def create_spike_file
24
+ opts = { name_as_class: Spiker.classify(name) }
25
+ template("app.rb.erb", "#{name}/app.rb", opts)
26
+ end
27
+
28
+ def create_guard_file
29
+ template("guardfile.rb", "#{name}/Guardfile")
30
+ end
31
+
32
+ def create_gem_file
33
+ template("gemfile.rb", "#{name}/Gemfile")
34
+ end
35
+
36
+ def create_env_file
37
+ template("../common/basic.env", "#{name}/.env")
38
+ end
39
+
40
+ def run_bundler
41
+ inside(name) do
42
+ run("bundle install")
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -14,7 +14,7 @@ module Spiker
14
14
  argument :name, type: :string
15
15
 
16
16
  def self.source_root
17
- "#{File.dirname(__FILE__)}/templates"
17
+ "#{File.dirname(__FILE__)}/templates/multi"
18
18
  end
19
19
 
20
20
  def create_spike_directories
@@ -27,35 +27,35 @@ module Spiker
27
27
  name_in_snake_case = Spiker.snake_case(name)
28
28
  name_as_class = Spiker.classify(name)
29
29
  opts = { name_as_class: name_as_class, name_in_snake_case: name_in_snake_case }
30
- template("multi_app_test.rb.erb", "#{name}/test/#{name_in_snake_case}_test.rb", opts)
31
- template("multi_test_helper.rb", "#{name}/test/test_helper.rb", opts)
30
+ template("app_test.rb.erb", "#{name}/test/#{name_in_snake_case}_test.rb", opts)
31
+ template("test_helper.rb", "#{name}/test/test_helper.rb", opts)
32
32
  end
33
33
 
34
34
  def create_app_files
35
35
  name_in_snake_case = Spiker.snake_case(name)
36
36
  opts = { name_as_class: Spiker.classify(name) }
37
- template("multi_app.rb.erb", "#{name}/lib/#{name_in_snake_case}.rb", opts)
37
+ template("app.rb.erb", "#{name}/lib/#{name_in_snake_case}.rb", opts)
38
38
  end
39
39
 
40
40
  def create_guard_file
41
- template("multi_guardfile.rb", "#{name}/Guardfile")
41
+ template("guardfile.rb", "#{name}/Guardfile")
42
42
  end
43
43
 
44
44
  def create_gem_file
45
- template("multi_gemfile.rb", "#{name}/Gemfile")
45
+ template("gemfile.rb", "#{name}/Gemfile")
46
46
  end
47
47
 
48
48
  def create_rake_file
49
- template("multi_rakefile.rb", "#{name}/Rakefile")
49
+ template("rakefile.rb", "#{name}/Rakefile")
50
50
  end
51
51
 
52
52
  def create_readme_file
53
53
  opts = { name_as_class: Spiker.classify(name), name: name }
54
- template("multi_readme.md.erb", "#{name}/README.md", opts)
54
+ template("readme.md.erb", "#{name}/README.md", opts)
55
55
  end
56
56
 
57
57
  def create_env_file
58
- template("basic.env", "#{name}/.env")
58
+ template("../common/basic.env", "#{name}/.env")
59
59
  end
60
60
 
61
61
  def run_bundler
@@ -13,7 +13,7 @@ module Spiker
13
13
  argument :name, type: :string
14
14
 
15
15
  def self.source_root
16
- "#{File.dirname(__FILE__)}/templates"
16
+ "#{File.dirname(__FILE__)}/templates/simple"
17
17
  end
18
18
 
19
19
  def create_spike_directory
@@ -22,19 +22,19 @@ module Spiker
22
22
 
23
23
  def create_spike_file
24
24
  opts = { name_as_class: Spiker.classify(name) }
25
- template("simple_app.rb.erb", "#{name}/app.rb", opts)
25
+ template("app.rb.erb", "#{name}/app.rb", opts)
26
26
  end
27
27
 
28
28
  def create_guard_file
29
- template("simple_guardfile.rb", "#{name}/Guardfile")
29
+ template("guardfile.rb", "#{name}/Guardfile")
30
30
  end
31
31
 
32
32
  def create_gem_file
33
- template("simple_gemfile.rb", "#{name}/Gemfile")
33
+ template("gemfile.rb", "#{name}/Gemfile")
34
34
  end
35
35
 
36
36
  def create_env_file
37
- template("basic.env", "#{name}/.env")
37
+ template("../common/basic.env", "#{name}/.env")
38
38
  end
39
39
 
40
40
  def run_bundler
@@ -0,0 +1,23 @@
1
+ require 'dotenv/load'
2
+ require 'minitest'
3
+ require 'minitest/autorun'
4
+ require 'minitest/reporters'
5
+ require 'minitest/given'
6
+
7
+ Minitest::Reporters.use!
8
+
9
+ describe 'When Initializing a <%= config[:name_as_class] %>' do
10
+ context 'Named Fred' do
11
+ Given(:fred) { <%= config[:name_as_class] %>.new(name: 'Fred') }
12
+ Then {
13
+ expect(fred.name).must_equal 'Fred'
14
+ }
15
+ end
16
+ end
17
+
18
+ class <%= config[:name_as_class] %>
19
+ attr_accessor :name
20
+ def initialize(name:)
21
+ @name = name
22
+ end
23
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
6
+
7
+ gem "minitest"
8
+ gem "minitest-reporters"
9
+ gem "minitest-given"
10
+
11
+ gem "guard"
12
+ gem "guard-minitest"
13
+
14
+ gem "dotenv"
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ clearing :on
4
+
5
+ guard :minitest, all_after_pass: true, test_folders: ["."], test_file_patterns: "*.rb" do
6
+ # We're using Minitest's Spec syntax, loaded by Given.
7
+ # We don't have to watch for spec files through because
8
+ # we're using a single file, which is also the app file.
9
+ watch(/^app\.rb$/) { "./app.rb" }
10
+ end
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'test_helper'
4
4
 
5
- class <%= config[:name_as_class] %>Test < MiniTest::Unit::TestCase
5
+ class <%= config[:name_as_class] %>Test < MiniTest::Test
6
6
  def test_default_class_instantiates
7
7
  assert <%= config[:name_as_class] %>.new
8
8
  end
@@ -11,7 +11,7 @@ require "dotenv/load"
11
11
  Minitest::Reporters.use!
12
12
 
13
13
  # ensure the environment is available
14
- class DefaultEnvironmentTest < MiniTest::Unit::TestCase
14
+ class DefaultEnvironmentTest < MiniTest::Test
15
15
  def test_default_environment
16
16
  assert_equal "test", ENV["TEST_VALUE"]
17
17
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Spiker
4
- VERSION = "0.1.4"
4
+ VERSION = "0.1.5"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spiker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aaron Norling
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-01-29 00:00:00.000000000 Z
11
+ date: 2022-01-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -47,19 +47,23 @@ files:
47
47
  - exe/spiker
48
48
  - lib/spiker.rb
49
49
  - lib/spiker/cli.rb
50
+ - lib/spiker/generators/given.rb
50
51
  - lib/spiker/generators/multi.rb
51
52
  - lib/spiker/generators/simple.rb
52
- - lib/spiker/generators/templates/basic.env
53
- - lib/spiker/generators/templates/multi_app.rb.erb
54
- - lib/spiker/generators/templates/multi_app_test.rb.erb
55
- - lib/spiker/generators/templates/multi_gemfile.rb
56
- - lib/spiker/generators/templates/multi_guardfile.rb
57
- - lib/spiker/generators/templates/multi_rakefile.rb
58
- - lib/spiker/generators/templates/multi_readme.md.erb
59
- - lib/spiker/generators/templates/multi_test_helper.rb
60
- - lib/spiker/generators/templates/simple_app.rb.erb
61
- - lib/spiker/generators/templates/simple_gemfile.rb
62
- - lib/spiker/generators/templates/simple_guardfile.rb
53
+ - lib/spiker/generators/templates/common/basic.env
54
+ - lib/spiker/generators/templates/given/app.rb.erb
55
+ - lib/spiker/generators/templates/given/gemfile.rb
56
+ - lib/spiker/generators/templates/given/guardfile.rb
57
+ - lib/spiker/generators/templates/multi/app.rb.erb
58
+ - lib/spiker/generators/templates/multi/app_test.rb.erb
59
+ - lib/spiker/generators/templates/multi/gemfile.rb
60
+ - lib/spiker/generators/templates/multi/guardfile.rb
61
+ - lib/spiker/generators/templates/multi/rakefile.rb
62
+ - lib/spiker/generators/templates/multi/readme.md.erb
63
+ - lib/spiker/generators/templates/multi/test_helper.rb
64
+ - lib/spiker/generators/templates/simple/app.rb.erb
65
+ - lib/spiker/generators/templates/simple/gemfile.rb
66
+ - lib/spiker/generators/templates/simple/guardfile.rb
63
67
  - lib/spiker/version.rb
64
68
  - spiker.gemspec
65
69
  homepage: http://github.com/norlinga/spiker