utf8_proc 0.2.3 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0f0100ceec29ddf6573a113e96b40afc739d7584
4
- data.tar.gz: 8698ee90244f05aec2754f3aaf1701a7a13cd8cc
3
+ metadata.gz: 51fd48320809134499eb6cc1ec7d84f91034df30
4
+ data.tar.gz: 8b25e229470de1b9e666d8bf55cebd4b647797ed
5
5
  SHA512:
6
- metadata.gz: adae5ae7a317c87d0a75553161530152c26d2479c7b8849eeff5cf7109476ad0e9255e4e13bd039eea780173ea8bc1eb43beebbc2ef0658ca069b363d33eb0bc
7
- data.tar.gz: 8429060afb0af89b5e2fb3ac2a5cc54220bf9ed5e164f611b871aaa1bb9399ef71f0a5511b6b14826d8260284d615ad6d41ab4c5761def775ba1cfcf0a2b0d2f
6
+ metadata.gz: 03dee7d55aa9c396d079f1267033a3978ace36717c94b05a32d8225cda0e2c2d09f22e5f6fa058510b923796e948e031fabc48c6331b95d06a10ae0634400897
7
+ data.tar.gz: 2b3af9256deaa1cfea16eea4e6470e36edb37b091c8dd9e009d7e420e6ef50125e03f81c2921ee4ece325834f1c6dd698920ede15bbf7bb9de591713ea53ec65
data/.rubocop.yml ADDED
@@ -0,0 +1,93 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.0
3
+
4
+ # Metrics
5
+ Metrics/AbcSize:
6
+ Description: >-
7
+ A calculated magnitude based on number of assignments,
8
+ branches, and conditions.
9
+ Reference: 'http://c2.com/cgi/wiki?AbcMetric'
10
+ Enabled: false
11
+ Max: 20
12
+
13
+ Metrics/BlockNesting:
14
+ Description: 'Avoid excessive block nesting'
15
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#three-is-the-number-thou-shalt-count'
16
+ Enabled: true
17
+ Max: 4
18
+
19
+ Metrics/ClassLength:
20
+ Description: 'Avoid classes longer than 250 lines of code.'
21
+ Enabled: true
22
+ Max: 250
23
+
24
+ Metrics/CyclomaticComplexity:
25
+ Description: >-
26
+ A complexity metric that is strongly correlated to the number
27
+ of test cases needed to validate a method.
28
+ Enabled: true
29
+
30
+ Metrics/LineLength:
31
+ Description: 'Limit lines to 80 characters.'
32
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#80-character-limits'
33
+ Enabled: false
34
+
35
+ Metrics/MethodLength:
36
+ Description: 'Avoid methods longer than 30 lines of code.'
37
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#short-methods'
38
+ Enabled: true
39
+ Max: 30
40
+
41
+ Metrics/ModuleLength:
42
+ Description: 'Avoid modules longer than 250 lines of code.'
43
+ Enabled: true
44
+ Max: 250
45
+
46
+ Metrics/ParameterLists:
47
+ Description: 'Avoid parameter lists longer than three or four parameters.'
48
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#too-many-params'
49
+ Enabled: true
50
+
51
+ Metrics/PerceivedComplexity:
52
+ Description: >-
53
+ A complexity metric geared towards measuring complexity for a
54
+ human reader.
55
+ Enabled: false
56
+
57
+ # Style
58
+ Style/AsciiComments:
59
+ Enabled: false
60
+
61
+ Style/CollectionMethods:
62
+ Enabled: true
63
+
64
+ Style/ConditionalAssignment:
65
+ Enabled: false
66
+
67
+ Style/Documentation:
68
+ Enabled: false
69
+
70
+ Style/FormatString:
71
+ EnforcedStyle: percent
72
+
73
+ Style/HashSyntax:
74
+ EnforcedStyle: ruby19_no_mixed_keys
75
+
76
+ Style/MethodCalledOnDoEndBlock:
77
+ Enabled: true
78
+
79
+ Style/PercentLiteralDelimiters:
80
+ PreferredDelimiters:
81
+ '%i': '[]'
82
+ '%I': '[]'
83
+ '%w': '[]'
84
+ '%W': '[]'
85
+
86
+ Style/StringLiterals:
87
+ EnforcedStyle: double_quotes
88
+
89
+ Style/SymbolArray:
90
+ Enabled: true
91
+
92
+ Style/TrailingCommaInLiteral:
93
+ EnforcedStyleForMultiline: comma
data/.travis.yml CHANGED
@@ -7,6 +7,13 @@ rvm:
7
7
  - 2.2.6
8
8
  - 2.1.10
9
9
  - 2.0.0
10
+ - ruby-head
11
+ - jruby-9.1.5.0
12
+ - jruby-head
13
+ matrix:
14
+ allow_failures:
15
+ - rvm: ruby-head
16
+ - rvm: jruby-head
10
17
  before_install:
11
18
  - wget -O utf8proc.zip https://github.com/JuliaLang/utf8proc/archive/v2.1.0.zip
12
19
  - unzip utf8proc.zip
data/README.md CHANGED
@@ -55,6 +55,8 @@ UTF8Proc.normalize(utf8_string, form = :nfc)
55
55
  UTF8Proc::LIBRARY_VERSION
56
56
  ```
57
57
 
58
+ (Like `unf`) on JRuby the gem will fall-back to using `java.text.normalizer`. The interface remains the same.
59
+
58
60
  ## Contributing
59
61
 
60
62
  Bug reports and pull requests are welcome on GitHub at https://github.com/nomoon/utf8_proc. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
data/Rakefile CHANGED
@@ -8,12 +8,16 @@ Rake::TestTask.new(:test) do |t|
8
8
  t.test_files = FileList["test/**/*_test.rb"]
9
9
  end
10
10
 
11
- require "rake/extensiontask"
11
+ if defined?(JRUBY_VERSION)
12
+ task default: :test
13
+ else
14
+ require "rake/extensiontask"
12
15
 
13
- task build: :compile
16
+ task build: :compile
14
17
 
15
- Rake::ExtensionTask.new("utf8_proc") do |ext|
16
- ext.lib_dir = "lib/utf8_proc"
17
- end
18
+ Rake::ExtensionTask.new("utf8_proc") do |ext|
19
+ ext.lib_dir = "lib/utf8_proc"
20
+ end
18
21
 
19
- task default: %i[clobber compile test]
22
+ task default: %i[clobber compile test]
23
+ end
data/lib/utf8_proc.rb CHANGED
@@ -1,6 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
  require "utf8_proc/version"
3
- require "utf8_proc/utf8_proc"
4
3
 
5
4
  module UTF8Proc
5
+ if defined?(JRUBY_VERSION)
6
+ require "utf8_proc/jruby"
7
+ include JRuby
8
+ else
9
+ require "utf8_proc/utf8_proc"
10
+ end
6
11
  end
@@ -0,0 +1,59 @@
1
+ # frozen_string_literal: true
2
+ # rubocop:disable MethodName
3
+
4
+ # This file should only be required within JRuby
5
+
6
+ require "java"
7
+
8
+ module UTF8Proc
9
+ module JRuby
10
+ LIBRARY_VERSION = "Java #{ENV_JAVA['java.version']}".freeze
11
+
12
+ JTNORM = java.text.Normalizer
13
+ private_constant :JTNORM
14
+
15
+ def self.included(receiver)
16
+ receiver.extend(ClassMethods)
17
+ end
18
+
19
+ module ClassMethods
20
+ def NFC(string)
21
+ JTNORM.normalize(string, JTNORM::Form::NFC)
22
+ end
23
+
24
+ def NFD(string)
25
+ JTNORM.normalize(string, JTNORM::Form::NFD)
26
+ end
27
+
28
+ def NFKC(string)
29
+ JTNORM.normalize(string, JTNORM::Form::NFKC)
30
+ end
31
+
32
+ def NFKD(string)
33
+ JTNORM.normalize(string, JTNORM::Form::NFKD)
34
+ end
35
+
36
+ def NFKC_CF(string)
37
+ NFKC(string).to_java(:string).toLowerCase
38
+ end
39
+
40
+ def normalize(string, form = :nfc)
41
+ case form
42
+ when :nfc
43
+ NFC(string)
44
+ when :nfd
45
+ NFD(string)
46
+ when :nfkc
47
+ NFKC(string)
48
+ when :nfkd
49
+ NFKD(string)
50
+ when :nfkc_cf
51
+ NFKC_CF(string)
52
+ else
53
+ raise ArgumentError, "Second argument must be one of [:nfc (default)," \
54
+ " :nfd, :nfkc, :nfkd, :nfkc_cf]"
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module UTF8Proc
3
- VERSION = "0.2.3"
3
+ VERSION = "0.3.0".freeze
4
4
  end
data/utf8_proc.gemspec CHANGED
@@ -20,11 +20,15 @@ Gem::Specification.new do |spec|
20
20
  f.match(%r{^(test|spec|features)/})
21
21
  end
22
22
  spec.require_paths = ["lib"]
23
- spec.extensions = ["ext/utf8_proc/extconf.rb"]
24
23
 
25
24
  spec.add_development_dependency "bundler", "~> 1.14"
26
25
  spec.add_development_dependency "rake", "~> 12.0"
27
26
  spec.add_development_dependency "pry", "~> 0.10"
28
- spec.add_development_dependency "rake-compiler", "~> 1.0"
29
27
  spec.add_development_dependency "minitest", "~> 5.10"
28
+ spec.add_development_dependency "rubocop", "~> 0.47"
29
+
30
+ unless defined?(JRUBY_VERSION)
31
+ spec.extensions = ["ext/utf8_proc/extconf.rb"]
32
+ spec.add_development_dependency "rake-compiler", "~> 1.0"
33
+ end
30
34
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: utf8_proc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Bellefleur
@@ -53,33 +53,47 @@ dependencies:
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0.10'
55
55
  - !ruby/object:Gem::Dependency
56
- name: rake-compiler
56
+ name: minitest
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '1.0'
61
+ version: '5.10'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '1.0'
68
+ version: '5.10'
69
69
  - !ruby/object:Gem::Dependency
70
- name: minitest
70
+ name: rubocop
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '5.10'
75
+ version: '0.47'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '5.10'
82
+ version: '0.47'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rake-compiler
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '1.0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '1.0'
83
97
  description:
84
98
  email:
85
99
  - nomoon@phoebus.ca
@@ -89,6 +103,7 @@ extensions:
89
103
  extra_rdoc_files: []
90
104
  files:
91
105
  - ".gitignore"
106
+ - ".rubocop.yml"
92
107
  - ".ruby-gemset"
93
108
  - ".ruby-version"
94
109
  - ".travis.yml"
@@ -103,6 +118,7 @@ files:
103
118
  - ext/utf8_proc/utf8_proc.c
104
119
  - ext/utf8_proc/utf8_proc.h
105
120
  - lib/utf8_proc.rb
121
+ - lib/utf8_proc/jruby.rb
106
122
  - lib/utf8_proc/version.rb
107
123
  - utf8_proc.gemspec
108
124
  homepage: https://github.com/nomoon/utf8_proc