tango 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/README.md +8 -0
- data/lib/tango/config_files.rb +3 -1
- data/lib/tango/fetch.rb +9 -0
- data/lib/tango/met_and_meet.rb +7 -3
- data/lib/tango/runner.rb +2 -0
- data/lib/tango/version.rb +1 -1
- data/spec/met_and_meet_spec.rb +20 -0
- metadata +5 -4
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
data/lib/tango/config_files.rb
CHANGED
@@ -1,12 +1,14 @@
|
|
1
1
|
require 'erb'
|
2
|
+
require 'fileutils'
|
2
3
|
|
3
4
|
module Tango
|
4
5
|
module ConfigFiles
|
5
6
|
|
6
|
-
def write(path, contents)
|
7
|
+
def write(path, contents, permissions = nil)
|
7
8
|
contents = unindent(contents)
|
8
9
|
contents = ERB.new(contents).result(binding)
|
9
10
|
File.open(path, "w") {|file| file.write(contents) }
|
11
|
+
FileUtils.chmod(permissions, path) if permissions
|
10
12
|
end
|
11
13
|
|
12
14
|
private
|
data/lib/tango/fetch.rb
ADDED
data/lib/tango/met_and_meet.rb
CHANGED
@@ -9,14 +9,18 @@ module Tango
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def meet(&meet_block)
|
12
|
-
|
12
|
+
# Cache the met block in case something inside the meet
|
13
|
+
# block calls another step with another met block:
|
14
|
+
met_block = @met_block
|
13
15
|
|
14
|
-
if
|
16
|
+
raise MeetWithoutMetError if met_block.nil?
|
17
|
+
|
18
|
+
if instance_eval(&met_block)
|
15
19
|
log "already met."
|
16
20
|
else
|
17
21
|
log "not already met."
|
18
22
|
instance_eval(&meet_block)
|
19
|
-
if instance_eval(
|
23
|
+
if instance_eval(&met_block)
|
20
24
|
log "met."
|
21
25
|
else
|
22
26
|
raise CouldNotMeetError
|
data/lib/tango/runner.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'tango/as_user'
|
2
2
|
require 'tango/config_files'
|
3
3
|
require 'tango/delegate'
|
4
|
+
require 'tango/fetch'
|
4
5
|
require 'tango/met_and_meet'
|
5
6
|
require 'tango/shell'
|
6
7
|
require 'tango/working_directory'
|
@@ -10,6 +11,7 @@ module Tango
|
|
10
11
|
include AsUser
|
11
12
|
include ConfigFiles
|
12
13
|
include Delegate
|
14
|
+
include Fetch
|
13
15
|
include MetAndMeet
|
14
16
|
include Shell
|
15
17
|
include WorkingDirectory
|
data/lib/tango/version.rb
CHANGED
data/spec/met_and_meet_spec.rb
CHANGED
@@ -69,6 +69,26 @@ module Tango
|
|
69
69
|
end.should raise_error(MeetWithoutMetError)
|
70
70
|
end
|
71
71
|
|
72
|
+
it "should not have met blocks trample on one another" do
|
73
|
+
klass = Class.new do
|
74
|
+
include MetAndMeet
|
75
|
+
|
76
|
+
def log(message); end
|
77
|
+
|
78
|
+
def a
|
79
|
+
met? { false }
|
80
|
+
meet { b }
|
81
|
+
end
|
82
|
+
|
83
|
+
def b
|
84
|
+
met? { @b_done }
|
85
|
+
meet { @b_done = true }
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
expect { klass.new.a }.should raise_error(CouldNotMeetError)
|
90
|
+
end
|
91
|
+
|
72
92
|
end
|
73
93
|
end
|
74
94
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tango
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 15
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 8
|
10
|
+
version: 0.0.8
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Pete Yandell
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-04-
|
18
|
+
date: 2011-04-13 00:00:00 +10:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -54,6 +54,7 @@ files:
|
|
54
54
|
- lib/tango/as_user.rb
|
55
55
|
- lib/tango/config_files.rb
|
56
56
|
- lib/tango/delegate.rb
|
57
|
+
- lib/tango/fetch.rb
|
57
58
|
- lib/tango/logger.rb
|
58
59
|
- lib/tango/met_and_meet.rb
|
59
60
|
- lib/tango/runner.rb
|