rdf-rdfxml 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,5 @@
1
1
  require File.join(File.dirname(__FILE__), 'spec_helper')
2
+ require 'rdf/spec/writer'
2
3
  autoload :CGI, 'cgi'
3
4
 
4
5
  class FOO < RDF::Vocabulary("http://foo/"); end
@@ -6,8 +7,11 @@ class FOO < RDF::Vocabulary("http://foo/"); end
6
7
  describe "RDF::RDFXML::Writer" do
7
8
  before(:each) do
8
9
  @graph = RDF::Graph.new
10
+ @writer = RDF::RDFXML::Writer
9
11
  end
10
12
 
13
+ it_should_behave_like RDF_Writer
14
+
11
15
  describe "with types" do
12
16
  it "should serialize resource without type" do
13
17
  @graph << [RDF::URI.new("http://release/"), RDF::DC.title, "foo"]
@@ -290,7 +294,6 @@ describe "RDF::RDFXML::Writer" do
290
294
  end
291
295
  end
292
296
 
293
- # FIXME
294
297
  describe "with default namespace" do
295
298
  it "should serialize with default namespace" do
296
299
  @graph << [RDF::URI.new("http://release/"), RDF.type, FOO.Release]
@@ -381,7 +384,7 @@ describe "RDF::RDFXML::Writer" do
381
384
  # Serialize ntstr to a string and compare against regexps
382
385
  def serialize(options = {})
383
386
  @debug = []
384
- result = RDF::RDFXML::Writer.buffer(options.merge(:debug => @debug)) do |writer|
387
+ result = @writer.buffer(options.merge(:debug => @debug)) do |writer|
385
388
  writer << @graph
386
389
  end
387
390
  puts @debug.join("\n") if $DEBUG
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rdf-rdfxml
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 19
4
5
  prerelease: false
5
6
  segments:
6
7
  - 0
7
8
  - 2
8
- - 1
9
- version: 0.2.1
9
+ - 2
10
+ version: 0.2.2
10
11
  platform: ruby
11
12
  authors:
12
13
  - Gregg Kellogg
@@ -14,30 +15,34 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2010-06-28 00:00:00 -07:00
18
+ date: 2010-08-03 00:00:00 -07:00
18
19
  default_executable:
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
21
22
  name: rdf
22
23
  prerelease: false
23
24
  requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
24
26
  requirements:
25
27
  - - ">="
26
28
  - !ruby/object:Gem::Version
29
+ hash: 19
27
30
  segments:
28
31
  - 0
29
32
  - 2
30
- - 1
31
- version: 0.2.1
33
+ - 2
34
+ version: 0.2.2
32
35
  type: :runtime
33
36
  version_requirements: *id001
34
37
  - !ruby/object:Gem::Dependency
35
38
  name: nokogiri
36
39
  prerelease: false
37
40
  requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
38
42
  requirements:
39
43
  - - ">="
40
44
  - !ruby/object:Gem::Version
45
+ hash: 29
41
46
  segments:
42
47
  - 1
43
48
  - 3
@@ -49,9 +54,11 @@ dependencies:
49
54
  name: rspec
50
55
  prerelease: false
51
56
  requirement: &id003 !ruby/object:Gem::Requirement
57
+ none: false
52
58
  requirements:
53
59
  - - ">="
54
60
  - !ruby/object:Gem::Version
61
+ hash: 3
55
62
  segments:
56
63
  - 0
57
64
  version: "0"
@@ -61,23 +68,27 @@ dependencies:
61
68
  name: rdf-spec
62
69
  prerelease: false
63
70
  requirement: &id004 !ruby/object:Gem::Requirement
71
+ none: false
64
72
  requirements:
65
73
  - - ">="
66
74
  - !ruby/object:Gem::Version
75
+ hash: 19
67
76
  segments:
68
77
  - 0
69
78
  - 2
70
- - 1
71
- version: 0.2.1
79
+ - 2
80
+ version: 0.2.2
72
81
  type: :development
73
82
  version_requirements: *id004
74
83
  - !ruby/object:Gem::Dependency
75
84
  name: rdf-isomorphic
76
85
  prerelease: false
77
86
  requirement: &id005 !ruby/object:Gem::Requirement
87
+ none: false
78
88
  requirements:
79
89
  - - ">="
80
90
  - !ruby/object:Gem::Version
91
+ hash: 3
81
92
  segments:
82
93
  - 0
83
94
  version: "0"
@@ -87,9 +98,11 @@ dependencies:
87
98
  name: yard
88
99
  prerelease: false
89
100
  requirement: &id006 !ruby/object:Gem::Requirement
101
+ none: false
90
102
  requirements:
91
103
  - - ">="
92
104
  - !ruby/object:Gem::Version
105
+ hash: 3
93
106
  segments:
94
107
  - 0
95
108
  version: "0"
@@ -115,6 +128,8 @@ files:
115
128
  - README.rdoc
116
129
  - Rakefile
117
130
  - VERSION
131
+ - etc/doap.nt
132
+ - etc/doap.xml
118
133
  - example.rb
119
134
  - lib/rdf/rdfxml.rb
120
135
  - lib/rdf/rdfxml/format.rb
@@ -123,7 +138,6 @@ files:
123
138
  - lib/rdf/rdfxml/patches/literal_hacks.rb
124
139
  - lib/rdf/rdfxml/patches/nokogiri_hacks.rb
125
140
  - lib/rdf/rdfxml/patches/qname_hacks.rb
126
- - lib/rdf/rdfxml/patches/rdf_escape.rb
127
141
  - lib/rdf/rdfxml/patches/seq.rb
128
142
  - lib/rdf/rdfxml/patches/uri_hacks.rb
129
143
  - lib/rdf/rdfxml/reader.rb
@@ -132,11 +146,11 @@ files:
132
146
  - lib/rdf/rdfxml/writer.rb
133
147
  - rdf-rdfxml.gemspec
134
148
  - script/console
149
+ - script/parse
135
150
  - spec/format_spec.rb
136
151
  - spec/graph_spec.rb
137
152
  - spec/literal_spec.rb
138
153
  - spec/matchers.rb
139
- - spec/rdf_escape_spec.rb
140
154
  - spec/rdf_helper.rb
141
155
  - spec/rdf_tests/cc197bad-dc9c-440d-a5b5-d52ba2e14234.nt
142
156
  - spec/rdf_tests/cc197bad-dc9c-440d-a5b5-d52ba2e14234.rdf
@@ -502,6 +516,7 @@ files:
502
516
  - spec/spec_helper.rb
503
517
  - spec/uri_spec.rb
504
518
  - spec/writer_spec.rb
519
+ - spec/rdf-iso-falure.rb
505
520
  has_rdoc: true
506
521
  homepage: http://github.com/gkellogg/rdf-rdfxml
507
522
  licenses: []
@@ -512,23 +527,27 @@ rdoc_options:
512
527
  require_paths:
513
528
  - lib
514
529
  required_ruby_version: !ruby/object:Gem::Requirement
530
+ none: false
515
531
  requirements:
516
532
  - - ">="
517
533
  - !ruby/object:Gem::Version
534
+ hash: 3
518
535
  segments:
519
536
  - 0
520
537
  version: "0"
521
538
  required_rubygems_version: !ruby/object:Gem::Requirement
539
+ none: false
522
540
  requirements:
523
541
  - - ">="
524
542
  - !ruby/object:Gem::Version
543
+ hash: 3
525
544
  segments:
526
545
  - 0
527
546
  version: "0"
528
547
  requirements: []
529
548
 
530
549
  rubyforge_project:
531
- rubygems_version: 1.3.6
550
+ rubygems_version: 1.3.7
532
551
  signing_key:
533
552
  specification_version: 3
534
553
  summary: RDF/XML reader/writer for RDF.rb.
@@ -537,7 +556,7 @@ test_files:
537
556
  - spec/graph_spec.rb
538
557
  - spec/literal_spec.rb
539
558
  - spec/matchers.rb
540
- - spec/rdf_escape_spec.rb
559
+ - spec/rdf-iso-falure.rb
541
560
  - spec/rdf_helper.rb
542
561
  - spec/reader_spec.rb
543
562
  - spec/spec_helper.rb
@@ -1,131 +0,0 @@
1
- # coding: utf-8
2
- require 'iconv'
3
-
4
- class String
5
- #private
6
- # "Borrowed" from JSON utf8_to_json
7
- RDF_MAP = {
8
- "\x0" => '\u0000',
9
- "\x1" => '\u0001',
10
- "\x2" => '\u0002',
11
- "\x3" => '\u0003',
12
- "\x4" => '\u0004',
13
- "\x5" => '\u0005',
14
- "\x6" => '\u0006',
15
- "\x7" => '\u0007',
16
- "\b" => '\b',
17
- "\t" => '\t',
18
- "\n" => '\n',
19
- "\xb" => '\u000B',
20
- "\f" => '\f',
21
- "\r" => '\r',
22
- "\xe" => '\u000E',
23
- "\xf" => '\u000F',
24
- "\x10" => '\u0010',
25
- "\x11" => '\u0011',
26
- "\x12" => '\u0012',
27
- "\x13" => '\u0013',
28
- "\x14" => '\u0014',
29
- "\x15" => '\u0015',
30
- "\x16" => '\u0016',
31
- "\x17" => '\u0017',
32
- "\x18" => '\u0018',
33
- "\x19" => '\u0019',
34
- "\x1a" => '\u001A',
35
- "\x1b" => '\u001B',
36
- "\x1c" => '\u001C',
37
- "\x1d" => '\u001D',
38
- "\x1e" => '\u001E',
39
- "\x1f" => '\u001F',
40
- '"' => '\"',
41
- '\\' => '\\\\',
42
- '/' => '/',
43
- } # :nodoc:
44
-
45
- if defined?(::Encoding)
46
- # Funky way to define constant, but if parsed in 1.8 it generates an 'invalid regular expression' error otherwise
47
- eval %(ESCAPE_RE = %r([\u{80}-\u{10ffff}]))
48
- else
49
- ESCAPE_RE = %r(
50
- [\xc2-\xdf][\x80-\xbf] |
51
- [\xe0-\xef][\x80-\xbf]{2} |
52
- [\xf0-\xf4][\x80-\xbf]{3}
53
- )nx
54
- end
55
-
56
- # Convert a UTF8 encoded Ruby string _string_ to an escaped string, encoded with
57
- # UTF16 big endian characters as \U????, and return it.
58
- #
59
- # \\:: Backslash
60
- # \':: Single quote
61
- # \":: Double quot
62
- # \n:: ASCII Linefeed
63
- # \r:: ASCII Carriage Return
64
- # \t:: ASCCII Horizontal Tab
65
- # \uhhhh:: character in BMP with Unicode value U+hhhh
66
- # \U00hhhhhh:: character in plane 1-16 with Unicode value U+hhhhhh
67
- def rdf_escape
68
- string = self + '' # XXX workaround: avoid buffer sharing
69
- string.gsub!(/["\\\/\x0-\x1f]/) { RDF_MAP[$&] }
70
- if defined?(::Encoding)
71
- string.force_encoding(Encoding::UTF_8)
72
- string.gsub!(ESCAPE_RE) { |c|
73
- s = c.dump.sub(/\"\\u\{(.+)\}\"/, '\1').upcase
74
- (s.length <= 4 ? "\\u0000"[0,6-s.length] : "\\U00000000"[0,10-s.length]) + s
75
- }
76
- string.force_encoding(Encoding::ASCII_8BIT)
77
- else
78
- string.gsub!(ESCAPE_RE) { |c|
79
- s = Iconv.new('utf-16be', 'utf-8').iconv(c).unpack('H*').first.upcase
80
- "\\u" + s
81
- }
82
- end
83
- string
84
- end
85
-
86
- # Unescape characters in strings.
87
- RDF_UNESCAPE_MAP = Hash.new { |h, k| h[k] = k.chr }
88
- RDF_UNESCAPE_MAP.update({
89
- ?" => '"',
90
- ?\\ => '\\',
91
- ?/ => '/',
92
- ?b => "\b",
93
- ?f => "\f",
94
- ?n => "\n",
95
- ?r => "\r",
96
- ?t => "\t",
97
- ?u => nil,
98
- })
99
-
100
- if defined?(::Encoding)
101
- UNESCAPE_RE = %r(
102
- (?:\\[\\bfnrt"/]) # Escaped control characters, " and /
103
- |(?:\\U00\h{6}) # 6 byte escaped Unicode
104
- |(?:\\u\h{4}) # 4 byte escaped Unicode
105
- )x
106
- else
107
- UNESCAPE_RE = %r((?:\\[\\bfnrt"/]|(?:\\u(?:[A-Fa-f\d]{4}))+|\\[\x20-\xff]))n
108
- end
109
-
110
- # Reverse operation of escape
111
- # From JSON parser
112
- def rdf_unescape
113
- return '' if self.empty?
114
- string = self.gsub(UNESCAPE_RE) do |c|
115
- case c[1,1]
116
- when 'U'
117
- raise RDF::ReaderError, "Long Unicode escapes no supported in Ruby 1.8" unless defined?(::Encoding)
118
- eval(c.sub(/\\U00(\h+)/, '"\u{\1}"'))
119
- when 'u'
120
- bytes = [c[2, 2].to_i(16), c[4, 2].to_i(16)]
121
- Iconv.new('utf-8', 'utf-16').iconv(bytes.pack("C*"))
122
- else
123
- RDF_UNESCAPE_MAP[c[1]]
124
- end
125
- end
126
- string.force_encoding(Encoding::UTF_8) if defined?(::Encoding)
127
- string
128
- rescue Iconv::Failure => e
129
- raise RDF::ReaderError, "Caught #{e.class}: #{e}"
130
- end
131
- end unless String.method_defined?(:rdf_escape)
@@ -1,36 +0,0 @@
1
- # coding: utf-8
2
- require File.join(File.dirname(__FILE__), 'spec_helper')
3
-
4
- describe "String RDF encoding" do
5
- {
6
- "Gregg" => 'Gregg',
7
- "Dürst" => 'D\u00FCrst',
8
- "simple literal" => 'simple literal',
9
- "backslash:\\" => 'backslash:\\\\',
10
- "dquote:\"" => 'dquote:\\"',
11
- "newline:\n" => 'newline:\\n',
12
- "return:\r" => 'return:\\r',
13
- "tab:\t" => 'tab:\\t',
14
- }.each_pair do |raw, encoded|
15
- specify "'#{raw}' should escape to '#{encoded}'" do
16
- raw.rdf_escape.should == encoded
17
- end
18
-
19
- specify "'#{encoded}' should unescape to '#{raw}'" do
20
- encoded.rdf_unescape.should == raw
21
- end
22
- end
23
-
24
- # 16-bit string encodings
25
- {
26
- "16-bit:\u{15678}another" => '16-bit:\\U00015678another',
27
- }.each_pair do |raw, encoded|
28
- specify "'#{raw}' should escape to '#{encoded}'" do
29
- raw.rdf_escape.should == encoded
30
- end
31
-
32
- specify "'#{encoded}' should unescape to '#{raw}'" do
33
- encoded.rdf_unescape.should == raw
34
- end
35
- end if defined?(::Encoding)
36
- end