starting_blocks 1.2.1 → 1.3.0

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
  SHA1:
3
- metadata.gz: 19a0a1f6a480f8b3044b50341b17c467084eb6ae
4
- data.tar.gz: 2747ea5cb18050cbaddcaeea8966505fc982958c
3
+ metadata.gz: 3ce4e880814c71fa1c9174d5cd5434ea103adf95
4
+ data.tar.gz: 0a161dd6c02163a8af232282868e8f64dbdf5b1e
5
5
  SHA512:
6
- metadata.gz: e986d863dc89b7ce661f682d76eff623f171b6e41039de3dda2004244a86b22643619d4ad3ffcfa9a143b43229a997846159e447ae7306f99a227b26db497ea9
7
- data.tar.gz: 8d84ed1409a3ec70f5d8fb75264255ec575a53de22995ed6d5d3c1aaab58b3379806654d9a9bdc1d1c436f29f4324ae7424d46c986e80b40ec40c3cb4d951bbd
6
+ metadata.gz: a805f694449086284b027a891c9801d8e5f5b6a49845ec712b3eb5baa361926ba620e244ab7722ce792bbd085fc9faa0c2112c850e3b987c91f66b626b73c5bf
7
+ data.tar.gz: 00f70b03454fad00d7323e33d0826b76547e96c03328202a2480d5db3afe4b76994ecd366177b10c67228f8cb9d3a838758a1a70859f5c4e271b296c4e3663e5
data/README.md CHANGED
@@ -1,9 +1,5 @@
1
1
  # Starting Blocks
2
2
 
3
- [![Build Status](https://travis-ci.org/darrencauthon/starting_blocks.png?branch=master)](https://travis-ci.org/darrencauthon/starting_blocks)
4
- [![Code Climate](https://codeclimate.com/github/darrencauthon/starting_blocks.png)](https://codeclimate.com/github/darrencauthon/starting_blocks)
5
- [![Coverage Status](https://coveralls.io/repos/darrencauthon/subtle/badge.png?branch=master)](https://coveralls.io/r/darrencauthon/starting_blocks)
6
-
7
3
  ## Why?
8
4
 
9
5
  The purpose of this gem is to run my Minitest specs, with no hassle. No Rakefile updates, no Gemfile/gemspec installs, and no regex Guard files.
@@ -35,25 +31,40 @@ sb
35
31
  Run the tests in any test or spec file after it is saved. Will also run the specs for any file that has a matching test or spec file:
36
32
 
37
33
  ````
38
- sb --watch
34
+ sb watch
35
+ ````
36
+
37
+ Run any arbitrary command through starting blocks. The results of the statement (notably the success or failure determined by the exit code) will be published through your starting blocks plugins.
38
+
39
+ ````
40
+ sb execute "git push heroku master"
39
41
  ````
40
42
 
43
+ ## Plugins
44
+
45
+ ### Blinky Light
41
46
  Turn your [blinky light](https://github.com/perryn/blinky) red/yellow/green based on the results of your test run:
42
47
 
43
48
  ````
44
- sb --blinky
49
+ gem install starting_blocks-blinky
50
+ sb blinky
45
51
  ````
46
52
 
47
- Pop a growl message based on the test results:
53
+ ### Growl
54
+ Pop a growl message based on your test results:
48
55
 
49
56
  ````
50
- sb --growl
57
+ gem install starting_blocks-growl
58
+ sb growl
51
59
  ````
52
60
 
53
- Run the tests with all of the options listed above:
61
+ ### Stopplicht
62
+
63
+ Change your stopplicht based on your test results:
54
64
 
55
65
  ````
56
- sb --growl --blinky --watch
66
+ gem install starting_blocks-stopplicht
67
+ sb growl
57
68
  ````
58
69
 
59
70
  ## Installation
@@ -61,11 +72,3 @@ sb --growl --blinky --watch
61
72
  Install it yourself with:
62
73
 
63
74
  $ gem install starting_blocks
64
-
65
- If you would like to use a [blinky light](https://github.com/perryn/blinky) to show the results of your tests:
66
-
67
- $ gem install starting_blocks-blinky
68
-
69
- If you would like growl results of your tests:
70
-
71
- $ gem install starting_blocks-growl
@@ -0,0 +1,13 @@
1
+ module StartingBlocks
2
+ module Bash
3
+ def self.run command
4
+ text = `#{command}`
5
+ result = $?
6
+ {
7
+ text: text,
8
+ success: result.success?,
9
+ exit_code: result.to_i
10
+ }
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,11 @@
1
+ module StartingBlocks
2
+
3
+ class BashPublisher
4
+
5
+ def receive_results results
6
+ puts results[:text]
7
+ end
8
+
9
+ end
10
+
11
+ end
@@ -52,9 +52,9 @@ module StartingBlocks
52
52
  def execute_these_files files
53
53
  requires = files.map { |x| "require '#{x}'" }.join("\n")
54
54
  if options[:use_bundler]
55
- `bundle exec ruby -e "#{requires}"`
55
+ Bash.run "bundle exec ruby -e \"#{requires}\""
56
56
  else
57
- `ruby -e "#{requires}"`
57
+ Bash.run "ruby -e \"#{requires}\""
58
58
  end
59
59
  end
60
60
 
@@ -0,0 +1,11 @@
1
+ module StartingBlocks
2
+
3
+ class PassThroughResultBuilder
4
+
5
+ def build_from results
6
+ results
7
+ end
8
+
9
+ end
10
+
11
+ end
@@ -1,12 +1,20 @@
1
1
  module StartingBlocks
2
2
  module Publisher
3
3
  class << self
4
- attr_accessor :subscribers, :result_parser
4
+ attr_accessor :subscribers, :result_builder
5
+
6
+ def subscribers
7
+ @subscribers ||= [BashPublisher.new]
8
+ end
9
+
10
+ def result_builder
11
+ @result_builder ||= StartingBlocks::ResultBuilder.new
12
+ end
5
13
 
6
14
  def publish_results results
7
- return unless @subscribers
8
- @subscribers.each do |s|
9
- parsed_results = StartingBlocks::Publisher.result_parser.parse(results)
15
+ return unless subscribers
16
+ subscribers.each do |s|
17
+ parsed_results = StartingBlocks::Publisher.result_builder.build_from results
10
18
  begin
11
19
  s.receive_results parsed_results
12
20
  rescue
@@ -15,8 +23,8 @@ module StartingBlocks
15
23
  end
16
24
 
17
25
  def publish_files_to_run files
18
- return unless @subscribers
19
- @subscribers.each do |s|
26
+ return unless subscribers
27
+ subscribers.each do |s|
20
28
  begin
21
29
  s.receive_files_to_run files
22
30
  rescue
@@ -26,5 +34,3 @@ module StartingBlocks
26
34
  end
27
35
  end
28
36
  end
29
- StartingBlocks::Publisher.subscribers = []
30
- StartingBlocks::Publisher.result_parser = StartingBlocks::ResultParser.new
@@ -1,10 +1,13 @@
1
1
  module StartingBlocks
2
- class ResultParser
3
2
 
4
- def parse text
5
- output = load_the_output_from text
6
- output[:color] = color
7
- output
3
+ class ResultBuilder
4
+
5
+ def build_from run_result
6
+ load_the_output_from(run_result[:text])
7
+ .merge(color: color,
8
+ text: run_result[:text],
9
+ exit_code: run_result[:exit_code],
10
+ success: run_result[:success])
8
11
  end
9
12
 
10
13
  private
@@ -17,7 +20,7 @@ module StartingBlocks
17
20
  end
18
21
 
19
22
  def load_the_output_from text
20
- @output = StartingBlocks::ResultTextParser.new.parse text
23
+ @output = StartingBlocks::TextParser.new.parse text
21
24
  end
22
25
 
23
26
  def tests_exist?
@@ -11,7 +11,6 @@ module StartingBlocks
11
11
  StartingBlocks::Publisher.publish_files_to_run files
12
12
  results = execute_these_files files
13
13
  StartingBlocks::Publisher.publish_results results
14
- puts results
15
14
  results
16
15
  end
17
16
 
@@ -1,5 +1,5 @@
1
1
  module StartingBlocks
2
- class ResultTextParser
2
+ class TextParser
3
3
  def parse(text)
4
4
  @text = text
5
5
  {
@@ -28,4 +28,3 @@ module StartingBlocks
28
28
  end
29
29
  end
30
30
  end
31
-
@@ -1,3 +1,3 @@
1
1
  module StartingBlocks
2
- VERSION = "1.2.1"
2
+ VERSION = "1.3.0"
3
3
  end
@@ -89,7 +89,7 @@ module StartingBlocks
89
89
  end
90
90
 
91
91
  def store_the_specs_if_they_failed results, specs
92
- parsed_results = StartingBlocks::Publisher.result_parser.parse(results)
92
+ parsed_results = StartingBlocks::Publisher.result_builder.build_from results
93
93
  if parsed_results[:failures] > 0 || parsed_results[:skips] > 0 || parsed_results[:errors] > 0
94
94
  @last_failed_run = specs
95
95
  else
@@ -1,11 +1,6 @@
1
- require "starting_blocks/version"
2
- require_relative 'starting_blocks/runner'
3
- require_relative 'starting_blocks/watcher'
4
- require_relative 'starting_blocks/result_parser'
5
- require_relative 'starting_blocks/result_text_parser'
6
- require_relative 'starting_blocks/publisher'
7
- require_relative 'starting_blocks/cli'
8
- require_relative 'starting_blocks/minitest_contract'
1
+ require_relative "starting_blocks/bash_publisher"
2
+ require_relative "starting_blocks/result_builder"
3
+ Dir[File.dirname(__FILE__) + '/starting_blocks/*.rb'].each { |f| require f }
9
4
 
10
5
  module StartingBlocks
11
6
 
@@ -52,6 +47,20 @@ module StartingBlocks
52
47
 
53
48
  def default_actions
54
49
  {
50
+ execute: -> do
51
+ StartingBlocks::Publisher.result_builder = StartingBlocks::PassThroughResultBuilder.new
52
+
53
+ statement_to_execute = ARGV[ARGV.index('execute') + 1]
54
+ StartingBlocks::Publisher.publish_files_to_run [statement_to_execute]
55
+ result = StartingBlocks::Bash.run(statement_to_execute)
56
+ StartingBlocks::Publisher.publish_results( { color: (result[:success] ? :green : :red),
57
+ tests: 1,
58
+ assertions: 1,
59
+ failures: (result[:success] ? 0 : 1),
60
+ errors: 0,
61
+ skips: 0 })
62
+ puts result[:text]
63
+ end,
55
64
  watch: -> do
56
65
  listener = StartingBlocks::Watcher.start_watching Dir, StartingBlocks.options
57
66
  StartingBlocks.display "Going to sleep, waiting for changes"
@@ -69,7 +78,7 @@ module StartingBlocks
69
78
  end,
70
79
  run_all_tests: -> do
71
80
  results = run_all_specs.call
72
- parsed_results = StartingBlocks::Publisher.result_parser.parse(results)
81
+ parsed_results = StartingBlocks::Publisher.result_builder.build_from results
73
82
  success = parsed_results[:color] == :green
74
83
  exit success
75
84
  end,
@@ -96,4 +105,3 @@ module StartingBlocks
96
105
  puts message if @verbose
97
106
  end
98
107
  end
99
- #StartingBlocks::Publisher.subscribers << StartingBlocks::Extensions::BlinkyLighting.new
@@ -4,12 +4,12 @@ describe StartingBlocks::Publisher do
4
4
 
5
5
  let(:results) { Object.new }
6
6
  let(:parsed_results) { Object.new }
7
- let(:result_parser) { mock() }
7
+ let(:result_builder) { mock() }
8
8
  let(:files) { Object.new }
9
9
 
10
10
  before do
11
- result_parser.stubs(:parse).with(results).returns parsed_results
12
- StartingBlocks::Publisher.result_parser = result_parser
11
+ result_builder.stubs(:build_from).with(results).returns parsed_results
12
+ StartingBlocks::Publisher.result_builder = result_builder
13
13
  end
14
14
 
15
15
  describe "#publish_results" do
@@ -1,21 +1,47 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
2
 
3
- describe StartingBlocks::ResultParser do
3
+ describe StartingBlocks::ResultBuilder do
4
4
 
5
5
  let(:parsed_output) { {} }
6
+ let(:text) { Object.new }
7
+ let(:success) { Object.new }
8
+ let(:exit_code) { Object.new }
6
9
 
7
10
  let(:output) do
8
- text = Object.new
9
11
  text_parser = Object.new
12
+ input = {
13
+ text: text,
14
+ success: success,
15
+ exit_code: exit_code,
16
+ }
10
17
 
11
- StartingBlocks::ResultTextParser.stubs(:new).returns text_parser
12
- text_parser.stubs(:parse).with(text).returns parsed_output
18
+ StartingBlocks::TextParser.stubs(:new).returns text_parser
19
+ text_parser.stubs(:parse).returns parsed_output
13
20
 
14
- StartingBlocks::ResultParser.new.parse text
21
+ StartingBlocks::ResultBuilder.new.build_from input
15
22
  end
16
23
 
17
- it "should return the result from the text parser" do
18
- output.must_be_same_as parsed_output
24
+
25
+ describe "returning results from the text parser" do
26
+
27
+ it "should return the data from the text parser" do
28
+ key, value = Object.new, Object.new
29
+ parsed_output[key] = value
30
+ output[key].must_be_same_as value
31
+ end
32
+
33
+ it "should return the text as the text" do
34
+ output[:text].must_be_same_as text
35
+ end
36
+
37
+ it "should return the success flag" do
38
+ output[:success].must_be_same_as success
39
+ end
40
+
41
+ it "should return the exit code" do
42
+ output[:exit_code].must_be_same_as exit_code
43
+ end
44
+
19
45
  end
20
46
 
21
47
  describe "different output scenarios" do
@@ -13,7 +13,6 @@ describe StartingBlocks::Runner do
13
13
  runner.expects(:execute_these_files).with(files).returns results
14
14
  StartingBlocks::Publisher.expects(:publish_files_to_run).with files
15
15
  StartingBlocks::Publisher.expects(:publish_results).with results
16
- runner.expects(:puts).with results
17
16
 
18
17
  @results = runner.run_files files
19
18
  end
@@ -48,7 +47,6 @@ describe StartingBlocks::Runner do
48
47
  runner.expects(:execute_these_files).with(files).returns results
49
48
  StartingBlocks::Publisher.expects(:publish_files_to_run).with files
50
49
  StartingBlocks::Publisher.expects(:publish_results).with results
51
- runner.expects(:puts).with results
52
50
 
53
51
  @results = runner.run_files files
54
52
  end
@@ -86,7 +84,6 @@ describe StartingBlocks::Runner do
86
84
  runner.expects(:execute_these_files).with(files_without_vendor).returns results
87
85
  StartingBlocks::Publisher.expects(:publish_files_to_run).with files_without_vendor
88
86
  StartingBlocks::Publisher.expects(:publish_results).with results
89
- runner.expects(:puts).with results
90
87
 
91
88
  @results = runner.run_files files
92
89
  end
@@ -1,6 +1,6 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
2
 
3
- describe StartingBlocks::ResultTextParser do
3
+ describe StartingBlocks::TextParser do
4
4
  describe "simple case" do
5
5
  let(:text) do <<EOF
6
6
  Fabulous tests in 0.000372s, 2688.1720 tests/s, 2688.1720 assertions/s.
@@ -22,7 +22,7 @@ EOF
22
22
  end
23
23
 
24
24
  def subject
25
- StartingBlocks::ResultTextParser.new
25
+ StartingBlocks::TextParser.new
26
26
  end
27
27
 
28
28
  it "should return the counts" do
@@ -49,7 +49,7 @@ EOF
49
49
  end
50
50
 
51
51
  def subject
52
- StartingBlocks::ResultTextParser.new
52
+ StartingBlocks::TextParser.new
53
53
  end
54
54
 
55
55
  it "should return the counts" do
@@ -76,7 +76,7 @@ EOF
76
76
  end
77
77
 
78
78
  def subject
79
- StartingBlocks::ResultTextParser.new
79
+ StartingBlocks::TextParser.new
80
80
  end
81
81
 
82
82
  it "should return the counts" do
@@ -105,7 +105,7 @@ EOF
105
105
  end
106
106
 
107
107
  def subject
108
- StartingBlocks::ResultTextParser.new
108
+ StartingBlocks::TextParser.new
109
109
  end
110
110
 
111
111
  it "should return the counts" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: starting_blocks
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Darren Cauthon
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-27 00:00:00.000000000 Z
11
+ date: 2014-07-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -110,19 +110,22 @@ files:
110
110
  - Rakefile
111
111
  - bin/sb
112
112
  - lib/starting_blocks.rb
113
+ - lib/starting_blocks/bash.rb
114
+ - lib/starting_blocks/bash_publisher.rb
113
115
  - lib/starting_blocks/cli.rb
114
116
  - lib/starting_blocks/minitest_contract.rb
117
+ - lib/starting_blocks/pass_through_result_builder.rb
115
118
  - lib/starting_blocks/publisher.rb
116
- - lib/starting_blocks/result_parser.rb
117
- - lib/starting_blocks/result_text_parser.rb
119
+ - lib/starting_blocks/result_builder.rb
118
120
  - lib/starting_blocks/runner.rb
121
+ - lib/starting_blocks/text_parser.rb
119
122
  - lib/starting_blocks/version.rb
120
123
  - lib/starting_blocks/watcher.rb
121
124
  - spec/spec_helper.rb
122
125
  - spec/starting_blocks/publisher_spec.rb
123
- - spec/starting_blocks/result_parser_spec.rb
124
- - spec/starting_blocks/result_text_parser_spec.rb
126
+ - spec/starting_blocks/result_builder_spec.rb
125
127
  - spec/starting_blocks/runner_spec.rb
128
+ - spec/starting_blocks/text_parser_spec.rb
126
129
  - spec/starting_blocks/watcher_spec.rb
127
130
  - starting_blocks.gemspec
128
131
  homepage: http://www.github.com/darrencauthon/starting_blocks
@@ -152,7 +155,7 @@ summary: One command to run all tests, test watcher, etc.
152
155
  test_files:
153
156
  - spec/spec_helper.rb
154
157
  - spec/starting_blocks/publisher_spec.rb
155
- - spec/starting_blocks/result_parser_spec.rb
156
- - spec/starting_blocks/result_text_parser_spec.rb
158
+ - spec/starting_blocks/result_builder_spec.rb
157
159
  - spec/starting_blocks/runner_spec.rb
160
+ - spec/starting_blocks/text_parser_spec.rb
158
161
  - spec/starting_blocks/watcher_spec.rb