fbo 0.1.3 → 0.1.4
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.
- checksums.yaml +4 -4
- data/lib/fbo/interpreter.rb +12 -1
- data/lib/fbo/version.rb +1 -1
- data/spec/fbo/interpreter_spec.rb +21 -13
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 73410fcfcca5e7d24f72b1647bd476d2524fd749
|
4
|
+
data.tar.gz: 169f5ab226cc08aa4bc9c8f9ab6aff6ba6813775
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 91db543ee60b0fe0ef767ac7d031bf7084e5928f5d3a7fd280ac2006b33e851dbfeeea7dd5b46bd7670a6195566ee12fbc56ee823bb948185eec052a73fe1563
|
7
|
+
data.tar.gz: 59dd1704c86d2a11bdd6205fe5317727a070d99e89240531609bd7fc1c7c2383ad056aa7ac1ceaf4dbc28cf16002db734adaa90349fb4af3f0f7af30a3475e5a
|
data/lib/fbo/interpreter.rb
CHANGED
@@ -5,8 +5,19 @@ module FBO
|
|
5
5
|
@parser = Parser.new
|
6
6
|
end
|
7
7
|
|
8
|
-
# Walk through
|
8
|
+
# Walk through all notices in the given file.
|
9
|
+
# For each notice, yield passing the text block and structure as args.
|
10
|
+
#
|
11
|
+
def each_notice(&block)
|
12
|
+
while true
|
13
|
+
string, structure = next_notice(&block)
|
14
|
+
break unless string
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
# Get the next notice from the file.
|
9
19
|
# If a block is given, yield passing the text block and structure as args.
|
20
|
+
# Return the text and structure.
|
10
21
|
#
|
11
22
|
def next_notice(&block)
|
12
23
|
return unless notice_text = next_notice_string
|
data/lib/fbo/version.rb
CHANGED
@@ -2,24 +2,32 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe FBO::Interpreter do
|
4
4
|
let(:filename) { File.join(File.dirname(__FILE__), '..', 'fixtures', 'FBOFeed20130331') }
|
5
|
-
let(:file) { FBO::File.new(filename) }
|
6
5
|
let(:actor) { MiniTest::Mock.new }
|
7
6
|
|
7
|
+
describe '#each_notice' do
|
8
|
+
let(:file) { FBO::File.new(filename) }
|
9
|
+
subject { FBO::Interpreter.new(file) }
|
8
10
|
|
9
|
-
|
10
|
-
|
11
|
+
it 'acts eight times - once on each notice' do
|
12
|
+
8.times { actor.expect(:process, nil, [String, Treetop::Runtime::SyntaxNode ]) }
|
13
|
+
subject.each_notice { |str, struct| actor.process(str, struct) }
|
14
|
+
actor.verify
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe '#next_notice' do
|
19
|
+
let(:file) { FBO::File.new(filename) }
|
20
|
+
subject { FBO::Interpreter.new(file) }
|
11
21
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
actor.verify
|
22
|
+
it 'acts on the first notice' do
|
23
|
+
actor.expect(:process, nil, [String, Treetop::Runtime::SyntaxNode ])
|
24
|
+
string, structure = subject.next_notice { |str, struct| actor.process(str, struct) }
|
25
|
+
actor.verify
|
17
26
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
end
|
27
|
+
string.must_match /^\<PRESOL\>/
|
28
|
+
string.must_match /\<SOLNBR\>SPE4A713R0795/
|
29
|
+
structure.type.must_equal :presol
|
30
|
+
structure.to_hash[:solicitation_number].must_equal 'SPE4A713R0795'
|
23
31
|
end
|
24
32
|
end
|
25
33
|
end
|