xamplr 1.9.6 → 1.9.7

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.
data/VERSION.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  ---
2
2
  :major: 1
3
3
  :minor: 9
4
- :patch: 6
4
+ :patch: 7
5
5
  :build:
@@ -1,3 +1,5 @@
1
+ # encoding utf-8
2
+
1
3
  require 'libxml'
2
4
 
3
5
  module Xampl
@@ -278,11 +280,13 @@ TODO -- can these ever happen?
278
280
  return existing_element || element
279
281
  when LibXML::XML::Reader::TYPE_TEXT, LibXML::XML::Reader::TYPE_CDATA, LibXML::XML::Reader::TYPE_SIGNIFICANT_WHITESPACE, LibXML::XML::Reader::TYPE_ENTITY_REFERENCE
280
282
  if element.has_mixed_content then
281
- text = @reader.read_string
283
+ text = @reader.read_string.force_encoding('utf-8')
284
+ # puts "#{ File.basename __FILE__ }:#{ __LINE__ } [#{__method__}] #{ text.encoding } [[#{ text }]]"
282
285
  the_text = element.note_adding_text_content(text, @is_realising)
283
286
  element << the_text
284
287
  else
285
- text = @reader.read_string
288
+ text = @reader.read_string.force_encoding('utf-8')
289
+ # puts "#{ File.basename __FILE__ }:#{ __LINE__ } [#{__method__}] #{ text.encoding } [[#{ text }]] (#{ @reader.class })"
286
290
  the_text = element.note_adding_text_content(text, @is_realising)
287
291
  element.add_content(the_text, false)
288
292
  end
@@ -199,7 +199,22 @@ module Xampl
199
199
  @body << "/>"
200
200
  else
201
201
  @body << ">"
202
- @body << content_esc(xampl._content) if xampl._content
202
+ begin
203
+ @body.real_concat(content_esc(xampl._content)) if xampl._content
204
+ rescue => e
205
+ begin
206
+ s = xampl._content.force_encoding(@body.encoding)
207
+ @body.real_concat(content_esc(s)) if xampl._content
208
+ rescue => e
209
+ puts "EXCEPTION: #{ e }"
210
+ puts "body encoding: #{ @body.encoding }"
211
+ puts "xampl._content encoding: #{ xampl._content.encoding }"
212
+ puts "content_esc(xampl._content) encoding: #{ content_esc(xampl._content).encoding }"
213
+ puts "xampl._content: [[[#{ xampl._content }]]]"
214
+ # puts "body so far: [[[#{ @body }]]]"
215
+ raise e
216
+ end
217
+ end
203
218
  end_element(xampl)
204
219
  end
205
220
  end
@@ -138,6 +138,11 @@ module Xampl
138
138
  when :ruby_format then
139
139
  return xampl.to_ruby(mentions)
140
140
  end
141
+ rescue => e
142
+ msg = "Failed to represent #{ xampl } due to: #{ e }"
143
+ puts msg
144
+ puts e.backtrace
145
+ raise msg
141
146
  end
142
147
 
143
148
  def realise(representation, target=nil)
@@ -345,6 +350,8 @@ module Xampl
345
350
  if require 'tokyocabinet' then
346
351
  require "xamplr/persisters/tokyo-cabinet"
347
352
  end
353
+ rescue LoadError => e
354
+ # Well. No Tokyo Cabinet.
348
355
  rescue
349
356
  # Well. No Tokyo Cabinet.
350
357
  end
@@ -353,6 +360,8 @@ module Xampl
353
360
  if require 'mongo' then
354
361
  require "xamplr/persisters/mongo"
355
362
  end
363
+ rescue LoadError => e
364
+ # Well. No MongoDB.
356
365
  rescue
357
366
  # Well. No MongoDB.
358
367
  end
@@ -28,7 +28,11 @@ module Xampl
28
28
 
29
29
  rmsg = nil
30
30
  unless result then
31
- rmsg = sprintf(msg, @tc_db.errmsg(@tc_db.ecode))
31
+ if @tc_db then
32
+ rmsg = sprintf(msg, @tc_db.errmsg(@tc_db.ecode))
33
+ else
34
+ rmsg = "either not actually a TokyoCabinet Error, or @tc_db was never opened"
35
+ end
32
36
  STDERR.puts "NOTE: TokyoCabinet Error!"
33
37
  STDERR.puts(rmsg)
34
38
  STDERR.puts "---------"
@@ -61,11 +65,8 @@ module Xampl
61
65
  @tc_db = nil
62
66
  # puts "#{ __FILE__ }:#{ __LINE__ } [#{__method__}] file: #{ @filename }, db: #{ @tc_db.class.name }"
63
67
 
64
- setup_db()
68
+ setup_db
65
69
 
66
- # note_errors("TC[[#{ @filename }]]:: optimisation error: %s\n") do
67
- # @tc_db.optimize(-1, -1, -1, TDB::TDEFLATE)
68
- # end
69
70
  # note_errors("TC[[#{ @filename }]]:: close error: %s\n") do
70
71
  # @tc_db.close
71
72
  # end
@@ -78,9 +79,17 @@ module Xampl
78
79
  rescue => e
79
80
  #TODO -- why do this???
80
81
  puts "#{ __FILE__ }:#{ __LINE__ } [#{__method__}] OH CRAP!!! #{ e }"
82
+ puts e.backtrace
81
83
  end
82
84
  end
83
85
 
86
+ def setup_db
87
+ open_tc_db
88
+ # note_errors("TC[[#{ @filename }]]:: optimisation error: %s\n") do
89
+ # @tc_db.optimize(-1, -1, -1, TDB::TDEFLATE)
90
+ # end
91
+ end
92
+
84
93
  def open_tc_db
85
94
  # if @tcdb then
86
95
  # puts "#{ __FILE__ }:#{ __LINE__ } [#{__method__}] ALREADY OPEN #{ @filename }"
@@ -379,7 +388,7 @@ module Xampl
379
388
  # puts " 1 #{ callers[1] }"
380
389
  # puts " 2 #{ callers[2] }"
381
390
 
382
- # open_tc_db
391
+ # setup_db
383
392
  @time_stamp = Time.now.to_f.to_s
384
393
 
385
394
  note_errors("TC[[#{ @filename }]]:: tranbegin error: %s\n") do
data/xamplr.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{xamplr}
8
- s.version = "1.9.6"
8
+ s.version = "1.9.7"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Bob Hutchison"]
12
- s.date = %q{2010-02-08}
12
+ s.date = %q{2010-02-18}
13
13
  s.description = %q{xamplr is the ruby version of xampl.}
14
14
  s.email = %q{hutch@recursive.ca}
15
15
  s.extra_rdoc_files = [
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xamplr
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.6
4
+ version: 1.9.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bob Hutchison
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-02-08 00:00:00 -05:00
12
+ date: 2010-02-18 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency