ffi-yajl 2.2.2-universal-java → 2.2.3-universal-java

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: f981c91f6adf9e12e018f5fce84e09ac04cb27d4
4
- data.tar.gz: 04569ec1630cc18ca33bccc618b942a49c16dae1
3
+ metadata.gz: 2e88b77318cf3455a334cc77b82b46f5d8a693b0
4
+ data.tar.gz: b983d62ab1c69061965c697c28d4a2f3eb903fff
5
5
  SHA512:
6
- metadata.gz: 0699a111fd13a6fe9213984f78f208d752213d81ba143e2cfff926bfd0c17d1fcd96e1134f5edd4d34b2dbf13504f02ecdf63f5e9051197e164751b0afe1e872
7
- data.tar.gz: e436c32c0ed5972df762f14c6109e814c074dc16ef38618f826d875ee31d67a94e5ff2ea43d56aac7fc011e2add7b04d18574f3c8bbc46748b2a96db916c87f5
6
+ metadata.gz: 3302ece29e45072a6dfbf7324ae21f4c101a64bedac60e3c670df685eb4e6a96471455ada31add25ccbc3683a209172ca75c3695c38c95bbbe112d78705265ff
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: universal-java
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
@@ -174,7 +174,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
174
174
  requirements:
175
175
  - - ">="
176
176
  - !ruby/object:Gem::Version
177
- version: 1.9.2
177
+ version: 1.9.3
178
178
  required_rubygems_version: !ruby/object:Gem::Requirement
179
179
  requirements:
180
180
  - - ">="
@@ -182,7 +182,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
182
182
  version: '0'
183
183
  requirements: []
184
184
  rubyforge_project:
185
- rubygems_version: 2.4.6
185
+ rubygems_version: 2.4.8
186
186
  signing_key:
187
187
  specification_version: 4
188
188
  summary: Ruby FFI wrapper around YAJL 2.x