gibbler 0.8.3 → 0.8.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/CHANGES.txt +4 -1
  2. data/gibbler.gemspec +1 -1
  3. data/lib/gibbler.rb +12 -10
  4. metadata +2 -2
data/CHANGES.txt CHANGED
@@ -1,6 +1,9 @@
1
1
  GIBBLER, CHANGES
2
2
 
3
- * TODO: Global salt
3
+
4
+ #### 0.8.4 (2010-06-19) ###############################
5
+
6
+ ADDED: Support for Gibbler.default_base which affects all generated digests.
4
7
 
5
8
  #### 0.8.3 (2010-05-04) ###############################
6
9
 
data/gibbler.gemspec CHANGED
@@ -1,7 +1,7 @@
1
1
  @spec = Gem::Specification.new do |s|
2
2
  s.name = "gibbler"
3
3
  s.rubyforge_project = "gibbler"
4
- s.version = "0.8.3"
4
+ s.version = "0.8.4"
5
5
  s.summary = "Gibbler: Git-like hashes for Ruby objects"
6
6
  s.description = s.summary
7
7
  s.author = "Delano Mandelbaum"
data/lib/gibbler.rb CHANGED
@@ -15,11 +15,12 @@ require 'digest/sha1'
15
15
  # "Hola, Tanneritos"
16
16
  #
17
17
  module Gibbler
18
- VERSION = "0.8.3"
18
+ VERSION = "0.8.4"
19
19
 
20
+ @default_base = 16
20
21
  @secret = nil
21
22
  class << self
22
- attr_accessor :secret
23
+ attr_accessor :secret, :default_base
23
24
  end
24
25
 
25
26
  require 'gibbler/mixins'
@@ -29,7 +30,6 @@ module Gibbler
29
30
  end
30
31
  end
31
32
 
32
-
33
33
  # = Gibbler::Digest
34
34
  #
35
35
  # A tiny subclass of String which adds a
@@ -37,19 +37,19 @@ end
37
37
  #
38
38
  class Gibbler::Digest < String
39
39
 
40
- # Return an integer assuming base 16.
40
+ # Return an integer assuming base is Gibbler.default_base.
41
41
  def to_i(base=nil)
42
- base ||= 16
42
+ base ||= Gibbler.default_base
43
43
  super(base)
44
44
  end
45
45
 
46
46
  # Returns a string. Takes an optional base.
47
47
  def to_s(base=nil)
48
- base.nil? ? super() : super().to_i(16).to_s(base)
48
+ base.nil? ? super() : super().to_i(Gibbler.default_base).to_s(base)
49
49
  end
50
50
 
51
- def base(base=16)
52
- self.class.new(self.to_i(16).to_s(base))
51
+ def base(base=Gibbler.default_base)
52
+ self.class.new(self.to_i(Gibbler.default_base).to_s(base))
53
53
  end
54
54
 
55
55
  def base36
@@ -77,7 +77,7 @@ class Gibbler::Digest < String
77
77
  # e.g.
78
78
  #
79
79
  # "kimmy".gibbler # => c8027100ecc54945ab15ddac529230e38b1ba6a1
80
- # "kimmy".gibbler.tiny # => c80271
80
+ # "kimmy".gibbler.shorter # => c80271
81
81
  #
82
82
  def shorter
83
83
  shorten(6)
@@ -235,7 +235,9 @@ module Gibbler
235
235
  def self.digest(str, digest_type=nil)
236
236
  digest_type ||= @@gibbler_digest_type
237
237
  str = [Gibbler.secret, str].join(':') unless Gibbler.secret.nil?
238
- digest_type.hexdigest str
238
+ dig = digest_type.hexdigest(str)
239
+ dig = dig.to_i(16).to_s(Gibbler.default_base) if 16 != Gibbler.default_base
240
+ dig
239
241
  end
240
242
 
241
243
  def self.gibbler_debug(*args)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gibbler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.3
4
+ version: 0.8.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Delano Mandelbaum
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-05-04 00:00:00 -04:00
12
+ date: 2010-06-19 00:00:00 -04:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency