starting_blocks 0.7.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/sb +1 -55
- data/lib/starting_blocks/cli.rb +61 -0
- data/lib/starting_blocks/version.rb +1 -1
- data/lib/starting_blocks.rb +80 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8bedc7d456d9b28ecf38984623ec989cebebb7b8
|
4
|
+
data.tar.gz: f69e0f6ee97a803daeff7d99a09ed32c1bb816fc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3b3b23afd3633ecd7b6c43e67530cc23849f4ccc047d78835799f333043f0c4b6de8685aac98eae7a018a260c31786d32e9ddc2f1c96aa1f4a2d1132bfee07b5
|
7
|
+
data.tar.gz: 75e06939b7609d64cb7a87d54eaeff818390bd8f739b04d62be5300446ec871140aeec5d1f32bf1683ffde44901cfd710f930ccb10ec60191980279669ed94a6
|
data/bin/sb
CHANGED
@@ -1,59 +1,5 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
#require File.expand_path(File.dirname(__FILE__) + '/../lib/starting_blocks.rb')
|
4
3
|
require 'starting_blocks'
|
5
4
|
|
6
|
-
|
7
|
-
|
8
|
-
arguments = ARGV
|
9
|
-
config_file = File.expand_path('~/.sb')
|
10
|
-
|
11
|
-
if File.exists?(config_file)
|
12
|
-
additional_arguments = File.read(config_file).split(' ')
|
13
|
-
arguments += additional_arguments
|
14
|
-
end
|
15
|
-
|
16
|
-
require 'starting_blocks-blinky' if arguments.include? '--blinky'
|
17
|
-
require 'starting_blocks-growl' if arguments.include? '--growl'
|
18
|
-
require 'starting_blocks-stopplicht' if arguments.include? '--stopplicht'
|
19
|
-
|
20
|
-
StartingBlocks.verbose = arguments.include? '--verbose'
|
21
|
-
options[:no_vendor] = arguments.include?('--vendor') == false
|
22
|
-
options[:use_bundler] = Dir['Gemfile'].count > 0
|
23
|
-
|
24
|
-
def run_all_specs options
|
25
|
-
files = ['**/*_spec.rb*', '**/*_test.rb*', '**/test_*.rb*'].map do |d|
|
26
|
-
Dir[d].
|
27
|
-
select { |f| File.file?(f) }.
|
28
|
-
map { |x| File.expand_path(x) }
|
29
|
-
end.flatten
|
30
|
-
|
31
|
-
StartingBlocks::Runner.new(options).run_files files
|
32
|
-
end
|
33
|
-
|
34
|
-
if arguments.include? '--watch'
|
35
|
-
listener = StartingBlocks::Watcher.start_watching Dir, options
|
36
|
-
StartingBlocks.display "Going to sleep, waiting for changes"
|
37
|
-
|
38
|
-
puts 'Enter "stop" to stop the listener'
|
39
|
-
puts 'Enter a blank line to run all of the tests'
|
40
|
-
|
41
|
-
listener.start
|
42
|
-
loop do
|
43
|
-
user_input = STDIN.gets
|
44
|
-
if user_input == "stop\n"
|
45
|
-
exit
|
46
|
-
elsif user_input == "\n"
|
47
|
-
run_all_specs options
|
48
|
-
end
|
49
|
-
end
|
50
|
-
elsif arguments.include? '--off'
|
51
|
-
StartingBlocks::Extensions::BlinkyLighting.turn_off!
|
52
|
-
else
|
53
|
-
results = run_all_specs options
|
54
|
-
|
55
|
-
parsed_results = StartingBlocks::Publisher.result_parser.parse(results)
|
56
|
-
success = parsed_results[:color] == :green
|
57
|
-
|
58
|
-
exit success
|
59
|
-
end
|
5
|
+
StartingBlocks::Cli.run ARGV
|
@@ -0,0 +1,61 @@
|
|
1
|
+
module StartingBlocks
|
2
|
+
|
3
|
+
module Cli
|
4
|
+
|
5
|
+
def self.run arguments
|
6
|
+
load_the_arguments_to_be_considered arguments
|
7
|
+
setup_the_system
|
8
|
+
run_the_appropriate_command
|
9
|
+
end
|
10
|
+
|
11
|
+
class << self
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def load_the_arguments_to_be_considered arguments
|
16
|
+
StartingBlocks.arguments = build_all_arguments_with arguments
|
17
|
+
end
|
18
|
+
|
19
|
+
def build_all_arguments_with arguments
|
20
|
+
args = [arguments, arguments_from_the_config_file].flatten
|
21
|
+
args.map { |x| x.gsub('--', '').to_sym }
|
22
|
+
end
|
23
|
+
|
24
|
+
def arguments_from_the_config_file
|
25
|
+
config_file = File.expand_path('~/.sb')
|
26
|
+
return [] unless File.exists?(config_file)
|
27
|
+
File.read(config_file).split(' ')
|
28
|
+
end
|
29
|
+
|
30
|
+
def setup_the_system
|
31
|
+
StartingBlocks.arguments.each do |argument|
|
32
|
+
if operation = StartingBlocks.conditional_operations[argument]
|
33
|
+
operation.call
|
34
|
+
else
|
35
|
+
try_to_load_a_blinky_extension argument
|
36
|
+
end
|
37
|
+
end
|
38
|
+
StartingBlocks.operations_to_always_run.each { |_, o| o.call }
|
39
|
+
end
|
40
|
+
|
41
|
+
def try_to_load_a_blinky_extension argument
|
42
|
+
begin
|
43
|
+
require "starting_blocks-#{argument}"
|
44
|
+
rescue LoadError => error
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def run_the_appropriate_command
|
49
|
+
StartingBlocks.actions[name_of_action_to_take].call
|
50
|
+
end
|
51
|
+
|
52
|
+
def name_of_action_to_take
|
53
|
+
action = StartingBlocks.actions.keys.select { |x| StartingBlocks.arguments.include? x }.first
|
54
|
+
action || :run_all_tests
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
data/lib/starting_blocks.rb
CHANGED
@@ -4,12 +4,91 @@ require_relative 'starting_blocks/watcher'
|
|
4
4
|
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
8
|
|
9
9
|
module StartingBlocks
|
10
10
|
|
11
11
|
class << self
|
12
12
|
attr_accessor :verbose
|
13
|
+
attr_accessor :options
|
14
|
+
attr_accessor :arguments
|
15
|
+
attr_accessor :conditional_operations
|
16
|
+
|
17
|
+
def options
|
18
|
+
@options ||= {}
|
19
|
+
end
|
20
|
+
|
21
|
+
def arguments
|
22
|
+
@arguments ||= []
|
23
|
+
end
|
24
|
+
|
25
|
+
def actions
|
26
|
+
@actions ||= default_actions
|
27
|
+
end
|
28
|
+
|
29
|
+
def conditional_operations
|
30
|
+
@conditional_operations ||= default_conditional_operations
|
31
|
+
end
|
32
|
+
|
33
|
+
def operations_to_always_run
|
34
|
+
@operations_to_always_run ||= default_operations_to_always_run
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def default_operations_to_always_run
|
40
|
+
{
|
41
|
+
"vendor" => (-> { StartingBlocks.options[:no_vendor] = (StartingBlocks.arguments.include?(:vendor) == false) }),
|
42
|
+
"bundler" => (-> { StartingBlocks.options[:use_bundler] = (Dir['Gemfile'].count > 0) } )
|
43
|
+
}
|
44
|
+
end
|
45
|
+
|
46
|
+
def default_conditional_operations
|
47
|
+
{
|
48
|
+
verbose: -> { StartingBlocks.verbose }
|
49
|
+
}
|
50
|
+
end
|
51
|
+
|
52
|
+
def default_actions
|
53
|
+
{
|
54
|
+
watch: -> do
|
55
|
+
listener = StartingBlocks::Watcher.start_watching Dir, StartingBlocks.options
|
56
|
+
StartingBlocks.display "Going to sleep, waiting for changes"
|
57
|
+
puts 'Enter "stop" to stop the listener'
|
58
|
+
puts 'Enter a blank line to run all of the tests'
|
59
|
+
listener.start
|
60
|
+
loop do
|
61
|
+
user_input = STDIN.gets
|
62
|
+
if user_input == "stop\n"
|
63
|
+
exit
|
64
|
+
elsif user_input == "\n"
|
65
|
+
run_all_specs.call
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end,
|
69
|
+
run_all_tests: -> do
|
70
|
+
results = run_all_specs.call
|
71
|
+
parsed_results = StartingBlocks::Publisher.result_parser.parse(results)
|
72
|
+
success = parsed_results[:color] == :green
|
73
|
+
exit success
|
74
|
+
end,
|
75
|
+
off: -> do
|
76
|
+
StartingBlocks::Extensions::BlinkyLighting.turn_off!
|
77
|
+
end
|
78
|
+
}
|
79
|
+
end
|
80
|
+
|
81
|
+
def run_all_specs
|
82
|
+
->() do
|
83
|
+
files = ['**/*_spec.rb*', '**/*_test.rb*', '**/test_*.rb*'].map do |d|
|
84
|
+
Dir[d].
|
85
|
+
select { |f| File.file?(f) }.
|
86
|
+
map { |x| File.expand_path(x) }
|
87
|
+
end.flatten
|
88
|
+
StartingBlocks::Runner.new(StartingBlocks.options).run_files files
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
13
92
|
end
|
14
93
|
|
15
94
|
def self.display message
|
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: 0.
|
4
|
+
version: 1.0.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-
|
11
|
+
date: 2014-05-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -110,6 +110,7 @@ files:
|
|
110
110
|
- Rakefile
|
111
111
|
- bin/sb
|
112
112
|
- lib/starting_blocks.rb
|
113
|
+
- lib/starting_blocks/cli.rb
|
113
114
|
- lib/starting_blocks/publisher.rb
|
114
115
|
- lib/starting_blocks/result_parser.rb
|
115
116
|
- lib/starting_blocks/result_text_parser.rb
|