e4u 0.0.1 → 0.0.2

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.
Files changed (4) hide show
  1. data/VERSION +1 -1
  2. data/lib/e4u/kddi.rb +18 -2
  3. data/spec/kddi_spec.rb +8 -0
  4. metadata +1 -1
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.0.2
@@ -66,8 +66,24 @@ module E4U
66
66
  end
67
67
 
68
68
  class KDDIWeb::Emoji < KDDI::Emoji
69
- def utf8
70
- sjis.unpack('n*').map{ |char| char - 1792 }.pack('U')
69
+ alias :parent_initialize :initialize
70
+ alias :parent_unicode_to_cp932 :unicode_to_cp932
71
+
72
+ def initialize attributes
73
+ attributes = attributes.dup
74
+ attributes.each do |key, val|
75
+ next unless key == :unicode
76
+ hex = val.sub(/\A[\>\*\+]/, '')
77
+ break if hex.size == 0
78
+ attributes[key] = hex.split(/\+/, -1).map { |ch|
79
+ "%04X" % [parent_unicode_to_cp932(ch.hex) - 1792]
80
+ }.join('+')
81
+ end
82
+ parent_initialize attributes
83
+ end
84
+
85
+ def unicode_to_cp932 octet
86
+ octet + 1792
71
87
  end
72
88
  end
73
89
  end
@@ -47,6 +47,10 @@ describe E4U::KDDI do
47
47
  @emj = @kddi.find{ |e| e[:number] == '44' }.kddi_emoji
48
48
  end
49
49
 
50
+ it "unicodeが返ってくること" do
51
+ @emj.unicode.should == 'E488'
52
+ end
53
+
50
54
  it "utf8が返ってくること" do
51
55
  @emj.utf8.should == [0xE488].pack('U')
52
56
  end
@@ -65,6 +69,10 @@ describe E4U::KDDI do
65
69
  @emj = @kddi.find{ |e| e[:number] == '44' }.kddiweb_emoji
66
70
  end
67
71
 
72
+ it "unicodeが変化していること" do
73
+ @emj.unicode.should == 'EF60'
74
+ end
75
+
68
76
  it "utf8が返ってくること" do
69
77
  @emj.utf8.should == [0xEF60].pack('U')
70
78
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: e4u
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - fistfvck