noble_names 1.0.0 → 1.1.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
  SHA256:
3
- metadata.gz: aca9a5ec054a904befe7713c8b1bb2de83b2badde064e28ba274ef0d94b74992
4
- data.tar.gz: 67720c835320318c01b2193755928f82bde606db4ab360daa2cd76625fef4e83
3
+ metadata.gz: 55fac8ca35e105fab52df4aac55c9617ee4066eefcddba318dfba63ccb4b026c
4
+ data.tar.gz: 65d66d6376cd0376d923bb57d0ffe3592fe4732326169a744b8f47bd6942559b
5
5
  SHA512:
6
- metadata.gz: 37c81bd00fb1ec5955179e1b6cecc2e278049be0b3bdb607d4307b7172d7b8bd118da9318c0cb79ae428ff1df7da872644c48b0e51dfcf1d9d63f7556e611a98
7
- data.tar.gz: 84ab027a7ceb38f420c17410e6f9136592bc7bdc38297b517f4de1d4f88b0e82686aa477d8feb7c45f20d1847e948ac019ad4c1c6fc0b73bea1fd058391d65c9
6
+ metadata.gz: 553a0ecebfb0d0f4896b9f08d2ad43319015f0b5ddec15df19dcf317d7ecff36a5d54a7016dd28b3f8869883d0a7ef9e492b68e1964d8a3c5b9dc9a621d526f2
7
+ data.tar.gz: ec9b7bb5c0a88b5188f2d076c9d44ffb01a2bcd8f08b453ad9f83366cb6d96895ae9730c010b324f9fc1ada4e6df229203ac4426d61d101541b0b706e2aa6598
@@ -0,0 +1,43 @@
1
+ # Use the latest 2.1 version of CircleCI pipeline process engine.
2
+ # See: https://circleci.com/docs/2.0/configuration-reference
3
+ version: 2.1
4
+
5
+ # Orbs are reusable packages of CircleCI configuration that you may share across projects, enabling you to create encapsulated, parameterized commands, jobs, and executors that can be used across multiple projects.
6
+ # See: https://circleci.com/docs/2.0/orb-intro/
7
+ orbs:
8
+ ruby: circleci/ruby@1.7.1
9
+
10
+ # Define a job to be invoked later in a workflow.
11
+ # See: https://circleci.com/docs/2.0/configuration-reference/#jobs
12
+ jobs:
13
+ build:
14
+ parameters:
15
+ ruby-version:
16
+ type: string
17
+ docker:
18
+ - image: cimg/ruby:3.1.0
19
+ executor: ruby/default
20
+ steps:
21
+ - checkout
22
+ - ruby/install:
23
+ version: << parameters.ruby-version >>
24
+ - run:
25
+ name: bundle install
26
+ command: gem install bundler && bundle install
27
+ - ruby/rubocop-check
28
+ - run:
29
+ name: Minitest
30
+ command: bundle exec rake
31
+ - run:
32
+ name: Flay
33
+ command: bundle exec flay
34
+
35
+ # Invoke jobs via workflows
36
+ # See: https://circleci.com/docs/2.0/configuration-reference/#workflows
37
+ workflows:
38
+ all-tests:
39
+ jobs:
40
+ - build:
41
+ matrix:
42
+ parameters:
43
+ ruby-version: ["2.6.0", "2.7.0", "3.1.2", "jruby-9.3.4.0"]
data/.gitignore CHANGED
@@ -8,3 +8,4 @@
8
8
  /pkg/
9
9
  /spec/reports/
10
10
  /tmp/
11
+ /vendor/bundle/
data/.rubocop.yml CHANGED
@@ -1,21 +1,8 @@
1
- Layout/AlignParameters:
2
- # Alignment of parameters in multi-line method calls.
3
- #
4
- # The `with_first_parameter` style aligns the following lines along the same
5
- # column as the first parameter.
6
- #
7
- # method_call(a,
8
- # b)
9
- #
10
- # The `with_fixed_indentation` style aligns the following lines with one
11
- # level of indentation relative to the start of the line with the method call.
12
- #
13
- # method_call(a,
14
- # b)
15
- EnforcedStyle: with_fixed_indentation
16
- SupportedStyles:
17
- - with_first_parameter
18
- - with_fixed_indentation
1
+
2
+ AllCops:
3
+ NewCops: enable
4
+ TargetRubyVersion: 2.6
5
+ SuggestExtensions: false
19
6
 
20
7
  Metrics/BlockLength:
21
8
  # Ignore the block lengths in these files as they are based on long blocks.
@@ -24,3 +11,8 @@ Metrics/BlockLength:
24
11
  - '*.gemspec'
25
12
  - '**/*.rake'
26
13
  - 'test/**/*.rb'
14
+
15
+ Metrics/ClassLength:
16
+ # Ignore the block lengths in these files as they are based on long blocks.
17
+ Exclude:
18
+ - 'test/**/*.rb'
data/.travis.yml CHANGED
@@ -5,6 +5,8 @@ rvm:
5
5
  - 2.3.3
6
6
  - 2.4.1
7
7
  - 2.5.0
8
+ - 2.7.0
9
+ - 3.1.2
8
10
  install:
9
11
  - bundle install --retry=3
10
12
  script:
data/CHANGELOG.md CHANGED
@@ -1,6 +1,6 @@
1
1
  <!--
2
2
 
3
- // Please add your own contribution below inside the Master section, no need to
3
+ // Please add your own contribution below inside the Main section, no need to
4
4
  // set a version number, that happens during a deploy.
5
5
  //
6
6
  // These docs are aimed at users rather than danger developers, so please limit technical
@@ -8,7 +8,11 @@
8
8
 
9
9
  -->
10
10
 
11
- ## master
11
+ ## main
12
+
13
+ * Changed `da` to `del` in Spanish.
14
+ * Fixed processing of business names to work as described in README: only fix the business particles and leave the rest of the name alone.
15
+ * Make recognition of business names case insensitive
12
16
 
13
17
  ### 1.0.0
14
18
 
@@ -16,3 +20,13 @@
16
20
  * Added project to code-climate.
17
21
  * Added support for native UTF-8 upcasing for ruby `>= 2.4`.
18
22
  * Drop support for ruby 1.9.3 and updated development dependencies.
23
+
24
+ ### 1.1.0
25
+
26
+ * Merged PR #5 by @judith-easybill:
27
+ * Fixes business particle handling
28
+ * Adds associated tests
29
+ * Replaced mentions of `master` with `main`
30
+ * Added ruby 3.1.2 to tested versions
31
+ * Dropped support for ruby < 2.5
32
+ * Added testing for ruby 3.1.2
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
3
5
  # Specify your gem's dependencies in noble_names.gemspec
data/README.md CHANGED
@@ -1,7 +1,6 @@
1
1
  # NobleNames
2
- [![Build Status](https://travis-ci.org/Haniyya/noble_names.svg?branch=master)](https://travis-ci.org/Haniyya/noble_names)
3
- [![Documentation
4
- Status](https://readthedocs.org/projects/noble-names/badge/?version=latest)](http://www.rubydoc.info/gems/noble_names)
2
+ [![CircleCI](https://circleci.com/gh/Haniyya/noble_names/tree/main.svg?style=svg)](https://circleci.com/gh/Haniyya/noble_names/tree/main)
3
+ [![Documentation Status](https://readthedocs.org/projects/noble-names/badge/?version=latest)](http://www.rubydoc.info/gems/noble_names)
5
4
  [![Maintainability](https://api.codeclimate.com/v1/badges/614fe2d4f930a092e6f5/maintainability)](https://codeclimate.com/github/Haniyya/noble_names/maintainability)
6
5
 
7
6
  A small Gem to capitalize names with regard to nobility particles and prefixes.
@@ -72,6 +71,7 @@ To install this gem onto your local machine, run `bundle exec rake install`.
72
71
  - Fork it ( https://github.com/Haniyya/noble_names/fork )
73
72
  - Create your feature branch (git checkout -b my-new-feature)
74
73
  - Commit your changes (git commit -am 'Add some feature')
74
+ - Add your changes to `CHANGELOG.md`.
75
75
  - Push to the branch (git push origin my-new-feature)
76
76
  - Create a new Pull Request
77
77
 
@@ -83,10 +83,9 @@ This gem has no runtime-dependencies outside of the standard library and is
83
83
  therefore compatible with the following ruby versions:
84
84
 
85
85
  - jruby
86
- - 2.5.0
87
- - 2.4.3
88
- - 2.3.0
89
- - 2.2.4
86
+ - 2.6.0
87
+ - 2.7.0
88
+ - 3.1.2
90
89
 
91
90
  Other verions might work to but are not tested in ci so far.
92
91
 
data/Rakefile CHANGED
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  require 'rake/testtask'
3
4
 
@@ -28,11 +29,9 @@ task :source_encoding do
28
29
  # We have a shebang. Encoding comment is to put on the second line
29
30
  file_content.sub!(/(\n|\r\n)/, "\\1#{magic_comment}\\1")
30
31
  else
31
- file_content = magic_comment + "\n" + file_content
32
+ file_content = "#{magic_comment}\n#{file_content}"
32
33
  end
33
34
 
34
- File.open(file_name, 'w') do |file|
35
- file.write file_content
36
- end
35
+ File.write(file_name, file_content)
37
36
  end
38
37
  end
data/bin/console CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  require 'bundler/setup'
4
5
  require 'noble_names'
@@ -22,7 +22,7 @@ nobility_particles:
22
22
  - 'la'
23
23
  spanish:
24
24
  - 'de'
25
- - 'da'
25
+ - 'del'
26
26
  portuguese:
27
27
  - 'de'
28
28
  - 'da'
@@ -32,4 +32,3 @@ nobility_particles:
32
32
  - 'de'
33
33
  - 'ter'
34
34
 
35
-
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  # :nodoc:
3
4
  module NobleNames
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  module NobleNames
3
4
  module CoreExt
@@ -1,9 +1,10 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  module NobleNames
3
4
  # The module responsible for maintaining and delivering
4
5
  # the match data as defined in the `data` directory.
5
6
  module Data
6
- DATA_PATH = File.expand_path('../../../data/', __FILE__).freeze
7
+ DATA_PATH = File.expand_path('../../data', __dir__).freeze
7
8
 
8
9
  @nobility_particles = MatchIndex.new('nobility_particles.yml')
9
10
  @nobility_prefixes = MatchIndex.new('nobility_prefixes.yml')
@@ -13,7 +14,7 @@ module NobleNames
13
14
  # Otherwise it calls super.
14
15
  def self.method_missing(method, *args, &block)
15
16
  var = instance_variable_get("@#{method}")
16
- var ? var : super
17
+ var || super
17
18
  end
18
19
 
19
20
  # Remember to define respond_to_missing.
@@ -1,5 +1,6 @@
1
+ # frozen_string_literal: true
1
2
 
2
- require_relative 'core_ext/string.rb'
3
+ require_relative 'core_ext/string'
3
4
 
4
5
  # :nodoc:
5
6
  module NobleNames
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  require 'yaml'
3
4
 
@@ -29,7 +30,7 @@ module NobleNames
29
30
  @data = YAML.load_file(File.expand_path(list, Data::DATA_PATH))
30
31
  @data = @data.values.first
31
32
  else
32
- @data = Hash[list]
33
+ @data = list.to_h
33
34
  end
34
35
  @lanugages = NobleNames.configuration.languages
35
36
  end
@@ -43,7 +44,7 @@ module NobleNames
43
44
  # MatchIndex.new('nobility_particles.yml')
44
45
  # .particles['von'] #=> 'von'
45
46
  def particles
46
- @particles ||= Hash[selected_data.collect { |v| [v.downcase, v] }]
47
+ @particles ||= selected_data.to_h { |v| [v.downcase, v] }
47
48
  end
48
49
 
49
50
  # Checks weither a word is in the nobility particle list.
@@ -77,7 +78,7 @@ module NobleNames
77
78
  def prefix?(word)
78
79
  reindex if languages != NobleNames.configuration.languages
79
80
  prefixes.each do |pre|
80
- return pre unless (word =~ Regexp.new('^' + pre.to_s)).nil?
81
+ return pre unless (word =~ Regexp.new("^#{pre}")).nil?
81
82
  end
82
83
  nil
83
84
  end
@@ -1,4 +1,5 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  module NobleNames
3
- VERSION = '1.0.0'.freeze
4
+ VERSION = '1.1.0'
4
5
  end
data/lib/noble_names.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  require 'noble_names/match_index'
3
4
  require 'noble_names/version'
@@ -39,7 +40,7 @@ module NobleNames
39
40
  # capitalize('john james') #=> 'John james'
40
41
  # capitalize('eBase') #=> 'eBase'
41
42
  def capitalize(word)
42
- if word =~ /[A-Z]|Ä|Ö|Ü/
43
+ if word.match?(/[A-Z]|Ä|Ö|Ü/)
43
44
  word
44
45
  else
45
46
  word.gsub first_small_letters do |letter|
@@ -48,12 +49,12 @@ module NobleNames
48
49
  end
49
50
  end
50
51
 
51
- # Checks weither a word is in the business particle list
52
+ # Checks whether a word is in the business particle list
52
53
  # @param [String] word The word in question.
53
54
  # @return [Boolean] result `true` if `word` is a business-particle
54
55
  # `false` otherwise
55
56
  def business_particle?(word)
56
- Data.business_particles.in_particle_list? word
57
+ Data.business_particles.in_particle_list? word.downcase
57
58
  end
58
59
 
59
60
  # Corrects only the business particle and leaves the
@@ -70,35 +71,30 @@ module NobleNames
70
71
  word
71
72
  .replace(Data.business_particles.particles[word.downcase])
72
73
  else
73
- noble_capitalize(word)
74
+ word
74
75
  end
75
76
  end
76
77
  end
77
78
 
78
79
  private
79
80
 
81
+ MUTATED_UPCASE_VOWELS = { 'ä' => 'Ä', 'ü' => 'Ü', 'ö' => 'Ö' }.freeze
82
+
80
83
  # Upcases a letter even if it is a german mutated vowel.
81
84
  # @return [String] letter the upcased letter.
82
85
  # @example
83
86
  # upcase('t') #=> 'T'
84
87
  def upcase(letter)
85
88
  return letter.upcase if STANDARD_UPACE_SUPPORT
86
- match = letter.match(/ä|ö|ü/)
87
- if match
88
- case match.to_s
89
- when 'ä' then 'Ä'
90
- when 'ö' then 'Ö'
91
- when 'ü' then 'Ü'
92
- end
93
- else letter.upcase
94
- end
89
+
90
+ MUTATED_UPCASE_VOWELS[letter] || letter.upcase
95
91
  end
96
92
 
97
93
  # A Regex literal to find the first letter of a string
98
94
  # as well as the first letter after a hyphon.
99
95
  # @return [Regexp] first_small_letters the regexp in question
100
96
  def first_small_letters
101
- /((\A.|(?<=\-).))/
97
+ /((\A.|(?<=-).))/
102
98
  end
103
99
  end
104
100
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: noble_names
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul Martensen
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-02-03 00:00:00.000000000 Z
11
+ date: 2022-05-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1'
19
+ version: '2'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1'
26
+ version: '2'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: flay
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -72,14 +72,28 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '0.52'
75
+ version: '1.28'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.28'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rubocop-minitest
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0.17'
76
90
  type: :development
77
91
  prerelease: false
78
92
  version_requirements: !ruby/object:Gem::Requirement
79
93
  requirements:
80
94
  - - "~>"
81
95
  - !ruby/object:Gem::Version
82
- version: '0.52'
96
+ version: '0.17'
83
97
  description: |2
84
98
  This Gem uses a list of nobility particles to keep track of what to
85
99
  capitalize and what not.
@@ -89,6 +103,7 @@ executables: []
89
103
  extensions: []
90
104
  extra_rdoc_files: []
91
105
  files:
106
+ - ".circleci/config.yml"
92
107
  - ".gitignore"
93
108
  - ".rubocop.yml"
94
109
  - ".travis.yml"
@@ -116,7 +131,8 @@ licenses:
116
131
  - MIT
117
132
  metadata:
118
133
  allowed_push_host: https://rubygems.org
119
- post_install_message:
134
+ rubygems_mfa_required: 'true'
135
+ post_install_message:
120
136
  rdoc_options: []
121
137
  require_paths:
122
138
  - lib
@@ -124,16 +140,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
124
140
  requirements:
125
141
  - - ">="
126
142
  - !ruby/object:Gem::Version
127
- version: '0'
143
+ version: 2.6.0
128
144
  required_rubygems_version: !ruby/object:Gem::Requirement
129
145
  requirements:
130
146
  - - ">="
131
147
  - !ruby/object:Gem::Version
132
148
  version: '0'
133
149
  requirements: []
134
- rubyforge_project:
135
- rubygems_version: 2.7.3
136
- signing_key:
150
+ rubygems_version: 3.0.3
151
+ signing_key:
137
152
  specification_version: 4
138
153
  summary: A gem that titleizes strings while respecting certain linguistic differences.
139
154
  test_files: []