rotor_machine 1.0.5 → 1.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 237bdb854d5723c43fed196b3d34b55628a68f177b56405cb4151f1c5b69a2f3
4
- data.tar.gz: aaaa6a934aa9929249a9d3c7e64d16d53cdab4a88e5d6f26686e7c2db5884e52
3
+ metadata.gz: ca40c7b0bde73376d2432b9bbaf53889c2e221732e9bd9ae7f36ab7007cb1ded
4
+ data.tar.gz: 72be1507e5a665d8bc5af4153121797824241761be5106d86deef1c6574be5a4
5
5
  SHA512:
6
- metadata.gz: d978cd64eb9227c03fb2eacd0fd18b68932155232cd422eb434a67dadca81ec866f3080eb3134bab3cabfb4274bdc1b095ed9044938333a2671f8445235cefff
7
- data.tar.gz: 99a9e9cfe0723dbf6531514fe21e409885322ecf6a74301c7f99205c226e24ac6ea8bb589583641c112e77e43623f1417d92389a55f1311e86672a3ecfea19f6
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
- self.step_rotors
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
@@ -1,4 +1,4 @@
1
1
  module RotorMachine
2
- VERSION_DATA = [1, 0, 5]
2
+ VERSION_DATA = [1, 0, 6]
3
3
  VERSION = VERSION_DATA.join(".")
4
4
  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.5
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-08 00:00:00.000000000 Z
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