sdl4r 0.9.3 → 0.9.4

Sign up to get free protection for your applications and to get access to all the features.
data/lib/sdl4r/tag.rb CHANGED
@@ -22,17 +22,17 @@ module SDL4R
22
22
  require 'open-uri'
23
23
  require 'stringio'
24
24
 
25
- require File.dirname(__FILE__) + '/sdl'
25
+ require File.dirname(__FILE__) + '/sdl4r'
26
26
  require File.dirname(__FILE__) + '/parser'
27
27
 
28
28
  # SDL documents are made of Tags.
29
29
  #
30
+ # See the README[link:files/README.html] for a longer explanation on SDL documents.
31
+ #
30
32
  # Do not assume that methods returning sets (Hash, Array, etc) of children/values/attributes/etc
31
33
  # in this class returns copies or implementations. It can be one or the other depending on the
32
- # method. The implementations are designed to be fast and correct, not too protect the Tag
33
- # instances from ill-use of the returned values.
34
- #
35
- # See the README[link:files/README.html] for a longer explanation on SDL documents.
34
+ # method. The implementations are designed to be correct and somewhat efficient, not too protect
35
+ # the Tag internal state from ill-use of the returned values.
36
36
  #
37
37
  # == Authors
38
38
  # Daniel Leuck, Philippe Vosges
@@ -557,8 +557,7 @@ module SDL4R
557
557
  return hash
558
558
 
559
559
  else
560
- hash = @attributesByNamespace[namespace]
561
- return hash.clone
560
+ return @attributesByNamespace[namespace]
562
561
  end
563
562
  end
564
563
  end
@@ -18,14 +18,8 @@
18
18
 
19
19
  module SDL4R
20
20
 
21
+ require 'bigdecimal'
21
22
  require 'test/unit'
22
-
23
- begin
24
- # Try to use the Flt library, which defines DecNum
25
- require "flt"
26
- rescue LoadError
27
- # Well, shouganai.
28
- end
29
23
 
30
24
  require File.dirname(__FILE__) + '/../../lib/sdl4r/tag'
31
25
  require File.dirname(__FILE__) + '/../../lib/sdl4r/sdl_binary'
@@ -206,15 +200,9 @@ EOF
206
200
  assert_equal(910.11, values[6])
207
201
  assert_equal(12.13, values[7])
208
202
  assert_equal(1415.16, values[8])
209
- if defined? Flt::DecNum
210
- assert_equal(Flt::DecNum("171.8"), values[9])
211
- assert_equal(Flt::DecNum("1.920"), values[10])
212
- assert_equal(Flt::DecNum("12345678901234567890"), values[11])
213
- else
214
- assert_equal(171.8, values[9])
215
- assert_equal(1.920, values[10])
216
- assert_equal(12345678901234567890, values[11])
217
- end
203
+ assert_equal(BigDecimal("171.8"), values[9])
204
+ assert_equal(BigDecimal("1.920"), values[10])
205
+ assert_equal(BigDecimal("12345678901234567890"), values[11])
218
206
  end
219
207
 
220
208
  def test_booleans
@@ -26,15 +26,9 @@ module SDL4R
26
26
  require 'fileutils'
27
27
  require 'pathname'
28
28
  require 'date'
29
- begin
30
- # Try to use the Flt library, which defines DecNum
31
- require "flt"
32
- rescue LoadError
33
- # Well, shouganai.
34
- end
35
29
 
36
30
  require 'test/unit'
37
- require File.dirname(__FILE__) + '/../../lib/sdl4r/tag'
31
+ require File.dirname(__FILE__) + '/../../lib/sdl4r'
38
32
 
39
33
  # SDL unit tests.
40
34
  #
@@ -128,10 +122,6 @@ module SDL4R
128
122
  end
129
123
 
130
124
  def test_tag_write_parse_basic_types
131
- if not defined? Flt::DecNum
132
- fail("this test fails without the Flt library")
133
- end
134
-
135
125
  test_tag_write_parse @@root_basic_types
136
126
  end
137
127
 
@@ -149,8 +139,8 @@ module SDL4R
149
139
 
150
140
  write_parse_root = Tag.new("test").read(root.to_s).child("root");
151
141
 
152
- # File.open("d:\\dev\\tmp\\root.sdl", "w") { |io| io.write(root.to_string) }
153
- # File.open("d:\\dev\\tmp\\root_reparsed.sdl", "w") { |io| io.write(write_parse_root.to_string) }
142
+ File.open("d:\\dev\\tmp\\root.sdl", "w") { |io| io.write(root.to_string) }
143
+ File.open("d:\\dev\\tmp\\root_reparsed.sdl", "w") { |io| io.write(write_parse_root.to_string) }
154
144
 
155
145
  assert_tags_equal(root, write_parse_root, "write/parse")
156
146
  end
@@ -0,0 +1,39 @@
1
+ #--
2
+ # Simple Declarative Language (SDL) for Ruby
3
+ # Copyright 2005 Ikayzo, inc.
4
+ #
5
+ # This program is free software. You can distribute or modify it under the
6
+ # terms of the GNU Lesser General Public License version 2.1 as published by
7
+ # the Free Software Foundation.
8
+ #
9
+ # This program is distributed AS IS and WITHOUT WARRANTY. OF ANY KIND,
10
+ # INCLUDING MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
11
+ # See the GNU Lesser General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU Lesser General Public License
14
+ # along with this program; if not, contact the Free Software Foundation, Inc.,
15
+ # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
16
+ #++
17
+
18
+ module SDL4R
19
+
20
+ require 'test/unit'
21
+ require "rexml/document"
22
+
23
+ require File.dirname(__FILE__) + '/../../lib/sdl4r/tag'
24
+
25
+ class SDLTest < Test::Unit::TestCase
26
+
27
+ def test_coerce_or_fail
28
+ # Most basic types are considered to be tested in other tests (like ParserTest)
29
+ tag = Tag.new "tag1"
30
+ assert_raise ArgumentError do tag.add_value(Object.new) end
31
+ assert_raise ArgumentError do tag.add_value([1, 2, 3]) end
32
+ assert_raise ArgumentError do tag.add_value({"a" => "b"}) end
33
+
34
+ # check translation of Rational
35
+ tag.add_value(Rational(3, 10))
36
+ assert_equal [0.3], tag.values
37
+ end
38
+ end
39
+ end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 9
8
- - 3
9
- version: 0.9.3
8
+ - 4
9
+ version: 0.9.4
10
10
  platform: ruby
11
11
  authors:
12
12
  - Philippe Vosges
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-08-05 00:00:00 +09:00
18
+ date: 2010-08-06 00:00:00 +09:00
19
19
  default_executable:
20
20
  dependencies: []
21
21
 
@@ -28,12 +28,13 @@ extensions: []
28
28
  extra_rdoc_files: []
29
29
 
30
30
  files:
31
+ - lib/sdl4r.rb
31
32
  - lib/sdl4r/sdl_time_span.rb
32
- - lib/sdl4r/sdl.rb
33
33
  - lib/sdl4r/sdl_parse_error.rb
34
34
  - lib/sdl4r/tag.rb
35
35
  - lib/sdl4r/parser.rb
36
36
  - lib/sdl4r/sdl_binary.rb
37
+ - lib/sdl4r/sdl4r.rb
37
38
  - lib/sdl4r/parser/reader.rb
38
39
  - lib/sdl4r/parser/tokenizer.rb
39
40
  - lib/sdl4r/parser/token.rb
@@ -43,10 +44,11 @@ files:
43
44
  - Rakefile
44
45
  - LICENSE
45
46
  - CHANGELOG
46
- - test/sdl4r/test_structures.sdl
47
47
  - test/sdl4r/parser_test.rb
48
- - test/sdl4r/test_basic_types.sdl
49
48
  - test/sdl4r/tag_test.rb
49
+ - test/sdl4r/sdl_test.rb
50
+ - test/sdl4r/test_structures.sdl
51
+ - test/sdl4r/test_basic_types.sdl
50
52
  - test/sdl4r/sdl4r_test.rb
51
53
  - doc/rdoc-style.css
52
54
  - doc/fr_file_index.html
@@ -54,6 +56,26 @@ files:
54
56
  - doc/fr_method_index.html
55
57
  - doc/index.html
56
58
  - doc/created.rid
59
+ - doc/files/README.html
60
+ - doc/files/LICENSE.html
61
+ - doc/files/CHANGELOG.html
62
+ - doc/files/lib/sdl4r_rb.html
63
+ - doc/files/lib/sdl4r/sdl_time_span_rb.html
64
+ - doc/files/lib/sdl4r/sdl_parse_error_rb.html
65
+ - doc/files/lib/sdl4r/tag_rb.html
66
+ - doc/files/lib/sdl4r/parser_rb.html
67
+ - doc/files/lib/sdl4r/sdl_binary_rb.html
68
+ - doc/files/lib/sdl4r/sdl4r_rb.html
69
+ - doc/files/lib/sdl4r/parser/reader_rb.html
70
+ - doc/files/lib/sdl4r/parser/tokenizer_rb.html
71
+ - doc/files/lib/sdl4r/parser/token_rb.html
72
+ - doc/files/lib/sdl4r/parser/time_span_with_zone_rb.html
73
+ - doc/classes/SDL4R.html
74
+ - doc/classes/SDL4R/Parser.html
75
+ - doc/classes/SDL4R/Tag.html
76
+ - doc/classes/SDL4R/SdlBinary.html
77
+ - doc/classes/SDL4R/SdlParseError.html
78
+ - doc/classes/SDL4R/SdlTimeSpan.html
57
79
  has_rdoc: true
58
80
  homepage: http://www.ikayzo.org/confluence/display/SDL/Home
59
81
  licenses: []
@@ -89,4 +111,5 @@ summary: Simple Declarative Language for Ruby library
89
111
  test_files:
90
112
  - test/sdl4r/parser_test.rb
91
113
  - test/sdl4r/tag_test.rb
114
+ - test/sdl4r/sdl_test.rb
92
115
  - test/sdl4r/sdl4r_test.rb