starting_blocks 1.0.0 → 1.1.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: 8bedc7d456d9b28ecf38984623ec989cebebb7b8
4
- data.tar.gz: f69e0f6ee97a803daeff7d99a09ed32c1bb816fc
3
+ metadata.gz: a570ce0b87dc0e06bba355362104f156bf390b81
4
+ data.tar.gz: 188d784ae83e06de86ee644d84552830f859e2ea
5
5
  SHA512:
6
- metadata.gz: 3b3b23afd3633ecd7b6c43e67530cc23849f4ccc047d78835799f333043f0c4b6de8685aac98eae7a018a260c31786d32e9ddc2f1c96aa1f4a2d1132bfee07b5
7
- data.tar.gz: 75e06939b7609d64cb7a87d54eaeff818390bd8f739b04d62be5300446ec871140aeec5d1f32bf1683ffde44901cfd710f930ccb10ec60191980279669ed94a6
6
+ metadata.gz: 4b3bd0160e74595d7e0d571c1a97b180d0133f69e2d9ff03781842185b18fbd9dfe303d3dd42ae2aaeb8db13133f0f9a63ac58e7e6a2be47af4c3419f630e45d
7
+ data.tar.gz: 7d6a5de4b19b44baca1cc64947045e7b82962551c9406dd83dd31b333bcd46276695ee67a97e29abfa65eebace058d193d201cc7fc75a9f9e439037edf23a031
@@ -0,0 +1,38 @@
1
+ module StartingBlocks
2
+
3
+ class Contract
4
+
5
+ attr_reader :options
6
+
7
+ def initialize options
8
+ @options = options
9
+ end
10
+
11
+ def self.inherited klass
12
+ @contract_types ||= []
13
+ @contract_types << klass
14
+ end
15
+
16
+ def file_clues
17
+ ["test", "spec"]
18
+ end
19
+
20
+ def extensions
21
+ []
22
+ end
23
+
24
+ def filter_these_files files
25
+ files
26
+ end
27
+
28
+ def execute_these_files files
29
+ raise 'You have to define how to execute these files.'
30
+ end
31
+
32
+ def self.for options
33
+ @contract_types.last.new options
34
+ end
35
+
36
+ end
37
+
38
+ end
@@ -0,0 +1,28 @@
1
+ module StartingBlocks
2
+
3
+ class MinitestContract < Contract
4
+
5
+ def file_clues
6
+ ["_test", "test_", "_spec"]
7
+ end
8
+
9
+ def extensions
10
+ ['.rb']
11
+ end
12
+
13
+ def filter_these_files files
14
+ files.select { |x| options[:include_vendor] || x.include?('/vendor/') == false }
15
+ end
16
+
17
+ def execute_these_files files
18
+ requires = files.map { |x| "require '#{x}'" }.join("\n")
19
+ if options[:use_bundler]
20
+ `bundle exec ruby -e "#{requires}"`
21
+ else
22
+ `ruby -e "#{requires}"`
23
+ end
24
+ end
25
+
26
+ end
27
+
28
+ end
@@ -2,12 +2,11 @@ module StartingBlocks
2
2
  class Runner
3
3
 
4
4
  def initialize options
5
- @use_bundler = options[:use_bundler]
6
- @include_vendor = options[:no_vendor] != true
5
+ @contract = StartingBlocks::Contract.for options
7
6
  end
8
7
 
9
8
  def run_files files
10
- files = files.select { |x| @include_vendor || x.include?('/vendor/') == false }
9
+ files = @contract.filter_these_files files
11
10
  StartingBlocks.display "Files to run: #{files.inspect}"
12
11
  StartingBlocks::Publisher.publish_files_to_run files
13
12
  results = execute_these_files files
@@ -19,12 +18,9 @@ module StartingBlocks
19
18
  private
20
19
 
21
20
  def execute_these_files files
22
- requires = files.map { |x| "require '#{x}'" }.join("\n")
23
- if @use_bundler
24
- `bundle exec ruby -e "#{requires}"`
25
- else
26
- `ruby -e "#{requires}"`
27
- end
21
+ @contract.execute_these_files files
28
22
  end
23
+
29
24
  end
25
+
30
26
  end
@@ -1,3 +1,3 @@
1
1
  module StartingBlocks
2
- VERSION = "1.0.0"
2
+ VERSION = "1.1.0"
3
3
  end
@@ -3,14 +3,13 @@ require 'listen'
3
3
  module StartingBlocks
4
4
  module Watcher
5
5
 
6
- TEST_FILE_CLUES = ["_test", "test_", "_spec"]
7
-
8
6
  @last_failed_run = nil
9
7
 
10
8
  class << self
11
9
  def start_watching(dir, options)
12
10
  StartingBlocks.display("Start watching #{dir.getwd} with #{options.inspect}")
13
11
  set_up_the_runner options
12
+ set_up_the_contract options
14
13
 
15
14
  location = dir.getwd
16
15
  @all_files = Dir['**/*']
@@ -59,6 +58,10 @@ module StartingBlocks
59
58
  @runner = StartingBlocks::Runner.new(options)
60
59
  end
61
60
 
61
+ def set_up_the_contract options
62
+ @contract = StartingBlocks::Contract.for options
63
+ end
64
+
62
65
  def store_the_specs_if_they_failed results, specs
63
66
  parsed_results = StartingBlocks::Publisher.result_parser.parse(results)
64
67
  if parsed_results[:failures] > 0 || parsed_results[:skips] > 0 || parsed_results[:errors] > 0
@@ -81,13 +84,13 @@ module StartingBlocks
81
84
  end
82
85
 
83
86
  def is_a_test_file?(file)
84
- matches = TEST_FILE_CLUES.select { |clue| file.to_s.include?(clue) }
87
+ matches = @contract.file_clues.select { |clue| file.to_s.include?(clue) }
85
88
  matches.count > 0
86
89
  end
87
90
 
88
91
  def flush_file_name(file)
89
92
  the_file = file.downcase.split('/')[-1]
90
- TEST_FILE_CLUES.reduce(the_file) { |t, i| t.gsub(i, '') }
93
+ @contract.file_clues.reduce(the_file) { |t, i| t.gsub(i, '') }
91
94
  end
92
95
  end
93
96
  end
@@ -5,6 +5,8 @@ require_relative 'starting_blocks/result_parser'
5
5
  require_relative 'starting_blocks/result_text_parser'
6
6
  require_relative 'starting_blocks/publisher'
7
7
  require_relative 'starting_blocks/cli'
8
+ require_relative 'starting_blocks/contract'
9
+ require_relative 'starting_blocks/minitest_contract'
8
10
 
9
11
  module StartingBlocks
10
12
 
@@ -80,7 +82,13 @@ module StartingBlocks
80
82
 
81
83
  def run_all_specs
82
84
  ->() do
83
- files = ['**/*_spec.rb*', '**/*_test.rb*', '**/test_*.rb*'].map do |d|
85
+ contract = StartingBlocks::Contract.for StartingBlocks.options
86
+ file_specs = contract.file_clues.map do |clue|
87
+ contract.extensions.map do |extension|
88
+ "**/*#{clue}*.#{extension.gsub('.', '')}"
89
+ end
90
+ end.flatten
91
+ files = file_specs.map do |d|
84
92
  Dir[d].
85
93
  select { |f| File.file?(f) }.
86
94
  map { |x| File.expand_path(x) }
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.0.0
4
+ version: 1.1.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-05-25 00:00:00.000000000 Z
11
+ date: 2014-06-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -111,6 +111,8 @@ files:
111
111
  - bin/sb
112
112
  - lib/starting_blocks.rb
113
113
  - lib/starting_blocks/cli.rb
114
+ - lib/starting_blocks/contract.rb
115
+ - lib/starting_blocks/minitest_contract.rb
114
116
  - lib/starting_blocks/publisher.rb
115
117
  - lib/starting_blocks/result_parser.rb
116
118
  - lib/starting_blocks/result_text_parser.rb
@@ -143,7 +145,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
143
145
  version: '0'
144
146
  requirements: []
145
147
  rubyforge_project:
146
- rubygems_version: 2.2.2
148
+ rubygems_version: 2.0.14
147
149
  signing_key:
148
150
  specification_version: 4
149
151
  summary: One command to run all tests, test watcher, etc.