royw-imdb 0.1.0 → 0.1.1

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,4 +1,4 @@
1
1
  ---
2
2
  :minor: 1
3
- :patch: 0
3
+ :patch: 1
4
4
  :major: 0
@@ -213,7 +213,7 @@ class ImdbMovie
213
213
  # Fetch the document with retry to handle the occasional glitches
214
214
  def document
215
215
  if @document.nil?
216
- html = fetch(self.url)
216
+ html = fetch(self.url.escape_unicode)
217
217
  @document = Hpricot(html)
218
218
  end
219
219
  @document
@@ -9,23 +9,35 @@ class OptionalLogger
9
9
  end
10
10
 
11
11
  # debug {...}
12
- def debug(&blk)
13
- @logger.debug(blk.call) unless @logger.nil?
12
+ def debug(msg=nil, &blk)
13
+ unless @logger.nil?
14
+ @logger.debug(msg) unless msg.nil?
15
+ @logger.debug(blk.call) unless blk.nil?
16
+ end
14
17
  end
15
18
 
16
19
  # info {...}
17
- def info(&blk)
18
- @logger.info(blk.call) unless @logger.nil?
20
+ def info(msg=nil, &blk)
21
+ unless @logger.nil?
22
+ @logger.info(msg) unless msg.nil?
23
+ @logger.info(blk.call) unless blk.nil?
24
+ end
19
25
  end
20
26
 
21
27
  # warn {...}
22
- def warn(&blk)
23
- @logger.warn(blk.call) unless @logger.nil?
28
+ def warn(msg=nil, &blk)
29
+ unless @logger.nil?
30
+ @logger.warn(msg) unless msg.nil?
31
+ @logger.warn(blk.call) unless blk.nil?
32
+ end
24
33
  end
25
34
 
26
35
  # error {...}
27
- def error(&blk)
28
- @logger.error(blk.call) unless @logger.nil?
36
+ def error(msg=nil, &blk)
37
+ unless @logger.nil?
38
+ @logger.error(msg) unless msg.nil?
39
+ @logger.error(blk.call) unless blk.nil?
40
+ end
29
41
  end
30
42
  end
31
43
 
@@ -8,6 +8,14 @@ class String
8
8
  end
9
9
  end
10
10
 
11
+ # this handles unicode characters by converting each byte to "%XX"
12
+ # where XX is the hex value
13
+ my_extension("escape_unicode") do
14
+ def escape_unicode
15
+ self.each_byte.collect{|c| c.to_i > 127 ? "%#{c.to_i.to_s(16)}" : c.chr}.join('')
16
+ end
17
+ end
18
+
11
19
  my_extension("strip_tags") do
12
20
  def strip_tags
13
21
  gsub(/<\/?[^>]*>/, "")
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: royw-imdb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roy Wright
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-04-17 00:00:00 -07:00
12
+ date: 2009-04-18 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15