spiker 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +2 -0
- data/lib/spiker/cli.rb +3 -3
- data/lib/spiker/generators/multi.rb +59 -0
- data/lib/spiker/generators/simple.rb +1 -1
- data/lib/spiker/generators/templates/multi_app.rb +7 -0
- data/lib/spiker/generators/templates/multi_app_test.rb +13 -0
- data/lib/spiker/generators/templates/multi_gemfile.rb +10 -0
- data/lib/spiker/generators/templates/multi_guardfile.rb +10 -0
- data/lib/spiker/generators/templates/multi_rakefile.rb +12 -0
- data/lib/spiker/generators/templates/multi_test_helper.rb +10 -0
- data/lib/spiker/version.rb +1 -1
- data/lib/spiker.rb +10 -0
- metadata +9 -3
- data/lib/spiker/generators/multiple.rb +0 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 81a09f3b2f5b6389926bfd1b9838e889f76f9dfdf7bf5379f6de063105059d83
|
4
|
+
data.tar.gz: 64502b16628bf74e3b4e2936dd5762a24280dc03c9b2bfc70ad9563be56bad1e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '097c6ab3468ca458bdb3454f43cd9ab5c7dd82983574e110efcad78057a1b060f44fb7e1786513d6f286facf1581e60c9e3b6ab8fb8fffe14ca97f09ebaa5e5c'
|
7
|
+
data.tar.gz: b2c60304559b5a6b92bc3478853f2d4f583b00943b3ddbe6dd347dc1981d4003dce5bd2327662a923151cc6709a13e667fbc6cd1cf658f86d3b04c06bc6e09cb
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
data/lib/spiker/cli.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
require "thor"
|
4
4
|
require_relative "version"
|
5
5
|
require_relative "generators/simple"
|
6
|
-
require_relative "generators/
|
6
|
+
require_relative "generators/multi"
|
7
7
|
|
8
8
|
module Spiker
|
9
9
|
# Accept options "single" and "multiple"
|
@@ -21,10 +21,10 @@ module Spiker
|
|
21
21
|
Spiker::Generators::Simple.start([name])
|
22
22
|
end
|
23
23
|
|
24
|
-
desc "
|
24
|
+
desc "multi NAME", "Spike over multiple files"
|
25
25
|
method_option :name, type: :string, aliases: "-n", desc: "Name of the spike"
|
26
26
|
def multiple(name)
|
27
|
-
Spiker::Generators::
|
27
|
+
Spiker::Generators::Multi.start([name])
|
28
28
|
end
|
29
29
|
end
|
30
30
|
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "thor/group"
|
4
|
+
require_relative "../../spiker"
|
5
|
+
|
6
|
+
module Spiker
|
7
|
+
module Generators
|
8
|
+
# Generates multiple spike files, seperating tests from the
|
9
|
+
# tested code. For when the spike gets too hairy for a single
|
10
|
+
# file.
|
11
|
+
class Multi < Thor::Group
|
12
|
+
include Thor::Actions
|
13
|
+
|
14
|
+
argument :name, type: :string
|
15
|
+
|
16
|
+
def self.source_root
|
17
|
+
"#{File.dirname(__FILE__)}/templates"
|
18
|
+
end
|
19
|
+
|
20
|
+
def create_spike_directories
|
21
|
+
empty_directory(name)
|
22
|
+
empty_directory("#{name}/lib")
|
23
|
+
empty_directory("#{name}/test")
|
24
|
+
end
|
25
|
+
|
26
|
+
def create_test_files
|
27
|
+
name_in_snake_case = Spiker.snake_case(name)
|
28
|
+
name_as_class = Spiker.classify(name)
|
29
|
+
opts = { name_as_class: name_as_class, name_in_snake_case: name_in_snake_case }
|
30
|
+
template("multi_app_test.rb", "#{name}/test/#{name_in_snake_case}_test.rb", opts)
|
31
|
+
template("multi_test_helper.rb", "#{name}/test/test_helper.rb", opts)
|
32
|
+
end
|
33
|
+
|
34
|
+
def create_app_files
|
35
|
+
name_in_snake_case = Spiker.snake_case(name)
|
36
|
+
opts = { name_as_class: Spiker.classify(name) }
|
37
|
+
template("multi_app.rb", "#{name}/lib/#{name_in_snake_case}.rb", opts)
|
38
|
+
end
|
39
|
+
|
40
|
+
def create_guard_file
|
41
|
+
template("multi_guardfile.rb", "#{name}/Guardfile")
|
42
|
+
end
|
43
|
+
|
44
|
+
def create_gem_file
|
45
|
+
template("multi_gemfile.rb", "#{name}/Gemfile")
|
46
|
+
end
|
47
|
+
|
48
|
+
def create_rake_file
|
49
|
+
template("multi_rakefile.rb", "#{name}/Rakefile")
|
50
|
+
end
|
51
|
+
|
52
|
+
def run_bundler
|
53
|
+
inside(name) do
|
54
|
+
run("bundle install")
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'test_helper'
|
4
|
+
|
5
|
+
class <%= config[:name_as_class] %>Test < MiniTest::Unit::TestCase
|
6
|
+
def test_default_class_instantiates
|
7
|
+
assert <%= config[:name_as_class] %>.new
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_default_class_responds_to_hello
|
11
|
+
assert_equal "Hello, world!", <%= config[:name_as_class] %>.hello
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
clearing :on
|
4
|
+
|
5
|
+
guard :minitest, all_after_pass: true do
|
6
|
+
# with Minitest::Unit
|
7
|
+
watch(%r{^test/(.*)\/?(.*)_test\.rb$})
|
8
|
+
watch(%r{^lib/(.*/)?([^/]+)\.rb$}) { |m| "test/#{m[1]}#{m[2]}_test.rb" }
|
9
|
+
watch(%r{^test/test_helper\.rb$}) { 'test' }
|
10
|
+
end
|
data/lib/spiker/version.rb
CHANGED
data/lib/spiker.rb
CHANGED
@@ -2,10 +2,20 @@
|
|
2
2
|
|
3
3
|
require_relative "spiker/version"
|
4
4
|
|
5
|
+
# Spiker is a simple spike generator.
|
5
6
|
module Spiker
|
6
7
|
class Error < StandardError; end
|
7
8
|
|
8
9
|
def self.classify(str)
|
9
10
|
str.split(/[^A-Za-z0-0]/).map(&:capitalize).join
|
10
11
|
end
|
12
|
+
|
13
|
+
def self.snake_case(str)
|
14
|
+
# lifted from ActiveSupport inflectors
|
15
|
+
str.gsub(/::/, "/")
|
16
|
+
.gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
|
17
|
+
.gsub(/([a-z\d])([A-Z])/, '\1_\2')
|
18
|
+
.tr("-", "_")
|
19
|
+
.downcase
|
20
|
+
end
|
11
21
|
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
|
+
version: 0.1.2
|
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-
|
11
|
+
date: 2022-01-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -47,8 +47,14 @@ files:
|
|
47
47
|
- exe/spiker
|
48
48
|
- lib/spiker.rb
|
49
49
|
- lib/spiker/cli.rb
|
50
|
-
- lib/spiker/generators/
|
50
|
+
- lib/spiker/generators/multi.rb
|
51
51
|
- lib/spiker/generators/simple.rb
|
52
|
+
- lib/spiker/generators/templates/multi_app.rb
|
53
|
+
- lib/spiker/generators/templates/multi_app_test.rb
|
54
|
+
- lib/spiker/generators/templates/multi_gemfile.rb
|
55
|
+
- lib/spiker/generators/templates/multi_guardfile.rb
|
56
|
+
- lib/spiker/generators/templates/multi_rakefile.rb
|
57
|
+
- lib/spiker/generators/templates/multi_test_helper.rb
|
52
58
|
- lib/spiker/generators/templates/simple_app.rb
|
53
59
|
- lib/spiker/generators/templates/simple_gemfile.rb
|
54
60
|
- lib/spiker/generators/templates/simple_guardfile.rb
|
@@ -1,15 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "thor/group"
|
4
|
-
module Spiker
|
5
|
-
module Generators
|
6
|
-
# Generates multiple spike files, seperating tests from the
|
7
|
-
# tested code. For when the spike gets too hairy for a single
|
8
|
-
# file.
|
9
|
-
class Multiple < Thor::Group
|
10
|
-
include Thor::Actions
|
11
|
-
|
12
|
-
argument :name, type: :string
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|