okao 0.1.0 → 0.1.1
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 +4 -4
- data/.gitignore +3 -3
- data/lib/okao.rb +1 -1
- data/lib/okao/cli.rb +12 -12
- data/lib/okao/emoticon.rb +24 -0
- data/lib/okao/parser.rb +4 -4
- data/lib/okao/version.rb +1 -1
- metadata +2 -3
- data/.ruby-version +0 -1
- data/Gemfile.lock +0 -50
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 17d8c5d875e25130465a8df21860fe05e4152010
|
4
|
+
data.tar.gz: 6926a690f5543aaa0889f9c1a93e114c674644f4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1495fb9a57dbbdcba7ab621797d409228e6e8118d0257c77a21d638f64430aa7079eaa910267f7671442da5a1658771c31feaf85f6381bbb8082d6af2bcc950c
|
7
|
+
data.tar.gz: 49be882abac61519a60b95ceb5d2b3fba77da475fc972bbb6c150127248267e4bfd62082d5a6863a8f7d6f95ea1394cc13c5bc432b4459e268ae6713b9e99c24
|
data/.gitignore
CHANGED
@@ -45,9 +45,9 @@ build-iPhoneSimulator/
|
|
45
45
|
|
46
46
|
# for a library or gem, you might want to ignore these files since the code is
|
47
47
|
# intended to run in multiple environments; otherwise, check them in:
|
48
|
-
|
49
|
-
|
50
|
-
|
48
|
+
Gemfile.lock
|
49
|
+
.ruby-version
|
50
|
+
.ruby-gemset
|
51
51
|
|
52
52
|
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
53
53
|
.rvmrc
|
data/lib/okao.rb
CHANGED
data/lib/okao/cli.rb
CHANGED
@@ -5,32 +5,32 @@ module Okao
|
|
5
5
|
class CLI < Thor
|
6
6
|
OKAOS = ['(^-^)', '(´O`)', '(;-;)', '(´Д`)', '(。-_-。)', '(´・ω・`)', '(-_-;)', '(_ _)']
|
7
7
|
|
8
|
-
desc 'to_okao [text][--file_path file_path]', 'Convert
|
8
|
+
desc 'to_okao [text][--file_path file_path]', 'Convert normal text to okao text'
|
9
9
|
option :file_path
|
10
10
|
def to_okao(text = nil)
|
11
|
-
|
12
|
-
|
13
|
-
|
11
|
+
init_emoticon
|
12
|
+
normal_text = load_file(options[:file_path])
|
13
|
+
normal_text ||= text
|
14
14
|
|
15
|
-
okao_text = Okao::Parser.to_okao(
|
15
|
+
okao_text = Okao::Parser.to_okao(normal_text)
|
16
16
|
puts okao_text
|
17
17
|
end
|
18
18
|
|
19
|
-
desc 'to_text [okao][--file_path file_path]', 'Convert okao text to
|
19
|
+
desc 'to_text [okao][--file_path file_path]', 'Convert okao text to normal text'
|
20
20
|
option :file_path
|
21
21
|
def to_text(okao = nil)
|
22
|
-
|
22
|
+
init_emoticon
|
23
23
|
okao_text = load_file(options[:file_path])
|
24
24
|
okao_text ||= okao
|
25
25
|
|
26
|
-
|
27
|
-
puts
|
26
|
+
normal_text = Okao::Parser.to_text(okao_text)
|
27
|
+
puts normal_text
|
28
28
|
end
|
29
29
|
|
30
30
|
desc 'exec [okao][--file_path file_path]', 'Execute okao script'
|
31
31
|
option :file_path
|
32
32
|
def exec(okao = nil)
|
33
|
-
|
33
|
+
init_emoticon
|
34
34
|
okao_text = load_file(options[:file_path])
|
35
35
|
okao_text ||= okao
|
36
36
|
|
@@ -42,8 +42,8 @@ module Okao
|
|
42
42
|
end
|
43
43
|
|
44
44
|
no_commands do
|
45
|
-
def
|
46
|
-
Okao::
|
45
|
+
def init_emoticon
|
46
|
+
Okao::Emoticon.init(okaos)
|
47
47
|
end
|
48
48
|
|
49
49
|
def okaos
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Okao
|
2
|
+
class Emoticon
|
3
|
+
class << self
|
4
|
+
def init(okaos)
|
5
|
+
okaos.each_with_index do |face, index|
|
6
|
+
var_name = "@face#{index}"
|
7
|
+
instance_variable_set(var_name, face)
|
8
|
+
|
9
|
+
define_singleton_method(var_name[1..-1]) do
|
10
|
+
instance_variable_get(var_name)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def to_h
|
16
|
+
instance_variables.reduce({}) do |acc, cur|
|
17
|
+
var_name = cur.to_s[1..-1]
|
18
|
+
hash = { var_name.to_sym => self.send(var_name) }
|
19
|
+
acc.merge(hash)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/lib/okao/parser.rb
CHANGED
@@ -7,7 +7,7 @@ module Okao
|
|
7
7
|
points = cur.codepoints.map { |c| c.to_s(8).to_i }
|
8
8
|
okaos = points.map do |point|
|
9
9
|
face_list = format('%06d', point.to_s).split('').map do |i|
|
10
|
-
Okao::
|
10
|
+
Okao::Emoticon.send("face#{i}")
|
11
11
|
end
|
12
12
|
|
13
13
|
face_list.join
|
@@ -18,17 +18,17 @@ module Okao
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def to_text(okao_line)
|
21
|
-
okao_hash = Okao::
|
21
|
+
okao_hash = Okao::Emoticon.to_h.invert
|
22
22
|
numbers = okao_line.gsub(/\(.*?\)/) do |m|
|
23
23
|
var_name = okao_hash[m]
|
24
24
|
var_name.slice(/\d/)
|
25
25
|
end
|
26
26
|
|
27
|
-
|
27
|
+
normal_text = numbers.gsub(/\d{6}/) do |n|
|
28
28
|
n.to_i(8).chr('UTF-8')
|
29
29
|
end
|
30
30
|
|
31
|
-
"#{
|
31
|
+
"#{normal_text}\n"
|
32
32
|
end
|
33
33
|
end
|
34
34
|
end
|
data/lib/okao/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: okao
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ta-chibana
|
@@ -104,11 +104,9 @@ extra_rdoc_files: []
|
|
104
104
|
files:
|
105
105
|
- ".gitignore"
|
106
106
|
- ".rspec"
|
107
|
-
- ".ruby-version"
|
108
107
|
- ".travis.yml"
|
109
108
|
- CODE_OF_CONDUCT.md
|
110
109
|
- Gemfile
|
111
|
-
- Gemfile.lock
|
112
110
|
- Guardfile
|
113
111
|
- LICENSE.txt
|
114
112
|
- README.md
|
@@ -118,6 +116,7 @@ files:
|
|
118
116
|
- exe/okao
|
119
117
|
- lib/okao.rb
|
120
118
|
- lib/okao/cli.rb
|
119
|
+
- lib/okao/emoticon.rb
|
121
120
|
- lib/okao/face.rb
|
122
121
|
- lib/okao/parser.rb
|
123
122
|
- lib/okao/version.rb
|
data/.ruby-version
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
2.3.1
|
data/Gemfile.lock
DELETED
@@ -1,50 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
okao (0.1.0)
|
5
|
-
thor (~> 0.19.1)
|
6
|
-
|
7
|
-
GEM
|
8
|
-
remote: https://rubygems.org/
|
9
|
-
specs:
|
10
|
-
byebug (9.0.5)
|
11
|
-
coderay (1.1.1)
|
12
|
-
diff-lcs (1.2.5)
|
13
|
-
method_source (0.8.2)
|
14
|
-
pry (0.10.3)
|
15
|
-
coderay (~> 1.1.0)
|
16
|
-
method_source (~> 0.8.1)
|
17
|
-
slop (~> 3.4)
|
18
|
-
pry-byebug (3.4.0)
|
19
|
-
byebug (~> 9.0)
|
20
|
-
pry (~> 0.10)
|
21
|
-
rake (10.5.0)
|
22
|
-
rspec (3.4.0)
|
23
|
-
rspec-core (~> 3.4.0)
|
24
|
-
rspec-expectations (~> 3.4.0)
|
25
|
-
rspec-mocks (~> 3.4.0)
|
26
|
-
rspec-core (3.4.4)
|
27
|
-
rspec-support (~> 3.4.0)
|
28
|
-
rspec-expectations (3.4.0)
|
29
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
30
|
-
rspec-support (~> 3.4.0)
|
31
|
-
rspec-mocks (3.4.1)
|
32
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
33
|
-
rspec-support (~> 3.4.0)
|
34
|
-
rspec-support (3.4.1)
|
35
|
-
slop (3.6.0)
|
36
|
-
thor (0.19.1)
|
37
|
-
|
38
|
-
PLATFORMS
|
39
|
-
ruby
|
40
|
-
|
41
|
-
DEPENDENCIES
|
42
|
-
bundler (~> 1.12)
|
43
|
-
okao!
|
44
|
-
pry
|
45
|
-
pry-byebug
|
46
|
-
rake (~> 10.0)
|
47
|
-
rspec (~> 3.0)
|
48
|
-
|
49
|
-
BUNDLED WITH
|
50
|
-
1.12.5
|