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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a83635eae4874bcb567fdcae912b250f3c4096620c5703885d5de9c501527090
4
- data.tar.gz: f2dc29b6a4dd30cf380c44b68f970f15ac93cea3db71ab86db22c657a4e9ea65
3
+ metadata.gz: 81a09f3b2f5b6389926bfd1b9838e889f76f9dfdf7bf5379f6de063105059d83
4
+ data.tar.gz: 64502b16628bf74e3b4e2936dd5762a24280dc03c9b2bfc70ad9563be56bad1e
5
5
  SHA512:
6
- metadata.gz: 63f83edb340f1480c296fbc6eff8e1f943086f0bfecf3146d0f9581d0a674131b66bb196ae65bcf9893e5c3003fa0dda49419b3acdfa06449f27c4118dafc448
7
- data.tar.gz: '03718cc66377cd005f6a27334da152ab2f331c52e5f58d60a0f24dcc73eda967a30cc94a8479433b59fdc19c577a9bf880ef36e92352bffde3b523069accab0e'
6
+ metadata.gz: '097c6ab3468ca458bdb3454f43cd9ab5c7dd82983574e110efcad78057a1b060f44fb7e1786513d6f286facf1581e60c9e3b6ab8fb8fffe14ca97f09ebaa5e5c'
7
+ data.tar.gz: b2c60304559b5a6b92bc3478853f2d4f583b00943b3ddbe6dd347dc1981d4003dce5bd2327662a923151cc6709a13e667fbc6cd1cf658f86d3b04c06bc6e09cb
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- spiker (0.1.1)
4
+ spiker (0.1.2)
5
5
  thor (~> 0.19)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -4,6 +4,8 @@ Spiker helps you validate your ideas under test. It can also be a basic educati
4
4
 
5
5
  ## Installation
6
6
 
7
+ [![Gem Version](https://badge.fury.io/rb/spiker.svg)](https://badge.fury.io/rb/spiker)
8
+
7
9
  Add this line to your application's Gemfile:
8
10
 
9
11
  ```ruby
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/multiple"
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 "multiple NAME", "Spike over multiple files"
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::Multiple.start([name])
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
@@ -21,7 +21,7 @@ module Spiker
21
21
  end
22
22
 
23
23
  def create_spike_file
24
- opts = {name_as_class: Spiker.classify(name)}
24
+ opts = { name_as_class: Spiker.classify(name) }
25
25
  template("simple_app.rb", "#{name}/app.rb", opts)
26
26
  end
27
27
 
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ class <%= config[:name_as_class] %>
4
+ def self.hello
5
+ "Hello, world!"
6
+ end
7
+ 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
+ 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 'guard'
10
+ gem 'guard-minitest'
@@ -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
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rake/testtask"
5
+
6
+ Rake::TestTask.new(:test) do |t|
7
+ t.libs << "test"
8
+ t.libs << "lib"
9
+ t.test_files = FileList["test/**/*_test.rb"]
10
+ end
11
+
12
+ task default: %i[test]
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ $LOAD_PATH.unshift File.expand_path("../lib", __dir__)
4
+ # require the default lib file
5
+ require "<%= config[:name_in_snake_case] %>"
6
+
7
+ require "minitest/autorun"
8
+ require "minitest/reporters"
9
+
10
+ Minitest::Reporters.use!
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Spiker
4
- VERSION = "0.1.1"
4
+ VERSION = "0.1.2"
5
5
  end
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.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-19 00:00:00.000000000 Z
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/multiple.rb
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