al_bhed 0.1.2 → 0.1.3

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: d245f88436e0c19ae6ae174ed3c4243821d803254dfb08c7c31ab66fefa148ae
4
- data.tar.gz: 5c3ee151f9b0dce5c2e538a8c25169ebd325f70f9aef2af1c9b87870cd6384a3
3
+ metadata.gz: cc05c3d88e54272c6049301bd8e60f02248e8becfb71772c641eec37ffcbd87b
4
+ data.tar.gz: e9bf5912ed5ac14521ea3fe955d9c78760f4a148c4f588690292fb7167060a3b
5
5
  SHA512:
6
- metadata.gz: 6e35f1be5c6e3e36e810f915f19e14f141091075e208b2df6baf6fcefd9cebcf92c0b9d50589e694e13008bf972856b114e1347d1ac5347f710595d2cd5ac1fb
7
- data.tar.gz: 4e3ed4acdea159f90dc9bb80e7a93ea571cf5042caa855b5fb82a8d456503fa11e10f00ac2d2f3c8fc7bba8aa93c8a9593de52028a9c695ca072e5f6ceb98c1a
6
+ metadata.gz: 71ae206b57bbb3cead5b4e6439b82d4051a062b94648bbe868b505c2f409eae309982e05347b2200b888b1c3a732b04436a11f5f61c1925defadc81cd0ef8791
7
+ data.tar.gz: e3e0a25b88e93ea602c43e358b3bfa256006f99bfb4713aeeaf56ebdb39bd0b04e94568734f05bc8fa4052a2ee342511e914a6acec293d876962609e43b152e3
@@ -0,0 +1,32 @@
1
+ # This workflow uses actions that are not certified by GitHub.
2
+ # They are provided by a third-party and are governed by
3
+ # separate terms of service, privacy policy, and support
4
+ # documentation.
5
+ # This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
6
+ # For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
7
+
8
+ name: Ruby
9
+
10
+ on:
11
+ push:
12
+ branches: [ master ]
13
+ pull_request:
14
+ branches: [ master ]
15
+
16
+ jobs:
17
+ test:
18
+
19
+ runs-on: ubuntu-latest
20
+
21
+ steps:
22
+ - uses: actions/checkout@v2
23
+ - name: Set up Ruby
24
+ uses: ruby/setup-ruby@v1
25
+ with:
26
+ ruby-version: 2.7
27
+ - name: Install dependencies
28
+ run: bundle install
29
+ - name: Run Rubocop
30
+ run: bundle exec rubocop lib
31
+ - name: Run tests
32
+ run: bundle exec rake spec
@@ -0,0 +1,5 @@
1
+ Layout/LineLength:
2
+ Max: 130
3
+
4
+ Style/StringLiterals:
5
+ EnforcedStyle: double_quotes
@@ -1,3 +1,7 @@
1
+ # v0.1.3
2
+ - add Rubocop and correct code
3
+ - add GitHub Actions as CI
4
+
1
5
  # v0.1.2
2
6
  - add `String#from_albhed` method
3
7
  - enabled to translate Japanese
data/Gemfile CHANGED
@@ -5,3 +5,4 @@ gemspec
5
5
 
6
6
  gem "rake", "~> 12.0"
7
7
  gem "rspec", "~> 3.0"
8
+ gem "rubocop", "~> 0.85.1", require: false
data/README.md CHANGED
@@ -1,3 +1,4 @@
1
+ ![](https://github.com/HrsUed/al_bhed/workflows/Ruby/badge.svg)
1
2
  # YmPrat
2
3
 
3
4
  Dnyhcmydun vun Ym Prat myhkiyka eh VEHYM VYHDYCO Q
@@ -1,101 +1,97 @@
1
+ # frozen_string_literal: false
2
+
1
3
  require "al_bhed/version"
2
4
 
5
+ # This is a namespace so as to open up for a built-in String class
3
6
  module AlBhed
4
7
  class Error < StandardError; end
5
8
 
6
- UPCASES = %w( A B C D E F G H I J K L M N O P Q R S T U V W X Y Z )
7
- UPCASED_ALBHEDS = %w( Y P L T A V K R E Z G M S H U B X N C D I J F Q O W )
8
- DOWNCASES = %w( a b c d e f g h i j k l m n o p q r s t u v w x y z )
9
- DOWNCASED_ALBHEDS = %w( y p l t a v k r e z g m s h u b x n c d i j f q o w )
9
+ UPCASES = %w[A B C D E F G H I J K L M N O P Q R S T U V W X Y Z].freeze
10
+ UPCASED_ALBHEDS = %w[Y P L T A V K R E Z G M S H U B X N C D I J F Q O W].freeze
11
+ DOWNCASES = %w[a b c d e f g h i j k l m n o p q r s t u v w x y z].freeze
12
+ DOWNCASED_ALBHEDS = %w[y p l t a v k r e z g m s h u b x n c d i j f q o w].freeze
10
13
 
11
- HIRA_KANA = %w( あ い う え お か き く け こ さ し す せ そ た ち つ て と な に ぬ ね の は ひ ふ へ ほ ま み む め も や ゆ よ ら り る れ ろ わ を ん )
12
- KATA_KANA = %w( ア イ ウ エ オ カ キ ク ケ コ サ シ ス セ ソ タ チ ツ テ ト ナ ニ ヌ ネ ノ ハ ヒ フ ヘ ホ マ ミ ム メ モ ヤ ユ ヨ ラ リ ル レ ロ ワ ヲ ン )
13
- HIRA_DAKUON = %w( が ぎ ぐ げ ご ざ じ ず ぜ ぞ だ ぢ づ で ど ば び ぶ べ ぼ ぱ ぴ ぷ ぺ ぽ )
14
- KATA_DAKUON = %w( ガ ギ グ ゲ ゴ ザ ジ ズ ゼ ゾ ダ ヂ ヅ デ ド バ ビ ブ ベ ボ パ ピ プ ペ ポ )
15
- KANA_ALBHEDS = %w( ワ ミ フ ネ ト ア チ ル テ ヨ ラ キ ヌ ヘ ホ サ ヒ ユ セ ソ ハ シ ス メ オ マ リ ク ケ ロ ヤ イ ツ レ コ タ ヲ モ ナ ニ ウ エ ノ カ ム ン )
16
- DAKUON_ALBHEDS = %w( ダ ジ ヅ デ ゾ バ ギ ブ ゲ ボ ガ ビ グ ベ ゴ ザ ヂ ズ ゼ ド プ ペ パ ポ ピ )
14
+ HIRA_KANA = %w[あ い う え お か き く け こ さ し す せ そ た ち つ て と な に ぬ ね の は ひ ふ へ ほ ま み む め も や ゆ よ ら り る れ ろ わ を ん].freeze
15
+ KATA_KANA = %w[ア イ ウ エ オ カ キ ク ケ コ サ シ ス セ ソ タ チ ツ テ ト ナ ニ ヌ ネ ノ ハ ヒ フ ヘ ホ マ ミ ム メ モ ヤ ユ ヨ ラ リ ル レ ロ ワ ヲ ン].freeze
16
+ HIRA_DAKUON = %w[が ぎ ぐ げ ご ざ じ ず ぜ ぞ だ ぢ づ で ど ば び ぶ べ ぼ ぱ ぴ ぷ ぺ ぽ].freeze
17
+ KATA_DAKUON = %w[ガ ギ グ ゲ ゴ ザ ジ ズ ゼ ゾ ダ ヂ ヅ デ ド バ ビ ブ ベ ボ パ ピ プ ペ ポ].freeze
18
+ KANA_ALBHEDS = %w[ワ ミ フ ネ ト ア チ ル テ ヨ ラ キ ヌ ヘ ホ サ ヒ ユ セ ソ ハ シ ス メ オ マ リ ク ケ ロ ヤ イ ツ レ コ タ ヲ モ ナ ニ ウ エ ノ カ ム ン].freeze
19
+ DAKUON_ALBHEDS = %w[ダ ジ ヅ デ ゾ バ ギ ブ ゲ ボ ガ ビ グ ベ ゴ ザ ヂ ズ ゼ ド プ ペ パ ポ ピ].freeze
20
+ end
17
21
 
18
- class ::String
19
- # Translate into Al Bhed
20
- #
21
- # Example:
22
- # >> "Hi!".to_albhed
23
- # => "Re!"
24
- #
25
- # Arguments:
26
- # nothing
27
- def to_albhed
28
- self.chars.inject("") do |results, c|
29
- if latin?(c)
30
- results << from_english_to_albhed(c)
31
- else
32
- results << from_japanese_to_albhed(c)
33
- end
34
- end
22
+ # a built-in String class
23
+ class String
24
+ # Translate into Al Bhed
25
+ #
26
+ # Example:
27
+ # >> "Hi!".to_albhed
28
+ # => "Re!"
29
+ #
30
+ # Arguments:
31
+ # nothing
32
+ def to_albhed
33
+ chars.inject("") do |results, c|
34
+ results << (latin?(c) ? from_english_to_albhed(c) : from_japanese_to_albhed(c))
35
35
  end
36
+ end
36
37
 
37
- # Translate Al Bhed into English
38
- #
39
- # Example:
40
- # >> "Re!".from_albhed
41
- # => "Hi!"
42
- #
43
- # Arguments:
44
- # hira: (Boolean)
45
- def from_albhed(hira: false)
46
- self.chars.inject("") do |results, c|
47
- if latin?(c)
48
- results << from_albhed_to_english(c)
49
- else
50
- results << from_albhed_to_japanese(c, hira: hira)
51
- end
52
- end
38
+ # Translate Al Bhed into English
39
+ #
40
+ # Example:
41
+ # >> "Re!".from_albhed
42
+ # => "Hi!"
43
+ #
44
+ # Arguments:
45
+ # hira: (Boolean)
46
+ def from_albhed(hira: false)
47
+ chars.inject("") do |results, c|
48
+ results << (latin?(c) ? from_albhed_to_english(c) : from_albhed_to_japanese(c, hira: hira))
53
49
  end
50
+ end
54
51
 
55
- private
52
+ private
56
53
 
57
- def latin?(c)
58
- ("a" .. "z").include?(c) || ("A" .. "Z").include?(c)
59
- end
54
+ def latin?(char)
55
+ ("a".."z").include?(char) || ("A".."Z").include?(char)
56
+ end
60
57
 
61
- def from_english_to_albhed(c)
62
- if idx = DOWNCASES.index(c)
63
- DOWNCASED_ALBHEDS[idx]
64
- elsif idx = UPCASES.index(c)
65
- UPCASED_ALBHEDS[idx]
66
- else
67
- c
68
- end
58
+ def from_english_to_albhed(char)
59
+ if (idx = AlBhed::DOWNCASES.index(char))
60
+ AlBhed::DOWNCASED_ALBHEDS[idx]
61
+ elsif (idx = AlBhed::UPCASES.index(char))
62
+ AlBhed::UPCASED_ALBHEDS[idx]
63
+ else
64
+ char
69
65
  end
66
+ end
70
67
 
71
- def from_albhed_to_english(c)
72
- if idx = DOWNCASED_ALBHEDS.index(c)
73
- DOWNCASES[idx]
74
- elsif idx = UPCASED_ALBHEDS.index(c)
75
- UPCASES[idx]
76
- else
77
- c
78
- end
68
+ def from_albhed_to_english(char)
69
+ if (idx = AlBhed::DOWNCASED_ALBHEDS.index(char))
70
+ AlBhed::DOWNCASES[idx]
71
+ elsif (idx = AlBhed::UPCASED_ALBHEDS.index(char))
72
+ AlBhed::UPCASES[idx]
73
+ else
74
+ char
79
75
  end
76
+ end
80
77
 
81
- def from_japanese_to_albhed(c)
82
- if idx = HIRA_KANA.index(c) || KATA_KANA.index(c)
83
- KANA_ALBHEDS[idx]
84
- elsif idx = HIRA_DAKUON.index(c) || KATA_DAKUON.index(c)
85
- DAKUON_ALBHEDS[idx]
86
- else
87
- c
88
- end
78
+ def from_japanese_to_albhed(char)
79
+ if (idx = AlBhed::HIRA_KANA.index(char) || AlBhed::KATA_KANA.index(char))
80
+ AlBhed::KANA_ALBHEDS[idx]
81
+ elsif (idx = AlBhed::HIRA_DAKUON.index(char) || AlBhed::KATA_DAKUON.index(char))
82
+ AlBhed::DAKUON_ALBHEDS[idx]
83
+ else
84
+ char
89
85
  end
86
+ end
90
87
 
91
- def from_albhed_to_japanese(c, hira: false)
92
- if idx = KANA_ALBHEDS.index(c)
93
- hira ? HIRA_KANA[idx] : KATA_KANA[idx]
94
- elsif idx = DAKUON_ALBHEDS.index(c)
95
- hira ? HIRA_DAKUON[idx] : KATA_DAKUON[idx]
96
- else
97
- c
98
- end
88
+ def from_albhed_to_japanese(char, hira: false)
89
+ if (idx = AlBhed::KANA_ALBHEDS.index(char))
90
+ hira ? AlBhed::HIRA_KANA[idx] : AlBhed::KATA_KANA[idx]
91
+ elsif (idx = AlBhed::DAKUON_ALBHEDS.index(char))
92
+ hira ? AlBhed::HIRA_DAKUON[idx] : AlBhed::KATA_DAKUON[idx]
93
+ else
94
+ char
99
95
  end
100
96
  end
101
97
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module AlBhed
2
- VERSION = "0.1.2"
4
+ VERSION = "0.1.3"
3
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: al_bhed
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - HrsUed
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-06-01 00:00:00.000000000 Z
11
+ date: 2020-06-08 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Translator for Al Bhed language in FINAL FANTASY X
14
14
  email:
@@ -17,9 +17,10 @@ executables: []
17
17
  extensions: []
18
18
  extra_rdoc_files: []
19
19
  files:
20
+ - ".github/workflows/ruby.yml"
20
21
  - ".gitignore"
21
22
  - ".rspec"
22
- - ".travis.yml"
23
+ - ".rubocop.yml"
23
24
  - CHANGELOG.md
24
25
  - CODE_OF_CONDUCT.md
25
26
  - Gemfile
@@ -1,6 +0,0 @@
1
- ---
2
- language: ruby
3
- cache: bundler
4
- rvm:
5
- - 2.5.1
6
- before_install: gem install bundler -v 2.1.4