tango 0.0.7 → 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- tango (0.0.7)
4
+ tango (0.0.8)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
data/README.md CHANGED
@@ -111,6 +111,14 @@ Useful Helper Methods
111
111
  end
112
112
  end
113
113
 
114
+ ### Fetching a Remote URL
115
+
116
+ step "..." do
117
+ cd "/tmp" do
118
+ fetch "http://example.com/something.tar.gz"
119
+ end
120
+ end
121
+
114
122
  Copyright
115
123
  ---------
116
124
 
@@ -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
@@ -0,0 +1,9 @@
1
+ module Tango
2
+ module Fetch
3
+
4
+ def fetch(url)
5
+ shell("wget", "--progress=bar:force", "--continue", url)
6
+ end
7
+
8
+ end
9
+ end
@@ -9,14 +9,18 @@ module Tango
9
9
  end
10
10
 
11
11
  def meet(&meet_block)
12
- raise MeetWithoutMetError if @met_block.nil?
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 instance_eval(&@met_block)
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(&@met_block)
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
@@ -1,3 +1,3 @@
1
1
  module Tango
2
- VERSION = "0.0.7"
2
+ VERSION = "0.0.8"
3
3
  end
@@ -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: 17
4
+ hash: 15
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 7
10
- version: 0.0.7
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-11 00:00:00 +10:00
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