Skip to content

Commit

Permalink
fixup! Apply linting to source and test code
Browse files Browse the repository at this point in the history
  • Loading branch information
erickguan committed Mar 5, 2024
1 parent ef63989 commit ef3ecb3
Show file tree
Hide file tree
Showing 15 changed files with 142 additions and 152 deletions.
4 changes: 1 addition & 3 deletions lib/ffi-icu/chardet.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,12 @@ def match_ptr_to_ruby(match_ptr)
result
end

# rubocop:disable Naming/AccessorMethodName
def set_text(text)
def set_text(text) # rubocop:disable Naming/AccessorMethodName
Lib.check_error do |status|
data = FFI::MemoryPointer.from_string(text)
Lib.ucsdet_setText(@detector, data, text.bytesize, status)
end
end
# rubocop:enable Naming/AccessorMethodName
end
end
end
10 changes: 5 additions & 5 deletions lib/ffi-icu/collation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module Collation
normalization_mode: 4,
strength: 5,
hiragana_quaternary_mode: 6,
numeric_collation: 7,
numeric_collation: 7
}.freeze

ATTRIBUTE_VALUES = {
Expand All @@ -27,7 +27,7 @@ module Collation
non_ignorable: 21,

lower_first: 24,
upper_first: 25,
upper_first: 25
}.freeze

ATTRIBUTE_VALUES_INVERSE = ATTRIBUTE_VALUES.to_h { |k, v| [v, k] }.freeze
Expand Down Expand Up @@ -79,12 +79,12 @@ def compare(a, b)

def greater?(a, b)
Lib.ucol_greater(@c, UCharPointer.from_string(a), a.jlength,
UCharPointer.from_string(b), b.jlength)
UCharPointer.from_string(b), b.jlength)
end

def greater_or_equal?(a, b)
Lib.ucol_greaterOrEqual(@c, UCharPointer.from_string(a), a.jlength,
UCharPointer.from_string(b), b.jlength)
UCharPointer.from_string(b), b.jlength)
end

def equal?(*args)
Expand All @@ -95,7 +95,7 @@ def equal?(*args)
a, b = args

Lib.ucol_equal(@c, UCharPointer.from_string(a), a.jlength,
UCharPointer.from_string(b), b.jlength)
UCharPointer.from_string(b), b.jlength)
end

def collate(sortable)
Expand Down
18 changes: 9 additions & 9 deletions lib/ffi-icu/duration_formatting.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ module DurationFormatting
long: :wide,
short: :short,
narrow: :narrow,
digital: :narrow,
digital: :narrow
}.freeze
UNIT_FORMAT_STRINGS = {
years: 'measure-unit/duration-year',
Expand All @@ -43,14 +43,14 @@ module DurationFormatting
seconds: 'measure-unit/duration-second',
milliseconds: 'measure-unit/duration-millisecond',
microseconds: 'measure-unit/duration-microsecond',
nanoseconds: 'measure-unit/duration-nanosecond',
nanoseconds: 'measure-unit/duration-nanosecond'
}.freeze
STYLES_TO_NUMBER_FORMAT_WIDTH = {
long: 'unit-width-full-name',
short: 'unit-width-short',
narrow: 'unit-width-narrow',
# digital for hours:minutes:seconds has some special casing.
digital: 'unit-width-narrow',
digital: 'unit-width-narrow'
}.freeze

def self.format(fields, locale:, style: :long)
Expand All @@ -75,7 +75,7 @@ def initialize(locale:, style: :long)
Lib.check_error do |error|
Lib.ulistfmt_openForType(@locale, :units, list_join_format, error)
end,
Lib.method(:ulistfmt_close),
Lib.method(:ulistfmt_close)
)
end

Expand Down Expand Up @@ -132,7 +132,7 @@ def hms_duration_units_pattern(fields)

@unit_res_bundle ||= FFI::AutoPointer.new(
Lib.check_error { |error| Lib.ures_open(Lib.resource_bundle_name(:unit), @locale, error) },
Lib.method(:ures_close),
Lib.method(:ures_close)
)

resource_key = 'durationUnits/'
Expand All @@ -147,7 +147,7 @@ def hms_duration_units_pattern(fields)
Lib.check_error do |error|
Lib.ures_getBykeyWithFallback(@unit_res_bundle, resource_key, nil, error)
end,
Lib.method(:ures_close),
Lib.method(:ures_close)
)
rescue MissingResourceError
# This combination of h,m,s not present for this locale.
Expand Down Expand Up @@ -253,9 +253,9 @@ def number_formatter(skeleton)
FFI::AutoPointer.new(
Lib.check_error do |error|
Lib.unumf_openForSkeletonAndLocale(skeleton_uchar, skeleton_uchar.length_in_uchars,
@locale, error)
@locale, error)
end,
Lib.method(:unumf_close),
Lib.method(:unumf_close)
)
end
end
Expand All @@ -264,7 +264,7 @@ def format_number(value, skeleton)
formatter = number_formatter(skeleton)
result = FFI::AutoPointer.new(
Lib.check_error { |error| Lib.unumf_openResult(error) },
Lib.method(:unumf_closeResult),
Lib.method(:unumf_closeResult)
)
value_str = value.to_s
Lib.check_error do |error|
Expand Down
Loading

0 comments on commit ef3ecb3

Please sign in to comment.