tango 0.1.9 → 0.1.10
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/tango/logger.rb +22 -4
- data/lib/tango/runner.rb +9 -3
- data/lib/tango/version.rb +1 -1
- data/spec/logger_spec.rb +13 -8
- data/spec/runner_spec.rb +3 -2
- metadata +5 -5
data/lib/tango/logger.rb
CHANGED
@@ -1,7 +1,20 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
3
|
module Tango
|
4
|
+
module TermANSIColorStubs
|
5
|
+
[:red, :green, :yellow].each do |color|
|
6
|
+
define_method(color) { |str| str }
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
4
10
|
class Logger
|
11
|
+
begin
|
12
|
+
require 'term/ansicolor'
|
13
|
+
include Term::ANSIColor
|
14
|
+
rescue LoadError
|
15
|
+
include TermANSIColorStubs
|
16
|
+
end
|
17
|
+
|
5
18
|
def self.instance
|
6
19
|
@logger ||= Logger.new
|
7
20
|
end
|
@@ -11,14 +24,19 @@ module Tango
|
|
11
24
|
@depth = 0
|
12
25
|
end
|
13
26
|
|
14
|
-
def
|
15
|
-
log "#{step_name} {"
|
27
|
+
def begin_step(step_name)
|
28
|
+
log "#{yellow(step_name)} {"
|
16
29
|
@depth += 1
|
17
30
|
end
|
18
31
|
|
19
|
-
def
|
32
|
+
def step_met(step_name)
|
33
|
+
@depth -= 1
|
34
|
+
log "} #{green("√ #{step_name}")}"
|
35
|
+
end
|
36
|
+
|
37
|
+
def step_not_met(step_name)
|
20
38
|
@depth -= 1
|
21
|
-
log "}
|
39
|
+
log "} #{red("✕ #{step_name}")}\n\n"
|
22
40
|
end
|
23
41
|
|
24
42
|
def log(message)
|
data/lib/tango/runner.rb
CHANGED
@@ -22,9 +22,15 @@ module Tango
|
|
22
22
|
define_method(step_name) do |*args|
|
23
23
|
description = step_description(step_name, args)
|
24
24
|
|
25
|
-
logger.
|
26
|
-
|
27
|
-
|
25
|
+
logger.begin_step(description)
|
26
|
+
begin
|
27
|
+
result = instance_exec(*args, &block)
|
28
|
+
rescue StandardError
|
29
|
+
logger.step_not_met(description)
|
30
|
+
raise
|
31
|
+
else
|
32
|
+
logger.step_met(description)
|
33
|
+
end
|
28
34
|
|
29
35
|
result
|
30
36
|
end
|
data/lib/tango/version.rb
CHANGED
data/spec/logger_spec.rb
CHANGED
@@ -11,22 +11,27 @@ module Tango
|
|
11
11
|
@logger = Logger.new(@io)
|
12
12
|
end
|
13
13
|
|
14
|
-
it "should output the step name when
|
15
|
-
@logger.
|
14
|
+
it "should output the step name when beginning a step" do
|
15
|
+
@logger.begin_step("example step")
|
16
16
|
@io.string.should == "example step {\n"
|
17
17
|
end
|
18
18
|
|
19
|
-
it "should output a closing brace when
|
20
|
-
@logger.
|
21
|
-
@logger.
|
19
|
+
it "should output a closing brace when a step is met" do
|
20
|
+
@logger.begin_step("example step")
|
21
|
+
@logger.step_met("example step")
|
22
22
|
@io.string.should == "example step {\n} √ example step\n"
|
23
23
|
end
|
24
24
|
|
25
|
+
it "should output a closing brace when a step is not met" do
|
26
|
+
@logger.begin_step("example step")
|
27
|
+
@logger.step_not_met("example step")
|
28
|
+
@io.string.should == "example step {\n} ✕ example step\n\n"
|
29
|
+
end
|
30
|
+
|
25
31
|
it "should indent nested steps" do
|
26
|
-
@logger.
|
27
|
-
@logger.
|
32
|
+
@logger.begin_step("outer step")
|
33
|
+
@logger.begin_step("inner step")
|
28
34
|
@io.string.should == "outer step {\n inner step {\n"
|
29
35
|
end
|
30
|
-
|
31
36
|
end
|
32
37
|
end
|
data/spec/runner_spec.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tango
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.10
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-03-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement: &
|
16
|
+
requirement: &70254852148920 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70254852148920
|
25
25
|
description: Experiment in deployment tools, taking ideas from babushka and elsewhere.
|
26
26
|
email:
|
27
27
|
- pete@notahat.com
|
@@ -86,7 +86,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
86
86
|
version: '0'
|
87
87
|
requirements: []
|
88
88
|
rubyforge_project: tango
|
89
|
-
rubygems_version: 1.8.
|
89
|
+
rubygems_version: 1.8.11
|
90
90
|
signing_key:
|
91
91
|
specification_version: 3
|
92
92
|
summary: Experiment in deployment tools.
|