base58 0.0.4 → 0.1.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.
@@ -18,14 +18,14 @@ Base58 is hosted by http://gemcutter.com. Please make sure you have added them t
18
18
  require 'base58'
19
19
 
20
20
  # Int to Base58
21
- Base58.int_to_base58(12345) # => 4ER
21
+ Base58.encode(12345) # => 4ER
22
22
 
23
23
  # Base58 to Int
24
- Base58.base58_to_int('A2Ph') # => 6639914
24
+ Base58.decode('A2Ph') # => 6639914
25
25
 
26
26
  == RDoc Documentation
27
27
 
28
- You can view the rdoc documentation online[http://douglasfshearer.com/rdoc/base58/].
28
+ You can view the rdoc documentation online[http://rdoc.info/projects/dougal/acts_as_indexed/].
29
29
 
30
30
  == Problems, Comments, Suggestions?
31
31
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.4
1
+ 0.1.0
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{base58}
8
- s.version = "0.0.4"
8
+ s.version = "0.1.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Douglas F Shearer"]
12
- s.date = %q{2009-11-27}
12
+ s.date = %q{2010-02-05}
13
13
  s.description = %q{Base58 is a Ruby library for converting ints to and from base58.}
14
14
  s.email = %q{dougal.s@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -12,7 +12,8 @@ class Base58
12
12
  def self.base58_to_int(base58_val)
13
13
  int_val = 0
14
14
  base58_val.reverse.split(//).each_with_index do |char,index|
15
- int_val += (ALPHABET.index(char))*(BASE**(index))
15
+ raise ArgumentError, 'Value passed not a valid Base58 String.' if (char_index = ALPHABET.index(char)).nil?
16
+ int_val += (char_index)*(BASE**(index))
16
17
  end
17
18
  int_val
18
19
  end
@@ -29,4 +30,9 @@ class Base58
29
30
  ALPHABET[int_val,1] + base58_val
30
31
  end
31
32
 
33
+ class << self
34
+ alias_method :encode, :int_to_base58
35
+ alias_method :decode, :base58_to_int
36
+ end
37
+
32
38
  end
@@ -521,4 +521,16 @@ EXAMPLES = { "6hKMCS" => 3471391110,
521
521
  assert_equal 'Value passed is not an Integer.', e.message
522
522
  end
523
523
 
524
+ def test_invalid_base58_string
525
+ e = assert_raise(ArgumentError) { Base58.base58_to_int('nh?') }
526
+ assert_equal 'Value passed not a valid Base58 String.', e.message
527
+ end
528
+
529
+ def test_encode_decode_aliases
530
+ int = 3471844090
531
+ str = Base58.encode(int)
532
+ assert_equal str, "6hN7hS"
533
+ assert_equal int, Base58.decode(str)
534
+ end
535
+
524
536
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: base58
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Douglas F Shearer
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-11-27 00:00:00 +00:00
12
+ date: 2010-02-05 00:00:00 +00:00
13
13
  default_executable:
14
14
  dependencies: []
15
15