rufus-mnemo 1.2.1 → 1.2.2
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.
- data/CHANGELOG.txt +5 -0
- data/{README.txt → README.rdoc} +19 -17
- data/Rakefile +2 -2
- data/lib/rufus/mnemo.rb +15 -8
- data/test/test.rb +25 -4
- metadata +4 -4
data/CHANGELOG.txt
CHANGED
data/{README.txt → README.rdoc}
RENAMED
@@ -8,26 +8,22 @@ The module Rufus::Mnemo has all the explanation.
|
|
8
8
|
|
9
9
|
== getting it
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
or at
|
14
|
-
|
15
|
-
http://rubyforge.org/frs/?group_id=4812
|
11
|
+
gem install rufus-mnemo
|
16
12
|
|
17
13
|
|
18
14
|
== usage
|
19
15
|
|
20
16
|
require 'rubygems'
|
21
17
|
require 'rufus/mnemo'
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
# =>
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
18
|
+
|
19
|
+
p Rufus::Mnemo.from_integer(125704)
|
20
|
+
p Rufus::Mnemo.from_i(125704)
|
21
|
+
p Rufus::Mnemo.to_s(125704)
|
22
|
+
# => "karasu"
|
23
|
+
|
24
|
+
p Rufus::Mnemo.to_integer('karasu')
|
25
|
+
p Rufus::Mnemo.to_i('karasu')
|
26
|
+
p Rufus::Mnemo.from_s('karasu')
|
31
27
|
# => 125704
|
32
28
|
|
33
29
|
|
@@ -35,7 +31,8 @@ http://rubyforge.org/frs/?group_id=4812
|
|
35
31
|
|
36
32
|
They are prefixed with the "wi" syllable (Thanks Stephan Wehner).
|
37
33
|
|
38
|
-
p Rufus::Mnemo
|
34
|
+
p Rufus::Mnemo.from_integer(-173866)
|
35
|
+
p Rufus::Mnemo.to_s(-173866)
|
39
36
|
# => 'winamote'
|
40
37
|
|
41
38
|
|
@@ -51,9 +48,14 @@ On the rufus-ruby list[http://groups.google.com/group/rufus-ruby] :
|
|
51
48
|
http://groups.google.com/group/rufus-ruby
|
52
49
|
|
53
50
|
|
51
|
+
== IRC
|
52
|
+
|
53
|
+
On freenode.net, the #ruote channel
|
54
|
+
|
55
|
+
|
54
56
|
== issue tracker
|
55
57
|
|
56
|
-
|
58
|
+
https://github.com/jmettraux/rufus-mnemo/issues
|
57
59
|
|
58
60
|
|
59
61
|
== source
|
@@ -65,7 +67,7 @@ http://github.com/jmettraux/rufus-mnemo
|
|
65
67
|
|
66
68
|
== author
|
67
69
|
|
68
|
-
John Mettraux, jmettraux@gmail.com
|
70
|
+
John Mettraux, jmettraux@gmail.com
|
69
71
|
http://jmettraux.wordpress.com
|
70
72
|
|
71
73
|
|
data/Rakefile
CHANGED
@@ -58,10 +58,10 @@ end
|
|
58
58
|
|
59
59
|
Rake::RDocTask.new do |rd|
|
60
60
|
|
61
|
-
rd.main = 'README.
|
61
|
+
rd.main = 'README.rdoc'
|
62
62
|
rd.rdoc_dir = "rdoc/#{GEMSPEC.name}"
|
63
63
|
|
64
|
-
rd.rdoc_files.include('README.
|
64
|
+
rd.rdoc_files.include('README.rdoc', 'CHANGELOG.txt', 'lib/**/*.rb')
|
65
65
|
|
66
66
|
rd.title = "#{GEMSPEC.name} #{GEMSPEC.version}"
|
67
67
|
end
|
data/lib/rufus/mnemo.rb
CHANGED
@@ -68,7 +68,7 @@ module Rufus
|
|
68
68
|
#
|
69
69
|
module Mnemo
|
70
70
|
|
71
|
-
VERSION = '1.2.
|
71
|
+
VERSION = '1.2.2'
|
72
72
|
|
73
73
|
SYL = %w[
|
74
74
|
b d g h j k m n p r s t z
|
@@ -95,14 +95,14 @@ module Rufus
|
|
95
95
|
|
96
96
|
return "#{NEG}#{from_integer(-integer)}" if integer < 0
|
97
97
|
|
98
|
-
to_special(
|
98
|
+
to_special(_from_integer(integer))
|
99
99
|
end
|
100
100
|
|
101
101
|
# Turns the given Mnemo word to its equivalent integer.
|
102
102
|
#
|
103
103
|
def self.to_integer(string)
|
104
104
|
|
105
|
-
|
105
|
+
_to_i(from_special(string))
|
106
106
|
end
|
107
107
|
|
108
108
|
# Turns a simple syllable into the equivalent number.
|
@@ -165,7 +165,7 @@ module Rufus
|
|
165
165
|
SPECIAL.inject(s) { |ss, (a, b)| ss.gsub(b, a) }
|
166
166
|
end
|
167
167
|
|
168
|
-
def self.
|
168
|
+
def self._from_integer(integer) # :nodoc:
|
169
169
|
|
170
170
|
return '' if integer == 0
|
171
171
|
|
@@ -179,21 +179,28 @@ module Rufus
|
|
179
179
|
from_i(rest) + SYL[mod]
|
180
180
|
end
|
181
181
|
|
182
|
-
def self.
|
182
|
+
def self._to_i(s) # :nodoc:
|
183
183
|
|
184
184
|
if s.length == 0
|
185
185
|
return 0
|
186
186
|
end
|
187
187
|
|
188
188
|
if m = s.match(NEGATIVE)
|
189
|
-
return -1 *
|
189
|
+
return -1 * _to_i(m[1])
|
190
190
|
end
|
191
191
|
|
192
|
-
SYL.length *
|
192
|
+
SYL.length * _to_i(s[0..-3]) + to_number(s[-2, 2])
|
193
193
|
end
|
194
194
|
|
195
195
|
class << self
|
196
|
-
|
196
|
+
|
197
|
+
alias to_string from_integer
|
198
|
+
alias to_s from_integer
|
199
|
+
alias from_i from_integer
|
200
|
+
|
201
|
+
alias to_i to_integer
|
202
|
+
alias from_string to_integer
|
203
|
+
alias from_s to_integer
|
197
204
|
end
|
198
205
|
end
|
199
206
|
end
|
data/test/test.rb
CHANGED
@@ -91,16 +91,37 @@ class MnemoTest < Test::Unit::TestCase
|
|
91
91
|
|
92
92
|
def test_collision_with_mathn
|
93
93
|
|
94
|
-
assert_equal 'dobejotehozi', Rufus::Mnemo.
|
94
|
+
assert_equal 'dobejotehozi', Rufus::Mnemo._from_integer(13477774722)
|
95
95
|
|
96
96
|
require 'mathn'
|
97
97
|
|
98
|
-
assert_equal 'dobejotehozi', Rufus::Mnemo.
|
98
|
+
assert_equal 'dobejotehozi', Rufus::Mnemo._from_integer(13477774722)
|
99
99
|
end
|
100
100
|
|
101
|
-
def
|
101
|
+
def test_aliases_i_to_s
|
102
102
|
|
103
|
-
assert_equal '
|
103
|
+
assert_equal 'wina', Rufus::Mnemo.from_integer(-35)
|
104
|
+
assert_equal 'wina', Rufus::Mnemo.from_i(-35)
|
105
|
+
assert_equal 'wina', Rufus::Mnemo.to_string(-35)
|
106
|
+
assert_equal 'wina', Rufus::Mnemo.to_s(-35)
|
107
|
+
|
108
|
+
assert_equal 'dobejotehotzu', Rufus::Mnemo.from_integer(13477774722)
|
109
|
+
assert_equal 'dobejotehotzu', Rufus::Mnemo.from_i(13477774722)
|
110
|
+
assert_equal 'dobejotehotzu', Rufus::Mnemo.to_string(13477774722)
|
111
|
+
assert_equal 'dobejotehotzu', Rufus::Mnemo.to_s(13477774722)
|
112
|
+
end
|
113
|
+
|
114
|
+
def test_aliases_s_to_i
|
115
|
+
|
116
|
+
assert_equal -35, Rufus::Mnemo.from_string('wina')
|
117
|
+
assert_equal -35, Rufus::Mnemo.from_s('wina')
|
118
|
+
assert_equal -35, Rufus::Mnemo.to_integer('wina')
|
119
|
+
assert_equal -35, Rufus::Mnemo.to_i('wina')
|
120
|
+
|
121
|
+
assert_equal 13477774722, Rufus::Mnemo.from_string('dobejotehotzu')
|
122
|
+
assert_equal 13477774722, Rufus::Mnemo.from_s('dobejotehotzu')
|
123
|
+
assert_equal 13477774722, Rufus::Mnemo.to_integer('dobejotehotzu')
|
124
|
+
assert_equal 13477774722, Rufus::Mnemo.to_i('dobejotehotzu')
|
104
125
|
end
|
105
126
|
end
|
106
127
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rufus-mnemo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 1.2.
|
9
|
+
- 2
|
10
|
+
version: 1.2.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- John Mettraux
|
@@ -51,7 +51,7 @@ files:
|
|
51
51
|
- CHANGELOG.txt
|
52
52
|
- CREDITS.txt
|
53
53
|
- LICENSE.txt
|
54
|
-
- README.
|
54
|
+
- README.rdoc
|
55
55
|
has_rdoc: true
|
56
56
|
homepage: http://github.com/jmettraux/rufus-mnemo/
|
57
57
|
licenses: []
|