pwim-emoticon 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "emoticon"
3
- s.version = "0.0.2"
3
+ s.version = "0.0.3"
4
4
  s.date = "2008-11-12"
5
5
  s.summary = "Emoticon (emoji) handling for Japanese mobile phones"
6
6
  s.email = "paul@tokyodev.com"
@@ -4,8 +4,8 @@ end
4
4
 
5
5
  module Emoticon
6
6
  def self.transcoder_for_carrier(carrier)
7
- name = carrier.capitalize
8
- if Transcoder.const_defined?(name)
7
+ name = carrier.to_s.capitalize
8
+ if !name.empty? && Transcoder.const_defined?(name)
9
9
  Transcoder.const_get(name).instance
10
10
  else
11
11
  Transcoder::Null.instance
@@ -11,6 +11,13 @@ class Emoticon::Transcoder::Docomo < Emoticon::Transcoder
11
11
  end
12
12
  end
13
13
 
14
+ def sjiscr_to_unicodecr(s)
15
+ s.gsub(/&#([0-9]{5});/i) do |match|
16
+ unicode = DOCOMO_SJIS_TO_UNICODE[$1.to_i].to_s(16).upcase
17
+ "&#x#{unicode};"
18
+ end
19
+ end
20
+
14
21
  private
15
22
 
16
23
  def to_sjis
@@ -5,7 +5,7 @@ require "emoticon/transcoder/au"
5
5
 
6
6
  class AuTest < Test::Unit::TestCase
7
7
  def setup
8
- @transcoder = Emoticon::Transcoder::Au.new
8
+ @transcoder = Emoticon::Transcoder::Au.instance
9
9
  end
10
10
 
11
11
  def test_internal_to_external
@@ -5,7 +5,7 @@ require "emoticon/transcoder/docomo"
5
5
 
6
6
  class DocomoTest < Test::Unit::TestCase
7
7
  def setup
8
- @transcoder = Emoticon::Transcoder::Docomo.new
8
+ @transcoder = Emoticon::Transcoder::Docomo.instance
9
9
  end
10
10
 
11
11
  def test_internal_to_external
@@ -17,4 +17,9 @@ class DocomoTest < Test::Unit::TestCase
17
17
  assert_equal "\xf8\x9f", @transcoder.internal_to_external(SOFTBANK_CR)
18
18
  assert_equal "\xf8\x9f", @transcoder.internal_to_external(SOFTBANK_UTF8)
19
19
  end
20
+
21
+ def test_sjiscr_to_unicodecr
22
+ s = @transcoder.sjiscr_to_unicodecr("<P>&#63647;</P>")
23
+ assert_equal("<P>&#xE63E;</P>", s)
24
+ end
20
25
  end
@@ -5,7 +5,7 @@ require "emoticon/transcoder/jphone"
5
5
 
6
6
  class JphoneTest < Test::Unit::TestCase
7
7
  def setup
8
- @transcoder = Emoticon::Transcoder::Jphone.new
8
+ @transcoder = Emoticon::Transcoder::Jphone.instance
9
9
  end
10
10
 
11
11
  def test_internal_to_external
@@ -5,7 +5,7 @@ require "emoticon/transcoder/softbank"
5
5
 
6
6
  class SoftbankTest < Test::Unit::TestCase
7
7
  def setup
8
- @transcoder = Emoticon::Transcoder::Softbank.new
8
+ @transcoder = Emoticon::Transcoder::Softbank.instance
9
9
  end
10
10
 
11
11
  def test_internal_to_external
@@ -5,7 +5,7 @@ require "emoticon/transcoder/vodafone"
5
5
 
6
6
  class VodafoneTest < Test::Unit::TestCase
7
7
  def setup
8
- @transcoder = Emoticon::Transcoder::Vodafone.new
8
+ @transcoder = Emoticon::Transcoder::Vodafone.instance
9
9
  end
10
10
 
11
11
  def test_internal_to_external
@@ -10,5 +10,7 @@ class EmoticonTest < Test::Unit::TestCase
10
10
  assert_instance_of(Emoticon::Transcoder::Jphone, Emoticon.transcoder_for_carrier("jphone"))
11
11
  assert_instance_of(Emoticon::Transcoder::Null, Emoticon.transcoder_for_carrier("emobile"))
12
12
  assert_instance_of(Emoticon::Transcoder::Null, Emoticon.transcoder_for_carrier("willcom"))
13
+ assert_instance_of(Emoticon::Transcoder::Null, Emoticon.transcoder_for_carrier(""))
14
+ assert_instance_of(Emoticon::Transcoder::Null, Emoticon.transcoder_for_carrier(nil))
13
15
  end
14
16
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pwim-emoticon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul McMahon