demoji 0.0.5 β†’ 0.0.6

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.
checksums.yaml CHANGED
@@ -1,7 +1,15 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: b914bc5b630cf9c50965db1ca53d64fba97567bd
4
- data.tar.gz: 8b7d5990c3f5f61b2f58e626831b856f4b15f82c
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ MzY4NGMyYmQ2NmMwNDliNTM3YTE3NmVjN2MzZDhlZTYwNTcxOTEyZg==
5
+ data.tar.gz: !binary |-
6
+ MGFlZjdhNjQ4YjY4NWM5YTNjYzM5NjljZjFlYTRhZDVlZGRlNTBjNA==
5
7
  SHA512:
6
- metadata.gz: 4139d2660aa5ae5586dc717f2af11e7f8c3aa98dcd10b7e49cbc56f968fce78695043f69ba8cefd23101f02d0ce7783ea788e88d75b09785bc495400873bfe2e
7
- data.tar.gz: 6825cdf5a4ae927bc9d7b250bff7cd7392207145b0c0c4831d49272fc5cc51ae25f065fc59bcda451a04d35be3084f071d3a3f656fa5017da3efd9dfe69e9d44
8
+ metadata.gz: !binary |-
9
+ OTBhZjExNjg1NDA4Y2IwYzVhYzM5MzJmN2ZhZjhlYzk4NDNmOTc2ZGMzYzdh
10
+ OTM5NWM2NDFhNDI1N2E4MTJlNDI3NWNhZjlmNWVjN2Q2YTdiNWE2NTNiYjdm
11
+ N2U1NDUzM2VkZWRjYjY0MjkyMzMwOGRhYzVjZjYxM2NkMjFjZGI=
12
+ data.tar.gz: !binary |-
13
+ MzdmMDAwMGJmY2ZkZGM3OTliMjhiMDhiZjcwMmJjMjBiYmJjYjgzZWM5OWMy
14
+ MGRmOWZiMDcxNTRkODFjZjgwODgwZTM2NzBiZmEyZjdhNDc2YzcwZjkwZDBk
15
+ ZTU3ZWEwZWVlMDRlNjZkZWYwN2QzZDdiZDhlNGQyZDU4NDg4OGY=
@@ -0,0 +1 @@
1
+ demoji
@@ -0,0 +1 @@
1
+ 1.9.3-p551
@@ -30,7 +30,7 @@ module Demoji
30
30
 
31
31
  def _fix_utf8_attributes
32
32
  self.attributes.each do |k, v|
33
- next if v.blank? || !v.is_a?(String)
33
+ next if v.blank? || !v.is_a?(String) || (self.column_for_attribute(k).type == :binary)
34
34
  self.send "#{k}=", _fix_chars(v)
35
35
  end
36
36
  end
@@ -1,3 +1,3 @@
1
1
  module Demoji
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
@@ -2,9 +2,13 @@ require 'spec_helper'
2
2
 
3
3
  describe TestUser do
4
4
 
5
+ def ord_to_str(ord)
6
+ ord.chr("UTF-8")
7
+ end
8
+
5
9
  it "doesn't blow up when trying to save emoji" do
6
10
  u = TestUser.new
7
- u.name = "😊"
11
+ u.name = ord_to_str(65554)
8
12
  expect{ u.save }.to_not raise_error
9
13
  expect(u).to be_persisted
10
14
  expect(u.reload.name.strip).to eql ""
@@ -15,40 +19,51 @@ describe TestUser do
15
19
  TestUser.any_instance.should_receive(:_fix_utf8_attributes).once
16
20
 
17
21
  u = TestUser.new
18
- u.name = "😊"
22
+ u.name = ord_to_str(65554)
19
23
  expect{ u.save }.to raise_error
20
24
  expect(u).to_not be_persisted
21
25
  end
22
26
 
23
27
  it "leaves other chars alone" do
24
28
  u = TestUser.new
25
- u.name = "Peter Perez\n😊"
29
+ u.name = "Peter Perez\n#{ord_to_str(65554)}"
30
+ expect{ u.save }.to_not raise_error
31
+ expect(u).to be_persisted
32
+ expect(u.reload.name.strip).to eql "Peter Perez"
33
+ end
34
+
35
+ it "fixes non-binary columns but leaves binary columns alone" do
36
+ u = TestUser.new
37
+ u.name = "Peter Perez\n#{ord_to_str(65554)}"
38
+ cart = "some binary data #{ord_to_str(65554)}"
39
+ u.cart = cart
26
40
  expect{ u.save }.to_not raise_error
27
41
  expect(u).to be_persisted
28
42
  expect(u.reload.name.strip).to eql "Peter Perez"
43
+ expect(u.reload.cart).to eql "some binary data \xF0\x90\x80\x92"
29
44
  end
30
45
 
31
46
  it "doesn't mess up with valid language specific chars" do
32
47
  u = TestUser.new
33
- u.name = "ΓΌΓ§Β£"
48
+ u.name = "#{ord_to_str(252)}"
34
49
  expect { u.save }.to_not raise_error
35
50
  expect(u).to be_persisted
36
- expect(u.reload.name.strip).to eql "ΓΌΓ§Β£"
51
+ expect(u.reload.name.strip).to eql "#{ord_to_str(252)}"
37
52
  end
38
53
 
39
54
  it "doesn't remove valid 3-byte utf8 chars" do
40
55
  u = TestUser.new
41
- u.name = "βœ” ✫ 𐌎 abc"
56
+ u.name = "#{ord_to_str(10004)} #{ord_to_str(10027)} #{ord_to_str(66318)} abc"
42
57
  expect { u.save }.to_not raise_error
43
58
  expect(u).to be_persisted
44
- expect(u.reload.name.strip).to eql "βœ” ✫ abc"
59
+ expect(u.reload.name.strip).to eql "#{ord_to_str(10004)} #{ord_to_str(10027)} abc"
45
60
  end
46
61
 
47
62
  it "doesn't remove valid 4-byte utf8 chars" do
48
63
  u = TestUser.new
49
- u.name = "βœ” ✫ 𠀋 abc"
64
+ u.name = "#{ord_to_str(10004)} #{ord_to_str(10027)} #{ord_to_str(131083)} abc"
50
65
  expect { u.save }.to_not raise_error
51
66
  expect(u).to be_persisted
52
- expect(u.reload.name.strip).to eql "βœ” ✫ abc"
67
+ expect(u.reload.name.strip).to eql "#{ord_to_str(10004)} #{ord_to_str(10027)} abc"
53
68
  end
54
69
  end
@@ -21,7 +21,10 @@ RSpec.configure do |config|
21
21
  ActiveRecord::Base.establish_connection db_config
22
22
 
23
23
  ActiveRecord::Base.connection.execute("DROP TABLE IF EXISTS `test_users`")
24
- ActiveRecord::Base.connection.execute("CREATE TABLE IF NOT EXISTS `test_users` (`id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(255) NOT NULL, PRIMARY KEY (`id`)) DEFAULT CHARSET=utf8;")
24
+ ActiveRecord::Base.connection.execute(
25
+ "CREATE TABLE IF NOT EXISTS `test_users` (`id` int(11) NOT NULL AUTO_INCREMENT, " \
26
+ "`name` varchar(255) NOT NULL, `cart` blob, PRIMARY KEY (`id`)) DEFAULT CHARSET=utf8;"
27
+ )
25
28
  end
26
29
 
27
30
  config.before(:each) do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: demoji
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Jairala
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-19 00:00:00.000000000 Z
11
+ date: 2017-07-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -28,42 +28,42 @@ dependencies:
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ! '>='
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ! '>='
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: activesupport
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ! '>='
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ! '>='
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: activerecord
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - ! '>='
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - ! '>='
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  description: Replace emojis as to not blow up utf8 MySQL
@@ -75,6 +75,8 @@ extra_rdoc_files: []
75
75
  files:
76
76
  - .gitignore
77
77
  - .rspec
78
+ - .ruby-gemset
79
+ - .ruby-version
78
80
  - Gemfile
79
81
  - LICENSE.txt
80
82
  - README.md
@@ -96,17 +98,17 @@ require_paths:
96
98
  - lib
97
99
  required_ruby_version: !ruby/object:Gem::Requirement
98
100
  requirements:
99
- - - '>='
101
+ - - ! '>='
100
102
  - !ruby/object:Gem::Version
101
103
  version: '0'
102
104
  required_rubygems_version: !ruby/object:Gem::Requirement
103
105
  requirements:
104
- - - '>='
106
+ - - ! '>='
105
107
  - !ruby/object:Gem::Version
106
108
  version: '0'
107
109
  requirements: []
108
110
  rubyforge_project:
109
- rubygems_version: 2.0.6
111
+ rubygems_version: 2.4.8
110
112
  signing_key:
111
113
  specification_version: 4
112
114
  summary: MySQL configured with utf-8 encoding blows up when trying to save text rows