rotor_machine 1.0.5 → 1.0.6
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/lib/rotor_machine/machine.rb +15 -2
- data/lib/rotor_machine/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ca40c7b0bde73376d2432b9bbaf53889c2e221732e9bd9ae7f36ab7007cb1ded
|
4
|
+
data.tar.gz: 72be1507e5a665d8bc5af4153121797824241761be5106d86deef1c6574be5a4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d9100dd5fb06326ec6dfad165c05c31a8e566f3e0645404358a263d1ad3eb7eb6b0e029149df61c727c85f13d811182a83ee3e1a5207540b512b91893421dc01
|
7
|
+
data.tar.gz: 7a02cb6c72df3202d7c27a4df9560e1b41fbe203b34b101074f53ba0a3dacb4636f02a667bfcab9d4dc4c08c91a051fe95867b87505b1612b37a949725672698
|
@@ -140,7 +140,7 @@ module RotorMachine
|
|
140
140
|
def encipher(text)
|
141
141
|
raise ArgumentError, "Cannot encipher; no rotors loaded" if (@rotors.count == 0)
|
142
142
|
raise ArgumentError, "Cannot encipher; no reflector loaded" if (@reflector.nil?)
|
143
|
-
text.upcase.chars.collect { |c| self.encipher_char(c) }.join("")
|
143
|
+
RotorMachine::Machine.letter_blocks(text.upcase.chars.collect { |c| self.encipher_char(c) }.join(""), 5)
|
144
144
|
end
|
145
145
|
|
146
146
|
##
|
@@ -214,8 +214,21 @@ module RotorMachine
|
|
214
214
|
ec = @plugboard.transpose(ec)
|
215
215
|
end
|
216
216
|
|
217
|
-
|
217
|
+
unless ec == c
|
218
|
+
self.step_rotors
|
219
|
+
end
|
218
220
|
ec
|
219
221
|
end
|
222
|
+
|
223
|
+
##
|
224
|
+
# Reformat a string into blocks of letters of uniform size.
|
225
|
+
#
|
226
|
+
# @param the_text [String] The text to reformat.
|
227
|
+
# @param block_size [Numeric] The size of the blocks of letters.
|
228
|
+
# @return [String] The reformatted text.
|
229
|
+
def self.letter_blocks(the_text, block_size)
|
230
|
+
the_text.chars.reject{|s| s.match(/\s/)}.each_slice(block_size).map(&:join).join(" ")
|
231
|
+
end
|
232
|
+
|
220
233
|
end
|
221
234
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rotor_machine
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tammy Cravit
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-02-
|
11
|
+
date: 2018-02-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tcravit_ruby_lib
|