rison 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.html CHANGED
@@ -1,6 +1,6 @@
1
1
  <html>
2
2
  <head>
3
- <title>rison.rubyforge.org</title>
3
+ <title>rison.rb</title>
4
4
  <style type="text/css" media="screen">
5
5
  html {
6
6
  height: 100%; margin-bottom: 1px;
@@ -13,13 +13,16 @@
13
13
  }
14
14
  code {
15
15
  font-family: "Panic Sans", "Bitstream Vera Sans Mono", Consolas, Monaco, monospace;
16
+ font-size: 11px;
16
17
  }
17
18
  </style>
18
19
  </head>
19
20
  <body>
20
21
 
21
22
 
22
- <h1>rison<span style="color:#F99">.rb</span></h1>
23
+ <h1>rison<span style="color:#F99">.rb</span> <small>1.2.0</small></h1>
24
+
25
+ <p>A <a href="http://dhaka.rubyforge.org/">Dhaka</a>-based <a href="http://mjtemplate.org/examples/rison.html">Rison</a> parser.</p>
23
26
 
24
27
  <h2>Installing</h2>
25
28
 
@@ -36,6 +39,8 @@
36
39
 
37
40
  Rison.load('(a:0)') # => {:a => 0}
38
41
 
42
+ Rison.load('abc def') # => Rison::ParseError: invalid Rison string: "abc def"
43
+
39
44
 
40
45
  Rison.dump(true) # => '!t'
41
46
 
@@ -43,13 +48,9 @@
43
48
 
44
49
  Rison.dump({:a => 0}) # => '(a:0)'
45
50
 
46
- </code></pre>
47
-
48
- <h2>Links</h2>
51
+ Rison.dump(Array) # => ArgumentError: cannot serialize: Array
49
52
 
50
- <p><a href="http://mjtemplate.org/examples/rison.html">Rison - Compact Data in URIs</a></p>
51
-
52
- <p><a href="http://dhaka.rubyforge.org/">Dhaka</a></p>
53
+ </code></pre>
53
54
 
54
55
 
55
56
  </body>
data/Rakefile.rb CHANGED
@@ -5,7 +5,7 @@ require 'rake/gempackagetask'
5
5
 
6
6
  GEMSPEC = Gem::Specification.new do |s|
7
7
  s.name = 'rison'
8
- s.version = '1.1.0'
8
+ s.version = '1.2.0'
9
9
  s.platform = Gem::Platform::RUBY
10
10
  s.has_rdoc = false
11
11
  s.summary = 'Pure Ruby parser for Rison (http://mjtemplate.org/examples/rison.html)'
data/lib/rison.rb CHANGED
@@ -6,8 +6,24 @@ require 'rison/dump'
6
6
 
7
7
  module Rison
8
8
 
9
+ class ParseError < ArgumentError
10
+ attr_reader :result
11
+
12
+ def initialize(invalid_string, result)
13
+ @result = result
14
+
15
+ super "invalid Rison string: %p" % invalid_string
16
+ end
17
+ end
18
+
9
19
  def self.load(data)
10
- evaluate(parse(lex(data)))
20
+ lexed = lex(data)
21
+
22
+ parsed = parse(lexed)
23
+
24
+ raise ParseError.new(data, parsed) if parsed.has_error?
25
+
26
+ evaluate(parsed)
11
27
  end
12
28
 
13
29
 
data/test/test_dump.rb CHANGED
@@ -62,4 +62,8 @@ class RisonDumpTests < Test::Unit::TestCase
62
62
  def test_non_empty_arrays
63
63
  assert_equal %{!(!t,!f,!n,'')}, r([true, false, nil, ''])
64
64
  end
65
+
66
+ def test_undumpable_objects
67
+ assert_raises(ArgumentError) { r(Array) }
68
+ end
65
69
  end
data/test/test_parser.rb CHANGED
@@ -4,13 +4,11 @@ require 'rison'
4
4
  class RisonParserTests < Test::Unit::TestCase
5
5
 
6
6
  def rison(string)
7
- parsed = Rison.parse(Rison.lex(string))
8
-
9
- parsed.has_error?? parsed : Rison.evaluate(parsed)
7
+ Rison.load(string)
10
8
  end
11
9
 
12
10
  def assert_invalid(string)
13
- rison(string).is_a?(Dhaka::ParseErrorResult)
11
+ assert_raises(Rison::ParseError) { rison(string) }
14
12
  end
15
13
 
16
14
  # cf. http://mjtemplate.org/examples/rison.html
@@ -94,7 +92,14 @@ class RisonParserTests < Test::Unit::TestCase
94
92
  end
95
93
 
96
94
  def test_invalid_expressions
95
+ assert_invalid '-h'
96
+ assert_invalid '1.5e+2'
97
+ assert_invalid '1.5E2'
98
+ assert_invalid '1.5E+2'
99
+ assert_invalid '1.5E-2'
97
100
  assert_invalid 'abc def'
101
+ assert_invalid 'US $10'
102
+ assert_invalid 'user@domain.com'
98
103
  end
99
104
 
100
105
  end
metadata CHANGED
@@ -1,40 +1,34 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.9.4.7
3
- specification_version: 2
4
2
  name: rison
5
3
  version: !ruby/object:Gem::Version
6
- version: 1.1.0
7
- date: 2007-11-19 00:00:00 +00:00
8
- summary: Pure Ruby parser for Rison (http://mjtemplate.org/examples/rison.html)
9
- require_paths:
10
- - lib
11
- email: twoggle@gmail.com
12
- homepage: http://rison.rubyforge.org/
13
- rubyforge_project:
14
- description: Pure Ruby parser for Rison (http://mjtemplate.org/examples/rison.html)
4
+ version: 1.2.0
5
+ platform: ruby
6
+ authors:
7
+ - Tim Fletcher
15
8
  autorequire:
16
- default_executable:
17
9
  bindir: bin
18
- has_rdoc: false
19
- required_ruby_version: !ruby/object:Gem::Requirement
20
- requirements:
21
- - - ">="
22
- - !ruby/object:Gem::Version
23
- version: "0"
24
- version:
25
- required_rubygems_version: !ruby/object:Gem::Requirement
26
- requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- version: "0"
30
- version:
31
- platform: ruby
32
- signing_key:
33
10
  cert_chain: []
34
11
 
35
- post_install_message:
36
- authors:
37
- - Tim Fletcher
12
+ date: 2007-12-06 00:00:00 +00:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: dhaka
17
+ version_requirement:
18
+ version_requirements: !ruby/object:Gem::Requirement
19
+ requirements:
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: "0"
23
+ version:
24
+ description: Pure Ruby parser for Rison (http://mjtemplate.org/examples/rison.html)
25
+ email: twoggle@gmail.com
26
+ executables: []
27
+
28
+ extensions: []
29
+
30
+ extra_rdoc_files: []
31
+
38
32
  files:
39
33
  - lib/rison
40
34
  - lib/rison/dump.rb
@@ -48,25 +42,31 @@ files:
48
42
  - COPYING.txt
49
43
  - Rakefile.rb
50
44
  - README.html
51
- test_files: []
52
-
45
+ has_rdoc: false
46
+ homepage: http://rison.rubyforge.org/
47
+ post_install_message:
53
48
  rdoc_options: []
54
49
 
55
- extra_rdoc_files: []
56
-
57
- executables: []
58
-
59
- extensions: []
60
-
50
+ require_paths:
51
+ - lib
52
+ required_ruby_version: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: "0"
57
+ version:
58
+ required_rubygems_version: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: "0"
63
+ version:
61
64
  requirements: []
62
65
 
63
- dependencies:
64
- - !ruby/object:Gem::Dependency
65
- name: dhaka
66
- version_requirement:
67
- version_requirements: !ruby/object:Gem::Requirement
68
- requirements:
69
- - - ">="
70
- - !ruby/object:Gem::Version
71
- version: "0"
72
- version:
66
+ rubyforge_project:
67
+ rubygems_version: 0.9.5
68
+ signing_key:
69
+ specification_version: 2
70
+ summary: Pure Ruby parser for Rison (http://mjtemplate.org/examples/rison.html)
71
+ test_files: []
72
+