detagger 0.2.1 → 0.2.2

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/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.1
1
+ 0.2.2
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "detagger"
8
- s.version = "0.2.1"
8
+ s.version = "0.2.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["christfo"]
12
- s.date = "2012-03-21"
12
+ s.date = "2012-04-10"
13
13
  s.description = "This is intended to be used as a mixin, usualy with some kind of library that parses\n optional command line arguments. The feature here is that the options may contain tags ('example_tag:') that\n are not resolved until they are used. This means that one option may refer to another. An example might be:\n --stage /tmp/fred --logfile stage:/my.log \n which would later provide a method 'logfile' that would return '/tmp/fred/my.log' "
14
14
  s.email = "chris.fordy@gmail.com"
15
15
  s.extra_rdoc_files = [
@@ -80,7 +80,7 @@ module Detagger
80
80
  end
81
81
 
82
82
  def unless_flag( flag, &blk )
83
- unless self.send("detag_#{flag}")
83
+ unless self.send(:detag, self.send(flag) )
84
84
  yield blk
85
85
  else
86
86
  puts "\033[31m!! Skipping step due to #{flag.to_s.quote} being true...\033[0m"
@@ -89,7 +89,7 @@ module Detagger
89
89
  end
90
90
 
91
91
  def if_flag( flag, &blk )
92
- if self.send( "detag_#{flag}" )
92
+ if self.send(:detag, self.send(flag) )
93
93
  yield blk
94
94
  else
95
95
  puts "\033[31m!! Skipping step due to #{flag.to_s.quote} being false...\033[0m"
@@ -22,6 +22,7 @@ describe Detagger do
22
22
 
23
23
  def jim; "" end
24
24
  def soph; nil end
25
+ def dave; true end
25
26
  def matt; "soph:" end
26
27
  def mike; "sue:soph:sue:jim:" end
27
28
 
@@ -115,4 +116,32 @@ describe Detagger do
115
116
  @options.set_detag_chain( @options, second )
116
117
  @options.detag_bob.should == "correct"
117
118
  end
119
+
120
+ it "will provide if flag sugar" do
121
+ result = "Nowt"
122
+ capture(:stdout) {
123
+ @options.if_flag(:soph) { result = "BAD" }
124
+ }.should =~ /Skipping step/
125
+ result.should == "Nowt"
126
+ capture(:stdout) {
127
+ @options.if_flag(:matt) { result = "BAD" }
128
+ }.should =~ /Skipping step/
129
+ result.should == "Nowt"
130
+ capture(:stdout) {
131
+ @options.if_flag(:dave) { result = "GOOD" }
132
+ }.should == ""
133
+ result.should == "GOOD"
134
+ end
135
+
136
+ it "will provide unless flag sugar" do
137
+ result = "Nowt"
138
+ capture(:stdout) {
139
+ @options.unless_flag(:dave) { result = "BAD" }
140
+ }.should =~ /Skipping step/
141
+ result.should == "Nowt"
142
+ capture(:stdout) {
143
+ @options.unless_flag(:matt) { result = "GOOD" }
144
+ }.should == ""
145
+ result.should == "GOOD"
146
+ end
118
147
  end
@@ -3,6 +3,18 @@ $LOAD_PATH.unshift(File.dirname(__FILE__))
3
3
  require 'rspec'
4
4
  require 'detagger'
5
5
 
6
+ def capture(*streams)
7
+ begin
8
+ result = StringIO.new
9
+ streams.each { |stream| eval "$#{stream} = result" }
10
+ yield
11
+ rescue SystemExit
12
+ ensure
13
+ streams.each { |stream| eval("$#{stream} = #{stream.to_s.upcase}") }
14
+ end
15
+ result.string
16
+ end
17
+
6
18
  # Requires supporting files with custom matchers and macros, etc,
7
19
  # in ./support/ and its subdirectories.
8
20
  Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: detagger
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 1
10
- version: 0.2.1
9
+ - 2
10
+ version: 0.2.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - christfo
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-03-21 00:00:00 Z
18
+ date: 2012-04-10 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  type: :runtime