bracket_notation 1.0.5 → 1.1.0

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.
Files changed (39) hide show
  1. data/CHANGELOG +8 -0
  2. data/Manifest +17 -1
  3. data/README.rdoc +31 -7
  4. data/Rakefile +2 -1
  5. data/bracket_notation.gemspec +9 -6
  6. data/init.rb +1 -1
  7. data/lib/bracket_notation.rb +3 -1
  8. data/lib/bracket_notation/evaluator.rb +2 -1
  9. data/lib/bracket_notation/expressions.rb +1 -1
  10. data/lib/bracket_notation/expressions/expression.rb +1 -1
  11. data/lib/bracket_notation/expressions/identifier.rb +1 -1
  12. data/lib/bracket_notation/expressions/terminal.rb +1 -1
  13. data/lib/bracket_notation/geometry.rb +31 -0
  14. data/lib/bracket_notation/geometry/point.rb +69 -0
  15. data/lib/bracket_notation/geometry/rect.rb +64 -0
  16. data/lib/bracket_notation/geometry/size.rb +69 -0
  17. data/lib/bracket_notation/parser.rb +1 -1
  18. data/lib/bracket_notation/scanner.rb +1 -1
  19. data/lib/bracket_notation/token.rb +1 -1
  20. data/lib/bracket_notation/version.rb +3 -3
  21. data/lib/bracket_notation/views.rb +33 -0
  22. data/lib/bracket_notation/views/branch.rb +40 -0
  23. data/lib/bracket_notation/views/leaf.rb +34 -0
  24. data/lib/bracket_notation/views/node.rb +152 -0
  25. data/lib/bracket_notation/views/tree.rb +181 -0
  26. data/test/functional/evaluator_test.rb +1 -1
  27. data/test/functional/node_test.rb +132 -0
  28. data/test/functional/parser_test.rb +1 -1
  29. data/test/functional/scanner_test.rb +1 -1
  30. data/test/functional/tree_test.rb +67 -0
  31. data/test/integration/layout_test.rb +151 -0
  32. data/test/integration/parsing_test.rb +1 -1
  33. data/test/test_helper.rb +1 -1
  34. data/test/unit/expression_test.rb +1 -1
  35. data/test/unit/point_test.rb +69 -0
  36. data/test/unit/rect_test.rb +58 -0
  37. data/test/unit/size_test.rb +69 -0
  38. data/test/unit/token_test.rb +1 -1
  39. metadata +48 -7
@@ -0,0 +1,58 @@
1
+ #--
2
+ # This file is part of BracketNotation.
3
+ #
4
+ # BracketNotation is free software: you can redistribute it and/or modify
5
+ # it under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation, either version 3 of the License, or
7
+ # (at your option) any later version.
8
+ #
9
+ # BracketNotation is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ # GNU General Public License for more details.
13
+ #
14
+ # You should have received a copy of the GNU General Public License
15
+ # along with BracketNotation. If not, see <http://www.gnu.org/licenses/>.
16
+ #++
17
+ # BracketNotation is a parser for generating syntax trees from sentences
18
+ # annotated with the kind of bracket notation that is commonly used by
19
+ # linguists. The result is a tree structure with nodes that describe the phrases
20
+ # and constituents of the sentence.
21
+ #
22
+ # BracketNotation was inspired by Yoichiro Hasebe's RSyntaxTree[http://yohasebe.com/rsyntaxtree/],
23
+ # and small portions of his code have been incorporated in the parser.
24
+ #
25
+ # Author:: Cody Brimhall (mailto:brimhall@somuchwit.com)
26
+ # Copyright:: Copyright (c) 2010-2011 Cody Brimhall
27
+ # License:: Distributed under the terms of the GNU General Public License, v. 3
28
+
29
+ require 'test_helper'
30
+
31
+ class RectTest < Test::Unit::TestCase
32
+ include BracketNotation::Geometry
33
+
34
+ context "a rect" do
35
+ setup do
36
+ @rect1 = Rect.new
37
+ @rect2 = Rect.new(Point.new(42, 42), Size.new)
38
+ @rect3 = Rect.new(Point.new, Size.new(42, 42))
39
+ @rect4 = Rect.new
40
+ end
41
+
42
+ should "initiaize to {{0,0},{0,0}}" do
43
+ assert @rect1.origin == Point.new and @rect1.size == Size.new
44
+ end
45
+
46
+ should "be immutable" do
47
+ assert_raise(NoMethodError) { @rect1.origin = Point.new }
48
+ assert_raise(NoMethodError) { @rect1.size = Size.new }
49
+ end
50
+
51
+ should "base equality on origin and size" do
52
+ assert_not_equal @rect1, @rect2
53
+ assert_not_equal @rect1, @rect3
54
+ assert_not_equal @rect2, @rect3
55
+ assert_equal @rect1, @rect4
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,69 @@
1
+ #--
2
+ # This file is part of BracketNotation.
3
+ #
4
+ # BracketNotation is free software: you can redistribute it and/or modify
5
+ # it under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation, either version 3 of the License, or
7
+ # (at your option) any later version.
8
+ #
9
+ # BracketNotation is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ # GNU General Public License for more details.
13
+ #
14
+ # You should have received a copy of the GNU General Public License
15
+ # along with BracketNotation. If not, see <http://www.gnu.org/licenses/>.
16
+ #++
17
+ # BracketNotation is a parser for generating syntax trees from sentences
18
+ # annotated with the kind of bracket notation that is commonly used by
19
+ # linguists. The result is a tree structure with nodes that describe the phrases
20
+ # and constituents of the sentence.
21
+ #
22
+ # BracketNotation was inspired by Yoichiro Hasebe's RSyntaxTree[http://yohasebe.com/rsyntaxtree/],
23
+ # and small portions of his code have been incorporated in the parser.
24
+ #
25
+ # Author:: Cody Brimhall (mailto:brimhall@somuchwit.com)
26
+ # Copyright:: Copyright (c) 2010-2011 Cody Brimhall
27
+ # License:: Distributed under the terms of the GNU General Public License, v. 3
28
+
29
+ require 'test_helper'
30
+
31
+ class SizeTest < Test::Unit::TestCase
32
+ include BracketNotation::Geometry
33
+
34
+ context "a size" do
35
+ setup do
36
+ @size1 = Size.new
37
+ @size2 = Size.new(42, 42)
38
+ @size3 = Size.new(42, 42)
39
+ @size4 = Size.new(42, 0)
40
+ @size5 = Size.new(0, 42)
41
+ end
42
+
43
+ should "initiaize to {0,0}" do
44
+ assert @size1.width == 0 and @size1.height == 0
45
+ end
46
+
47
+ should "be immutable" do
48
+ assert_raise(NoMethodError) { @size1.width = 0 }
49
+ assert_raise(NoMethodError) { @size1.height = 0 }
50
+ end
51
+
52
+ should "base equality on dimensions" do
53
+ assert_not_equal @size1, @size2
54
+ assert_equal @size2, @size3
55
+ end
56
+
57
+ should "create new size by adding to width" do
58
+ assert_equal @size1.size_by_adding_to_width(42), @size4
59
+ end
60
+
61
+ should "create new size by adding to height" do
62
+ assert_equal @size1.size_by_adding_to_height(42), @size5
63
+ end
64
+
65
+ should "create new size by adding to width and height" do
66
+ assert_equal @size1.size_by_adding_to_width_and_height(42, 42), @size2
67
+ end
68
+ end
69
+ end
@@ -23,7 +23,7 @@
23
23
  # and small portions of his code have been incorporated in the parser.
24
24
  #
25
25
  # Author:: Cody Brimhall (mailto:brimhall@somuchwit.com)
26
- # Copyright:: Copyright (c) 2010 Cody Brimhall
26
+ # Copyright:: Copyright (c) 2010-2011 Cody Brimhall
27
27
  # License:: Distributed under the terms of the GNU General Public License, v. 3
28
28
 
29
29
  require 'test_helper'
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: bracket_notation
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.0.5
5
+ version: 1.1.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - Cody Brimhall
@@ -10,20 +10,31 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-03-09 00:00:00 -08:00
13
+ date: 2011-03-23 00:00:00 -07:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
- name: shoulda
17
+ name: rmagick
18
18
  prerelease: false
19
19
  requirement: &id001 !ruby/object:Gem::Requirement
20
+ none: false
21
+ requirements:
22
+ - - ">="
23
+ - !ruby/object:Gem::Version
24
+ version: 2.13.1
25
+ type: :runtime
26
+ version_requirements: *id001
27
+ - !ruby/object:Gem::Dependency
28
+ name: shoulda
29
+ prerelease: false
30
+ requirement: &id002 !ruby/object:Gem::Requirement
20
31
  none: false
21
32
  requirements:
22
33
  - - ">="
23
34
  - !ruby/object:Gem::Version
24
35
  version: 2.11.3
25
36
  type: :development
26
- version_requirements: *id001
37
+ version_requirements: *id002
27
38
  description: Generates a representation of a syntax tree using a string of bracket notation.
28
39
  email: zbrimhall@gmail.com
29
40
  executables: []
@@ -40,15 +51,26 @@ extra_rdoc_files:
40
51
  - lib/bracket_notation/expressions/expression.rb
41
52
  - lib/bracket_notation/expressions/identifier.rb
42
53
  - lib/bracket_notation/expressions/terminal.rb
54
+ - lib/bracket_notation/geometry.rb
55
+ - lib/bracket_notation/geometry/point.rb
56
+ - lib/bracket_notation/geometry/rect.rb
57
+ - lib/bracket_notation/geometry/size.rb
43
58
  - lib/bracket_notation/parser.rb
44
59
  - lib/bracket_notation/scanner.rb
45
60
  - lib/bracket_notation/token.rb
46
61
  - lib/bracket_notation/version.rb
62
+ - lib/bracket_notation/views.rb
63
+ - lib/bracket_notation/views/branch.rb
64
+ - lib/bracket_notation/views/leaf.rb
65
+ - lib/bracket_notation/views/node.rb
66
+ - lib/bracket_notation/views/tree.rb
47
67
  files:
48
68
  - CHANGELOG
49
69
  - COPYING
70
+ - Manifest
50
71
  - README.rdoc
51
72
  - Rakefile
73
+ - bracket_notation.gemspec
52
74
  - init.rb
53
75
  - lib/bracket_notation.rb
54
76
  - lib/bracket_notation/evaluator.rb
@@ -56,19 +78,32 @@ files:
56
78
  - lib/bracket_notation/expressions/expression.rb
57
79
  - lib/bracket_notation/expressions/identifier.rb
58
80
  - lib/bracket_notation/expressions/terminal.rb
81
+ - lib/bracket_notation/geometry.rb
82
+ - lib/bracket_notation/geometry/point.rb
83
+ - lib/bracket_notation/geometry/rect.rb
84
+ - lib/bracket_notation/geometry/size.rb
59
85
  - lib/bracket_notation/parser.rb
60
86
  - lib/bracket_notation/scanner.rb
61
87
  - lib/bracket_notation/token.rb
62
88
  - lib/bracket_notation/version.rb
89
+ - lib/bracket_notation/views.rb
90
+ - lib/bracket_notation/views/branch.rb
91
+ - lib/bracket_notation/views/leaf.rb
92
+ - lib/bracket_notation/views/node.rb
93
+ - lib/bracket_notation/views/tree.rb
63
94
  - test/functional/evaluator_test.rb
95
+ - test/functional/node_test.rb
64
96
  - test/functional/parser_test.rb
65
97
  - test/functional/scanner_test.rb
98
+ - test/functional/tree_test.rb
99
+ - test/integration/layout_test.rb
66
100
  - test/integration/parsing_test.rb
67
101
  - test/test_helper.rb
68
102
  - test/unit/expression_test.rb
103
+ - test/unit/point_test.rb
104
+ - test/unit/rect_test.rb
105
+ - test/unit/size_test.rb
69
106
  - test/unit/token_test.rb
70
- - Manifest
71
- - bracket_notation.gemspec
72
107
  has_rdoc: true
73
108
  homepage: http://github.com/zbrimhall/bracket_notation
74
109
  licenses: []
@@ -98,15 +133,21 @@ required_rubygems_version: !ruby/object:Gem::Requirement
98
133
  requirements: []
99
134
 
100
135
  rubyforge_project: bracket_notation
101
- rubygems_version: 1.6.1
136
+ rubygems_version: 1.6.2
102
137
  signing_key:
103
138
  specification_version: 3
104
139
  summary: Provides a parser for strings that have been marked up with the bracket notation commonly used by syntacticians. The parser generates an abstract tree representation of the syntax of the string.
105
140
  test_files:
106
141
  - test/functional/evaluator_test.rb
142
+ - test/functional/node_test.rb
107
143
  - test/functional/parser_test.rb
108
144
  - test/functional/scanner_test.rb
145
+ - test/functional/tree_test.rb
146
+ - test/integration/layout_test.rb
109
147
  - test/integration/parsing_test.rb
110
148
  - test/test_helper.rb
111
149
  - test/unit/expression_test.rb
150
+ - test/unit/point_test.rb
151
+ - test/unit/rect_test.rb
152
+ - test/unit/size_test.rb
112
153
  - test/unit/token_test.rb