satyr 0.1 → 0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/satyr.rb +9 -2
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b52e512f3fb48bce3031e8d8b88ee0764fcc8f02
4
- data.tar.gz: 85e6bef907ae38f51c744df06443402f87f61c83
3
+ metadata.gz: d4e0f369f06852b90c9746acfea433bc58562e5d
4
+ data.tar.gz: d19091a16c16c806d62fb59165003c36304b86a7
5
5
  SHA512:
6
- metadata.gz: 9e7150a99c1df538f986fc7150f6c4ddf9b5a4fe7c5b05909211964358098d2dd12efd7780e180cecd23fa79353e84c10d8ccc08e7285c148ad26b7347130bd1
7
- data.tar.gz: 22f78ab04653c4504f4c9b30b982c450bee87967d43871102f5460200a4635b771b6690d9e1f88c871267c43787f3c1d0e2348b03d1d3c15761994f31a34baf1
6
+ metadata.gz: 79071b5a74ad49f90efa8500d21e2ecdec3675184c9bd85896e264c00fadb645c80def9ca1fbc3149be15e8692f04f70b8c6e03dca9de16d261ef5c8a23d47cf
7
+ data.tar.gz: b55c24742592f559027a48a1b2e83742ab194b7891f99aa6867d7d8f1405c9d3db79840b9ecd22a67984ec5e81e27a646b3a94a7f096f7bf34542d07fa073770
@@ -3,6 +3,11 @@ require 'ffi'
3
3
  # Ruby bindings for libsatyr
4
4
  module Satyr
5
5
 
6
+ def self.set_encoding str
7
+ str.force_encoding('UTF-8') if str.respond_to? :force_encoding
8
+ str
9
+ end
10
+
6
11
  # FFI wrappers for C functions. <em>Do not use this module directly</em>
7
12
  module FFI
8
13
  extend ::FFI::Library
@@ -86,7 +91,8 @@ module Satyr
86
91
  pointer = Satyr::FFI.sr_report_from_json_text json.to_s, error_msg
87
92
  error_msg = error_msg.read_pointer
88
93
  unless error_msg.null?
89
- message = error_msg.read_string.force_encoding('UTF-8')
94
+ message = error_msg.read_string
95
+ Satyr::set_encoding message
90
96
  Satyr::FFI.free error_msg
91
97
  raise SatyrError, "Failed to parse JSON: #{message}"
92
98
  end
@@ -168,7 +174,8 @@ module Satyr
168
174
  opts = {:frames => 0, :flags => :normal, :prefix => ""}.merge(opts)
169
175
  str_pointer = Satyr::FFI.sr_thread_get_duphash @struct.to_ptr, opts[:frames], opts[:prefix], opts[:flags]
170
176
  raise SatyrError, "Failed to compute duphash" if str_pointer.null?
171
- hash = str_pointer.read_string.force_encoding('UTF-8')
177
+ hash = str_pointer.read_string
178
+ Satyr::set_encoding hash
172
179
  Satyr::FFI.free str_pointer
173
180
  hash
174
181
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: satyr
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.1'
4
+ version: '0.2'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Milata
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-26 00:00:00.000000000 Z
11
+ date: 2014-10-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi