ffi-yajl 2.7.5-universal-mingw-ucrt

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 (43) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +22 -0
  3. data/README.md +118 -0
  4. data/bin/ffi-yajl-bench +36 -0
  5. data/ext/ffi_yajl/ext/dlopen/dlopen.c +40 -0
  6. data/ext/ffi_yajl/ext/dlopen/extconf.rb +16 -0
  7. data/ext/ffi_yajl/ext/dlopen/yajl.sym +18 -0
  8. data/ext/ffi_yajl/ext/encoder/encoder.c +395 -0
  9. data/ext/ffi_yajl/ext/encoder/extconf.rb +86 -0
  10. data/ext/ffi_yajl/ext/parser/extconf.rb +86 -0
  11. data/ext/ffi_yajl/ext/parser/parser.c +240 -0
  12. data/lib/ffi_yajl/benchmark/MIT-LICENSE +20 -0
  13. data/lib/ffi_yajl/benchmark/encode.rb +82 -0
  14. data/lib/ffi_yajl/benchmark/encode_json_and_marshal.rb +42 -0
  15. data/lib/ffi_yajl/benchmark/encode_json_and_yaml.rb +47 -0
  16. data/lib/ffi_yajl/benchmark/encode_profile.rb +34 -0
  17. data/lib/ffi_yajl/benchmark/http.rb +28 -0
  18. data/lib/ffi_yajl/benchmark/parse.rb +93 -0
  19. data/lib/ffi_yajl/benchmark/parse_json_and_marshal.rb +50 -0
  20. data/lib/ffi_yajl/benchmark/parse_json_and_yaml.rb +55 -0
  21. data/lib/ffi_yajl/benchmark/parse_profile.rb +33 -0
  22. data/lib/ffi_yajl/benchmark/parse_profile_ruby_prof.rb +34 -0
  23. data/lib/ffi_yajl/benchmark/parse_stream.rb +54 -0
  24. data/lib/ffi_yajl/benchmark/subjects/item.json +1 -0
  25. data/lib/ffi_yajl/benchmark/subjects/ohai.json +1216 -0
  26. data/lib/ffi_yajl/benchmark/subjects/ohai.marshal_dump +0 -0
  27. data/lib/ffi_yajl/benchmark/subjects/ohai.yml +975 -0
  28. data/lib/ffi_yajl/benchmark/subjects/twitter_search.json +1 -0
  29. data/lib/ffi_yajl/benchmark/subjects/twitter_stream.json +430 -0
  30. data/lib/ffi_yajl/benchmark/subjects/unicode.json +1 -0
  31. data/lib/ffi_yajl/benchmark.rb +27 -0
  32. data/lib/ffi_yajl/encoder.rb +94 -0
  33. data/lib/ffi_yajl/ext/.keep +0 -0
  34. data/lib/ffi_yajl/ext.rb +49 -0
  35. data/lib/ffi_yajl/ffi/encoder.rb +262 -0
  36. data/lib/ffi_yajl/ffi/parser.rb +163 -0
  37. data/lib/ffi_yajl/ffi.rb +153 -0
  38. data/lib/ffi_yajl/map_library_name.rb +109 -0
  39. data/lib/ffi_yajl/parser.rb +91 -0
  40. data/lib/ffi_yajl/platform.rb +29 -0
  41. data/lib/ffi_yajl/version.rb +25 -0
  42. data/lib/ffi_yajl.rb +50 -0
  43. metadata +128 -0
@@ -0,0 +1,153 @@
1
+ # Copyright (c) 2015 Lamont Granquist
2
+ # Copyright (c) 2015 Chef Software, Inc.
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining
5
+ # a copy of this software and associated documentation files (the
6
+ # "Software"), to deal in the Software without restriction, including
7
+ # without limitation the rights to use, copy, modify, merge, publish,
8
+ # distribute, sublicense, and/or sell copies of the Software, and to
9
+ # permit persons to whom the Software is furnished to do so, subject to
10
+ # the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be
13
+ # included in all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+
23
+ require "rubygems" unless defined?(Gem)
24
+
25
+ require "libyajl2"
26
+ begin
27
+ require "ffi" unless defined?(FFI)
28
+ rescue LoadError
29
+ $stderr.puts "FATAL: to use the ffi extension instead of the compiled C extension, the ffi gem must be installed"
30
+ $stderr.puts " (it is optional, so you must include it in your bundle manually)"
31
+ exit 1
32
+ end
33
+
34
+ require_relative "map_library_name"
35
+
36
+ module FFI_Yajl
37
+ extend ::FFI::Library
38
+
39
+ extend FFI_Yajl::MapLibraryName
40
+
41
+ ffi_open_yajl_library
42
+
43
+ class YajlCallbacks < ::FFI::Struct
44
+ layout :yajl_null, :pointer,
45
+ :yajl_boolean, :pointer,
46
+ :yajl_integer, :pointer,
47
+ :yajl_double, :pointer,
48
+ :yajl_number, :pointer,
49
+ :yajl_string, :pointer,
50
+ :yajl_start_map, :pointer,
51
+ :yajl_map_key, :pointer,
52
+ :yajl_end_map, :pointer,
53
+ :yajl_start_array, :pointer,
54
+ :yajl_end_array, :pointer
55
+ end
56
+
57
+ enum :yajl_status, %i{
58
+ yajl_status_ok
59
+ yajl_status_client_canceled
60
+ yajl_status_insufficient_data
61
+ yajl_status_error
62
+ }
63
+
64
+ # FFI::Enums are slow, should remove the rest
65
+ # enum :yajl_gen_status, [
66
+ # :yajl_gen_status_ok,
67
+ # :yajl_gen_keys_must_be_strings,
68
+ # :yajl_max_depth_exceeded,
69
+ # :yajl_gen_in_error_state,
70
+ # :yajl_gen_generation_complete,
71
+ # :yajl_gen_invalid_number,
72
+ # :yajl_gen_no_buf,
73
+ # ]
74
+
75
+ enum :yajl_option, [
76
+ :yajl_allow_comments, 0x01,
77
+ :yajl_dont_validate_strings, 0x02,
78
+ :yajl_allow_trailing_garbage, 0x04,
79
+ :yajl_allow_multiple_values, 0x08,
80
+ :yajl_allow_partial_values, 0x10
81
+ ]
82
+
83
+ enum :yajl_gen_option, [
84
+ :yajl_gen_beautify, 0x01,
85
+ :yajl_gen_indent_string, 0x02,
86
+ :yajl_gen_print_callback, 0x04,
87
+ :yajl_gen_validate_utf8, 0x08
88
+ ]
89
+
90
+ typedef :pointer, :yajl_handle
91
+ typedef :pointer, :yajl_gen
92
+
93
+ # yajl uses unsinged char *'s consistently
94
+ typedef :pointer, :ustring_pointer
95
+ typedef :string, :ustring
96
+
97
+ # const char *yajl_status_to_string (yajl_status code)
98
+ attach_function :yajl_status_to_string, [ :yajl_status ], :string
99
+ # yajl_handle yajl_alloc(const yajl_callbacks * callbacks, yajl_alloc_funcs * afs, void * ctx)
100
+ attach_function :yajl_alloc, %i{pointer pointer pointer}, :yajl_handle
101
+ # void yajl_free (yajl_handle handle)
102
+ attach_function :yajl_free, [:yajl_handle], :void
103
+ # yajl_status yajl_parse (yajl_handle hand, const unsigned char *jsonText, unsigned int jsonTextLength)
104
+ attach_function :yajl_parse, %i{yajl_handle ustring uint}, :yajl_status
105
+ # yajl_status yajl_parse_complete (yajl_handle hand)
106
+ attach_function :yajl_complete_parse, [:yajl_handle], :yajl_status
107
+ # unsigned char *yajl_get_error (yajl_handle hand, int verbose, const unsigned char *jsonText, unsigned int jsonTextLength)
108
+ attach_function :yajl_get_error, %i{yajl_handle int ustring int}, :ustring
109
+ # void yajl_free_error (yajl_handle hand, unsigned char *str)
110
+ attach_function :yajl_free_error, %i{yajl_handle ustring}, :void
111
+
112
+ #
113
+ attach_function :yajl_config, %i{yajl_handle yajl_option varargs}, :int
114
+
115
+ attach_function :yajl_gen_config, %i{yajl_gen yajl_gen_option varargs}, :int
116
+
117
+ # yajl_gen yajl_gen_alloc (const yajl_alloc_funcs *allocFuncs)
118
+ attach_function :yajl_gen_alloc, [:pointer], :yajl_gen
119
+ # yajl_gen yajl_gen_alloc2 (const yajl_print_t callback, const yajl_gen_config *config, const yajl_alloc_funcs *allocFuncs, void *ctx)
120
+ # attach_function :yajl_gen_alloc2, [:pointer, :pointer, :pointer, :pointer], :yajl_gen
121
+ # void yajl_gen_free (yajl_gen handle)
122
+ attach_function :yajl_gen_free, [:yajl_gen], :void
123
+
124
+ attach_function :yajl_gen_integer, %i{yajl_gen long_long}, :int
125
+ attach_function :yajl_gen_double, %i{yajl_gen double}, :int
126
+ attach_function :yajl_gen_number, %i{yajl_gen ustring int}, :int
127
+ attach_function :yajl_gen_string, %i{yajl_gen ustring int}, :int
128
+ attach_function :yajl_gen_null, [:yajl_gen], :int
129
+ attach_function :yajl_gen_bool, %i{yajl_gen int}, :int
130
+ attach_function :yajl_gen_map_open, [:yajl_gen], :int
131
+ attach_function :yajl_gen_map_close, [:yajl_gen], :int
132
+ attach_function :yajl_gen_array_open, [:yajl_gen], :int
133
+ attach_function :yajl_gen_array_close, [:yajl_gen], :int
134
+ # yajl_gen_status yajl_gen_get_buf (yajl_gen hand, const unsigned char **buf, unsigned int *len)
135
+ attach_function :yajl_gen_get_buf, %i{yajl_gen pointer pointer}, :int
136
+ # void yajl_gen_clear (yajl_gen hand)
137
+ attach_function :yajl_gen_clear, [:yajl_gen], :void
138
+ end
139
+
140
+ require_relative "encoder"
141
+ require_relative "parser"
142
+
143
+ module FFI_Yajl
144
+ class Parser
145
+ require_relative "ffi/parser"
146
+ include FFI_Yajl::FFI::Parser
147
+ end
148
+
149
+ class Encoder
150
+ require_relative "ffi/encoder"
151
+ include FFI_Yajl::FFI::Encoder
152
+ end
153
+ end
@@ -0,0 +1,109 @@
1
+ # Copyright (c) 2015 Lamont Granquist
2
+ # Copyright (c) 2015 Chef Software, Inc.
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining
5
+ # a copy of this software and associated documentation files (the
6
+ # "Software"), to deal in the Software without restriction, including
7
+ # without limitation the rights to use, copy, modify, merge, publish,
8
+ # distribute, sublicense, and/or sell copies of the Software, and to
9
+ # permit persons to whom the Software is furnished to do so, subject to
10
+ # the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be
13
+ # included in all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+
23
+ require "libyajl2"
24
+
25
+ # Mixin for use in finding the right yajl library on the system. The 'caller'
26
+ # needs to also mixin either the FFI module or the DLopen module. Those are
27
+ # deliberately not mixed in to avoid loading the dlopen module in the ffi
28
+ # codepath (which fails on jruby which does not have that C extension).
29
+
30
+ module FFI_Yajl
31
+ module MapLibraryName
32
+ private
33
+
34
+ # Stub for tests to override the host_os
35
+ #
36
+ # @api private
37
+ # @return [Array<String>] lower case ruby host_os string
38
+ def host_os
39
+ RbConfig::CONFIG["host_os"].downcase
40
+ end
41
+
42
+ # Array of yajl library names on the platform. Some platforms like Windows
43
+ # and Mac may have different names/extensions.
44
+ #
45
+ # @api private
46
+ # @return [Array<String>] Array of yajl library names for platform
47
+ def library_names
48
+ case host_os
49
+ when /mingw|mswin/
50
+ [ "libyajl.so", "yajl.dll" ]
51
+ when /cygwin/
52
+ [ "libyajl.so", "cygyajl.dll" ]
53
+ when /darwin/
54
+ [ "libyajl.bundle", "libyajl.dylib" ]
55
+ else
56
+ [ "libyajl.so" ]
57
+ end
58
+ end
59
+
60
+ # Array of yajl library names prepended with the libyajl2 path to use to
61
+ # load those directly and bypass the system libyajl by default. Since
62
+ # these are full paths, this API checks to ensure that the file exists on
63
+ # the filesystem. May return an empty array.
64
+ #
65
+ # @api private
66
+ # @return [Array<String>] Array of full paths to libyajl2 gem libraries
67
+ def expanded_library_names
68
+ library_names.map do |libname|
69
+ pathname = File.expand_path(File.join(Libyajl2.opt_path, libname))
70
+ pathname if File.file?(pathname)
71
+ end.compact
72
+ end
73
+
74
+ # Iterate across the expanded library names in the libyajl2-gem and then
75
+ # attempt to load the system libraries. Uses the native dlopen extension
76
+ # that ships in this gem.
77
+ #
78
+ # @api private
79
+ def dlopen_yajl_library
80
+ found = false
81
+ ( expanded_library_names + library_names ).each do |libname|
82
+
83
+ dlopen(libname)
84
+ found = true
85
+ break
86
+ rescue ArgumentError
87
+
88
+ end
89
+ raise "cannot find yajl library for platform" unless found
90
+ end
91
+
92
+ # Iterate across the expanded library names in the libyajl2-gem and attempt
93
+ # to load them. If they are missing just use `ffi_lib 'yajl'` to accept
94
+ # the FFI default algorithm to find the library.
95
+ #
96
+ # @api private
97
+ def ffi_open_yajl_library
98
+ found = false
99
+ expanded_library_names.each do |libname|
100
+
101
+ ffi_lib libname
102
+ found = true
103
+ rescue LoadError
104
+
105
+ end
106
+ ffi_lib "yajl" unless found
107
+ end
108
+ end
109
+ end
@@ -0,0 +1,91 @@
1
+ # Copyright (c) 2015 Lamont Granquist
2
+ # Copyright (c) 2015 Chef Software, Inc.
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining
5
+ # a copy of this software and associated documentation files (the
6
+ # "Software"), to deal in the Software without restriction, including
7
+ # without limitation the rights to use, copy, modify, merge, publish,
8
+ # distribute, sublicense, and/or sell copies of the Software, and to
9
+ # permit persons to whom the Software is furnished to do so, subject to
10
+ # the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be
13
+ # included in all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+
23
+ module FFI_Yajl
24
+ class ParseError < StandardError; end
25
+
26
+ class Parser
27
+ attr_writer :stack, :key_stack
28
+ attr_accessor :key, :finished
29
+
30
+ attr_accessor :opts
31
+
32
+ #
33
+ # stack used to build up our complex object
34
+ #
35
+ def stack
36
+ @stack ||= []
37
+ end
38
+
39
+ #
40
+ # stack to keep track of keys as we create nested hashes
41
+ #
42
+ def key_stack
43
+ @key_stack ||= []
44
+ end
45
+
46
+ def self.parse(obj, *args)
47
+ new(*args).parse(obj)
48
+ end
49
+
50
+ def initialize(opts = {})
51
+ @opts = opts ? opts.dup : {}
52
+ # JSON gem uses 'symbolize_names' and ruby-yajl supports this as well
53
+ @opts[:symbolize_keys] = true if @opts[:symbolize_names]
54
+ end
55
+
56
+ def parse(str)
57
+ raise FFI_Yajl::ParseError, "input must be a string or IO" unless str.is_a?(String) || str.respond_to?(:read)
58
+
59
+ # initialization that we can do in pure ruby
60
+ yajl_opts = {}
61
+
62
+ if @opts[:check_utf8] == false && @opts[:dont_validate_strings] == false
63
+ raise ArgumentError, "options check_utf8 and dont_validate_strings are both false which conflict"
64
+ end
65
+ if @opts[:check_utf8] == true && @opts[:dont_validate_strings] == true
66
+ raise ArgumentError, "options check_utf8 and dont_validate_strings are both true which conflict"
67
+ end
68
+
69
+ yajl_opts[:yajl_allow_comments] = true
70
+
71
+ if @opts.key?(:allow_comments)
72
+ yajl_opts[:yajl_allow_comments] = @opts[:allow_comments]
73
+ end
74
+
75
+ yajl_opts[:yajl_dont_validate_strings] = (@opts[:check_utf8] == false || @opts[:dont_validate_strings])
76
+ yajl_opts[:yajl_allow_trailing_garbage] = @opts[:allow_trailing_garbage]
77
+ yajl_opts[:yajl_allow_multiple_values] = @opts[:allow_multiple_values]
78
+ yajl_opts[:yajl_allow_partial_values] = @opts[:allow_partial_values]
79
+
80
+ yajl_opts[:unique_key_checking] = @opts[:unique_key_checking]
81
+
82
+ # XXX: bug-compat with ruby-yajl
83
+ return nil if str == ""
84
+
85
+ str = str.read if str.respond_to?(:read)
86
+
87
+ # call either the ext or ffi hook
88
+ do_yajl_parse(str, yajl_opts)
89
+ end
90
+ end
91
+ end
@@ -0,0 +1,29 @@
1
+ # Copyright (c) 2015 Lamont Granquist
2
+ # Copyright (c) 2015 Chef Software, Inc.
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining
5
+ # a copy of this software and associated documentation files (the
6
+ # "Software"), to deal in the Software without restriction, including
7
+ # without limitation the rights to use, copy, modify, merge, publish,
8
+ # distribute, sublicense, and/or sell copies of the Software, and to
9
+ # permit persons to whom the Software is furnished to do so, subject to
10
+ # the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be
13
+ # included in all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+
23
+ module FFI_Yajl
24
+ module Platform
25
+ def windows?
26
+ !!(RUBY_PLATFORM =~ /mswin|mingw|cygwin|windows/)
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,25 @@
1
+ # Copyright (c) 2015 Lamont Granquist
2
+ # Copyright:: Copyright (c) Chef Software Inc.
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining
5
+ # a copy of this software and associated documentation files (the
6
+ # "Software"), to deal in the Software without restriction, including
7
+ # without limitation the rights to use, copy, modify, merge, publish,
8
+ # distribute, sublicense, and/or sell copies of the Software, and to
9
+ # permit persons to whom the Software is furnished to do so, subject to
10
+ # the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be
13
+ # included in all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+
23
+ module FFI_Yajl
24
+ VERSION = "2.7.5".freeze
25
+ end
data/lib/ffi_yajl.rb ADDED
@@ -0,0 +1,50 @@
1
+ # Copyright (c) 2015 Lamont Granquist
2
+ # Copyright (c) 2015 Chef Software, Inc.
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining
5
+ # a copy of this software and associated documentation files (the
6
+ # "Software"), to deal in the Software without restriction, including
7
+ # without limitation the rights to use, copy, modify, merge, publish,
8
+ # distribute, sublicense, and/or sell copies of the Software, and to
9
+ # permit persons to whom the Software is furnished to do so, subject to
10
+ # the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be
13
+ # included in all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+
23
+ #
24
+ # Precedence:
25
+ #
26
+ # - The FORCE_FFI_YAJL env var takes precedence over everything else, the user
27
+ # theoretically knows best
28
+ # - Java always gets ffi because jruby only supports ffi
29
+ # - There is a conflict between loading libyajl 1.x and 2.x in the same VM
30
+ # process (on a fundamental basis, simply guru medidate about how the
31
+ # c-symbols work if you load both libs). For some reason the ffi interface
32
+ # seems to work fine sometimes (i'm not sure how) so we fall back to that--
33
+ # this is much more likely to be converted into a raise than to have the warn
34
+ # dropped, so don't bother asking for that.
35
+ # - Then we try the c-ext and rescue into ffi that fails
36
+ #
37
+ if ENV["FORCE_FFI_YAJL"] == "ext"
38
+ require_relative "ffi_yajl/ext"
39
+ elsif ENV["FORCE_FFI_YAJL"] == "ffi"
40
+ require_relative "ffi_yajl/ffi"
41
+ elsif RUBY_PLATFORM == "java"
42
+ require_relative "ffi_yajl/ffi"
43
+ else
44
+ begin
45
+ require_relative "ffi_yajl/ext"
46
+ rescue LoadError
47
+ warn "failed to load the ffi-yajl c-extension, falling back to ffi interface"
48
+ require_relative "ffi_yajl/ffi"
49
+ end
50
+ end
metadata ADDED
@@ -0,0 +1,128 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ffi-yajl
3
+ version: !ruby/object:Gem::Version
4
+ version: 2.7.5
5
+ platform: universal-mingw-ucrt
6
+ authors:
7
+ - Lamont Granquist
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2025-11-18 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: libyajl2
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '2.1'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '2.1'
27
+ - !ruby/object:Gem::Dependency
28
+ name: yajl
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: cookstyle
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '8.1'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '8.1'
55
+ description: Ruby FFI wrapper around YAJL 2.x
56
+ email: lamont@chef.io
57
+ executables:
58
+ - ffi-yajl-bench
59
+ extensions: []
60
+ extra_rdoc_files:
61
+ - README.md
62
+ - LICENSE
63
+ files:
64
+ - LICENSE
65
+ - README.md
66
+ - bin/ffi-yajl-bench
67
+ - ext/ffi_yajl/ext/dlopen/dlopen.c
68
+ - ext/ffi_yajl/ext/dlopen/extconf.rb
69
+ - ext/ffi_yajl/ext/dlopen/yajl.sym
70
+ - ext/ffi_yajl/ext/encoder/encoder.c
71
+ - ext/ffi_yajl/ext/encoder/extconf.rb
72
+ - ext/ffi_yajl/ext/parser/extconf.rb
73
+ - ext/ffi_yajl/ext/parser/parser.c
74
+ - lib/ffi_yajl.rb
75
+ - lib/ffi_yajl/benchmark.rb
76
+ - lib/ffi_yajl/benchmark/MIT-LICENSE
77
+ - lib/ffi_yajl/benchmark/encode.rb
78
+ - lib/ffi_yajl/benchmark/encode_json_and_marshal.rb
79
+ - lib/ffi_yajl/benchmark/encode_json_and_yaml.rb
80
+ - lib/ffi_yajl/benchmark/encode_profile.rb
81
+ - lib/ffi_yajl/benchmark/http.rb
82
+ - lib/ffi_yajl/benchmark/parse.rb
83
+ - lib/ffi_yajl/benchmark/parse_json_and_marshal.rb
84
+ - lib/ffi_yajl/benchmark/parse_json_and_yaml.rb
85
+ - lib/ffi_yajl/benchmark/parse_profile.rb
86
+ - lib/ffi_yajl/benchmark/parse_profile_ruby_prof.rb
87
+ - lib/ffi_yajl/benchmark/parse_stream.rb
88
+ - lib/ffi_yajl/benchmark/subjects/item.json
89
+ - lib/ffi_yajl/benchmark/subjects/ohai.json
90
+ - lib/ffi_yajl/benchmark/subjects/ohai.marshal_dump
91
+ - lib/ffi_yajl/benchmark/subjects/ohai.yml
92
+ - lib/ffi_yajl/benchmark/subjects/twitter_search.json
93
+ - lib/ffi_yajl/benchmark/subjects/twitter_stream.json
94
+ - lib/ffi_yajl/benchmark/subjects/unicode.json
95
+ - lib/ffi_yajl/encoder.rb
96
+ - lib/ffi_yajl/ext.rb
97
+ - lib/ffi_yajl/ext/.keep
98
+ - lib/ffi_yajl/ffi.rb
99
+ - lib/ffi_yajl/ffi/encoder.rb
100
+ - lib/ffi_yajl/ffi/parser.rb
101
+ - lib/ffi_yajl/map_library_name.rb
102
+ - lib/ffi_yajl/parser.rb
103
+ - lib/ffi_yajl/platform.rb
104
+ - lib/ffi_yajl/version.rb
105
+ homepage: http://github.com/chef/ffi-yajl
106
+ licenses:
107
+ - MIT
108
+ metadata: {}
109
+ post_install_message:
110
+ rdoc_options: []
111
+ require_paths:
112
+ - lib
113
+ required_ruby_version: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '3.1'
118
+ required_rubygems_version: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - ">="
121
+ - !ruby/object:Gem::Version
122
+ version: '0'
123
+ requirements: []
124
+ rubygems_version: 3.3.27
125
+ signing_key:
126
+ specification_version: 4
127
+ summary: Ruby FFI wrapper around YAJL 2.x
128
+ test_files: []