Skip to content

Commit

Permalink
Apply linting to source and test code
Browse files Browse the repository at this point in the history
  • Loading branch information
erickguan committed Mar 2, 2024
1 parent 77a26fb commit a5c0c77
Show file tree
Hide file tree
Showing 24 changed files with 780 additions and 676 deletions.
2 changes: 1 addition & 1 deletion benchmark/detect.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
Benchmark.bmbm do |results|
results.report("rchardet:") { TESTS.times { CharDet.detect("æåø") } }
results.report("ffi-icu:") { TESTS.times { ICU::CharDet.detect("æåø") } }
end
end
4 changes: 2 additions & 2 deletions benchmark/shared.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@

Benchmark.bmbm do |results|
results.report("rchardet instance:") { TESTS.times { $rchardet.reset; $rchardet.feed("æåø"); $rchardet.result } }
results.report("ffi-icu instance:") { TESTS.times { $icu.detect("æåø") } }
end
results.report("ffi-icu instance:") { TESTS.times { $icu.detect("æåø") } }
end
3 changes: 1 addition & 2 deletions lib/ffi-icu/break_iterator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,5 @@ def current
def boundary?(offset)
Lib.ubrk_isBoundary(@iterator, Integer(offset)) != 0
end

end # BreakIterator
end # ICU
end # ICU
3 changes: 0 additions & 3 deletions lib/ffi-icu/chardet.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
module ICU
module CharDet

def self.detect(string)
Detector.new.detect string
end
Expand Down Expand Up @@ -77,8 +76,6 @@ def set_text(text)
Lib.ucsdet_setText(@detector, data, text.bytesize, status)
end
end

end # Detector
end # CharDet
end # ICU

58 changes: 28 additions & 30 deletions lib/ffi-icu/collation.rb
Original file line number Diff line number Diff line change
@@ -1,37 +1,36 @@
module ICU
module Collation

ATTRIBUTES = {
french_collation: 0,
alternate_handling: 1,
case_first: 2,
case_level: 3,
normalization_mode: 4,
strength: 5,
hiragana_quaternary_mode: 6,
numeric_collation: 7,
french_collation: 0,
alternate_handling: 1,
case_first: 2,
case_level: 3,
normalization_mode: 4,
strength: 5,
hiragana_quaternary_mode: 6,
numeric_collation: 7,
}.freeze

ATTRIBUTE_VALUES = {
nil => -1,
primary: 0,
secondary: 1,
default_strength: 2,
tertiary: 2,
quaternary: 3,
identical: 15,

false => 16,
true => 17,

shifted: 20,
non_ignorable: 21,

lower_first: 24,
upper_first: 25,
nil => -1,
primary: 0,
secondary: 1,
default_strength: 2,
tertiary: 2,
quaternary: 3,
identical: 15,

false => 16,
true => 17,

shifted: 20,
non_ignorable: 21,

lower_first: 24,
upper_first: 25,
}.freeze

ATTRIBUTE_VALUES_INVERSE = Hash[ATTRIBUTE_VALUES.map {|k,v| [v, k]}].freeze
ATTRIBUTE_VALUES_INVERSE = Hash[ATTRIBUTE_VALUES.map { |k, v| [v, k] }].freeze

def self.collate(locale, arr)
Collator.new(locale).collate(arr)
Expand Down Expand Up @@ -80,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 @@ -98,7 +97,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 Expand Up @@ -151,6 +150,5 @@ def #{attribute}=(value)
CODE
end
end # Collator

end # Collate
end # ICU
Loading

0 comments on commit a5c0c77

Please sign in to comment.