iba 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 14fbefc240682b4cf95c79cf93598e2e8b12dd70
4
+ data.tar.gz: c3501eda480f88b302353c718a3a452d470c94d2
5
+ SHA512:
6
+ metadata.gz: c13f36b28278479f94947f0c62c3fb600d16c5c3db034825fb580b6d4d76f61e00a7c6110661720a22cd525e3054894d599fd355241c3ac2be03c67adfa56927
7
+ data.tar.gz: 0a5e9b56dcbde33f6033d32ec7117ce03ff3dc37c158b5cfd2da323d5880508b2dae6ddf585d88b38c6639d286198a3180bfd87166795d58053ddf2f898b0815
data/Rakefile CHANGED
@@ -1,3 +1,18 @@
1
- load 'tasks/setup.rb'
1
+ require 'rake/clean'
2
+ require 'bundler/gem_tasks'
3
+ require 'rake/testtask'
4
+
5
+ namespace :test do
6
+
7
+ Rake::TestTask.new(:run) do |t|
8
+ t.libs = ['lib']
9
+ t.test_files = FileList['test/**/*_test.rb']
10
+ t.ruby_opts += ['-w']
11
+ end
12
+
13
+ end
14
+
15
+ desc 'Alias to test:run'
16
+ task :test => 'test:run'
2
17
 
3
18
  task :default => 'test:run'
data/lib/iba.rb CHANGED
@@ -1,186 +1,205 @@
1
1
  module Iba
2
+ class Combinator
3
+ def initialize &blk
4
+ @block = blk
5
+ end
2
6
 
3
- class Combinator
4
- def initialize &blk
5
- @block = blk
6
- end
7
-
8
- def call
9
- @block.call
10
- end
7
+ def call
8
+ @block.call
9
+ end
11
10
 
12
- def to_s
13
- expression._to_s
14
- end
11
+ def to_s
12
+ expression._to_s
13
+ end
15
14
 
16
- def expression
17
- @expression ||= EmptyExpression.new._parse(&@block)
18
- end
15
+ def expression
16
+ @expression ||= EmptyExpression.new._parse(&@block)
17
+ end
19
18
 
20
- def analyse
21
- str = "#{self.to_s} is #{self.call.inspect}"
22
- if expression.class == MethodCallExpression and expression._method == :==
23
- b = @block.binding
24
- lft = expression._reciever
25
- rgt = expression._args.first
26
- exprs = [lft, rgt].map {|e| display_subexpression e}.compact
27
- str << "\n"
28
- str << exprs.join(", ")
29
- end
30
- str
31
- end
19
+ def analyse
20
+ str = "#{self} is #{call.inspect}"
21
+ if expression.class == MethodCallExpression && expression._method == :==
22
+ lft = expression._reciever
23
+ rgt = expression._args.first
24
+ exprs = [lft, rgt].map { |e| display_subexpression e }.compact
25
+ str << "\n"
26
+ str << exprs.join(', ')
27
+ end
28
+ str
29
+ end
32
30
 
33
- private
31
+ private
34
32
 
35
- def display_subexpression expr
36
- if expr.class == LiteralExpression
37
- nil
38
- else
39
- str = expr._to_s
40
- "#{str} is #{eval(str, @block.binding).inspect}"
33
+ def display_subexpression expr
34
+ if expr.class == LiteralExpression
35
+ nil
36
+ else
37
+ str = expr._to_s
38
+ "#{str} is #{eval(str, @block.binding).inspect}"
39
+ end
41
40
  end
42
41
  end
43
42
 
44
- end
43
+ class EmptyExpression
44
+ def method_missing method, *args
45
+ MethodCallExpression.new self, method, args
46
+ end
45
47
 
46
- class EmptyExpression
47
- def method_missing method, *args
48
- return MethodCallExpression.new self, method, args
49
- end
48
+ def _parse &blk
49
+ b = blk.binding
50
+
51
+ vars = eval 'local_variables', b
52
+ ivars = eval 'instance_variables', b
50
53
 
51
- def _parse &blk
52
- b = blk.binding
54
+ _override_instance_variables ivars
53
55
 
54
- vars = eval "local_variables", b
55
- ivars = eval "instance_variables", b
56
+ _override_local_variables vars, b
56
57
 
57
- _override_instance_variables ivars
58
+ result = instance_eval(&blk)
59
+ unless result.class == MethodCallExpression
60
+ result = LiteralExpression.new(result)
61
+ end
58
62
 
59
- _override_local_variables vars, b
63
+ _restore_local_variables vars, b
60
64
 
61
- result = self.instance_eval(&blk)
62
- unless result.class == MethodCallExpression
63
- result = LiteralExpression.new(result)
65
+ result
64
66
  end
65
67
 
66
- _restore_local_variables vars, b
67
-
68
- result
69
- end
68
+ def _override_instance_variables vars
69
+ vars.each do |v|
70
+ next if v =~ /^@_/
71
+ eval "#{v} = Iba::MethodCallExpression.new(Iba::EmptyExpression.new, :#{v}, [])"
72
+ end
73
+ end
70
74
 
71
- def _override_instance_variables vars
72
- vars.each do |v|
73
- next if v =~ /^@_/
74
- eval "#{v} = Iba::MethodCallExpression.new(Iba::EmptyExpression.new, :#{v}, [])"
75
+ def _override_local_variables vars, b
76
+ vars.each do |v|
77
+ next if v =~ /^_/
78
+ eval "_#{v} = #{v}", b
79
+ eval "#{v} = Iba::MethodCallExpression.new(Iba::EmptyExpression.new, :#{v}, [])", b
80
+ end
75
81
  end
76
- end
77
82
 
78
- def _override_local_variables vars, b
79
- vars.each do |v|
80
- next if v =~ /^_/
81
- eval "_#{v} = #{v}", b
82
- eval "#{v} = Iba::MethodCallExpression.new(Iba::EmptyExpression.new, :#{v}, [])", b
83
+ def _restore_local_variables vars, b
84
+ vars.each do |v|
85
+ next if v =~ /^_/
86
+ eval "#{v} = _#{v}", b
87
+ end
83
88
  end
84
- end
85
89
 
86
- def _restore_local_variables vars, b
87
- vars.each do |v|
88
- next if v =~ /^_/
89
- eval "#{v} = _#{v}", b
90
+ def _to_s
91
+ ''
90
92
  end
91
93
  end
92
94
 
93
- def _to_s
94
- ""
95
- end
96
- end
97
-
98
- class LiteralExpression
99
- def initialize val
100
- @value = val
101
- end
95
+ class LiteralExpression
96
+ def initialize val
97
+ @value = val
98
+ end
102
99
 
103
- def _to_s
104
- @value.inspect
100
+ def _to_s
101
+ @value.inspect
102
+ end
105
103
  end
106
- end
107
104
 
108
- class MethodCallExpression
109
- attr_reader :_method, :_reciever, :_args
105
+ class MethodCallExpression
106
+ attr_reader :_method, :_reciever, :_args
110
107
 
111
- def initialize reciever, methodname, args
112
- @_reciever = reciever
113
- @_method = methodname
114
- @_args = args.map {|a| _wrap(a)}
115
- end
108
+ def initialize reciever, methodname, args
109
+ @_reciever = reciever
110
+ @_method = methodname
111
+ @_args = args.map { |a| _wrap(a) }
112
+ end
116
113
 
117
- def _to_s
118
- rcv = @_reciever._to_s
119
- args = @_args.map {|a| a.respond_to?(:_to_s) ? a._to_s : a.to_s }
120
-
121
- if @_method == :[]
122
- "#{rcv}[#{args[0]}]"
123
- elsif method_is_operator?
124
- case @_args.length
125
- when 0
126
- "#{@_method.to_s.sub(/@$/, '')}#{rcv}"
127
- when 1
128
- "(#{rcv} #{@_method} #{args.first})"
114
+ def _to_s
115
+ rcv = @_reciever._to_s
116
+ args = @_args.map { |a| a.respond_to?(:_to_s) ? a._to_s : a.to_s }
117
+
118
+ if @_method == :[]
119
+ "#{rcv}[#{args[0]}]"
120
+ elsif method_is_operator?
121
+ case @_args.length
122
+ when 0
123
+ "#{@_method.to_s.sub(/@$/, '')}#{rcv}"
124
+ when 1
125
+ "(#{rcv} #{@_method} #{args.first})"
126
+ else
127
+ raise NotImplementedError
128
+ end
129
129
  else
130
- raise NotImplementedError
130
+ str = rcv == '' ? '' : "#{rcv}."
131
+ str << @_method.to_s
132
+ str << "(#{args.join(', ')})" unless @_args.empty?
133
+ str
131
134
  end
132
- else
133
- str = rcv == "" ? "" : "#{rcv}."
134
- str << @_method.to_s
135
- unless @_args.empty?
136
- str << "(#{args.join(', ')})"
137
- end
138
- str
139
135
  end
140
- end
141
136
 
142
- def method_missing method, *args
143
- super if method.to_s =~ /^_/
144
- return MethodCallExpression.new self, method, args
145
- end
137
+ def method_missing method, *args
138
+ super if method.to_s =~ /^_/
139
+ MethodCallExpression.new self, method, args
140
+ end
146
141
 
147
- def method_is_operator?
148
- @_method.to_s !~ /^[a-z]/
149
- end
142
+ def method_is_operator?
143
+ @_method.to_s !~ /^[a-z]/
144
+ end
150
145
 
151
- def to_s
152
- method_missing :to_s
153
- end
146
+ def to_s
147
+ method_missing :to_s
148
+ end
154
149
 
155
- def == other
156
- method_missing :==, other
157
- end
150
+ def == other
151
+ method_missing :==, other
152
+ end
158
153
 
159
- private
154
+ private
160
155
 
161
- def _wrap arg
162
- if arg.class == MethodCallExpression
163
- arg
164
- else
165
- LiteralExpression.new arg
156
+ def _wrap arg
157
+ if arg.class == MethodCallExpression
158
+ arg
159
+ else
160
+ LiteralExpression.new arg
161
+ end
166
162
  end
167
163
  end
168
- end
169
164
 
170
- module BlockAssertion
171
- def assert *args
172
- if block_given?
173
- if yield
174
- assert_block("true") { true }
175
- else
176
- msg = args.empty? ? "" : args.first
177
- ana = Combinator.new(&Proc.new).analyse
178
- assert_block(build_message(msg, "#{ana}.")) { false }
165
+ module BlockAssertion
166
+ if RUBY_VERSION < '1.9'
167
+
168
+ def assert *args
169
+ if block_given?
170
+ if yield
171
+ assert_block('true') { true }
172
+ else
173
+ msg = args.empty? ? '' : args.first
174
+ ana = Combinator.new(&Proc.new).analyse
175
+ assert_block(build_message msg, "#{ana}.") { false }
176
+ end
177
+ else
178
+ super
179
+ end
179
180
  end
181
+
180
182
  else
181
- super
183
+
184
+ def assert *args
185
+ if block_given?
186
+ if yield
187
+ assert_block('true') { true }
188
+ else
189
+ msg = args.empty? ? '' : args.first
190
+ ana = Combinator.new(&Proc.new).analyse
191
+ assert_block(message(msg) { ana }) { false }
192
+ end
193
+ else
194
+ test, msg = *args
195
+ case msg
196
+ when nil, String
197
+ msg = message(msg) { '<false> is not true' }
198
+ end
199
+ super test, msg
200
+ end
201
+ end
202
+
182
203
  end
183
204
  end
184
205
  end
185
-
186
- end
data/test/.rubocop.yml ADDED
@@ -0,0 +1,10 @@
1
+ inherit_from: ../.rubocop.yml
2
+
3
+ # We need to rescue Exception to test exceptions thrown by assert
4
+ # TODO: Remove once support for Ruby 1.8 is dropped.
5
+ Lint/RescueException:
6
+ Enabled: false
7
+
8
+ # Allow compact syntax when adding to Test::Unit::TestCase
9
+ Style/ClassAndModuleChildren:
10
+ Enabled: false
data/test/analyse_test.rb CHANGED
@@ -3,41 +3,41 @@ require File.expand_path('test_helper.rb', File.dirname(__FILE__))
3
3
  # Test how the combinator analyses the parsed block contents.
4
4
  class AnalyseTest < Test::Unit::TestCase
5
5
  def test_empty_block
6
- assert_equal "nil is nil", combinator { }.analyse
6
+ assert_equal 'nil is nil', combinator {}.analyse
7
7
  end
8
8
 
9
9
  def test_variable
10
10
  foo = 23
11
- assert_equal "foo is 23", combinator { foo }.analyse
11
+ assert_equal 'foo is 23', combinator { foo }.analyse
12
12
  end
13
13
 
14
14
  def test_operator_equals
15
15
  foo = 42
16
16
  bar = 23
17
- assert_equal "(foo == bar) is false\nfoo is 42, bar is 23",
18
- combinator { foo == bar }.analyse
17
+ result = combinator { foo == bar }.analyse
18
+ assert_equal "(foo == bar) is false\nfoo is 42, bar is 23", result
19
19
  end
20
20
 
21
21
  def test_operator_equals_literal
22
22
  foo = 42
23
- assert_equal "(foo == 23) is false\nfoo is 42",
24
- combinator { foo == 23 }.analyse
23
+ result = combinator { foo == 23 }.analyse
24
+ assert_equal "(foo == 23) is false\nfoo is 42", result
25
25
  end
26
26
 
27
27
  def test_operator_equals_array_literal
28
- foo = [1, "bar"]
29
- assert_equal "(foo == [2, \"baz\"]) is false\nfoo is [1, \"bar\"]",
30
- combinator { foo == [2, "baz"] }.analyse
28
+ foo = [1, 'bar']
29
+ result = combinator { foo == [2, 'baz'] }.analyse
30
+ assert_equal "(foo == [2, \"baz\"]) is false\nfoo is [1, \"bar\"]", result
31
31
  end
32
32
 
33
33
  def test_string_variable
34
- foo = "blub"
34
+ foo = 'blub'
35
35
  assert_equal "foo is \"blub\"", combinator { foo }.analyse
36
36
  end
37
37
 
38
38
  def test_array_variable
39
39
  foo = [1, 2]
40
- assert_equal "foo is [1, 2]", combinator { foo }.analyse
40
+ assert_equal 'foo is [1, 2]', combinator { foo }.analyse
41
41
  end
42
42
 
43
43
  def test_object_variable
@@ -47,12 +47,11 @@ class AnalyseTest < Test::Unit::TestCase
47
47
  end
48
48
 
49
49
  def test_literal
50
- assert_equal "23 is 23", combinator { 23 }.analyse
50
+ assert_equal '23 is 23', combinator { 23 }.analyse
51
51
  end
52
52
 
53
53
  def test_instance_variable
54
54
  @foo = 23
55
- assert_equal "@foo is 23", combinator { @foo }.analyse
55
+ assert_equal '@foo is 23', combinator { @foo }.analyse
56
56
  end
57
57
  end
58
-
data/test/assert_test.rb CHANGED
@@ -7,15 +7,13 @@ class AssertTest < Test::Unit::TestCase
7
7
  end
8
8
 
9
9
  def failing_block_assertion_test message, &block
10
- begin
11
- assert(&block)
12
- rescue Exception => e
13
- assert_equal message, e.message
14
- end
10
+ assert(&block)
11
+ rescue Exception => e
12
+ assert_equal message, e.message
15
13
  end
16
14
 
17
15
  def test_simple_failing_assert
18
- failing_block_assertion_test("false is false.") { false }
16
+ failing_block_assertion_test('false is false.') { false }
19
17
  end
20
18
 
21
19
  def test_operator_equals_assert
@@ -33,26 +31,21 @@ class AssertTest < Test::Unit::TestCase
33
31
  def test_assert_with_custom_message
34
32
  foo = false
35
33
  begin
36
- assert("We want foo") { foo }
34
+ assert('We want foo') { foo }
37
35
  rescue Exception => e
38
36
  assert_equal "We want foo.\nfoo is false.", e.message
39
37
  end
40
38
  end
41
39
 
42
- def test_original_assert
43
- begin
44
- assert false
45
- rescue Exception => e
46
- assert_equal "<false> is not true.", e.message
47
- end
40
+ def test_blockless_assert
41
+ assert false
42
+ rescue Exception => e
43
+ assert_equal '<false> is not true.', e.message
48
44
  end
49
45
 
50
- def test_original_assert_with_custom_message
51
- begin
52
- assert false, "We want the truth"
53
- rescue Exception => e
54
- assert_equal "We want the truth.\n<false> is not true.", e.message
55
- end
46
+ def test_blockless_assert_with_custom_message
47
+ assert false, 'We want the truth'
48
+ rescue Exception => e
49
+ assert_equal "We want the truth.\n<false> is not true.", e.message
56
50
  end
57
51
  end
58
-
data/test/call_test.rb CHANGED
@@ -3,7 +3,7 @@ require File.expand_path('test_helper.rb', File.dirname(__FILE__))
3
3
  # Test how the combinator calls the passed block.
4
4
  class CallTest < Test::Unit::TestCase
5
5
  def test_empty_combinator
6
- assert_equal nil, combinator { }.call
6
+ assert_equal nil, combinator {}.call
7
7
  end
8
8
 
9
9
  def test_variable
data/test/display_test.rb CHANGED
@@ -3,55 +3,55 @@ require File.expand_path('test_helper.rb', File.dirname(__FILE__))
3
3
  # Test how the combinator displays the parsed block contents.
4
4
  class DisplayTest < Test::Unit::TestCase
5
5
  def test_empty_combinator
6
- assert_equal "nil", combinator { }.to_s
6
+ assert_equal 'nil', combinator {}.to_s
7
7
  end
8
8
 
9
9
  def test_literal_number
10
- assert_equal "23", combinator { 23 }.to_s
10
+ assert_equal '23', combinator { 23 }.to_s
11
11
  end
12
12
 
13
13
  def test_literal_string
14
- assert_equal "\"aa\"", combinator { "aa" }.to_s
14
+ assert_equal "\"aa\"", combinator { 'aa' }.to_s
15
15
  end
16
16
 
17
17
  def test_method_calls
18
- assert_equal "foo", combinator { foo }.to_s
19
- assert_equal "foo.foo", combinator { foo.foo }.to_s
20
- assert_equal "foo.foo(1)", combinator { foo.foo 1 }.to_s
21
- assert_equal "foo(1)", combinator { foo 1 }.to_s
22
- assert_equal "foo(bar)", combinator { foo bar }.to_s
23
- assert_equal "foo(1).bar", combinator { foo(1).bar }.to_s
24
- assert_equal "foo.foo.foo", combinator { foo.foo.foo }.to_s
25
- assert_equal "foo(bar.baz)", combinator { foo bar.baz }.to_s
18
+ assert_equal 'foo', combinator { foo }.to_s
19
+ assert_equal 'foo.foo', combinator { foo.foo }.to_s
20
+ assert_equal 'foo.foo(1)', combinator { foo.foo 1 }.to_s
21
+ assert_equal 'foo(1)', combinator { foo 1 }.to_s
22
+ assert_equal 'foo(bar)', combinator { foo bar }.to_s
23
+ assert_equal 'foo(1).bar', combinator { foo(1).bar }.to_s
24
+ assert_equal 'foo.foo.foo', combinator { foo.foo.foo }.to_s
25
+ assert_equal 'foo(bar.baz)', combinator { foo bar.baz }.to_s
26
26
  end
27
27
 
28
28
  def test_operators
29
- assert_equal "(foo + 1)", combinator { foo + 1 }.to_s
30
- assert_equal "(foo - 1)", combinator { foo - 1 }.to_s
29
+ assert_equal '(foo + 1)', combinator { foo + 1 }.to_s
30
+ assert_equal '(foo - 1)', combinator { foo - 1 }.to_s
31
31
  end
32
32
 
33
33
  def test_operator_equals
34
- assert_equal "(foo == 1)", combinator { foo == 1 }.to_s
34
+ assert_equal '(foo == 1)', combinator { foo == 1 }.to_s
35
35
  end
36
36
 
37
37
  def test_array_index
38
- assert_equal "foo[1]", combinator { foo[1] }.to_s
38
+ assert_equal 'foo[1]', combinator { foo[1] }.to_s
39
39
  end
40
40
 
41
41
  def test_to_s_method
42
- assert_equal "foo.to_s", combinator { foo.to_s }.to_s
42
+ assert_equal 'foo.to_s', combinator { foo.to_s }.to_s
43
43
  end
44
44
 
45
45
  def test_operator_unary_minus
46
- assert_equal "-foo", combinator { -foo }.to_s
46
+ assert_equal '-foo', combinator { -foo }.to_s
47
47
  end
48
48
 
49
49
  def test_operator_if_wont_work
50
- assert_equal "bar", combinator { foo ? bar : baz }.to_s
50
+ assert_equal 'bar', combinator { foo ? bar : baz }.to_s
51
51
  end
52
52
 
53
53
  def test_defined_instance_variables
54
54
  @foo = 1
55
- assert_equal "@foo", combinator { @foo }.to_s
55
+ assert_equal '@foo', combinator { @foo }.to_s
56
56
  end
57
57
  end
data/test/test_helper.rb CHANGED
@@ -2,11 +2,10 @@ require 'test/unit'
2
2
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
3
  require 'iba'
4
4
 
5
- class Test::Unit::TestCase
5
+ class Test::Unit::TestCase
6
6
  include Iba::BlockAssertion
7
7
 
8
8
  def combinator &blk
9
- return Iba::Combinator.new(&blk)
9
+ Iba::Combinator.new(&blk)
10
10
  end
11
-
12
11
  end
metadata CHANGED
@@ -1,89 +1,82 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: iba
3
- version: !ruby/object:Gem::Version
4
- hash: 27
5
- prerelease: false
6
- segments:
7
- - 0
8
- - 0
9
- - 2
10
- version: 0.0.2
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.3
11
5
  platform: ruby
12
- authors:
6
+ authors:
13
7
  - Matijs van Zuijlen
14
8
  autorequire:
15
9
  bindir: bin
16
10
  cert_chain: []
17
-
18
- date: 2011-02-25 00:00:00 +01:00
19
- default_executable:
20
- dependencies: []
21
-
11
+ date: 2015-05-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rake
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '10.1'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '10.1'
22
27
  description: Asserts blocks, prints introspective failure messages.
23
- email:
28
+ email:
24
29
  - matijs@matijs.net
25
30
  executables: []
26
-
27
31
  extensions: []
28
-
29
- extra_rdoc_files:
32
+ extra_rdoc_files:
30
33
  - README.rdoc
31
34
  - LICENSE
32
35
  - COPYING.LESSER
33
36
  - COPYING
34
- files:
35
- - lib/iba.rb
36
- - test/analyse_test.rb
37
- - test/test_helper.rb
38
- - test/call_test.rb
39
- - test/assert_test.rb
40
- - test/display_test.rb
41
- - tasks/test.rake
42
- - tasks/setup.rb
43
- - tasks/notes.rake
37
+ files:
38
+ - COPYING
44
39
  - COPYING.LESSER
45
40
  - LICENSE
46
41
  - README.rdoc
47
42
  - Rakefile
48
- - COPYING
49
- has_rdoc: true
43
+ - lib/iba.rb
44
+ - test/.rubocop.yml
45
+ - test/analyse_test.rb
46
+ - test/assert_test.rb
47
+ - test/call_test.rb
48
+ - test/display_test.rb
49
+ - test/test_helper.rb
50
50
  homepage: http://www.github.com/mvz/iba
51
51
  licenses: []
52
-
52
+ metadata: {}
53
53
  post_install_message:
54
- rdoc_options:
55
- - --main
54
+ rdoc_options:
55
+ - "--main"
56
56
  - README.rdoc
57
- require_paths:
57
+ require_paths:
58
58
  - lib
59
- required_ruby_version: !ruby/object:Gem::Requirement
60
- none: false
61
- requirements:
59
+ required_ruby_version: !ruby/object:Gem::Requirement
60
+ requirements:
62
61
  - - ">="
63
- - !ruby/object:Gem::Version
64
- hash: 3
65
- segments:
66
- - 0
67
- version: "0"
68
- required_rubygems_version: !ruby/object:Gem::Requirement
69
- none: false
70
- requirements:
62
+ - !ruby/object:Gem::Version
63
+ version: '0'
64
+ required_rubygems_version: !ruby/object:Gem::Requirement
65
+ requirements:
71
66
  - - ">="
72
- - !ruby/object:Gem::Version
73
- hash: 3
74
- segments:
75
- - 0
76
- version: "0"
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
77
69
  requirements: []
78
-
79
70
  rubyforge_project:
80
- rubygems_version: 1.3.7
71
+ rubygems_version: 2.4.5
81
72
  signing_key:
82
- specification_version: 3
73
+ specification_version: 4
83
74
  summary: Introspective Block Assertions
84
- test_files:
75
+ test_files:
76
+ - test/.rubocop.yml
85
77
  - test/analyse_test.rb
86
78
  - test/assert_test.rb
87
79
  - test/call_test.rb
88
80
  - test/display_test.rb
89
81
  - test/test_helper.rb
82
+ has_rdoc:
data/tasks/notes.rake DELETED
@@ -1,122 +0,0 @@
1
- # The following code is based on Bones 2.5.1
2
- #
3
-
4
- module Bones
5
-
6
- # A helper class used to find and display any annotations in a collection of
7
- # project files.
8
- #
9
- class AnnotationExtractor
10
-
11
- class Annotation < Struct.new(:line, :tag, :text)
12
- # Returns a string representation of the annotation. If the
13
- # <tt>:tag</tt> parameter is given as +true+, then the annotation tag
14
- # will be included in the string.
15
- #
16
- def to_s( opts = {} )
17
- s = "[%3d] " % line
18
- s << "[#{tag}] " if opts[:tag]
19
- s << text
20
- end
21
- end
22
-
23
- # Enumerate all the annoations for the given _project_ and _tag_. This
24
- # will search for all athe annotations and display them on standard
25
- # output.
26
- #
27
- def self.enumerate tag, id = nil, opts = {}
28
- extractor = new(tag, id)
29
- extractor.display(extractor.find, opts)
30
- end
31
-
32
- attr_reader :tag, :id
33
-
34
- # Creates a new annotation extractor configured to use the _project_ open
35
- # strcut and to search for the given _tag_ (which can be more than one tag
36
- # via a regular expression 'or' operation -- i.e. THIS|THAT|OTHER)
37
- #
38
- def initialize tag, id
39
- @tag = tag
40
- @id = @id_rgxp = nil
41
-
42
- unless id.nil? or id.empty?
43
- @id = id
44
- @id_rgxp = Regexp.new(Regexp.escape(id), Regexp::IGNORECASE)
45
- end
46
- end
47
-
48
- # Iterate over all the files in the project and extract annotations from
49
- # the those files. Returns the results as a hash for display.
50
- #
51
- def find
52
- results = {}
53
- rgxp = %r/(#{tag}):?\s*(.*?)(?:\s*(?:-?%>|\*+\/))?$/o
54
-
55
- files = Dir.glob("lib/**/*.rb")
56
- files += Dir.glob("test/**/*.rb")
57
- files += Dir.glob("bin/*")
58
- files.each do |fn|
59
- results.update(extract_annotations_from(fn, rgxp))
60
- end
61
-
62
- results
63
- end
64
-
65
- # Extract any annotations from the given _file_ using the regular
66
- # expression _pattern_ provided.
67
- #
68
- def extract_annotations_from( file, pattern )
69
- lineno = 0
70
- result = File.readlines(file).inject([]) do |list, line|
71
- lineno += 1
72
- next list unless m = pattern.match(line)
73
- next list << Annotation.new(lineno, m[1], m[2]) unless id
74
-
75
- text = m[2]
76
- if text =~ @id_rgxp
77
- list << Annotation.new(lineno, m[1], text)
78
- end
79
- list
80
- end
81
- result.empty? ? {} : { file => result }
82
- end
83
-
84
- # Print the results of the annotation extraction to the screen. If the
85
- # <tt>:tags</tt> option is set to +true+, then the annotation tag will be
86
- # displayed.
87
- #
88
- def display( results, opts = {} )
89
- results.keys.sort.each do |file|
90
- puts "#{file}:"
91
- results[file].each do |note|
92
- puts " * #{note.to_s(opts)}"
93
- end
94
- puts
95
- end
96
- end
97
-
98
- end # class AnnotationExtractor
99
- end # module Bones
100
-
101
- note_tags = ["TODO", "FIXME", "OPTIMIZE"]
102
-
103
- desc "Enumerate all annotations"
104
- task :notes do |t|
105
- id = if t.application.top_level_tasks.length > 1
106
- t.application.top_level_tasks.slice!(1..-1).join(' ')
107
- end
108
- Bones::AnnotationExtractor.enumerate(
109
- note_tags.join('|'), id, :tag => true)
110
- end
111
-
112
- namespace :notes do
113
- note_tags.each do |tag|
114
- desc "Enumerate all #{tag} annotations"
115
- task tag.downcase.to_sym do |t|
116
- id = if t.application.top_level_tasks.length > 1
117
- t.application.top_level_tasks.slice!(1..-1).join(' ')
118
- end
119
- Bones::AnnotationExtractor.enumerate(tag, id)
120
- end
121
- end
122
- end
data/tasks/setup.rb DELETED
@@ -1,6 +0,0 @@
1
- require 'rake/clean'
2
-
3
- # Load the other rake files in the tasks folder
4
- tasks_dir = File.expand_path(File.dirname(__FILE__))
5
- rakefiles = Dir.glob(File.join(tasks_dir, '*.rake')).sort
6
- import(*rakefiles)
data/tasks/test.rake DELETED
@@ -1,14 +0,0 @@
1
- require 'rake/testtask'
2
-
3
- namespace :test do
4
-
5
- Rake::TestTask.new(:run) do |t|
6
- t.libs = ['lib']
7
- t.test_files = FileList['test/**/*_test.rb']
8
- t.ruby_opts += ["-w"]
9
- end
10
-
11
- end
12
-
13
- desc 'Alias to test:run'
14
- task :test => 'test:run'