summaryrefslogtreecommitdiff
path: root/lib/ffi_yajl/ffi
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2015-07-09 08:45:46 -0700
committerLamont Granquist <lamont@scriptkiddie.org>2015-07-09 08:45:46 -0700
commitc1e912caf966bc29b346c193f1b74e23e0f66781 (patch)
tree70ddb27b5d8f32766e89fe6b86375373daedf013 /lib/ffi_yajl/ffi
parent8fabdd3fddbd222109976fddb0d38255a9490f1d (diff)
downloadffi-yajl-c1e912caf966bc29b346c193f1b74e23e0f66781.tar.gz
remaining autofixable cops
Diffstat (limited to 'lib/ffi_yajl/ffi')
-rw-r--r--lib/ffi_yajl/ffi/encoder.rb8
-rw-r--r--lib/ffi_yajl/ffi/parser.rb48
2 files changed, 26 insertions, 30 deletions
diff --git a/lib/ffi_yajl/ffi/encoder.rb b/lib/ffi_yajl/ffi/encoder.rb
index 94588d0..250ed68 100644
--- a/lib/ffi_yajl/ffi/encoder.rb
+++ b/lib/ffi_yajl/ffi/encoder.rb
@@ -27,7 +27,7 @@ module FFI_Yajl
module FFI
module Encoder
def do_yajl_encode(obj, yajl_gen_opts, opts)
- yajl_gen = FFI_Yajl.yajl_gen_alloc(nil);
+ yajl_gen = FFI_Yajl.yajl_gen_alloc(nil)
# configure the yajl encoder
if yajl_gen_opts[:yajl_gen_beautify]
@@ -58,7 +58,7 @@ module FFI_Yajl
FFI_Yajl.yajl_gen_free(yajl_gen)
- return string
+ string
end
end
end
@@ -273,8 +273,6 @@ class Object
str = to_s
status = FFI_Yajl.yajl_gen_string(yajl_gen, str, str.bytesize)
end
- if ( status ) != 0
- FFI_Yajl::Encoder.raise_error_for_status(status, str)
- end
+ FFI_Yajl::Encoder.raise_error_for_status(status, str) if ( status ) != 0
end
end
diff --git a/lib/ffi_yajl/ffi/parser.rb b/lib/ffi_yajl/ffi/parser.rb
index d0d152a..e3226c0 100644
--- a/lib/ffi_yajl/ffi/parser.rb
+++ b/lib/ffi_yajl/ffi/parser.rb
@@ -23,34 +23,32 @@
module FFI_Yajl
module FFI
module Parser
- def set_value(val)
- case stack.last
- when Hash
- raise FFI_Yajl::ParseError.new("internal error: missing key in parse") if key.nil?
- if @opts[:unique_key_checking] && stack.last.has_key?(key)
- raise FFI_Yajl::ParseError.new("repeated key: #{key}")
- end
- stack.last[key] = val
- when Array
- stack.last.push(val)
- else
- stack.push(val)
+ def set_value(val)
+ case stack.last
+ when Hash
+ raise FFI_Yajl::ParseError.new("internal error: missing key in parse") if key.nil?
+ if @opts[:unique_key_checking] && stack.last.key?(key)
+ raise FFI_Yajl::ParseError.new("repeated key: #{key}")
end
+ stack.last[key] = val
+ when Array
+ stack.last.push(val)
+ else
+ stack.push(val)
end
+ end
- def stack_pop
- if stack.length > 1
- set_value( stack.pop )
- end
- end
+ def stack_pop
+ set_value( stack.pop ) if stack.length > 1
+ end
- def key_push
- key_stack.push(key)
- end
+ def key_push
+ key_stack.push(key)
+ end
- def key_pop
- @key = key_stack.pop
- end
+ def key_pop
+ @key = key_stack.pop
+ end
def setup_callbacks
@null_callback = ::FFI::Function.new(:int, [:pointer]) do |ctx|
@@ -85,7 +83,7 @@ module FFI_Yajl
end
@start_map_callback = ::FFI::Function.new(:int, [:pointer]) do |ctx|
key_push # for key => { } case, save the key
- stack.push(Hash.new)
+ stack.push({})
1
end
@map_key_callback = ::FFI::Function.new(:int, [:pointer, :string, :size_t]) do |ctx, key, keylen|
@@ -101,7 +99,7 @@ module FFI_Yajl
end
@start_array_callback = ::FFI::Function.new(:int, [:pointer]) do |ctx|
key_push # for key => [ ] case, save the key
- stack.push(Array.new)
+ stack.push([])
1
end
@end_array_callback = ::FFI::Function.new(:int, [:pointer]) do |ctx|