Skip to content

Commit 3e3807c

Browse files
ydahbyroot
authored andcommitted
Fix RFC 8785 number formatter spelling
1 parent 808577a commit 3e3807c

5 files changed

Lines changed: 17 additions & 17 deletions

File tree

‎ext/json/ext/generator/generator.c‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ typedef struct JSON_Generator_StateStruct {
3232
} JSON_Generator_State;
3333

3434
static VALUE mJSON, cState, cFragment, eGeneratorError, eNestingError, Encoding_UTF_8, default_sort_keys_proc,
35-
rfc8785_number_formater_proc, rfc8785_sort_keys_proc;
35+
rfc8785_number_formatter_proc, rfc8785_sort_keys_proc;
3636

3737
static ID i_to_s, i_to_json, i_new, i_encode;
3838
static VALUE sym_indent, sym_space, sym_space_before, sym_object_nl, sym_array_nl, sym_max_nesting, sym_allow_nan, sym_allow_duplicate_key,
@@ -1171,7 +1171,7 @@ static void generate_json_float(FBuffer *buffer, struct generate_json_data *data
11711171
}
11721172

11731173
if (RB_UNLIKELY(data->state->rfc8785)) {
1174-
VALUE str = rb_proc_call_with_block(rfc8785_number_formater_proc, 1, &obj, Qnil);
1174+
VALUE str = rb_proc_call_with_block(rfc8785_number_formatter_proc, 1, &obj, Qnil);
11751175
Check_Type(str, T_STRING);
11761176
fbuffer_append_str(buffer, str);
11771177
return;
@@ -1754,15 +1754,15 @@ static VALUE cState_set_default_sort_keys_proc(VALUE self, VALUE proc)
17541754
return default_sort_keys_proc = proc;
17551755
}
17561756

1757-
static VALUE cState_set_rfc8785_number_formater_proc(VALUE self, VALUE proc)
1757+
static VALUE cState_set_rfc8785_number_formatter_proc(VALUE self, VALUE proc)
17581758
{
17591759
if (!rb_obj_is_proc(proc)) {
1760-
rb_raise(rb_eTypeError, "rfc8785_number_formater_proc must be a Proc");
1760+
rb_raise(rb_eTypeError, "rfc8785_number_formatter_proc must be a Proc");
17611761
}
1762-
if (rfc8785_number_formater_proc) {
1763-
rb_raise(rb_eArgError, "rfc8785_number_formater_proc can only be set once");
1762+
if (rfc8785_number_formatter_proc) {
1763+
rb_raise(rb_eArgError, "rfc8785_number_formatter_proc can only be set once");
17641764
}
1765-
return rfc8785_number_formater_proc = proc;
1765+
return rfc8785_number_formatter_proc = proc;
17661766
}
17671767

17681768
static VALUE cState_set_rfc8785_sort_keys_proc(VALUE self, VALUE proc)
@@ -2036,7 +2036,7 @@ void Init_generator(void)
20362036
VALUE mGenerator = rb_define_module_under(mExt, "Generator");
20372037

20382038
rb_global_variable(&default_sort_keys_proc);
2039-
rb_global_variable(&rfc8785_number_formater_proc);
2039+
rb_global_variable(&rfc8785_number_formatter_proc);
20402040
rb_global_variable(&rfc8785_sort_keys_proc);
20412041

20422042
rb_global_variable(&eGeneratorError);
@@ -2049,7 +2049,7 @@ void Init_generator(void)
20492049
rb_define_alloc_func(cState, cState_s_allocate);
20502050
rb_define_singleton_method(cState, "from_state", cState_from_state_s, 1);
20512051
rb_define_singleton_method(cState, "default_sort_keys_proc=", cState_set_default_sort_keys_proc, 1);
2052-
rb_define_singleton_method(cState, "rfc8785_number_formater_proc=", cState_set_rfc8785_number_formater_proc, 1);
2052+
rb_define_singleton_method(cState, "rfc8785_number_formatter_proc=", cState_set_rfc8785_number_formatter_proc, 1);
20532053
rb_define_singleton_method(cState, "rfc8785_sort_keys_proc=", cState_set_rfc8785_sort_keys_proc, 1);
20542054

20552055
rb_define_method(cState, "initialize", cState_initialize, -1);

‎java/src/json/ext/Generator.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ static void generateFloat(ThreadContext context, Session session, RubyFloat obje
421421
}
422422

423423
if (state.rfc8785()) {
424-
RubyProc numberProc = (RubyProc)GeneratorState.rfc8785NumberFormaterProc;
424+
RubyProc numberProc = (RubyProc)GeneratorState.rfc8785NumberFormatterProc;
425425
RubyString numberString = (RubyString)Helpers.invoke(context, numberProc, "call", object);
426426
buffer.write(numberString.toString().getBytes(UTF_8));
427427
} else {

‎java/src/json/ext/GeneratorState.java‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public class GeneratorState extends RubyObject {
3737
private boolean allowDuplicateKey = false;
3838

3939
private static IRubyObject defaultSortKeyProc;
40-
public static IRubyObject rfc8785NumberFormaterProc;
40+
public static IRubyObject rfc8785NumberFormatterProc;
4141
public static IRubyObject rfc8785SortKeysProc;
4242

4343
/**
@@ -176,9 +176,9 @@ public static IRubyObject setDefaultSortKeyProc(IRubyObject klass, IRubyObject p
176176
return proc;
177177
}
178178

179-
@JRubyMethod(meta=true, name="rfc8785_number_formater_proc=")
180-
public static IRubyObject setRfc8785NumberFormaterProc(IRubyObject klass, IRubyObject proc) {
181-
rfc8785NumberFormaterProc = proc;
179+
@JRubyMethod(meta=true, name="rfc8785_number_formatter_proc=")
180+
public static IRubyObject setRfc8785NumberFormatterProc(IRubyObject klass, IRubyObject proc) {
181+
rfc8785NumberFormatterProc = proc;
182182
return proc;
183183
}
184184

‎lib/json/ext.rb‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def shareable_lambda(block) # :nodoc:
5959
})
6060

6161
# Directly lifted from Gregg Kellogg's json-canonicalization
62-
generator::State.rfc8785_number_formater_proc = shareable_lambda(->(num) {
62+
generator::State.rfc8785_number_formatter_proc = shareable_lambda(->(num) {
6363
if num.zero?
6464
"0"
6565
else

‎lib/json/truffle_ruby/generator.rb‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ def self.valid_utf8?(string)
112112
# while generating a JSON text from a Ruby data structure.
113113
class State
114114
singleton_class.attr_accessor :default_sort_keys_proc # :nodoc:
115-
singleton_class.attr_accessor :rfc8785_number_formater_proc # :nodoc:
115+
singleton_class.attr_accessor :rfc8785_number_formatter_proc # :nodoc:
116116
singleton_class.attr_accessor :rfc8785_sort_keys_proc # :nodoc:
117117

118118
def self.generate(obj, opts = nil, io = nil)
@@ -728,7 +728,7 @@ def to_json(state = nil, *args)
728728
raise GeneratorError.new("#{self} not allowed in JSON", self)
729729
end
730730
elsif state.rfc8785?
731-
State.rfc8785_number_formater_proc.call(self)
731+
State.rfc8785_number_formatter_proc.call(self)
732732
else
733733
to_s
734734
end

0 commit comments

Comments
 (0)