fbo 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 73410fcfcca5e7d24f72b1647bd476d2524fd749
4
- data.tar.gz: 169f5ab226cc08aa4bc9c8f9ab6aff6ba6813775
3
+ metadata.gz: ef4552a83b8f9ea2c230b313030dcceeaa8cceec
4
+ data.tar.gz: 4d23253323be1c32ea1b851913614165c89691cc
5
5
  SHA512:
6
- metadata.gz: 91db543ee60b0fe0ef767ac7d031bf7084e5928f5d3a7fd280ac2006b33e851dbfeeea7dd5b46bd7670a6195566ee12fbc56ee823bb948185eec052a73fe1563
7
- data.tar.gz: 59dd1704c86d2a11bdd6205fe5317727a070d99e89240531609bd7fc1c7c2383ad056aa7ac1ceaf4dbc28cf16002db734adaa90349fb4af3f0f7af30a3475e5a
6
+ metadata.gz: 8cc68dc78677417516f8b51ff388f4dc54f6bbff627b764a3e21272cea3d92e91d03c0ecd920d42212d8d1da20d6fb7cac4be064c9f9abd7b2c06eac32a0534b
7
+ data.tar.gz: 8dbaca1de6506f7f578b51f237124080714d99dd1e16a1d28f116ff0ed3c435d8c8a0b8c9b23ae1ece543c3fd223a7ab6e9e88b97e4be1bc9a4fb599ff805795
data/lib/fbo.rb CHANGED
@@ -8,6 +8,7 @@ module FBO
8
8
 
9
9
  end
10
10
 
11
+ require 'fbo/exceptions'
11
12
  require 'fbo/file'
12
13
  require 'fbo/chunked_file'
13
14
  require 'fbo/segmented_file'
@@ -15,4 +16,3 @@ require 'fbo/remote_file'
15
16
  require 'fbo/parser'
16
17
  require 'fbo/node_extensions'
17
18
  require 'fbo/interpreter'
18
-
@@ -0,0 +1,12 @@
1
+ module FBO
2
+ class ParserError < ::StandardError
3
+ attr_reader :data, :parent
4
+
5
+ def initialize(msg, data: nil, e: nil)
6
+ super(msg)
7
+ @data = data
8
+ @parent = e
9
+ set_backtrace(e.backtrace) if e
10
+ end
11
+ end
12
+ end
@@ -51,7 +51,7 @@ module FBO
51
51
  # Parse the text to extract a structure of data for the notice.
52
52
  #
53
53
  def parse_notice(text)
54
- tree = @parser.parse(text)
54
+ tree = @parser.parse(text)
55
55
  tree.elements.first
56
56
  end
57
57
  end
@@ -159,7 +159,6 @@ module FBO
159
159
  class PasswordNode < SimplePropertyNode; end
160
160
  class ProjectIDNode < SimplePropertyNode; end
161
161
  class UploadTypeNode < SimplePropertyNode; end
162
- class CorrectionNode < SimplePropertyNode; end
163
162
 
164
163
  # Complex properties may contain other simple properties
165
164
  #
data/lib/fbo/parser.rb CHANGED
@@ -33,7 +33,8 @@ module FBO
33
33
  line = parser.failure_line
34
34
  column = parser.failure_column
35
35
  reason = parser.failure_reason
36
- raise Exception, "Parse error at line #{ line }, column #{ column }: #{ reason }"
36
+ raise FBO::ParserError.new("Could not parse data: line #{ line }, column #{ column }, reason '#{ reason }'",
37
+ data:data)
37
38
  end
38
39
  clean_tree(tree)
39
40
  end
data/lib/fbo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module FBO
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.5"
3
3
  end
@@ -7,7 +7,7 @@ describe FBO::Parser do
7
7
  subject { FBO::Parser.new(file) }
8
8
 
9
9
  it 'parses the data all at once' do
10
- subject.expects(:parse_string).with(file.contents)
10
+ subject.expects(:parse_string).with(file.contents)
11
11
  subject.parse
12
12
  end
13
13
 
@@ -49,4 +49,24 @@ describe FBO::Parser do
49
49
  'FBO::Dump::PresolicitationNode' ]
50
50
  end
51
51
  end
52
+
53
+ context 'a bad String' do
54
+ let(:contents) { "<PRESOL>\n</PRESOL>\n<COMBINE>\n<COMBINE>\n</COMBINE>\n<AMDCSS>\n</AMDCSS>\n" }
55
+ let(:file) { stub('FBO::File', contents: contents) }
56
+ subject { FBO::Parser.new(file) }
57
+
58
+ it 'raises a ParserError' do
59
+ proc { subject.parse }.must_raise FBO::ParserError
60
+ end
61
+ end
62
+
63
+ context 'a collection of data with a bad String' do
64
+ let(:contents) { [ '<PRESOL></PRESOL>', '<COMBINE><COMBINE></COMBINE>', '<AMDCSS></AMDCSS>' ] }
65
+ let(:file) { stub('FBO::ChunkedFile', contents: contents) }
66
+ subject { FBO::Parser.new(file) }
67
+
68
+ it 'raises a ParserError' do
69
+ proc { subject.parse }.must_raise FBO::ParserError
70
+ end
71
+ end
52
72
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fbo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Kottom
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-12 00:00:00.000000000 Z
11
+ date: 2014-03-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: treetop
@@ -116,6 +116,7 @@ files:
116
116
  - lib/fbo.rb
117
117
  - lib/fbo/chunked_file.rb
118
118
  - lib/fbo/dump.treetop
119
+ - lib/fbo/exceptions.rb
119
120
  - lib/fbo/file.rb
120
121
  - lib/fbo/interpreter.rb
121
122
  - lib/fbo/node_extensions.rb