squarecoder 0.0.0

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.
Files changed (44) hide show
  1. data/LICENSE.txt +20 -0
  2. data/README.rdoc +15 -0
  3. data/lib/doc/Squarecoder.html +116 -0
  4. data/lib/doc/Squarecoder/Transcoder.html +236 -0
  5. data/lib/doc/String.html +266 -0
  6. data/lib/doc/created.rid +5 -0
  7. data/lib/doc/images/add.png +0 -0
  8. data/lib/doc/images/brick.png +0 -0
  9. data/lib/doc/images/brick_link.png +0 -0
  10. data/lib/doc/images/bug.png +0 -0
  11. data/lib/doc/images/bullet_black.png +0 -0
  12. data/lib/doc/images/bullet_toggle_minus.png +0 -0
  13. data/lib/doc/images/bullet_toggle_plus.png +0 -0
  14. data/lib/doc/images/date.png +0 -0
  15. data/lib/doc/images/delete.png +0 -0
  16. data/lib/doc/images/find.png +0 -0
  17. data/lib/doc/images/loadingAnimation.gif +0 -0
  18. data/lib/doc/images/macFFBgHack.png +0 -0
  19. data/lib/doc/images/package.png +0 -0
  20. data/lib/doc/images/page_green.png +0 -0
  21. data/lib/doc/images/page_white_text.png +0 -0
  22. data/lib/doc/images/page_white_width.png +0 -0
  23. data/lib/doc/images/plugin.png +0 -0
  24. data/lib/doc/images/ruby.png +0 -0
  25. data/lib/doc/images/tag_blue.png +0 -0
  26. data/lib/doc/images/tag_green.png +0 -0
  27. data/lib/doc/images/transparent.png +0 -0
  28. data/lib/doc/images/wrench.png +0 -0
  29. data/lib/doc/images/wrench_orange.png +0 -0
  30. data/lib/doc/images/zoom.png +0 -0
  31. data/lib/doc/index.html +73 -0
  32. data/lib/doc/js/darkfish.js +153 -0
  33. data/lib/doc/js/jquery.js +18 -0
  34. data/lib/doc/js/navigation.js +142 -0
  35. data/lib/doc/js/search.js +94 -0
  36. data/lib/doc/js/search_index.js +1 -0
  37. data/lib/doc/js/searcher.js +228 -0
  38. data/lib/doc/rdoc.css +543 -0
  39. data/lib/doc/table_of_contents.html +64 -0
  40. data/lib/squarecoder.rb +8 -0
  41. data/lib/squarecoder/core_ext/string.rb +23 -0
  42. data/lib/squarecoder/errors.rb +4 -0
  43. data/lib/squarecoder/transcoder.rb +32 -0
  44. metadata +91 -0
@@ -0,0 +1,64 @@
1
+ <!DOCTYPE html>
2
+
3
+ <html>
4
+ <head>
5
+ <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
6
+
7
+ <title>Table of Contents</title>
8
+
9
+ <link type="text/css" media="screen" href="./rdoc.css" rel="stylesheet">
10
+
11
+ <script type="text/javascript">
12
+ var rdoc_rel_prefix = "./";
13
+ </script>
14
+
15
+ <script type="text/javascript" charset="utf-8" src="./js/jquery.js"></script>
16
+ <script type="text/javascript" charset="utf-8" src="./js/navigation.js"></script>
17
+ <script type="text/javascript" charset="utf-8" src="./js/search_index.js"></script>
18
+ <script type="text/javascript" charset="utf-8" src="./js/search.js"></script>
19
+ <script type="text/javascript" charset="utf-8" src="./js/searcher.js"></script>
20
+ <script type="text/javascript" charset="utf-8" src="./js/darkfish.js"></script>
21
+
22
+
23
+ <body class="indexpage">
24
+ <h1>Table of Contents</h1>
25
+
26
+
27
+ <h2 id="classes">Classes/Modules</h2>
28
+ <ul>
29
+ <li class="module">
30
+ <a href="Squarecoder.html">Squarecoder</a>
31
+ </li>
32
+ <li class="class">
33
+ <a href="Squarecoder/Transcoder.html">Squarecoder::Transcoder</a>
34
+ </li>
35
+ <li class="class">
36
+ <a href="String.html">String</a>
37
+ </li>
38
+
39
+ </ul>
40
+
41
+ <h2 id="methods">Methods</h2>
42
+ <ul>
43
+
44
+ <li class="method"><a href="Squarecoder/Transcoder.html#method-c-decode">::decode &mdash; Squarecoder::Transcoder</a>
45
+
46
+ <li class="method"><a href="Squarecoder/Transcoder.html#method-c-encode">::encode &mdash; Squarecoder::Transcoder</a>
47
+
48
+ <li class="method"><a href="String.html#method-i-square_decode">#square_decode &mdash; String</a>
49
+
50
+ <li class="method"><a href="String.html#method-i-square_decode-21">#square_decode! &mdash; String</a>
51
+
52
+ <li class="method"><a href="String.html#method-i-square_encode">#square_encode &mdash; String</a>
53
+
54
+ <li class="method"><a href="String.html#method-i-square_encode-21">#square_encode! &mdash; String</a>
55
+
56
+ </ul>
57
+
58
+
59
+ <footer id="validator-badges">
60
+ <p><a href="http://validator.w3.org/check/referer">[Validate]</a>
61
+ <p>Generated by <a href="https://github.com/rdoc/rdoc">RDoc</a> 3.11.
62
+ <p>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish Rdoc Generator</a> 3.
63
+ </footer>
64
+
@@ -0,0 +1,8 @@
1
+ require 'rubygems'
2
+ require 'singleton'
3
+
4
+ module Squarecoder
5
+ require 'squarecoder/core_ext/string'
6
+ require 'squarecoder/errors'
7
+ require 'squarecoder/transcoder'
8
+ end
@@ -0,0 +1,23 @@
1
+ class String
2
+
3
+ # Encode a String
4
+ def square_encode
5
+ dup.square_encode!
6
+ end
7
+
8
+ # Encode a String (in-place)
9
+ def square_encode!
10
+ replace( Squarecoder::Transcoder.encode( self ) )
11
+ end
12
+
13
+ # Decode an encoded String
14
+ def square_decode
15
+ dup.square_decode!
16
+ end
17
+
18
+ # Decode a string (in-place)
19
+ def square_decode!
20
+ replace( Squarecoder::Transcoder.decode( self ) )
21
+ end
22
+
23
+ end
@@ -0,0 +1,4 @@
1
+ module Squarecoder
2
+ class InputTooLongError < StandardError # :nodoc:
3
+ end
4
+ end
@@ -0,0 +1,32 @@
1
+ module Squarecoder
2
+
3
+ # A Transcoder is a Singleton used to encode and decode strings.
4
+ #
5
+ # Squarecoder::Transcoder.encode("haveaniceday") # => "hae and via ecy"
6
+ # Squarecoder::Transcoder.decode("hae and via ecy") # => "haveaniceday"
7
+ # "haveaniceday".square_encode # => "hae and via ecy"
8
+ # "hae and via ecy".square_decode # => "haveaniceday"
9
+ class Transcoder
10
+
11
+ include Singleton
12
+
13
+ # Encode a String in square code
14
+ def self.encode a_string
15
+ this_string = a_string
16
+ raise Squarecoder::InputTooLongError if this_string.length > 81
17
+ len = ( this_string.length ** ( 0.5 ) ).ceil
18
+ arry = this_string.scan( /./ ).each_slice( len ).to_a
19
+ if arry.last.length != len
20
+ arry.last.fill( ' ', arry.last.length..( len - 1 ) )
21
+ end
22
+ arry.transpose.collect { |line| line.join }.join(' ').rstrip
23
+ end
24
+
25
+ # Decode a String from square code
26
+ def self.decode a_string
27
+ encode( a_string ).gsub(' ', '')
28
+ end
29
+
30
+ end
31
+
32
+ end
metadata ADDED
@@ -0,0 +1,91 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: squarecoder
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Aaron Breckenridge
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-11-25 00:00:00.000000000Z
13
+ dependencies: []
14
+ description: A library to encode and decode strings using the square code encryption
15
+ method.
16
+ email: aaronbreckenridge@gmail.com
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files:
20
+ - README.rdoc
21
+ files:
22
+ - README.rdoc
23
+ - lib/doc/created.rid
24
+ - lib/doc/images/add.png
25
+ - lib/doc/images/brick.png
26
+ - lib/doc/images/brick_link.png
27
+ - lib/doc/images/bug.png
28
+ - lib/doc/images/bullet_black.png
29
+ - lib/doc/images/bullet_toggle_minus.png
30
+ - lib/doc/images/bullet_toggle_plus.png
31
+ - lib/doc/images/date.png
32
+ - lib/doc/images/delete.png
33
+ - lib/doc/images/find.png
34
+ - lib/doc/images/loadingAnimation.gif
35
+ - lib/doc/images/macFFBgHack.png
36
+ - lib/doc/images/package.png
37
+ - lib/doc/images/page_green.png
38
+ - lib/doc/images/page_white_text.png
39
+ - lib/doc/images/page_white_width.png
40
+ - lib/doc/images/plugin.png
41
+ - lib/doc/images/ruby.png
42
+ - lib/doc/images/tag_blue.png
43
+ - lib/doc/images/tag_green.png
44
+ - lib/doc/images/transparent.png
45
+ - lib/doc/images/wrench.png
46
+ - lib/doc/images/wrench_orange.png
47
+ - lib/doc/images/zoom.png
48
+ - lib/doc/index.html
49
+ - lib/doc/js/darkfish.js
50
+ - lib/doc/js/jquery.js
51
+ - lib/doc/js/navigation.js
52
+ - lib/doc/js/search.js
53
+ - lib/doc/js/search_index.js
54
+ - lib/doc/js/searcher.js
55
+ - lib/doc/rdoc.css
56
+ - lib/doc/Squarecoder/Transcoder.html
57
+ - lib/doc/Squarecoder.html
58
+ - lib/doc/String.html
59
+ - lib/doc/table_of_contents.html
60
+ - lib/squarecoder/core_ext/string.rb
61
+ - lib/squarecoder/errors.rb
62
+ - lib/squarecoder/transcoder.rb
63
+ - lib/squarecoder.rb
64
+ - LICENSE.txt
65
+ homepage: http://github.com/breckenedge/squarecoder
66
+ licenses: []
67
+ post_install_message:
68
+ rdoc_options:
69
+ - -m
70
+ - README.rdoc
71
+ require_paths:
72
+ - lib
73
+ required_ruby_version: !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ! '>='
77
+ - !ruby/object:Gem::Version
78
+ version: 1.8.7
79
+ required_rubygems_version: !ruby/object:Gem::Requirement
80
+ none: false
81
+ requirements:
82
+ - - ! '>='
83
+ - !ruby/object:Gem::Version
84
+ version: 1.3.6
85
+ requirements: []
86
+ rubyforge_project:
87
+ rubygems_version: 1.8.11
88
+ signing_key:
89
+ specification_version: 3
90
+ summary: encode and decode strings using the square code encryption method
91
+ test_files: []