to_insane 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -37,8 +37,16 @@ Paypal address: mailto:dougal.s@gmail.com
37
37
  27.to_insane(4,'A2Ph')
38
38
 
39
39
  # Other Inputs
40
- # :url_safe uses characters that are RFC URL non reserved
41
- # :max uses the number of characters
40
+ # :url_safe uses the max number characters that are RFC URL non reserved
41
+ # :max uses the max number of characters for given character set. Default character set is 87
42
+ 27.to_insane(:url_safe)
43
+ 27.to_insane(:max)
44
+
45
+ == Info
46
+ Default Character set. I choose not to use any slashes or quotes of any sort to prevent breaking
47
+
48
+ INSANECHARACTERS = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ-._~+[]|$!*(),{}^<>#%;?:@&='
49
+
42
50
  == Credits
43
51
 
44
52
  Ryan Ong - http://ryangong.net
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.2.0
data/lib/to_insane.rb CHANGED
@@ -2,13 +2,16 @@
2
2
  # Distributed under the MIT license as included with this plugin.
3
3
  #
4
4
 
5
- INSANECHARACTERS = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ-._~+[]|$!*(),{}^<>#%;/?:@&='
5
+ INSANECHARACTERS = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ-._~+[]|$!*(),{}^<>#%;?:@&='
6
6
 
7
7
  class String
8
8
  # Converts a string to a base x integer using y character set.
9
9
  def from_insane(base_val = 58, alpha = INSANECHARACTERS)
10
- base_val = INSANECHARACTERS.size if base_val == :max
11
- base_val = 63 if base_val == :url_safe
10
+ base_val = alpha.size if base_val == :max
11
+ if base_val == :url_safe
12
+ base_val = 63
13
+ alpha = INSANECHARACTERS
14
+ end
12
15
  raise ArgumentError, "Base Value is not valid. Integer, :max, :url_safe" unless base_val.kind_of? Integer
13
16
  raise ArgumentError, "Base size is too large for given character set. Please use a Base value larger than 0 and less than #{alpha.length}" if base_val > alpha.length or base_val <= 0
14
17
  raise ArgumentError, "Character set needs to be larger than 0" if alpha.size <= 0
@@ -26,8 +29,11 @@ end
26
29
  class Integer
27
30
  # Converts a base10 integer to a base x string.
28
31
  def to_insane(base_val = 58, alpha = INSANECHARACTERS)
29
- base_val = INSANECHARACTERS.size if base_val == :max
30
- base_val = 63 if base_val == :url_safe
32
+ base_val = alpha.size if base_val == :max
33
+ if base_val == :url_safe
34
+ base_val = 63
35
+ alpha = INSANECHARACTERS
36
+ end
31
37
  raise ArgumentError, "Base Value is not valid. Integer, :max, :url_safe" unless base_val.kind_of? Integer
32
38
  raise ArgumentError, "Base size is too large for given character set. Please use a Base value larger than 0 and less than #{alpha.length}" if base_val > alpha.length or base_val <= 0
33
39
  raise ArgumentError, "Character set needs to be larger than 0" if alpha.size <= 0
data/to_insane.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{to_insane}
8
- s.version = "0.1.0"
8
+ s.version = "0.2.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Ryan Ong"]
@@ -16,17 +16,12 @@ Gem::Specification.new do |s|
16
16
  "README.rdoc"
17
17
  ]
18
18
  s.files = [
19
- ".README.rdoc.swp",
20
- ".Rakefile.swp",
21
19
  "CHANGELOG",
22
20
  "MIT-LICENSE",
23
21
  "README.rdoc",
24
22
  "Rakefile",
25
23
  "VERSION",
26
- "lib/.base58.rb.swp",
27
- "lib/.to_insane.rb.swp",
28
24
  "lib/to_insane.rb",
29
- "test/.test_to_insane.rb.swp",
30
25
  "test/test_to_insane.rb",
31
26
  "to_insane.gemspec"
32
27
  ]
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: to_insane
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.0
5
+ version: 0.2.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - Ryan Ong
@@ -23,17 +23,12 @@ extensions: []
23
23
  extra_rdoc_files:
24
24
  - README.rdoc
25
25
  files:
26
- - .README.rdoc.swp
27
- - .Rakefile.swp
28
26
  - CHANGELOG
29
27
  - MIT-LICENSE
30
28
  - README.rdoc
31
29
  - Rakefile
32
30
  - VERSION
33
- - lib/.base58.rb.swp
34
- - lib/.to_insane.rb.swp
35
31
  - lib/to_insane.rb
36
- - test/.test_to_insane.rb.swp
37
32
  - test/test_to_insane.rb
38
33
  - to_insane.gemspec
39
34
  has_rdoc: true
data/.README.rdoc.swp DELETED
Binary file
data/.Rakefile.swp DELETED
Binary file
data/lib/.base58.rb.swp DELETED
Binary file
Binary file
Binary file