munemo 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE.txt +21 -0
- data/README.md +67 -0
- data/lib/munemo.rb +102 -0
- data/munemo.gemspec +37 -0
- metadata +64 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 58544bdcc0e4133c7bd3108cda59b8b77140eb82
|
4
|
+
data.tar.gz: 0b8c204f2da2f15029eb548e21ee3ba71eee3e5d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: afad3fd77bd35e9668cf8076ede605400d00a1ea77191735d838d6d8fa4dc6d7c7c961b24187863ae2efea542216d86c4cb42a11a789dbc56888c2446d756d76
|
7
|
+
data.tar.gz: 40723aa89e387b9742053b52db30af48c85a847baf20cf7037f6f267d979936d9d54c57c9cfe1006da1e913196869015522a93209269b3372d84b35dfa8f9788
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
|
2
|
+
Copyright (c) 2015-2015, John Mettraux, jmettraux@gmail.com
|
3
|
+
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
of this software and associated documentation files (the "Software"), to deal
|
6
|
+
in the Software without restriction, including without limitation the rights
|
7
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
copies of the Software, and to permit persons to whom the Software is
|
9
|
+
furnished to do so, subject to the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be included in
|
12
|
+
all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
20
|
+
THE SOFTWARE.
|
21
|
+
|
data/README.md
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
|
2
|
+
# munemo
|
3
|
+
|
4
|
+
A port of [mnemo](https://github.com/flon-io/mnemo) from C to Ruby. Mnemo and munemo are reworked versions of [rufus-mnemo](https://github.com/jmettraux/rufus-mnemo).
|
5
|
+
|
6
|
+
Munemo uses the following syllables to map integer numbers to strings.
|
7
|
+
```ruby
|
8
|
+
SYLS = %w[
|
9
|
+
ba bi bu be bo
|
10
|
+
cha chi chu che cho
|
11
|
+
da di du de do
|
12
|
+
fa fi fu fe fo
|
13
|
+
ga gi gu ge go
|
14
|
+
ha hi hu he ho
|
15
|
+
ja ji ju je jo
|
16
|
+
ka ki ku ke ko
|
17
|
+
la li lu le lo
|
18
|
+
ma mi mu me mo
|
19
|
+
na ni nu ne no
|
20
|
+
pa pi pu pe po
|
21
|
+
ra ri ru re ro
|
22
|
+
sa si su se so
|
23
|
+
sha shi shu she sho
|
24
|
+
ta ti tu te to
|
25
|
+
tsa tsi tsu tse tso
|
26
|
+
wa wi wu we wo
|
27
|
+
ya yi yu ye yo
|
28
|
+
za zi zu ze zo
|
29
|
+
]
|
30
|
+
```
|
31
|
+
The syllable `xa` prefixes negative numbers.
|
32
|
+
|
33
|
+
Interface:
|
34
|
+
```ruby
|
35
|
+
# Munemo.to_s(i)
|
36
|
+
|
37
|
+
Munemo.to_s(0) # => 'ba'
|
38
|
+
Munemo.to_s(1) # => 'bi'
|
39
|
+
Munemo.to_s(99) # => 'zo'
|
40
|
+
Munemo.to_s(100) # => 'biba'
|
41
|
+
Munemo.to_s(101) # => 'bibi'
|
42
|
+
Munemo.to_s(392406) # => 'kogochi'
|
43
|
+
Munemo.to_s(25437225) # => 'haleshuha'
|
44
|
+
|
45
|
+
Munemo.to_s(-1) # => 'xabi'
|
46
|
+
Munemo.to_s(-99) # => 'xazo'
|
47
|
+
Munemo.to_s(-100) # => 'xabiba'
|
48
|
+
|
49
|
+
|
50
|
+
# Munemo.to_i(s)
|
51
|
+
|
52
|
+
Munemo.to_i('blah blah blah')
|
53
|
+
# => ArgumentError: "unknown syllable 'bl'"
|
54
|
+
|
55
|
+
Munemo.to_i('xabixabi')
|
56
|
+
# => ArgumentError: "unknown syllable 'xa'"
|
57
|
+
|
58
|
+
Munemo.to_i('yoshida') # => 947110
|
59
|
+
Munemo.to_i('bajo') # => 34
|
60
|
+
Munemo.to_i('xabaji') # => -31
|
61
|
+
Munemo.to_i('tonukatsu') # => 79523582
|
62
|
+
```
|
63
|
+
|
64
|
+
## LICENSE
|
65
|
+
|
66
|
+
MIT, see [LICENSE.txt](LICENSE.txt)
|
67
|
+
|
data/lib/munemo.rb
ADDED
@@ -0,0 +1,102 @@
|
|
1
|
+
|
2
|
+
#--
|
3
|
+
# Copyright (c) 2015-2015, John Mettraux, jmettraux@gmail.com
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
# of this software and associated documentation files (the "Software"), to deal
|
7
|
+
# in the Software without restriction, including without limitation the rights
|
8
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
# copies of the Software, and to permit persons to whom the Software is
|
10
|
+
# furnished to do so, subject to the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be included in
|
13
|
+
# all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
# THE SOFTWARE.
|
22
|
+
#
|
23
|
+
# Made in Japan.
|
24
|
+
#++
|
25
|
+
|
26
|
+
|
27
|
+
module Munemo
|
28
|
+
|
29
|
+
VERSION = '1.0.0'
|
30
|
+
|
31
|
+
SYLS = %w[
|
32
|
+
ba bi bu be bo
|
33
|
+
cha chi chu che cho
|
34
|
+
da di du de do
|
35
|
+
fa fi fu fe fo
|
36
|
+
ga gi gu ge go
|
37
|
+
ha hi hu he ho
|
38
|
+
ja ji ju je jo
|
39
|
+
ka ki ku ke ko
|
40
|
+
la li lu le lo
|
41
|
+
ma mi mu me mo
|
42
|
+
na ni nu ne no
|
43
|
+
pa pi pu pe po
|
44
|
+
ra ri ru re ro
|
45
|
+
sa si su se so
|
46
|
+
sha shi shu she sho
|
47
|
+
ta ti tu te to
|
48
|
+
tsa tsi tsu tse tso
|
49
|
+
wa wi wu we wo
|
50
|
+
ya yi yu ye yo
|
51
|
+
za zi zu ze zo
|
52
|
+
]
|
53
|
+
SYL_COUNT = SYLS.count
|
54
|
+
NEG = 'xa'
|
55
|
+
|
56
|
+
|
57
|
+
def self.tos(i, sio)
|
58
|
+
|
59
|
+
mod = i % SYL_COUNT
|
60
|
+
rst = i / SYL_COUNT
|
61
|
+
|
62
|
+
tos(rst, sio) if rst > 0
|
63
|
+
|
64
|
+
sio.print(SYLS[mod])
|
65
|
+
end
|
66
|
+
|
67
|
+
def self.to_s(i)
|
68
|
+
|
69
|
+
sio = StringIO.new
|
70
|
+
|
71
|
+
if i < 0
|
72
|
+
sio.print(NEG)
|
73
|
+
i = -i
|
74
|
+
end
|
75
|
+
|
76
|
+
tos(i, sio)
|
77
|
+
|
78
|
+
sio.string
|
79
|
+
end
|
80
|
+
|
81
|
+
def self.to_i(s)
|
82
|
+
|
83
|
+
sign = 1
|
84
|
+
result = 0
|
85
|
+
|
86
|
+
if s[0, 2] == NEG
|
87
|
+
sign = -1
|
88
|
+
s = s[2..-1]
|
89
|
+
end
|
90
|
+
|
91
|
+
loop do
|
92
|
+
break if s.length < 1
|
93
|
+
i = SYLS.index(s[0, 2]) || SYLS.index(s[0, 3])
|
94
|
+
fail ArgumentError.new("unknown syllable '#{s[0, 2]}'") unless i
|
95
|
+
result = SYL_COUNT * result + i
|
96
|
+
s = s[SYLS[i].length..-1]
|
97
|
+
end
|
98
|
+
|
99
|
+
sign * result
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
data/munemo.gemspec
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
|
2
|
+
Gem::Specification.new do |s|
|
3
|
+
|
4
|
+
s.name = 'munemo'
|
5
|
+
|
6
|
+
s.version = File.read(
|
7
|
+
File.expand_path('../lib/munemo.rb', __FILE__)
|
8
|
+
).match(/ VERSION *= *['"]([^'"]+)/)[1]
|
9
|
+
|
10
|
+
s.platform = Gem::Platform::RUBY
|
11
|
+
s.authors = [ 'John Mettraux' ]
|
12
|
+
s.email = [ 'jmettraux@gmail.com' ]
|
13
|
+
s.homepage = 'http://github.com/jmettraux/munemo'
|
14
|
+
s.rubyforge_project = 'rufus'
|
15
|
+
s.license = 'MIT'
|
16
|
+
s.summary = 'turns integer into somewhat japanese sounding strings'
|
17
|
+
|
18
|
+
s.description = %{
|
19
|
+
Turns integer into somewhat japanese sounding strings.
|
20
|
+
A successor to rufus-mnemo.
|
21
|
+
}.strip
|
22
|
+
|
23
|
+
#s.files = `git ls-files`.split("\n")
|
24
|
+
s.files = Dir[
|
25
|
+
'Rakefile',
|
26
|
+
'lib/**/*.rb', #'spec/**/*.rb', 'test/**/*.rb',
|
27
|
+
'*.gemspec', '*.txt', '*.rdoc', '*.md'
|
28
|
+
]
|
29
|
+
|
30
|
+
#s.add_runtime_dependency 'tzinfo'
|
31
|
+
|
32
|
+
#s.add_development_dependency 'rake'
|
33
|
+
s.add_development_dependency 'rspec', '>= 2.13.0'
|
34
|
+
|
35
|
+
s.require_path = 'lib'
|
36
|
+
end
|
37
|
+
|
metadata
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: munemo
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- John Mettraux
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-12-30 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rspec
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 2.13.0
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 2.13.0
|
27
|
+
description: |-
|
28
|
+
Turns integer into somewhat japanese sounding strings.
|
29
|
+
A successor to rufus-mnemo.
|
30
|
+
email:
|
31
|
+
- jmettraux@gmail.com
|
32
|
+
executables: []
|
33
|
+
extensions: []
|
34
|
+
extra_rdoc_files: []
|
35
|
+
files:
|
36
|
+
- lib/munemo.rb
|
37
|
+
- munemo.gemspec
|
38
|
+
- LICENSE.txt
|
39
|
+
- README.md
|
40
|
+
homepage: http://github.com/jmettraux/munemo
|
41
|
+
licenses:
|
42
|
+
- MIT
|
43
|
+
metadata: {}
|
44
|
+
post_install_message:
|
45
|
+
rdoc_options: []
|
46
|
+
require_paths:
|
47
|
+
- lib
|
48
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - '>='
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '0'
|
53
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - '>='
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: '0'
|
58
|
+
requirements: []
|
59
|
+
rubyforge_project: rufus
|
60
|
+
rubygems_version: 2.0.14
|
61
|
+
signing_key:
|
62
|
+
specification_version: 4
|
63
|
+
summary: turns integer into somewhat japanese sounding strings
|
64
|
+
test_files: []
|