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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cb42052147996e0d44fdbaee04e245b538affecb
4
- data.tar.gz: 4fb9642b21ee11a0840110cd21ed1488ba779662
3
+ metadata.gz: 73410fcfcca5e7d24f72b1647bd476d2524fd749
4
+ data.tar.gz: 169f5ab226cc08aa4bc9c8f9ab6aff6ba6813775
5
5
  SHA512:
6
- metadata.gz: 5cdded369892b66f85d27ee09eacff5dcbca57f96508eed2d119b01d93e7c66b1f4ed86c8185dadbf4797ab211d1b59c8dad59040343b88db4ec7fd515a7b71f
7
- data.tar.gz: 0c496f7dc170fcb6bd98eef097fcc74a422049c6ee10ab3e3b0950881bff49f31dd900b77a4f437d025795bcd2eca6b0067d427e218e95ab227d9fa77af9a050
6
+ metadata.gz: 91db543ee60b0fe0ef767ac7d031bf7084e5928f5d3a7fd280ac2006b33e851dbfeeea7dd5b46bd7670a6195566ee12fbc56ee823bb948185eec052a73fe1563
7
+ data.tar.gz: 59dd1704c86d2a11bdd6205fe5317727a070d99e89240531609bd7fc1c7c2383ad056aa7ac1ceaf4dbc28cf16002db734adaa90349fb4af3f0f7af30a3475e5a
@@ -5,8 +5,19 @@ module FBO
5
5
  @parser = Parser.new
6
6
  end
7
7
 
8
- # Walk through the file returning each notice text block and structure.
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
@@ -1,3 +1,3 @@
1
1
  module FBO
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
@@ -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
- context 'with input FBO::File' do
10
- subject { FBO::Interpreter.new(file) }
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
- describe '#next_notice' do
13
- it 'acts on the first notice' do
14
- actor.expect(:process, nil, [String, Treetop::Runtime::SyntaxNode ])
15
- string, structure = subject.next_notice { |str, struct| actor.process(str, struct) }
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
- string.must_match /^\<PRESOL\>/
19
- string.must_match /\<SOLNBR\>SPE4A713R0795/
20
- structure.type.must_equal :presol
21
- structure.to_hash[:solicitation_number].must_equal 'SPE4A713R0795'
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fbo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Kottom