syamei 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1964e79f0545ff204316ba91d8481ffde0a4e9319100cbef1fca9a903b69db79
4
- data.tar.gz: f70a295490ac640e9b368b8cf5824ccbcd76f2537358c6a9c4b2d551cf54607e
3
+ metadata.gz: 86bf38cf7528cb77522ead5c43ecd275444de150dc8d5f4bebb169643319f62a
4
+ data.tar.gz: d2d2ca428d52ca0cb232220c7158e5bfdb3c7e74cfe5c005e48ad79555c1b388
5
5
  SHA512:
6
- metadata.gz: ea8df52e09b4f3f5bc0b1c33543d76862f0fc65305bfb655a3bc9860070a3319150575279265abaeaf3da23ace240070d2966b7d3adc13c5f178202bba472aaa
7
- data.tar.gz: 26d275fb6c472c9c20f1dcd3cf29d05b3eb542bd6e23ea6cae54d226b9bc7d939f84481d3d611fbb50275f342275001b6f9a05c5188f3c238aec91f4799df7f4
6
+ metadata.gz: d852243858bb738a76333ad9d6f4d4f9e6d0dde18460efb8a9748a8166013fac69855a7049ee0af5ce724482efe6bafd9e6236549f8609352f5869f67d168db8
7
+ data.tar.gz: 3228226073380dffc485b08eb0acc505eca8bc4f42e4f6d1d616930b8eac49f106ea13c3758a4d8a543115064f72085b898a116e7bc740a6bd082b3fa4594645
@@ -0,0 +1,101 @@
1
+ version: 2
2
+ jobs:
3
+ build:
4
+ parallelism: 3
5
+ docker:
6
+ - image: circleci/ruby:2.6.7
7
+ environment:
8
+ BUNDLE_JOBS: 3
9
+ BUNDLE_RETRY: 3
10
+ BUNDLE_PATH: vendor/bundle
11
+
12
+ steps:
13
+ - checkout
14
+
15
+ - run:
16
+ name: install Bundler
17
+ command: |
18
+ echo 'export BUNDLER_VERSION=$(cat Gemfile.lock | tail -1 | tr -d " ")' >> $BASH_ENV
19
+ source $BASH_ENV
20
+ gem install bundler
21
+
22
+ - run:
23
+ name: Which bundler?
24
+ command: bundle -v
25
+
26
+ - restore_cache:
27
+ keys:
28
+ - gem-sample-{{ checksum "Gemfile.lock" }}
29
+ - gem-sample-
30
+
31
+ - run:
32
+ name: Bundle Install
33
+ command: bundle check --path vendor/bundle || bundle install --deployment
34
+
35
+ - save_cache:
36
+ key: gem-sample-{{ checksum "Gemfile.lock" }}
37
+ paths:
38
+ - vendor/bundle
39
+
40
+ - run:
41
+ name: run rubocop
42
+ command: |
43
+ bundle exec rubocop
44
+ - run:
45
+ name: Run rspec in parallel
46
+ command: |
47
+ bundle exec rspec --profile 10 \
48
+ --format RspecJunitFormatter \
49
+ --out test_results/rspec.xml \
50
+ --format progress \
51
+ $(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)
52
+ - store_test_results:
53
+ path: test_results
54
+ - store_artifacts:
55
+ path: test_results
56
+ destination: test-results
57
+ - store_artifacts:
58
+ path: coverage
59
+ destination: coverage-results
60
+ deploy:
61
+ docker:
62
+ - image: circleci/ruby:2.6.7
63
+
64
+ steps:
65
+ - checkout
66
+
67
+ - run:
68
+ name: install Bundler
69
+ command: |
70
+ echo 'export BUNDLER_VERSION=$(cat Gemfile.lock | tail -1 | tr -d " ")' >> $BASH_ENV
71
+ source $BASH_ENV
72
+ gem install bundler
73
+ - run:
74
+ name: Which bundler?
75
+ command: bundle -v
76
+
77
+ - restore_cache:
78
+ keys:
79
+ - gem-deploy-{{ checksum "Gemfile.lock" }}
80
+ - gem-deploy-
81
+
82
+ - run:
83
+ name: Bundle Install
84
+ command: bundle check --path vendor/bundle || bundle install
85
+
86
+ - save_cache:
87
+ key: gem-deploy-{{ checksum "Gemfile.lock" }}
88
+ paths:
89
+ - vendor/bundle
90
+
91
+ workflows:
92
+ version: 2
93
+ build-and-deploy:
94
+ jobs:
95
+ - build
96
+ - deploy:
97
+ requires:
98
+ - build
99
+ filters:
100
+ branches:
101
+ only: master
@@ -0,0 +1,17 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: bundler
4
+ directory: "/"
5
+ schedule:
6
+ interval: daily
7
+ time: "20:00"
8
+ open-pull-requests-limit: 10
9
+ ignore:
10
+ - dependency-name: rubocop
11
+ versions:
12
+ - 1.10.0
13
+ - 1.11.0
14
+ - 1.12.0
15
+ - 1.12.1
16
+ - 1.9.0
17
+ - 1.9.1
data/.gitignore CHANGED
@@ -6,10 +6,13 @@
6
6
  /pkg/
7
7
  /spec/reports/
8
8
  /tmp/
9
- Gemfile.lock
9
+ /vendor/
10
10
 
11
11
  # rspec failure tracking
12
12
  .rspec_status
13
13
 
14
14
  # RubyMine
15
- .idea/*
15
+ .idea/*
16
+
17
+ /cache/
18
+ /spec/vcr/
data/.rubocop.yml ADDED
@@ -0,0 +1,100 @@
1
+ AllCops:
2
+ Exclude:
3
+ - "tmp/**/*"
4
+ - "config/initializers/*"
5
+ - "vendor/**/*"
6
+ - "bin/*"
7
+ DisplayCopNames: true
8
+ TargetRubyVersion: 2.7.3
9
+
10
+ Style/AsciiComments:
11
+ Enabled: false
12
+
13
+ Style/Documentation:
14
+ Enabled: false
15
+
16
+ Style/NumericLiterals:
17
+ Enabled: false
18
+
19
+ Bundler/OrderedGems:
20
+ Enabled: false
21
+
22
+ Metrics/BlockLength:
23
+ Exclude:
24
+ - 'syamei.gemspec'
25
+ - 'spec/**/*'
26
+
27
+ Style/FrozenStringLiteralComment:
28
+ Enabled: false
29
+
30
+ Layout/EmptyLinesAroundAttributeAccessor:
31
+ Enabled: true
32
+
33
+ Layout/SpaceAroundMethodCallOperator:
34
+ Enabled: true
35
+
36
+ Lint/DeprecatedOpenSSLConstant:
37
+ Enabled: true
38
+
39
+ Lint/RaiseException:
40
+ Enabled: true
41
+
42
+ Lint/StructNewOverride:
43
+ Enabled: true
44
+
45
+ Layout/LineLength:
46
+ Max: 120
47
+
48
+ Lint/DuplicateElsifCondition:
49
+ Enabled: true
50
+
51
+ Lint/MixedRegexpCaptureTypes:
52
+ Enabled: true
53
+
54
+ Style/AccessorGrouping:
55
+ Enabled: true
56
+
57
+ Style/ArrayCoercion:
58
+ Enabled: true
59
+
60
+ Style/BisectedAttrAccessor:
61
+ Enabled: true
62
+
63
+ Style/CaseLikeIf:
64
+ Enabled: true
65
+
66
+ Style/ExponentialNotation:
67
+ Enabled: false
68
+
69
+ Style/HashAsLastArrayItem:
70
+ Enabled: false
71
+
72
+ Style/HashEachMethods:
73
+ Enabled: true
74
+
75
+ Style/HashLikeCase:
76
+ Enabled: true
77
+
78
+ Style/HashTransformKeys:
79
+ Enabled: true
80
+
81
+ Style/HashTransformValues:
82
+ Enabled: true
83
+
84
+ Style/RedundantAssignment:
85
+ Enabled: true
86
+
87
+ Style/RedundantFetchBlock:
88
+ Enabled: true
89
+
90
+ Style/RedundantFileExtensionInRequire:
91
+ Enabled: true
92
+
93
+ Style/RedundantRegexpCharacterClass:
94
+ Enabled: true
95
+
96
+ Style/RedundantRegexpEscape:
97
+ Enabled: true
98
+
99
+ Style/SlicingWithRange:
100
+ Enabled: true
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.6.6
1
+ 2.7.3
data/.travis.yml CHANGED
@@ -3,5 +3,5 @@ sudo: false
3
3
  language: ruby
4
4
  cache: bundler
5
5
  rvm:
6
- - 2.6.3
7
- before_install: gem install bundler -v 1.17.2
6
+ - 2.7.3
7
+ before_install: gem install bundler
data/Gemfile CHANGED
@@ -1,6 +1,6 @@
1
- source "https://rubygems.org"
1
+ source 'https://rubygems.org'
2
2
 
3
- git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
3
+ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
4
4
 
5
5
  # Specify your gem's dependencies in syamei.gemspec
6
6
  gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,71 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ syamei (0.2.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ ast (2.4.2)
10
+ diff-lcs (1.4.4)
11
+ docile (1.3.5)
12
+ parallel (1.20.1)
13
+ parser (3.0.1.1)
14
+ ast (~> 2.4.1)
15
+ rainbow (3.0.0)
16
+ rake (13.0.3)
17
+ regexp_parser (2.1.1)
18
+ rexml (3.2.5)
19
+ rspec (3.10.0)
20
+ rspec-core (~> 3.10.0)
21
+ rspec-expectations (~> 3.10.0)
22
+ rspec-mocks (~> 3.10.0)
23
+ rspec-core (3.10.1)
24
+ rspec-support (~> 3.10.0)
25
+ rspec-expectations (3.10.1)
26
+ diff-lcs (>= 1.2.0, < 2.0)
27
+ rspec-support (~> 3.10.0)
28
+ rspec-mocks (3.10.2)
29
+ diff-lcs (>= 1.2.0, < 2.0)
30
+ rspec-support (~> 3.10.0)
31
+ rspec-support (3.10.2)
32
+ rspec_junit_formatter (0.4.1)
33
+ rspec-core (>= 2, < 4, != 2.12.0)
34
+ rubocop (0.93.1)
35
+ parallel (~> 1.10)
36
+ parser (>= 2.7.1.5)
37
+ rainbow (>= 2.2.2, < 4.0)
38
+ regexp_parser (>= 1.8)
39
+ rexml
40
+ rubocop-ast (>= 0.6.0)
41
+ ruby-progressbar (~> 1.7)
42
+ unicode-display_width (>= 1.4.0, < 2.0)
43
+ rubocop-ast (1.5.0)
44
+ parser (>= 3.0.1.1)
45
+ rubocop-rspec (1.44.1)
46
+ rubocop (~> 0.87)
47
+ rubocop-ast (>= 0.7.1)
48
+ ruby-progressbar (1.11.0)
49
+ simplecov (0.21.2)
50
+ docile (~> 1.1)
51
+ simplecov-html (~> 0.11)
52
+ simplecov_json_formatter (~> 0.1)
53
+ simplecov-html (0.12.3)
54
+ simplecov_json_formatter (0.1.3)
55
+ unicode-display_width (1.7.0)
56
+
57
+ PLATFORMS
58
+ ruby
59
+
60
+ DEPENDENCIES
61
+ bundler (~> 2.2)
62
+ rake (>= 12.3.3)
63
+ rspec
64
+ rspec_junit_formatter
65
+ rubocop
66
+ rubocop-rspec
67
+ simplecov
68
+ syamei!
69
+
70
+ BUNDLED WITH
71
+ 2.2.17
data/README.md CHANGED
@@ -1,4 +1,6 @@
1
1
  # Syamei
2
+ [![Gem Version](https://badge.fury.io/rb/syamei.svg)](https://badge.fury.io/rb/syamei)
3
+ [![MIT License](http://img.shields.io/badge/license-MIT-blue.svg?style=flat)](LICENSE)
2
4
 
3
5
  syameiは、法人格の存在チェック、削除に使用するライブラリです。
4
6
  会社名の名寄せなどで利用されることを目的としています。
@@ -23,7 +25,40 @@ Or install it yourself as:
23
25
 
24
26
  社名のみを返す(法人格を削除)
25
27
  ```
26
- Syamei.only('株式会社xxx') => "xxx"
28
+ Syamei.only('株式会社xxx') => "xxx"     # 引数1つはすべて
29
+ Syamei.only('株式会社xxx', 0) => "xxx"     # type=0はすべて
30
+ Syamei.only('株式会社xxx', 1) => "xxx"     # type=1は法人格フル
31
+ Syamei.only('株式会社xxx', 2) => "株式会社xxx" # type=2は特殊文字
32
+ Syamei.only('株式会社xxx', 3) => "株式会社xxx" # type=3は省略文字
33
+ Syamei.only('株式会社xxx', 4) => "株式会社xxx" # type=4はカナ
34
+
35
+ Syamei.only('㈱xxx') => "xxx"  # 引数1つはすべて
36
+ Syamei.only('㈱xxx', 0) => "xxx"  # type=0はすべて
37
+ Syamei.only('㈱xxx', 1) => "㈱xxx" # type=1は法人格フル
38
+ Syamei.only('㈱xxx', 2) => "xxx"  # type=2は特殊文字
39
+ Syamei.only('㈱xxx', 3) => "㈱xxx" # type=3は省略文字
40
+ Syamei.only('㈱xxx', 4) => "㈱xxx" # type=4はカナ
41
+
42
+ Syamei.only('(株)xxx') => "xxx"  # 引数1つはすべて
43
+ Syamei.only('(株)xxx', 0) => "xxx"  # type=0はすべて
44
+ Syamei.only('(株)xxx', 1) => "(株)xxx" # type=1は法人格フル
45
+ Syamei.only('(株)xxx', 2) => "(株)xxx" # type=2は特殊文字
46
+ Syamei.only('(株)xxx', 3) => "xxx"  # type=3は省略文字
47
+ Syamei.only('(株)xxx', 4) => "(株)xxx" # type=4はカナ
48
+
49
+ Syamei.only('カ)xxx') => "xxx"  # 引数1つはすべて
50
+ Syamei.only('カ)xxx', 0) => "xxx"  # type=0はすべて
51
+ Syamei.only('カ)xxx', 1) => "カ)xxx" # type=1は法人格フル
52
+ Syamei.only('カ)xxx', 2) => "カ)xxx" # type=2は特殊文字
53
+ Syamei.only('カ)xxx', 3) => "カ)xxx" # type=3は省略文字
54
+ Syamei.only('カ)xxx', 4) => "xxx"  # type=4はカナ
55
+
56
+ Syamei.only('xxx(カ') => "xxx"  # 引数1つはすべて
57
+ Syamei.only('xxx(カ', 0) => "xxx"  # type=0はすべて
58
+ Syamei.only('xxx(カ', 1) => "xxx(カ" # type=1は法人格フル
59
+ Syamei.only('xxx(カ', 2) => "xxx(カ" # type=2は特殊文字
60
+ Syamei.only('xxx(カ', 3) => "xxx(カ" # type=3は省略文字
61
+ Syamei.only('xxx(カ', 4) => "xxx"  # type=4はカナ
27
62
  ```
28
63
 
29
64
  末尾の法人格を削除
@@ -54,4 +89,4 @@ Syamei.list
54
89
  1. Create your feature branch (git checkout -b my-new-feature)
55
90
  1. Commit your changes (git commit -am 'Add some feature')
56
91
  1. Push to the branch (git push origin my-new-feature)
57
- 1. Create new Pull Request
92
+ 1. Create new Pull Request
data/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
3
 
4
4
  RSpec::Core::RakeTask.new(:spec)
5
5
 
6
- task :default => :spec
6
+ task default: :spec
@@ -1,131 +1,38 @@
1
1
  notations:
2
- full:
3
- - '株式会社'
4
- - '有限会社'
5
- - '合名会社'
6
- - '合資会社'
7
- - '合同会社'
8
- - '医療法人社団'
9
- - '医療法人財団'
10
- - '医療法人'
11
- - '社会医療法人'
12
- - '財団法人'
13
- - '一般財団法人'
14
- - '公益財団法人'
15
- - '社団法人'
16
- - '一般社団法人'
17
- - '公益社団法人'
18
- - '宗教法人'
19
- - '学校法人'
20
- - '社会福祉法人'
21
- - '更生保護法人'
22
- - '相互会社'
23
- - '特定非営利活動法人'
24
- - '独立行政法人'
25
- - '地方独立行政法人'
26
- - '弁護士法人'
27
- - '有限責任中間法人'
28
- - '無限責任中間法人'
29
- - '行政書士法人'
30
- - '司法書士法人'
31
- - '税理士法人'
32
- - '国立大学法人'
33
- - '公立大学法人'
34
- - '農事組合法人'
35
- - '管理組合法人'
36
- - '社会保険労務士法人'
37
- - '営業所'
38
- - '出張所'
39
- abbreviation:
40
- - '㈱'
41
- - '\(株\)'
42
- - '㈲'
43
- - '\(有\)'
44
- - '\(名\)'
45
- - '\(資\)'
46
- - '\(同\)'
47
- - '\(医\)'
48
- - '\(財\)'
49
- - '\(一財\)'
50
- - '\(公財\)'
51
- - '\(社\)'
52
- - '\(一社\)'
53
- - '\(公社\)'
54
- - '\(宗\)'
55
- - '\(学\)'
56
- - '\(福\)'
57
- - '\(相\)'
58
- - '\(特非\)'
59
- - '\(独\)'
60
- - '\(地独\)'
61
- - '\(弁\)'
62
- - '\(行\)'
63
- - '\(司\)'
64
- - '\(税\)'
65
- - '\(中\)'
66
- - '\(大\)'
67
- - '\(営\)'
68
- - '\(出\)'
69
- kana:
70
- - 'カ\)'
71
- - '\(カ\)'
72
- - '\(カ'
73
- - 'ユ\)'
74
- - '\(ユ\)'
75
- - '\(ユ'
76
- - 'メ\)'
77
- - '\(メ\)'
78
- - '\(メ'
79
- - 'シ\)'
80
- - '\(シ\)'
81
- - '\(シ'
82
- - 'ド\)'
83
- - '\(ド\)'
84
- - '\(ド'
85
- - 'シユウ\)'
86
- - 'ガク\)'
87
- - 'フク\)'
88
- - 'ホゴ\)'
89
- - '\(ホゴ\)'
90
- - '\(ホゴ'
91
- - 'ソ\)'
92
- - '\(ソ\)'
93
- - '\(ソ'
94
- - 'トクヒ\)'
95
- - '\(トクヒ\)'
96
- - '\(トクヒ'
97
- - 'ドク\)'
98
- - '\(ドク\)'
99
- - '\(ドク'
100
- - 'チドク\)'
101
- - '\(チドク\)'
102
- - '\(チドク'
103
- - 'ベン\)'
104
- - '\(ベン\)'
105
- - '\(ベン'
106
- - 'ギヨ\)'
107
- - '\(ギヨ\)'
108
- - '\(ギヨ'
109
- - 'シホウ\)'
110
- - '\(シホウ\)'
111
- - '\(シホウ'
112
- - 'ゼイ\)'
113
- - '\(ゼイ\)'
114
- - '\(ゼイ'
115
- - 'ノウ\)'
116
- - '\(ノウ\)'
117
- - '\(ノウ'
118
- - 'カンリ\)'
119
- - '\(カンリ\)'
120
- - '\(カンリ'
121
- - 'ロウム\)'
122
- - '\(ロウム\)'
123
- - '\(ロウム'
124
- - '\(ダイ\)'
125
- - '\(ダイ'
126
- - 'エイ\)'
127
- - '\(エイ\)'
128
- - '\(エイ'
129
- - 'シユツ\)'
130
- - '\(シユツ\)'
131
- - '\(シユツ'
2
+ - ['出張所', '', '\(出\)', 'シユツ\)', '\(シユツ\)', '\(シユツ']
3
+ - ['管理組合法人', '', '', 'カンリ\)', '\(カンリ\)', '\(カンリ']
4
+ - ['司法書士法人', '', '\(司\)', 'シホウ\)', '\(シホウ\)', '\(シホウ']
5
+ - ['独立行政法人', '', '\(独\)', 'ドク\)', '\(ドク\)', '\(ドク']
6
+ - ['株式会社', '㈱', '\(株\)', 'カ\)', '\(カ\)', '\(カ']
7
+ - ['有限会社', '㈲', '\(有\)', 'ユ\)', '\(ユ\)', '\(ユ']
8
+ - ['合名会社', '', '\(名\)', 'メ\)', '\(メ\)', '\(メ']
9
+ - ['合資会社', '', '\(資\)', 'シ\)', '\(シ\)', '\(シ']
10
+ - ['合同会社', '', '\(同\)', 'ド\)', '\(ド\)', '\(ド']
11
+ - ['医療法人社団', '', '\(医\)', 'イ\)', '', '\(イ']
12
+ - ['医療法人財団', '', '\(医\)', 'イ\)', '', '\(イ']
13
+ - ['医療法人', '', '\(医\)', 'イ\)', '', '\(イ']
14
+ - ['社会医療法人', '', '\(医\)', 'イ\)', '', '\(イ']
15
+ - ['財団法人', '', '\(財\)', 'ザイ\)', '', '']
16
+ - ['一般財団法人', '', '\(一財\)', 'ザイ\)', '', '']
17
+ - ['公益財団法人', '', '\(公財\)', 'ザイ\)', '', '']
18
+ - ['社団法人', '', '\(社\)', 'シヤ\)', '', '']
19
+ - ['一般社団法人', '', '\(一社\)', 'シヤ\)', '', '']
20
+ - ['公益社団法人', '', '\(公社\)', 'シヤ\)', '', '']
21
+ - ['宗教法人', '', '\(宗\)', '', '', '']
22
+ - ['学校法人', '', '\(学\)', 'ガク\)', '', '']
23
+ - ['社会福祉法人', '', '\(福\)', 'フク\)', '', '']
24
+ - ['更生保護法人', '', '', 'ホゴ\)', '\(ホゴ\)', '\(ホゴ']
25
+ - ['相互会社', '', '\(相\)', 'ソ\)', '\(ソ\)', '\(ソ']
26
+ - ['特定非営利活動法人', '', '\(特非\)', 'トクヒ\)', '\(トクヒ\)', '\(トクヒ']
27
+ - ['地方独立行政法人', '', '\(地独\)', 'チドク\)', '\(チドク\)', '\(チドク']
28
+ - ['弁護士法人', '', '\(弁\)', 'ベン\)', '\(ベン\)', '\(ベン']
29
+ - ['有限責任中間法人', '', '\(中\)', 'チユウ\)', '\(チユウ\)', '\(チユウ']
30
+ - ['無限責任中間法人', '', '\(中\)', 'チユウ\)', '\(チユウ\)', '\(チユウ']
31
+ - ['行政書士法人', '', '\(行\)', 'ギヨ\)', '\(ギヨ\)', '\(ギヨ']
32
+ - ['税理士法人', '', '\(税\)', 'ゼイ\)', '\(ゼイ\)', '\(ゼイ']
33
+ - ['国立大学法人', '', '\(大\)', 'ダイ\)', '\(ダイ\)', '\(ダイ']
34
+ - ['公立大学法人', '', '\(大\)', 'ダイ\)', '\(ダイ\)', '\(ダイ']
35
+ - ['農事組合法人', '', '', 'ノウ\)', '\(ノウ\)', '\(ノウ']
36
+ - ['社会保険労務士法人', '', '', 'ロウム\)', '\(ロウム\)', '\(ロウム']
37
+ - ['営業所', '', '\(営\)', 'エイ\)', '\(エイ\)', '\(エイ']
38
+
data/lib/syamei.rb CHANGED
@@ -4,21 +4,36 @@ require 'yaml'
4
4
  module Syamei
5
5
  class Error < StandardError; end
6
6
 
7
- NOTATION = YAML.load_file(File.expand_path(File.join('..', 'data', 'notations.yml'), __FILE__))['notations']['full'].join('|')
8
- ABBREVIATION = YAML.load_file(File.expand_path(File.join('..', 'data', 'notations.yml'), __FILE__))['notations']['abbreviation'].join('|')
9
- KANA = YAML.load_file(File.expand_path(File.join('..', 'data', 'notations.yml'), __FILE__))['notations']['kana'].join('|')
7
+ DATA = YAML.load_file(File.expand_path(File.join('..', 'data', 'notations.yml'), __FILE__))['notations']
8
+ NOTATION = DATA.map { |n| n[0] }.compact.reject(&:empty?).flatten.uniq
9
+ SPECIAL = DATA.map { |n| n[1] }.compact.reject(&:empty?).flatten.uniq
10
+ ABBREVIATION = DATA.map { |n| n[2] }.compact.reject(&:empty?).flatten.uniq
11
+ KANA_HEAD = DATA.map { |n| n[3] }.compact.reject(&:empty?).flatten.uniq
12
+ KANA_MIDDLE = DATA.map { |n| n[4] }.compact.reject(&:empty?).flatten.uniq
13
+ KANA_TAIL = DATA.map { |n| n[5] }.compact.reject(&:empty?).flatten.uniq
10
14
 
11
15
  COMPLEX_TYPE = {
12
- 0 => [NOTATION, ABBREVIATION, KANA].join('|'),
13
- 1 => NOTATION,
14
- 2 => ABBREVIATION,
15
- 3 => KANA
16
+ 0 => {
17
+ all: [NOTATION, SPECIAL, ABBREVIATION, KANA_HEAD, KANA_TAIL].join('|'),
18
+ head: [NOTATION, SPECIAL, ABBREVIATION, KANA_HEAD].join('|'),
19
+ tail: [NOTATION, SPECIAL, ABBREVIATION, KANA_TAIL].join('|')
20
+ },
21
+ 1 => NOTATION.join('|'),
22
+ 2 => SPECIAL.join('|'),
23
+ 3 => ABBREVIATION.join('|'),
24
+ 4 => {
25
+ all: [KANA_HEAD, KANA_TAIL].join('|'),
26
+ head: KANA_HEAD.join('|'),
27
+ tail: KANA_TAIL.join('|')
28
+ }
16
29
  }.freeze
17
30
 
18
31
  # 前株の存在チェック
19
32
  def self.with_beginning?(name, type = 0)
20
33
  return false if name.nil? || name.empty?
21
34
 
35
+ return name.match?(/^(#{COMPLEX_TYPE[type][:head]}).*$/) if type.zero? || type == 4
36
+
22
37
  name.match?(/^(#{COMPLEX_TYPE[type]}).*$/)
23
38
  end
24
39
 
@@ -26,6 +41,8 @@ module Syamei
26
41
  def self.with_end?(name, type = 0)
27
42
  return false if name.nil? || name.empty?
28
43
 
44
+ return name.match?(/.*(#{COMPLEX_TYPE[type][:tail]})$/) if type.zero? || type == 4
45
+
29
46
  name.match?(/.*(#{COMPLEX_TYPE[type]})$/)
30
47
  end
31
48
 
@@ -40,6 +57,8 @@ module Syamei
40
57
  def self.with_beginning(name, type = 0)
41
58
  return nil if name.nil? || name.empty?
42
59
 
60
+ return name.gsub(/(#{COMPLEX_TYPE[type][:tail]})$/, '').strip if type.zero? || type == 4
61
+
43
62
  name.gsub(/(#{COMPLEX_TYPE[type]})$/, '').strip
44
63
  end
45
64
 
@@ -47,6 +66,8 @@ module Syamei
47
66
  def self.with_end(name, type = 0)
48
67
  return nil if name.nil? || name.empty?
49
68
 
69
+ return name.gsub(/^(#{COMPLEX_TYPE[type][:head]})/, '').strip if type.zero? || type == 4
70
+
50
71
  name.gsub(/^(#{COMPLEX_TYPE[type]})/, '').strip
51
72
  end
52
73
 
@@ -55,29 +76,18 @@ module Syamei
55
76
  return nil if name.nil? || name.empty?
56
77
 
57
78
  name = with_beginning(name, type)
58
- name = with_end(name, type)
59
- name
79
+ with_end(name, type)
60
80
  end
61
81
 
62
- # 前株と後株の置換
63
- # def self.replace_begin_to_end(name, type=0)
64
- # # notation
65
- # # 前株消す
66
- # # 後株に付与
67
- # end
82
+ def self.notation(name, type = 0)
83
+ return nil if name.nil? || name.empty?
68
84
 
69
- # 後株と前株の置換
70
- # def self.replace_end_to_begin(name, type=0)
71
- # # notation
72
- # # 後株消す
73
- # # 前株に付与
74
- # end
85
+ return name[/(#{COMPLEX_TYPE[type][:all]})/, 1] if type.zero? || type == 4
75
86
 
76
- def self.notation(name, type = 0)
77
87
  name[/(#{COMPLEX_TYPE[type]})/, 1]
78
88
  end
79
89
 
80
90
  def self.list
81
- COMPLEX_TYPE[0].gsub('|', ' ').gsub('\\', '')
91
+ COMPLEX_TYPE[0][:all].gsub('|', ' ').gsub('\\', '')
82
92
  end
83
93
  end
@@ -1,3 +1,3 @@
1
1
  module Syamei
2
- VERSION = "0.1.0"
2
+ VERSION = '0.2.0'.freeze
3
3
  end
data/syamei.gemspec CHANGED
@@ -1,40 +1,44 @@
1
-
2
- lib = File.expand_path("../lib", __FILE__)
1
+ lib = File.expand_path('lib', __dir__)
3
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require "syamei/version"
3
+ require 'syamei/version'
5
4
 
6
5
  Gem::Specification.new do |spec|
7
- spec.name = "syamei"
6
+ spec.name = 'syamei'
8
7
  spec.version = Syamei::VERSION
9
- spec.authors = ["Shuhei Yamashita"]
10
- spec.email = ["y.shuhei0501@gmail.com"]
8
+ spec.authors = ['Shuhei Yamashita']
9
+ spec.email = ['y.shuhei0501@gmail.com']
11
10
 
12
- spec.summary = %q{Cut company name notation.}
13
- spec.description = %q{Cut company name notation.}
14
- spec.homepage = "https://github.com/yposi/syamei"
15
- spec.license = "MIT"
11
+ spec.summary = 'Cut company name notation.'
12
+ spec.description = 'Cut company name notation.'
13
+ spec.homepage = 'https://github.com/yposi/syamei'
14
+ spec.license = 'MIT'
16
15
 
17
16
  # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
17
  # to allow pushing to a single host or delete this section to allow pushing to any host.
19
18
  if spec.respond_to?(:metadata)
20
- spec.metadata["homepage_uri"] = spec.homepage
21
- spec.metadata["source_code_uri"] = "https://github.com/yposi/syamei"
22
- spec.metadata["changelog_uri"] = "https://github.com/yposi/syamei"
19
+ spec.metadata['homepage_uri'] = spec.homepage
20
+ spec.metadata['source_code_uri'] = 'https://github.com/yposi/syamei'
21
+ spec.metadata['changelog_uri'] = 'https://github.com/yposi/syamei'
23
22
  else
24
- raise "RubyGems 2.0 or newer is required to protect against " \
25
- "public gem pushes."
23
+ raise 'RubyGems 2.0 or newer is required to protect against ' \
24
+ 'public gem pushes.'
26
25
  end
27
26
 
28
27
  # Specify which files should be added to the gem when it is released.
29
28
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
30
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
29
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
31
30
  `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
32
31
  end
33
- spec.bindir = "exe"
32
+ spec.bindir = 'exe'
34
33
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
35
- spec.require_paths = ["lib"]
34
+ spec.require_paths = ['lib']
35
+ spec.required_ruby_version = '>= 2.7'
36
36
 
37
- spec.add_development_dependency "bundler", "~> 1.17"
38
- spec.add_development_dependency "rake", "~> 10.0"
39
- spec.add_development_dependency "rspec", "~> 3.0"
37
+ spec.add_development_dependency 'bundler', '~> 2.2'
38
+ spec.add_development_dependency 'rake', '>= 12.3.3'
39
+ spec.add_development_dependency 'rspec'
40
+ spec.add_development_dependency 'rspec_junit_formatter'
41
+ spec.add_development_dependency 'rubocop'
42
+ spec.add_development_dependency 'rubocop-rspec'
43
+ spec.add_development_dependency 'simplecov'
40
44
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: syamei
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shuhei Yamashita
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-07-16 00:00:00.000000000 Z
11
+ date: 2021-05-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -16,42 +16,98 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.17'
19
+ version: '2.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.17'
26
+ version: '2.2'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '10.0'
33
+ version: 12.3.3
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '10.0'
40
+ version: 12.3.3
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: '3.0'
47
+ version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: '3.0'
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec_junit_formatter
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubocop
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rubocop-rspec
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: simplecov
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
55
111
  description: Cut company name notation.
56
112
  email:
57
113
  - y.shuhei0501@gmail.com
@@ -59,19 +115,17 @@ executables: []
59
115
  extensions: []
60
116
  extra_rdoc_files: []
61
117
  files:
118
+ - ".circleci/config.yml"
119
+ - ".github/dependabot.yml"
62
120
  - ".gitignore"
63
- - ".idea/.gitignore"
64
- - ".idea/inspectionProfiles/Project_Default.xml"
65
- - ".idea/misc.xml"
66
- - ".idea/modules.xml"
67
- - ".idea/syamei.iml"
68
- - ".idea/vcs.xml"
69
121
  - ".rakeTasks"
70
122
  - ".rspec"
123
+ - ".rubocop.yml"
71
124
  - ".ruby-version"
72
125
  - ".travis.yml"
73
126
  - CODE_OF_CONDUCT.md
74
127
  - Gemfile
128
+ - Gemfile.lock
75
129
  - LICENSE.txt
76
130
  - README.md
77
131
  - Rakefile
@@ -96,14 +150,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
96
150
  requirements:
97
151
  - - ">="
98
152
  - !ruby/object:Gem::Version
99
- version: '0'
153
+ version: '2.7'
100
154
  required_rubygems_version: !ruby/object:Gem::Requirement
101
155
  requirements:
102
156
  - - ">="
103
157
  - !ruby/object:Gem::Version
104
158
  version: '0'
105
159
  requirements: []
106
- rubygems_version: 3.0.3
160
+ rubygems_version: 3.1.6
107
161
  signing_key:
108
162
  specification_version: 4
109
163
  summary: Cut company name notation.