ffi-yajl 2.2.2 → 2.2.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8d07aff0a45df417a5b0fe9fa0fef6f5fd26ee68
4
- data.tar.gz: d9e8e77d8ee6d8259acab2aeb21a261d32ca7fc0
3
+ metadata.gz: d781f4b2a16bfdf584c9e5e18aacc4acead4e2d1
4
+ data.tar.gz: b983d62ab1c69061965c697c28d4a2f3eb903fff
5
5
  SHA512:
6
- metadata.gz: 036fb796941adbf951a11fdbf82d1c6e7de4fbfee8cce3ec497b7eed09b084436082fcc7acc7a8f360b1a800eeb648d0cbabeeedf6c2953a55a8cc60b10ae8bd
7
- data.tar.gz: c980a1037e3fa00a18189d3d440e80c48716ce1cd229f8f817e49d943c8d386fee43a721970f25bf635d1fa98c379113c7e70ed41c3d9b5b8a11d9992e804a31
6
+ metadata.gz: 3ff1a41b3526497a2c8b76ddba312121973aa1191d968e284ca084c96db7c243dc38f01443de87c0673565f09a68604586e0a036732fbda6a18dda24d590f524
7
+ data.tar.gz: ab3ac6089aa276b4937ec8c51cffc76800e1595d17b40c6449df7cd30edeeba27959c87a34ed1fea658c6b8a1fbbbc4198591748630a4c6c8e7123de2f182f5d
data/Rakefile CHANGED
@@ -4,12 +4,18 @@ require 'rspec/core/rake_task'
4
4
  require 'rubygems/package_task'
5
5
  require 'rake/extensiontask'
6
6
  require 'ffi_yajl/version'
7
+ require 'github_changelog_generator/task'
7
8
 
8
9
  Dir[File.expand_path("../*gemspec", __FILE__)].reverse_each do |gemspec_path|
9
10
  gemspec = eval(IO.read(gemspec_path))
10
11
  Gem::PackageTask.new(gemspec).define
11
12
  end
12
13
 
14
+ GitHubChangelogGenerator::RakeTask.new :changelog do |config|
15
+ config.since_tag = '1.0.1'
16
+ config.exclude_labels = %w{duplicate question invalid wontfix changelog_skip}
17
+ end
18
+
13
19
  desc "Build it and ship it"
14
20
  task ship: [:clean, :gem] do
15
21
  sh("git tag #{FFI_Yajl::VERSION}")
@@ -41,7 +41,15 @@ module FFI_Yajl
41
41
  # call either the ext or ffi hook
42
42
  str = do_yajl_encode(obj, yajl_gen_opts, opts)
43
43
  # we can skip cleaning the whole string for utf-8 issues if we have yajl validate as we go
44
- str.encode!("utf-8", "binary", undef: :replace) unless yajl_gen_opts[:yajl_gen_validate_utf8]
44
+
45
+ str.force_encoding("UTF-8")
46
+ unless yajl_gen_opts[:yajl_gen_validate_utf8]
47
+ if str.respond_to?(:scrub)
48
+ str.scrub!
49
+ else
50
+ str.encode!("UTF-16le", undef: :replace, invalid: :replace).encode!('UTF-8')
51
+ end
52
+ end
45
53
  str
46
54
  end
47
55
 
@@ -56,7 +64,12 @@ module FFI_Yajl
56
64
 
57
65
  def self.raise_error_for_status(status, token = nil)
58
66
  # scrub token to valid utf-8 since we may be issuing an exception on an invalid utf-8 token
59
- token = token.to_s.encode("utf-8", "binary", undef: :replace)
67
+ token = token.to_s.force_encoding("UTF-8")
68
+ if token.respond_to?(:scrub)
69
+ token.scrub!
70
+ else
71
+ token.encode!("UTF-16le", undef: :replace, invalid: :replace).encode!('UTF-8')
72
+ end
60
73
  case status
61
74
  when 1 # yajl_gen_keys_must_be_strings
62
75
  raise FFI_Yajl::EncodeError, "YAJL internal error: attempted use of non-string object as key"
@@ -21,5 +21,5 @@
21
21
  # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
22
 
23
23
  module FFI_Yajl
24
- VERSION = "2.2.2"
24
+ VERSION = "2.2.3"
25
25
  end
@@ -180,13 +180,14 @@ describe "FFI_Yajl::Encoder" do
180
180
  "passwd" => {
181
181
  "root" => { "dir" => "/root", "gid" => 0, "uid" => 0, "shell" => "/bin/sh", "gecos" => "Elan Ruusam\xc3\xa4e" },
182
182
  "glen" => { "dir" => "/home/glen", "gid" => 500, "uid" => 500, "shell" => "/bin/bash", "gecos" => "Elan Ruusam\xE4e" },
183
+ "helmüt" => { "dir" => "/home/helmüt", "gid" => 500, "uid" => 500, "shell" => "/bin/bash", "gecos" => "Hañs Helmüt" },
183
184
  },
184
185
  },
185
186
  },
186
187
  }
187
188
 
188
189
  it "raises an error on invalid json" do
189
- expect { encoder.encode(ruby) }.to raise_error(FFI_Yajl::EncodeError, /Invalid UTF-8 string 'Elan Ruusam.e': cannot encode to UTF-8/)
190
+ expect { encoder.encode(ruby) }.to raise_error(FFI_Yajl::EncodeError, /Invalid UTF-8 string 'Elan Ruusam.*': cannot encode to UTF-8/)
190
191
  end
191
192
 
192
193
  context "when validate_utf8 is off" do
@@ -203,6 +204,18 @@ describe "FFI_Yajl::Encoder" do
203
204
  it "returns valid utf8" do
204
205
  expect( encoder.encode(ruby).valid_encoding? ).to be true
205
206
  end
207
+
208
+ it "does not mangle valid utf8" do
209
+ json = encoder.encode(ruby)
210
+ expect(json).to match(/Hañs Helmüt/)
211
+ end
212
+
213
+ it "does not grow after a round trip" do
214
+ json = encoder.encode(ruby)
215
+ ruby2 = FFI_Yajl::Parser.parse(json)
216
+ json2 = encoder.encode(ruby2)
217
+ expect(json).to eql(json2)
218
+ end
206
219
  end
207
220
  end
208
221
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ffi-yajl
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.2
4
+ version: 2.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lamont Granquist
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-15 00:00:00.000000000 Z
11
+ date: 2016-01-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -177,7 +177,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
177
177
  requirements:
178
178
  - - ">="
179
179
  - !ruby/object:Gem::Version
180
- version: 1.9.2
180
+ version: 1.9.3
181
181
  required_rubygems_version: !ruby/object:Gem::Requirement
182
182
  requirements:
183
183
  - - ">="
@@ -185,7 +185,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
185
185
  version: '0'
186
186
  requirements: []
187
187
  rubyforge_project:
188
- rubygems_version: 2.4.6
188
+ rubygems_version: 2.4.8
189
189
  signing_key:
190
190
  specification_version: 4
191
191
  summary: Ruby FFI wrapper around YAJL 2.x