gravity_falls_message 0.0.1 → 0.0.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 51e68853e44988a10e325f0dbcae25d8af1d0cac
4
- data.tar.gz: 609060a40297ae2f77602857f988e3924ad3c2b1
3
+ metadata.gz: 817f729928c9cc85ad30ca7618e0a941a001c8c9
4
+ data.tar.gz: ab78e5432f681c00d1433684b26235761422c4fa
5
5
  SHA512:
6
- metadata.gz: 6f6bad51562f6e710e850380b21747f267b31e93fea56e27f5d591f3e24689b6c3a107fa62ef4e4a0a355436a2db3cbb4687036ab42ff676ca199745b1ee9f79
7
- data.tar.gz: 9fc5a8aaaf6f7ad5914745a374e38b9b4cf96ca9386968c545ae321e8dcb9149b73ccf7eb45fd26e1f0fa3aa0b3c0d654cf61da644a014273b945dc7c64c71cb
6
+ metadata.gz: 3e1fed23a1d33ca0419f53acbba3b50655155e8ff5474bf622ccde561a5546c1f65d17db42f61210659da828b6983fcc657e3d157cd0acfe554c5a5ec8a74dbd
7
+ data.tar.gz: 3d837070eeeec7024d58829354c79cc64e2a6e24edeeb14989196c175da85076219c3c58186a0edfb949ca18b382f9121b9a592c9d65e8cadbd0ab7800301100
data/README.md CHANGED
@@ -43,8 +43,8 @@ Options other than those listed here are ignored.
43
43
  **Valid Options:**
44
44
 
45
45
  - `encode:` When present or `true`, switches the Cipher so it encodes the message rather than decoding it.
46
- - `key:` A `String`. Characters other than `/[a-zA-z]/` are ignored.
47
- - `shift:` An `Integer` representing the number of characters to shift. Defaults to 3. Must be positive (for now).
46
+ - `key:` A `String`. Characters other than `/[a-zA-Z]/` are ignored.
47
+ - `shift:` An `Integer` representing the number of characters to shift. Defaults to 3.
48
48
 
49
49
  ### Decoding Messages
50
50
 
@@ -73,6 +73,12 @@ Options other than those listed here are ignored.
73
73
  > GravityFallsMessage.decode(message, 'caesar')
74
74
  => "WELCOME TO GRAVITY FALLS."
75
75
 
76
+ # decode a message using the caesar cipher with a specified shift
77
+ > message = "THIS IS A MORE COMPLICATED TEST"
78
+ => "THIS IS A MORE COMPLICATED TEST"
79
+ > GravityFallsMessage.decode(message, 'caesar', shift: 5)
80
+ => "YMNX NX F RTWJ HTRUQNHFYJI YJXY"
81
+
76
82
  # decode a message using the vigenere cipher
77
83
  > message = "NLMXQWWN IIZ LZFNF"
78
84
  => "NLMXQWWN IIZ LZFNF"
@@ -107,6 +113,11 @@ Options other than those listed here are ignored.
107
113
  > GravityFallsMessage.encode(message, 'caesar')
108
114
  => "ZHOFRPH WR JUDYLWB IDOOV."
109
115
 
116
+ # encode a message using the caesar cipher with a specified shift
117
+ > message = "YMNX NX F RTWJ HTRUQNHFYJI YJXY"
118
+ => "YMNX NX F RTWJ HTRUQNHFYJI YJXY"
119
+ > GravityFallsMessage.encode(message, 'caesar', shift: 5)
120
+
110
121
  # encode a message using the vigenere cipher
111
122
  > message = "REMEMBER BIG HENRY"
112
123
  => "REMEMBER BIG HENRY"
@@ -13,6 +13,7 @@ module GravityFallsMessage
13
13
  when 'atbash' then Cipher.atbash(message)
14
14
  when 'binary' then Cipher.binary(message)
15
15
  when 'caesar' then Cipher.caesar(message, options)
16
+ when 'rotated_caesar' then Cipher.rotated_caesar(message, options)
16
17
  when 'vigenere' then Cipher.vigenere(message, options)
17
18
  end
18
19
  end
@@ -1,3 +1,3 @@
1
1
  module GravityFallsMessage
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -36,6 +36,20 @@ class GravityFallsMessageTest < Minitest::Test
36
36
  solution: 'ANTHYDING CAN HADPLEN'
37
37
  }
38
38
  ]
39
+
40
+ @two_position_caesar_crypts = {
41
+ 'OAUVG' => "MYSTE",
42
+ 'EWTUG AQW OCTKNAP' => "CURSE YOU MARILYN"
43
+ }
44
+
45
+ @five_position_caesar_crypt = {
46
+ "YMNX NX F RTWJ HTRUQNHFYJI YJXY" => "THIS IS A MORE COMPLICATED TEST"
47
+ }
48
+
49
+ @negative_shift_value_crypt = {
50
+ "OCDN DN V IZBVODQZ NCDAO QVGPZ OZNO" => "THIS IS A NEGATIVE SHIFT VALUE TEST"
51
+ }
52
+
39
53
  end
40
54
 
41
55
  should "decode a message using the a1z26 cipher" do
@@ -61,14 +75,32 @@ class GravityFallsMessageTest < Minitest::Test
61
75
  assert_equal solution, GravityFallsMessage.decode(cryptogram, 'caesar')
62
76
  end
63
77
  end
64
-
78
+
79
+ should "decode a message using the caesar cipher with a two position shift" do
80
+ @two_position_caesar_crypts.each_pair do |cryptogram, solution|
81
+ assert_equal solution, GravityFallsMessage.decode(cryptogram, 'caesar', shift: 2)
82
+ end
83
+ end
84
+
85
+ should "decode a message using the caesar cipher with a five position shift" do
86
+ @five_position_caesar_crypt.each_pair do |cryptogram, solution|
87
+ assert_equal solution, GravityFallsMessage.decode(cryptogram, 'caesar', shift: 5)
88
+ end
89
+ end
90
+
91
+ should "decode a message using the caesar cipher with a negative five position shift" do
92
+ @negative_shift_value_crypt.each_pair do |cryptogram, solution|
93
+ assert_equal solution, GravityFallsMessage.decode(cryptogram, 'caesar', shift: -5)
94
+ end
95
+ end
96
+
65
97
  should "decode a message using the vigenere cipher" do
66
98
  @vigenere_crypts.each do |crypt|
67
99
  assert_equal crypt[:solution], GravityFallsMessage.decode(crypt[:cryptogram], 'vigenere', {key: crypt[:key]})
68
100
  end
69
101
  end
70
102
 
71
-
103
+ # Encode tests
72
104
  should "encode a message using the a1z26 cipher" do
73
105
  @a1z26_crypts.each_pair do |cryptogram, solution|
74
106
  assert_equal cryptogram, GravityFallsMessage.encode(solution, 'a1z26')
@@ -93,6 +125,24 @@ class GravityFallsMessageTest < Minitest::Test
93
125
  end
94
126
  end
95
127
 
128
+ should "encode a message using the caesar cipher with a two position shift" do
129
+ @two_position_caesar_crypts.each_pair do |cryptogram, solution|
130
+ assert_equal cryptogram, GravityFallsMessage.encode(solution, 'caesar', shift: 2)
131
+ end
132
+ end
133
+
134
+ should "encode a message using the caesar cipher with a five position shift" do
135
+ @five_position_caesar_crypt.each_pair do |cryptogram, solution|
136
+ assert_equal cryptogram, GravityFallsMessage.encode(solution, 'caesar', shift: 5)
137
+ end
138
+ end
139
+
140
+ should "encode a message using the caesar cipher with a negative five position shift" do
141
+ @negative_shift_value_crypt.each_pair do |cryptogram, solution|
142
+ assert_equal cryptogram, GravityFallsMessage.encode(solution, 'caesar', shift: -5)
143
+ end
144
+ end
145
+
96
146
  should "encode a message using the vigenere cipher" do
97
147
  @vigenere_crypts.each do |crypt|
98
148
  assert_equal crypt[:cryptogram], GravityFallsMessage.encode(crypt[:solution], 'vigenere', {key: crypt[:key]})
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gravity_falls_message
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Hall
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-25 00:00:00.000000000 Z
11
+ date: 2014-10-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler