ffi-yajl 2.2.3-universal-java → 2.4.0-universal-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +37 -74
- data/bin/ffi-yajl-bench +7 -7
- data/ext/ffi_yajl/ext/dlopen/extconf.rb +5 -5
- data/ext/ffi_yajl/ext/encoder/encoder.c +4 -0
- data/ext/ffi_yajl/ext/encoder/extconf.rb +14 -14
- data/ext/ffi_yajl/ext/parser/extconf.rb +14 -14
- data/lib/ffi_yajl.rb +7 -7
- data/lib/ffi_yajl/benchmark.rb +5 -5
- data/lib/ffi_yajl/benchmark/encode.rb +8 -8
- data/lib/ffi_yajl/benchmark/encode_json_and_marshal.rb +9 -9
- data/lib/ffi_yajl/benchmark/encode_json_and_yaml.rb +11 -11
- data/lib/ffi_yajl/benchmark/encode_profile.rb +5 -5
- data/lib/ffi_yajl/benchmark/http.rb +12 -12
- data/lib/ffi_yajl/benchmark/parse.rb +8 -8
- data/lib/ffi_yajl/benchmark/parse_json_and_marshal.rb +10 -10
- data/lib/ffi_yajl/benchmark/parse_json_and_yaml.rb +11 -11
- data/lib/ffi_yajl/benchmark/parse_profile.rb +5 -5
- data/lib/ffi_yajl/benchmark/parse_profile_ruby_prof.rb +4 -4
- data/lib/ffi_yajl/benchmark/parse_stream.rb +11 -11
- data/lib/ffi_yajl/encoder.rb +2 -2
- data/lib/ffi_yajl/ext.rb +9 -9
- data/lib/ffi_yajl/ffi.rb +36 -36
- data/lib/ffi_yajl/ffi/encoder.rb +10 -26
- data/lib/ffi_yajl/ffi/parser.rb +14 -13
- data/lib/ffi_yajl/map_library_name.rb +6 -6
- data/lib/ffi_yajl/parser.rb +2 -2
- data/lib/ffi_yajl/version.rb +2 -2
- metadata +11 -87
- data/Rakefile +0 -179
- data/spec/ffi_yajl/encoder_spec.rb +0 -221
- data/spec/ffi_yajl/map_library_name_spec.rb +0 -115
- data/spec/ffi_yajl/parser_spec.rb +0 -569
- data/spec/spec_helper.rb +0 -45
data/lib/ffi_yajl/ffi/encoder.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# Copyright (c) 2015 Lamont Granquist
|
2
|
-
# Copyright (c) 2015 Chef Software
|
2
|
+
# Copyright (c) 2015-2017, Chef Software Inc.
|
3
3
|
#
|
4
4
|
# Permission is hereby granted, free of charge, to any person obtaining
|
5
5
|
# a copy of this software and associated documentation files (the
|
@@ -20,8 +20,8 @@
|
|
20
20
|
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
21
|
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
22
|
|
23
|
-
require
|
24
|
-
require
|
23
|
+
require "date"
|
24
|
+
require "stringio" unless defined?(StringIO)
|
25
25
|
|
26
26
|
module FFI_Yajl
|
27
27
|
module FFI
|
@@ -73,7 +73,7 @@ class Hash
|
|
73
73
|
end
|
74
74
|
else
|
75
75
|
if ( status = FFI_Yajl.yajl_gen_map_open(yajl_gen) ) != 0
|
76
|
-
FFI_Yajl::Encoder.raise_error_for_status(status,
|
76
|
+
FFI_Yajl::Encoder.raise_error_for_status(status, "{")
|
77
77
|
end
|
78
78
|
each do |key, value|
|
79
79
|
# Perf Fix: mutate state hash rather than creating new copy
|
@@ -83,7 +83,7 @@ class Hash
|
|
83
83
|
value.ffi_yajl(yajl_gen, state)
|
84
84
|
end
|
85
85
|
if ( status = FFI_Yajl.yajl_gen_map_close(yajl_gen) ) != 0
|
86
|
-
FFI_Yajl::Encoder.raise_error_for_status(status,
|
86
|
+
FFI_Yajl::Encoder.raise_error_for_status(status, "}")
|
87
87
|
end
|
88
88
|
end
|
89
89
|
end
|
@@ -98,13 +98,13 @@ class Array
|
|
98
98
|
end
|
99
99
|
else
|
100
100
|
if ( status = FFI_Yajl.yajl_gen_array_open(yajl_gen) ) != 0
|
101
|
-
FFI_Yajl::Encoder.raise_error_for_status(status,
|
101
|
+
FFI_Yajl::Encoder.raise_error_for_status(status, "[")
|
102
102
|
end
|
103
103
|
each do |value|
|
104
104
|
value.ffi_yajl(yajl_gen, state)
|
105
105
|
end
|
106
106
|
if ( status = FFI_Yajl.yajl_gen_array_close(yajl_gen) ) != 0
|
107
|
-
FFI_Yajl::Encoder.raise_error_for_status(status,
|
107
|
+
FFI_Yajl::Encoder.raise_error_for_status(status, "]")
|
108
108
|
end
|
109
109
|
end
|
110
110
|
end
|
@@ -155,30 +155,13 @@ class FalseClass
|
|
155
155
|
end
|
156
156
|
end
|
157
157
|
|
158
|
-
class
|
158
|
+
class Integer
|
159
159
|
def ffi_yajl(yajl_gen, state)
|
160
160
|
str = to_s
|
161
161
|
if str == "NaN" || str == "Infinity" || str == "-Infinity"
|
162
162
|
raise ::FFI_Yajl::EncodeError, "'#{str}' is an invalid number"
|
163
163
|
end
|
164
|
-
if state[:processing_key]
|
165
|
-
if ( status = FFI_Yajl.yajl_gen_string(yajl_gen, str, str.bytesize) ) != 0
|
166
|
-
FFI_Yajl::Encoder.raise_error_for_status(status, str)
|
167
|
-
end
|
168
|
-
else
|
169
|
-
if ( status = FFI_Yajl.yajl_gen_integer(yajl_gen, self) ) != 0
|
170
|
-
FFI_Yajl::Encoder.raise_error_for_status(status, str)
|
171
|
-
end
|
172
|
-
end
|
173
|
-
end
|
174
|
-
end
|
175
164
|
|
176
|
-
class Bignum
|
177
|
-
def ffi_yajl(yajl_gen, state)
|
178
|
-
str = to_s
|
179
|
-
if str == "NaN" || str == "Infinity" || str == "-Infinity"
|
180
|
-
raise ::FFI_Yajl::EncodeError, "'#{str}' is an invalid number"
|
181
|
-
end
|
182
165
|
if state[:processing_key]
|
183
166
|
if ( status = FFI_Yajl.yajl_gen_string(yajl_gen, str, str.bytesize) ) != 0
|
184
167
|
FFI_Yajl::Encoder.raise_error_for_status(status, str)
|
@@ -197,6 +180,7 @@ class Float
|
|
197
180
|
if str == "NaN" || str == "Infinity" || str == "-Infinity"
|
198
181
|
raise ::FFI_Yajl::EncodeError, "'#{str}' is an invalid number"
|
199
182
|
end
|
183
|
+
|
200
184
|
if state[:processing_key]
|
201
185
|
if ( status = FFI_Yajl.yajl_gen_string(yajl_gen, str, str.bytesize) ) != 0
|
202
186
|
FFI_Yajl::Encoder.raise_error_for_status(status, str)
|
@@ -265,7 +249,7 @@ end
|
|
265
249
|
# I feel dirty
|
266
250
|
class Object
|
267
251
|
def ffi_yajl(yajl_gen, state)
|
268
|
-
if !state[:processing_key] &&
|
252
|
+
if !state[:processing_key] && respond_to?(:to_json)
|
269
253
|
str = to_json(state[:json_opts])
|
270
254
|
# #yajl_gen_number outputs a string without quotes around it
|
271
255
|
status = FFI_Yajl.yajl_gen_number(yajl_gen, str, str.bytesize)
|
data/lib/ffi_yajl/ffi/parser.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# Copyright (c) 2015 Lamont Granquist
|
2
|
-
# Copyright (c) 2015 Chef Software
|
2
|
+
# Copyright (c) 2015-2018, Chef Software Inc.
|
3
3
|
#
|
4
4
|
# Permission is hereby granted, free of charge, to any person obtaining
|
5
5
|
# a copy of this software and associated documentation files (the
|
@@ -23,13 +23,14 @@
|
|
23
23
|
module FFI_Yajl
|
24
24
|
module FFI
|
25
25
|
module Parser
|
26
|
-
def set_value(val) # rubocop:disable
|
26
|
+
def set_value(val) # rubocop:disable Naming/AccessorMethodName
|
27
27
|
case stack.last
|
28
28
|
when Hash
|
29
29
|
raise FFI_Yajl::ParseError, "internal error: missing key in parse" if key.nil?
|
30
30
|
if @opts[:unique_key_checking] && stack.last.key?(key)
|
31
31
|
raise FFI_Yajl::ParseError, "repeated key: #{key}"
|
32
32
|
end
|
33
|
+
|
33
34
|
stack.last[key] = val
|
34
35
|
when Array
|
35
36
|
stack.last.push(val)
|
@@ -55,29 +56,29 @@ module FFI_Yajl
|
|
55
56
|
set_value(nil)
|
56
57
|
1
|
57
58
|
end
|
58
|
-
@boolean_callback = ::FFI::Function.new(:int,
|
59
|
+
@boolean_callback = ::FFI::Function.new(:int, %i{pointer int}) do |ctx, boolval|
|
59
60
|
set_value(boolval == 1 ? true : false)
|
60
61
|
1
|
61
62
|
end
|
62
|
-
@integer_callback = ::FFI::Function.new(:int,
|
63
|
+
@integer_callback = ::FFI::Function.new(:int, %i{pointer long_long}) do |ctx, intval|
|
63
64
|
set_value(intval)
|
64
65
|
1
|
65
66
|
end
|
66
|
-
@number_callback = ::FFI::Function.new(:int,
|
67
|
+
@number_callback = ::FFI::Function.new(:int, %i{pointer string size_t}) do |ctx, stringval, stringlen|
|
67
68
|
s = stringval.slice(0, stringlen)
|
68
|
-
s.force_encoding(
|
69
|
+
s.force_encoding("UTF-8") if defined? Encoding
|
69
70
|
# XXX: I can't think of a better way to do this right now. need to call to_f if and only if its a float.
|
70
71
|
v = ( s =~ /[\.eE]/ ) ? s.to_f : s.to_i
|
71
72
|
set_value(v)
|
72
73
|
1
|
73
74
|
end
|
74
|
-
@double_callback = ::FFI::Function.new(:int,
|
75
|
+
@double_callback = ::FFI::Function.new(:int, %i{pointer double}) do |ctx, doubleval|
|
75
76
|
set_value(doubleval)
|
76
77
|
1
|
77
78
|
end
|
78
|
-
@string_callback = ::FFI::Function.new(:int,
|
79
|
+
@string_callback = ::FFI::Function.new(:int, %i{pointer string size_t}) do |ctx, stringval, stringlen|
|
79
80
|
s = stringval.slice(0, stringlen)
|
80
|
-
s.force_encoding(
|
81
|
+
s.force_encoding("UTF-8") if defined? Encoding
|
81
82
|
set_value(s)
|
82
83
|
1
|
83
84
|
end
|
@@ -86,9 +87,9 @@ module FFI_Yajl
|
|
86
87
|
stack.push({})
|
87
88
|
1
|
88
89
|
end
|
89
|
-
@map_key_callback = ::FFI::Function.new(:int,
|
90
|
+
@map_key_callback = ::FFI::Function.new(:int, %i{pointer string size_t}) do |ctx, key, keylen|
|
90
91
|
s = key.slice(0, keylen)
|
91
|
-
s.force_encoding(
|
92
|
+
s.force_encoding("UTF-8") if defined? Encoding
|
92
93
|
self.key = @opts[:symbolize_keys] ? s.to_sym : s
|
93
94
|
1
|
94
95
|
end
|
@@ -143,12 +144,12 @@ module FFI_Yajl
|
|
143
144
|
::FFI_Yajl.yajl_config(yajl_handle, :yajl_allow_partial_values, :int, 1)
|
144
145
|
end
|
145
146
|
|
146
|
-
if
|
147
|
+
if ::FFI_Yajl.yajl_parse(yajl_handle, str, str.bytesize) != :yajl_status_ok
|
147
148
|
# FIXME: dup the error and call yajl_free_error?
|
148
149
|
error = ::FFI_Yajl.yajl_get_error(yajl_handle, 1, str, str.bytesize)
|
149
150
|
raise ::FFI_Yajl::ParseError, error
|
150
151
|
end
|
151
|
-
if
|
152
|
+
if ::FFI_Yajl.yajl_complete_parse(yajl_handle) != :yajl_status_ok
|
152
153
|
# FIXME: dup the error and call yajl_free_error?
|
153
154
|
error = ::FFI_Yajl.yajl_get_error(yajl_handle, 1, str, str.bytesize)
|
154
155
|
raise ::FFI_Yajl::ParseError, error
|
@@ -20,7 +20,7 @@
|
|
20
20
|
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
21
|
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
22
|
|
23
|
-
require
|
23
|
+
require "libyajl2"
|
24
24
|
|
25
25
|
# Mixin for use in finding the right yajl library on the system. The 'caller'
|
26
26
|
# needs to also mixin either the FFI module or the DLopen module. Those are
|
@@ -34,16 +34,16 @@ module FFI_Yajl
|
|
34
34
|
# Stub for tests to override the host_os
|
35
35
|
#
|
36
36
|
# @api private
|
37
|
-
# @return Array<String> lower case ruby host_os string
|
37
|
+
# @return [Array<String>] lower case ruby host_os string
|
38
38
|
def host_os
|
39
|
-
RbConfig::CONFIG[
|
39
|
+
RbConfig::CONFIG["host_os"].downcase
|
40
40
|
end
|
41
41
|
|
42
42
|
# Array of yajl library names on the platform. Some platforms like Windows
|
43
43
|
# and Mac may have different names/extensions.
|
44
44
|
#
|
45
45
|
# @api private
|
46
|
-
# @return Array<String> Array of yajl library names for platform
|
46
|
+
# @return [Array<String>] Array of yajl library names for platform
|
47
47
|
def library_names
|
48
48
|
case host_os
|
49
49
|
when /mingw|mswin/
|
@@ -63,7 +63,7 @@ module FFI_Yajl
|
|
63
63
|
# the filesystem. May return an empty array.
|
64
64
|
#
|
65
65
|
# @api private
|
66
|
-
# @return Array<String> Array of full paths to libyajl2 gem libraries
|
66
|
+
# @return [Array<String>] Array of full paths to libyajl2 gem libraries
|
67
67
|
def expanded_library_names
|
68
68
|
library_names.map do |libname|
|
69
69
|
pathname = File.expand_path(File.join(Libyajl2.opt_path, libname))
|
@@ -103,7 +103,7 @@ module FFI_Yajl
|
|
103
103
|
rescue LoadError
|
104
104
|
end
|
105
105
|
end
|
106
|
-
ffi_lib
|
106
|
+
ffi_lib "yajl" unless found
|
107
107
|
end
|
108
108
|
end
|
109
109
|
end
|
data/lib/ffi_yajl/parser.rb
CHANGED
@@ -65,10 +65,10 @@ module FFI_Yajl
|
|
65
65
|
raise ArgumentError, "options check_utf8 and dont_validate_strings are both true which conflict"
|
66
66
|
end
|
67
67
|
|
68
|
-
yajl_opts[:yajl_allow_comments]
|
68
|
+
yajl_opts[:yajl_allow_comments] = true
|
69
69
|
|
70
70
|
if @opts.key?(:allow_comments)
|
71
|
-
yajl_opts[:yajl_allow_comments]
|
71
|
+
yajl_opts[:yajl_allow_comments] = @opts[:allow_comments]
|
72
72
|
end
|
73
73
|
|
74
74
|
yajl_opts[:yajl_dont_validate_strings] = (@opts[:check_utf8] == false || @opts[:dont_validate_strings])
|
data/lib/ffi_yajl/version.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# Copyright (c) 2015 Lamont Granquist
|
2
|
-
# Copyright (c)
|
2
|
+
# Copyright:: Copyright (c) Chef Software Inc.
|
3
3
|
#
|
4
4
|
# Permission is hereby granted, free of charge, to any person obtaining
|
5
5
|
# a copy of this software and associated documentation files (the
|
@@ -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.
|
24
|
+
VERSION = "2.4.0".freeze
|
25
25
|
end
|
metadata
CHANGED
@@ -1,97 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ffi-yajl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.4.0
|
5
5
|
platform: universal-java
|
6
6
|
authors:
|
7
7
|
- Lamont Granquist
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-04-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: rake
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '10.1'
|
20
|
-
type: :development
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - "~>"
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '10.1'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: rspec
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - "~>"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '2.99'
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - "~>"
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '2.99'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: pry
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - "~>"
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '0.9'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - "~>"
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0.9'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: rake-compiler
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - "~>"
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: 0.8.3
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - "~>"
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: 0.8.3
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: mime-types
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - "~>"
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '1.16'
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - "~>"
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '1.16'
|
83
13
|
- !ruby/object:Gem::Dependency
|
84
14
|
name: libyajl2
|
85
15
|
requirement: !ruby/object:Gem::Requirement
|
86
16
|
requirements:
|
87
|
-
- - "
|
17
|
+
- - ">="
|
88
18
|
- !ruby/object:Gem::Version
|
89
19
|
version: '1.2'
|
90
20
|
type: :runtime
|
91
21
|
prerelease: false
|
92
22
|
version_requirements: !ruby/object:Gem::Requirement
|
93
23
|
requirements:
|
94
|
-
- - "
|
24
|
+
- - ">="
|
95
25
|
- !ruby/object:Gem::Version
|
96
26
|
version: '1.2'
|
97
27
|
- !ruby/object:Gem::Dependency
|
@@ -109,7 +39,7 @@ dependencies:
|
|
109
39
|
- !ruby/object:Gem::Version
|
110
40
|
version: '1.5'
|
111
41
|
description: Ruby FFI wrapper around YAJL 2.x
|
112
|
-
email: lamont@
|
42
|
+
email: lamont@chef.io
|
113
43
|
executables:
|
114
44
|
- ffi-yajl-bench
|
115
45
|
extensions: []
|
@@ -119,7 +49,6 @@ extra_rdoc_files:
|
|
119
49
|
files:
|
120
50
|
- LICENSE
|
121
51
|
- README.md
|
122
|
-
- Rakefile
|
123
52
|
- bin/ffi-yajl-bench
|
124
53
|
- ext/ffi_yajl/ext/dlopen/dlopen.c
|
125
54
|
- ext/ffi_yajl/ext/dlopen/extconf.rb
|
@@ -158,15 +87,11 @@ files:
|
|
158
87
|
- lib/ffi_yajl/parser.rb
|
159
88
|
- lib/ffi_yajl/platform.rb
|
160
89
|
- lib/ffi_yajl/version.rb
|
161
|
-
- spec/ffi_yajl/encoder_spec.rb
|
162
|
-
- spec/ffi_yajl/map_library_name_spec.rb
|
163
|
-
- spec/ffi_yajl/parser_spec.rb
|
164
|
-
- spec/spec_helper.rb
|
165
90
|
homepage: http://github.com/chef/ffi-yajl
|
166
91
|
licenses:
|
167
|
-
-
|
92
|
+
- MIT
|
168
93
|
metadata: {}
|
169
|
-
post_install_message:
|
94
|
+
post_install_message:
|
170
95
|
rdoc_options: []
|
171
96
|
require_paths:
|
172
97
|
- lib
|
@@ -174,16 +99,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
174
99
|
requirements:
|
175
100
|
- - ">="
|
176
101
|
- !ruby/object:Gem::Version
|
177
|
-
version:
|
102
|
+
version: '2.2'
|
178
103
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
179
104
|
requirements:
|
180
105
|
- - ">="
|
181
106
|
- !ruby/object:Gem::Version
|
182
107
|
version: '0'
|
183
108
|
requirements: []
|
184
|
-
|
185
|
-
|
186
|
-
signing_key:
|
109
|
+
rubygems_version: 3.2.3
|
110
|
+
signing_key:
|
187
111
|
specification_version: 4
|
188
112
|
summary: Ruby FFI wrapper around YAJL 2.x
|
189
113
|
test_files: []
|
data/Rakefile
DELETED
@@ -1,179 +0,0 @@
|
|
1
|
-
$LOAD_PATH << File.expand_path(File.join(File.dirname( __FILE__ ), "lib"))
|
2
|
-
|
3
|
-
require 'rspec/core/rake_task'
|
4
|
-
require 'rubygems/package_task'
|
5
|
-
require 'rake/extensiontask'
|
6
|
-
require 'ffi_yajl/version'
|
7
|
-
require 'github_changelog_generator/task'
|
8
|
-
|
9
|
-
Dir[File.expand_path("../*gemspec", __FILE__)].reverse_each do |gemspec_path|
|
10
|
-
gemspec = eval(IO.read(gemspec_path))
|
11
|
-
Gem::PackageTask.new(gemspec).define
|
12
|
-
end
|
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
|
-
|
19
|
-
desc "Build it and ship it"
|
20
|
-
task ship: [:clean, :gem] do
|
21
|
-
sh("git tag #{FFI_Yajl::VERSION}")
|
22
|
-
sh("git push --tags")
|
23
|
-
Dir[File.expand_path("../pkg/*.gem", __FILE__)].reverse_each do |built_gem|
|
24
|
-
sh("gem push #{built_gem}")
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
unix_gemspec = eval(File.read("ffi-yajl.gemspec"))
|
29
|
-
|
30
|
-
task :clean do
|
31
|
-
sh "rm -f Gemfile.lock"
|
32
|
-
sh "rm -rf pkg/* tmp/* .bundle lib/ffi_yajl/ext/*"
|
33
|
-
end
|
34
|
-
|
35
|
-
desc "install the gem locally"
|
36
|
-
task install: [:package] do
|
37
|
-
if defined?(RUBY_ENGINE) && RUBY_ENGINE == "jruby"
|
38
|
-
sh %{gem install pkg/#{unix_gemspec.name}-#{unix_gemspec.version}-universal-java.gem}
|
39
|
-
else
|
40
|
-
sh %{gem install pkg/#{unix_gemspec.name}-#{unix_gemspec.version}.gem}
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
spec = Gem::Specification.load('ffi-yajl.gemspec')
|
45
|
-
|
46
|
-
Rake::ExtensionTask.new do |ext|
|
47
|
-
ext.name = 'encoder'
|
48
|
-
ext.lib_dir = 'lib/ffi_yajl/ext'
|
49
|
-
ext.ext_dir = 'ext/ffi_yajl/ext/encoder'
|
50
|
-
ext.gem_spec = spec
|
51
|
-
end
|
52
|
-
|
53
|
-
Rake::ExtensionTask.new do |ext|
|
54
|
-
ext.name = 'parser'
|
55
|
-
ext.lib_dir = 'lib/ffi_yajl/ext'
|
56
|
-
ext.ext_dir = 'ext/ffi_yajl/ext/parser'
|
57
|
-
ext.gem_spec = spec
|
58
|
-
end
|
59
|
-
|
60
|
-
Rake::ExtensionTask.new do |ext|
|
61
|
-
ext.name = 'dlopen'
|
62
|
-
ext.lib_dir = 'lib/ffi_yajl/ext'
|
63
|
-
ext.ext_dir = 'ext/ffi_yajl/ext/dlopen'
|
64
|
-
ext.gem_spec = spec
|
65
|
-
end
|
66
|
-
|
67
|
-
#
|
68
|
-
# test tasks
|
69
|
-
#
|
70
|
-
|
71
|
-
desc "Run all specs against both extensions"
|
72
|
-
task :spec do
|
73
|
-
Rake::Task["spec:ffi"].invoke
|
74
|
-
if !defined?(RUBY_ENGINE) || RUBY_ENGINE !~ /jruby/
|
75
|
-
Rake::Task["spec:ext"].invoke
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
namespace :spec do
|
80
|
-
desc "Run all specs against ffi extension"
|
81
|
-
RSpec::Core::RakeTask.new(:ffi) do |t|
|
82
|
-
ENV['FORCE_FFI_YAJL'] = "ffi"
|
83
|
-
t.pattern = FileList['spec/**/*_spec.rb']
|
84
|
-
end
|
85
|
-
if !defined?(RUBY_ENGINE) || RUBY_ENGINE !~ /jruby/
|
86
|
-
desc "Run all specs again c extension"
|
87
|
-
RSpec::Core::RakeTask.new(:ext) do |t|
|
88
|
-
ENV['FORCE_FFI_YAJL'] = "ext"
|
89
|
-
t.pattern = FileList['spec/**/*_spec.rb']
|
90
|
-
end
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
if RUBY_VERSION.to_f >= 1.9
|
95
|
-
namespace :integration do
|
96
|
-
begin
|
97
|
-
require 'kitchen'
|
98
|
-
rescue LoadError
|
99
|
-
task :vagrant do
|
100
|
-
puts "test-kitchen gem is not installed"
|
101
|
-
end
|
102
|
-
task :cloud do
|
103
|
-
puts "test-kitchen gem is not installed"
|
104
|
-
end
|
105
|
-
else
|
106
|
-
desc 'Run Test Kitchen with Vagrant'
|
107
|
-
task :vagrant do
|
108
|
-
Kitchen.logger = Kitchen.default_file_logger
|
109
|
-
Kitchen::Config.new.instances.each do |instance|
|
110
|
-
instance.test(:always)
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
desc 'Run Test Kitchen with cloud plugins'
|
115
|
-
task :cloud do
|
116
|
-
if ENV['TRAVIS_PULL_REQUEST'] != 'true'
|
117
|
-
ENV['KITCHEN_YAML'] = '.kitchen.cloud.yml'
|
118
|
-
sh "kitchen test --concurrency 4"
|
119
|
-
end
|
120
|
-
end
|
121
|
-
end
|
122
|
-
end
|
123
|
-
namespace :style do
|
124
|
-
desc 'Run Ruby style checks'
|
125
|
-
begin
|
126
|
-
require 'rubocop/rake_task'
|
127
|
-
rescue LoadError
|
128
|
-
task :rubocop do
|
129
|
-
puts "rubocop gem is not installed"
|
130
|
-
end
|
131
|
-
else
|
132
|
-
RuboCop::RakeTask.new(:rubocop) do |t|
|
133
|
-
t.fail_on_error = false
|
134
|
-
end
|
135
|
-
end
|
136
|
-
|
137
|
-
desc 'Run Ruby smell checks'
|
138
|
-
begin
|
139
|
-
require 'reek/rake/task'
|
140
|
-
rescue LoadError
|
141
|
-
task :reek do
|
142
|
-
puts "reek gem is not installed"
|
143
|
-
end
|
144
|
-
else
|
145
|
-
Reek::Rake::Task.new(:reek) do |t|
|
146
|
-
t.fail_on_error = false
|
147
|
-
# t.config_files = '.reek.yml'
|
148
|
-
end
|
149
|
-
end
|
150
|
-
end
|
151
|
-
else
|
152
|
-
namespace :integration do
|
153
|
-
task :vagrant do
|
154
|
-
puts "test-kitchen unsupported on ruby 1.8"
|
155
|
-
end
|
156
|
-
task :cloud do
|
157
|
-
puts "test-kitchen unsupported on ruby 1.8"
|
158
|
-
end
|
159
|
-
end
|
160
|
-
namespace :style do
|
161
|
-
task :rubocop do
|
162
|
-
puts "rubocop unsupported on ruby 1.8"
|
163
|
-
end
|
164
|
-
task :reek do
|
165
|
-
puts "reek unsupported on ruby 1.8"
|
166
|
-
end
|
167
|
-
end
|
168
|
-
end
|
169
|
-
|
170
|
-
desc 'Run all style checks'
|
171
|
-
task style: ['style:rubocop', 'style:reek']
|
172
|
-
|
173
|
-
desc 'Run style + spec tests by default on travis'
|
174
|
-
task travis: %w{style spec}
|
175
|
-
|
176
|
-
desc 'Run style, spec and test kichen on travis'
|
177
|
-
task travis_all: ['style', 'spec', 'integration:cloud']
|
178
|
-
|
179
|
-
task default: ['style', 'spec', 'integration:vagrant']
|