gibbler 0.8.4 → 0.8.5
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES.txt +5 -0
- data/Rakefile +43 -64
- data/VERSION.yml +4 -0
- data/gibbler.gemspec +71 -45
- data/lib/gibbler.rb +16 -1
- data/try/01_mixins_try.rb +6 -0
- data/try/02_compat_try.rb +14 -0
- data/try/05_gibbler_digest_try.rb +41 -0
- data/try/10_basic_try.rb +130 -0
- data/try/11_basic_sha256_try.rb +28 -0
- data/try/14_extended_try.rb +78 -0
- data/try/15_file_try.rb +36 -0
- data/try/16_uri_try.rb +28 -0
- data/try/17_complex_object_try.rb +27 -0
- data/try/18_proc_try.rb +35 -0
- data/try/20_time_try.rb +27 -0
- data/try/30_secret_try.rb +21 -0
- data/try/50_history_try.rb +30 -0
- data/try/51_hash_history_try.rb +71 -0
- data/try/52_array_history_try.rb +35 -0
- data/try/53_string_history_try.rb +29 -0
- data/try/57_arbitrary_history_try.rb +31 -0
- data/try/59_history_exceptions_try.rb +31 -0
- data/try/80_performance_try.rb +82 -0
- data/try/90_alias_try.rb +47 -0
- metadata +50 -15
data/CHANGES.txt
CHANGED
data/Rakefile
CHANGED
@@ -1,85 +1,64 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require '
|
5
|
-
include FileUtils
|
1
|
+
require "rubygems"
|
2
|
+
require "rake"
|
3
|
+
require "rake/clean"
|
4
|
+
require 'yaml'
|
6
5
|
|
7
6
|
begin
|
8
7
|
require 'hanna/rdoctask'
|
9
8
|
rescue LoadError
|
10
9
|
require 'rake/rdoctask'
|
11
10
|
end
|
12
|
-
|
13
|
-
|
14
|
-
task :default => :package
|
15
11
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
CHANGES = "CHANGES.txt"
|
21
|
-
LICENSE = "LICENSE.txt"
|
22
|
-
|
23
|
-
# Files and directories to be deleted when you run "rake clean"
|
24
|
-
CLEAN.include [ 'pkg', '*.gem', '.config', 'doc']
|
25
|
-
|
26
|
-
name = 'gibbler'
|
27
|
-
load "#{name}.gemspec"
|
28
|
-
version = @spec.version
|
29
|
-
|
30
|
-
# That's it! The following defaults should allow you to get started
|
31
|
-
# on other things.
|
32
|
-
|
33
|
-
|
34
|
-
# TESTS/SPECS =========================================================
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
# INSTALL =============================================================
|
12
|
+
config = YAML.load_file("VERSION.yml")
|
13
|
+
task :default => ["build"]
|
14
|
+
CLEAN.include [ 'pkg', 'doc' ]
|
15
|
+
name = "gibbler"
|
39
16
|
|
40
|
-
|
41
|
-
|
17
|
+
begin
|
18
|
+
require "jeweler"
|
19
|
+
Jeweler::Tasks.new do |gem|
|
20
|
+
gem.version = "#{config[:MAJOR]}.#{config[:MINOR]}.#{config[:PATCH]}"
|
21
|
+
gem.name = name
|
22
|
+
gem.rubyforge_project = gem.name
|
23
|
+
gem.summary = "Gibbler: Git-like hashes for Ruby objects"
|
24
|
+
gem.description = gem.summary
|
25
|
+
gem.email = "delano@solutious.com"
|
26
|
+
gem.homepage = "http://github.com/delano/gibbler"
|
27
|
+
gem.authors = ["Delano Mandelbaum"]
|
28
|
+
gem.add_dependency("attic", ">= 0.4.0")
|
29
|
+
end
|
30
|
+
Jeweler::GemcutterTasks.new
|
31
|
+
rescue LoadError
|
32
|
+
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
42
33
|
end
|
43
34
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
35
|
+
|
36
|
+
Rake::RDocTask.new do |rdoc|
|
37
|
+
version = "#{config[:MAJOR]}.#{config[:MINOR]}.#{config[:PATCH]}"
|
38
|
+
rdoc.rdoc_dir = "doc"
|
39
|
+
rdoc.title = "#{name} #{version}"
|
40
|
+
rdoc.rdoc_files.include("README*")
|
41
|
+
rdoc.rdoc_files.include("LICENSE.txt")
|
42
|
+
rdoc.rdoc_files.include("bin/*.rb")
|
43
|
+
rdoc.rdoc_files.include("lib/**/*.rb")
|
50
44
|
end
|
51
45
|
|
52
46
|
|
53
|
-
#
|
47
|
+
# Rubyforge Release / Publish Tasks ==================================
|
54
48
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
end
|
49
|
+
#about 'Publish website to rubyforge'
|
50
|
+
task 'publish:rdoc' => 'doc/index.html' do
|
51
|
+
#sh "scp -rp doc/* rubyforge.org:/var/www/gforge-projects/#{name}/"
|
52
|
+
end
|
60
53
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
end
|
54
|
+
#about 'Public release to rubyforge'
|
55
|
+
task 'publish:gem' => [:package] do |t|
|
56
|
+
sh <<-end
|
57
|
+
rubyforge add_release -o Any -a CHANGES.txt -f -n README.md #{name} #{name} #{@spec.version} pkg/#{name}-#{@spec.version}.gem &&
|
58
|
+
rubyforge add_file -o Any -a CHANGES.txt -f -n README.md #{name} #{name} #{@spec.version} pkg/#{name}-#{@spec.version}.tgz
|
67
59
|
end
|
68
60
|
end
|
69
61
|
|
70
62
|
|
71
63
|
|
72
|
-
# RUBY DOCS TASK ==================================
|
73
|
-
|
74
|
-
Rake::RDocTask.new do |t|
|
75
|
-
t.rdoc_dir = 'doc'
|
76
|
-
t.title = @spec.summary
|
77
|
-
t.options << '--line-numbers'
|
78
|
-
t.options << '--charset' << 'utf-8'
|
79
|
-
t.rdoc_files.include(LICENSE)
|
80
|
-
t.rdoc_files.include(README)
|
81
|
-
t.rdoc_files.include(CHANGES)
|
82
|
-
t.rdoc_files.include('lib/**/*.rb')
|
83
|
-
end
|
84
|
-
|
85
64
|
|
data/VERSION.yml
ADDED
data/gibbler.gemspec
CHANGED
@@ -1,45 +1,71 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
s.
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{gibbler}
|
8
|
+
s.version = "0.8.5"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Delano Mandelbaum"]
|
12
|
+
s.date = %q{2010-12-23}
|
13
|
+
s.description = %q{Gibbler: Git-like hashes for Ruby objects}
|
14
|
+
s.email = %q{delano@solutious.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE.txt",
|
17
|
+
"README.rdoc"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
"CHANGES.txt",
|
21
|
+
"LICENSE.txt",
|
22
|
+
"README.rdoc",
|
23
|
+
"Rakefile",
|
24
|
+
"VERSION.yml",
|
25
|
+
"gibbler.gemspec",
|
26
|
+
"lib/gibbler.rb",
|
27
|
+
"lib/gibbler/aliases.rb",
|
28
|
+
"lib/gibbler/history.rb",
|
29
|
+
"lib/gibbler/mixins.rb",
|
30
|
+
"try/01_mixins_try.rb",
|
31
|
+
"try/02_compat_try.rb",
|
32
|
+
"try/05_gibbler_digest_try.rb",
|
33
|
+
"try/10_basic_try.rb",
|
34
|
+
"try/11_basic_sha256_try.rb",
|
35
|
+
"try/14_extended_try.rb",
|
36
|
+
"try/15_file_try.rb",
|
37
|
+
"try/16_uri_try.rb",
|
38
|
+
"try/17_complex_object_try.rb",
|
39
|
+
"try/18_proc_try.rb",
|
40
|
+
"try/20_time_try.rb",
|
41
|
+
"try/30_secret_try.rb",
|
42
|
+
"try/50_history_try.rb",
|
43
|
+
"try/51_hash_history_try.rb",
|
44
|
+
"try/52_array_history_try.rb",
|
45
|
+
"try/53_string_history_try.rb",
|
46
|
+
"try/57_arbitrary_history_try.rb",
|
47
|
+
"try/59_history_exceptions_try.rb",
|
48
|
+
"try/80_performance_try.rb",
|
49
|
+
"try/90_alias_try.rb"
|
50
|
+
]
|
51
|
+
s.homepage = %q{http://github.com/delano/gibbler}
|
52
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
53
|
+
s.require_paths = ["lib"]
|
54
|
+
s.rubyforge_project = %q{gibbler}
|
55
|
+
s.rubygems_version = %q{1.3.7}
|
56
|
+
s.summary = %q{Gibbler: Git-like hashes for Ruby objects}
|
57
|
+
|
58
|
+
if s.respond_to? :specification_version then
|
59
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
60
|
+
s.specification_version = 3
|
61
|
+
|
62
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
63
|
+
s.add_runtime_dependency(%q<attic>, [">= 0.4.0"])
|
64
|
+
else
|
65
|
+
s.add_dependency(%q<attic>, [">= 0.4.0"])
|
66
|
+
end
|
67
|
+
else
|
68
|
+
s.add_dependency(%q<attic>, [">= 0.4.0"])
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
data/lib/gibbler.rb
CHANGED
@@ -15,7 +15,17 @@ require 'digest/sha1'
|
|
15
15
|
# "Hola, Tanneritos"
|
16
16
|
#
|
17
17
|
module Gibbler
|
18
|
-
VERSION
|
18
|
+
module VERSION
|
19
|
+
def self.to_s
|
20
|
+
load_config
|
21
|
+
[@version[:MAJOR], @version[:MINOR], @version[:PATCH]].join('.')
|
22
|
+
end
|
23
|
+
alias_method :inspect, :to_s
|
24
|
+
def self.load_config
|
25
|
+
require 'yaml'
|
26
|
+
@version ||= YAML.load_file(File.join(GIBBLER_LIB_HOME, '..', 'VERSION.yml'))
|
27
|
+
end
|
28
|
+
end
|
19
29
|
|
20
30
|
@default_base = 16
|
21
31
|
@secret = nil
|
@@ -223,6 +233,7 @@ module Gibbler
|
|
223
233
|
def self.debug?; @@gibbler_debug; end
|
224
234
|
def self.enable_debug; @@gibbler_debug = true; end
|
225
235
|
def self.disable_debug; @@gibbler_debug = false; end
|
236
|
+
def self.debug=(v); @@gibbler_debug = v; end
|
226
237
|
# Returns the current digest class.
|
227
238
|
def self.digest_type; @@gibbler_digest_type; end
|
228
239
|
|
@@ -314,6 +325,10 @@ module Gibbler
|
|
314
325
|
gibbler_debug :gibbler_fields, gibbler_fields
|
315
326
|
gibbler_fields.each do |n|
|
316
327
|
value = instance_variable_get("@#{n}")
|
328
|
+
unless value.respond_to? :__gibbler
|
329
|
+
gibbler_debug klass, :skipping, n
|
330
|
+
next
|
331
|
+
end
|
317
332
|
d << '%s:%s:%s' % [value.class, n, value.__gibbler(digest_type)]
|
318
333
|
end
|
319
334
|
d = d.join(':').__gibbler(digest_type)
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'gibbler'
|
2
|
+
|
3
|
+
## Gibbler Objects have gibbler_cache method
|
4
|
+
"kimmy".respond_to? :gibbler_cache
|
5
|
+
#=> true
|
6
|
+
|
7
|
+
## Gibbler Objects have __gibbler_cache method
|
8
|
+
"kimmy".respond_to? :__gibbler_cache
|
9
|
+
#=> true
|
10
|
+
|
11
|
+
## __gibbler_cache returns the same value as gibbler_cache
|
12
|
+
@a = "kimmy" and @a.gibbler
|
13
|
+
@a.gibbler_cache
|
14
|
+
#=> @a.__gibbler_cache
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'gibbler'
|
2
|
+
|
3
|
+
## has short method
|
4
|
+
"kimmy".gibbler.short
|
5
|
+
#=> Gibbler::Digest.new("c8027100")
|
6
|
+
|
7
|
+
# can Gibbler::Digest#short
|
8
|
+
Gibbler::Digest.new("1234567890").short
|
9
|
+
#=> Gibbler::Digest.new("12345678")
|
10
|
+
|
11
|
+
# == is strict (only exact matches)
|
12
|
+
Gibbler::Digest.new("1234567890") != "12345678"
|
13
|
+
#=> true
|
14
|
+
|
15
|
+
# === is relaxed (allows partial matches)
|
16
|
+
Gibbler::Digest.new("1234567890") === "12345678"
|
17
|
+
#=> true
|
18
|
+
|
19
|
+
# supports base36 output
|
20
|
+
Gibbler::Digest.new("1234567890").base36
|
21
|
+
#=> 'zx2tc40'
|
22
|
+
|
23
|
+
# base36 works on digests too
|
24
|
+
"kimmy".gibbler.base36
|
25
|
+
#=> 'nd2w8270caslmly0ix3s8ruh0y8yjdt'
|
26
|
+
|
27
|
+
# base36 digests can be short too
|
28
|
+
"kimmy".gibbler.base36.short
|
29
|
+
#=> 'nd2w8270'
|
30
|
+
|
31
|
+
# to_s returns a string and can accept a base
|
32
|
+
"kimmy".gibbler.to_s(16)
|
33
|
+
#=> "kimmy".gibbler.base(16).to_s
|
34
|
+
|
35
|
+
# base takes a base
|
36
|
+
"kimmy".gibbler.base(17)
|
37
|
+
#=> '12gaabd69eg5b32gf69a7a021c22g977d4gf46d6'
|
38
|
+
|
39
|
+
# to_s can take a base
|
40
|
+
"kimmy".gibbler.to_s(36)
|
41
|
+
#=> "kimmy".gibbler.base36
|
data/try/10_basic_try.rb
ADDED
@@ -0,0 +1,130 @@
|
|
1
|
+
require 'gibbler'
|
2
|
+
|
3
|
+
#Gibbler.enable_debug
|
4
|
+
|
5
|
+
# include Gibbler raises exception
|
6
|
+
begin
|
7
|
+
a = Class.new
|
8
|
+
a.send :include, Gibbler
|
9
|
+
rescue RuntimeError
|
10
|
+
:success
|
11
|
+
end
|
12
|
+
#=> :success
|
13
|
+
|
14
|
+
# Symbol digests are consistent
|
15
|
+
:kimmy.gibbler
|
16
|
+
#=> '52be7494a602d85ff5d8a8ab4ffe7f1b171587df'
|
17
|
+
|
18
|
+
# String digests are consistent
|
19
|
+
'kimmy'.gibbler
|
20
|
+
#=> 'c8027100ecc54945ab15ddac529230e38b1ba6a1'
|
21
|
+
|
22
|
+
# String and Symbol return different digests
|
23
|
+
:kimmy.gibbler != "kimmy".gibbler
|
24
|
+
#=> true
|
25
|
+
|
26
|
+
# Class digests are consistent
|
27
|
+
Class.gibbler
|
28
|
+
#=> '25ac269ae3ef18cdb4143ad02ca315afb5026de9'
|
29
|
+
|
30
|
+
# Fixnum instance digests are consistent
|
31
|
+
1.gibbler
|
32
|
+
#=> 'a9cad665549bd22a4346fcf602d9d3c3b0482bbe'
|
33
|
+
|
34
|
+
# Bignum instance
|
35
|
+
100000000000.gibbler
|
36
|
+
#=> '608256db120251843843bba57e9b2c7adb7342aa'
|
37
|
+
|
38
|
+
# Empty Hash instance digests are consistent
|
39
|
+
Hash.new.gibbler
|
40
|
+
#=> '4fdcadc66a38feb9c57faf3c5a18d5e76a6d29bf'
|
41
|
+
|
42
|
+
# Populated Hash instance
|
43
|
+
{ :a => [1,2,3, [4,5,6]], :b => { :c => Class } }.gibbler
|
44
|
+
#=> "1d4b62e1e9f2c097b0cefb6877bf47c2015cdd21"
|
45
|
+
|
46
|
+
# Empty Array instance
|
47
|
+
Array.new.gibbler
|
48
|
+
#=> '48fda57c05684c9e5c3259557851943572183a21'
|
49
|
+
|
50
|
+
# Populated Array instance
|
51
|
+
[1, 2, :runtime, [3, "four", [Object, true]]].gibbler
|
52
|
+
#=> "3e1d79d113a409a96a13ca3879fc4c42027aa74b"
|
53
|
+
|
54
|
+
# Knows when a Hash has not changed
|
55
|
+
a = { :magic => true }
|
56
|
+
a.gibbler
|
57
|
+
a[:magic] = true
|
58
|
+
a.gibbled?
|
59
|
+
# => false
|
60
|
+
|
61
|
+
# Knows when a Hash has changed
|
62
|
+
a = { :magic => true }
|
63
|
+
a.gibbler
|
64
|
+
a[:magic] = false
|
65
|
+
a.gibbled?
|
66
|
+
#=> true
|
67
|
+
|
68
|
+
# Two Symbol digests don't cross streams
|
69
|
+
a, b = :something, :anything
|
70
|
+
a.gibbler
|
71
|
+
b.gibbler
|
72
|
+
[a.gibbler_cache.short, b.gibbler_cache.short]
|
73
|
+
#=> ["667ce086", "92d5f7cd"]
|
74
|
+
|
75
|
+
# Two String digests don't cross streams"
|
76
|
+
a, b = 'something', 'anything'
|
77
|
+
a.gibbler
|
78
|
+
b.gibbler
|
79
|
+
[a.gibbler_cache.short, b.gibbler_cache.short]
|
80
|
+
#=> ["ce0c7694", "c13b2f02"]
|
81
|
+
|
82
|
+
## DISABLED: If gibbler/history is required, there will be an
|
83
|
+
## additional attic_var (:gibbler_history), but only if the
|
84
|
+
## gibbler_history method has been called already (the history
|
85
|
+
## remains nil by default). The fix is not straightfroward and
|
86
|
+
## tests are not important anyway so disabling them is fine.
|
87
|
+
## Symbol has list of attic vars", [:gibbler_cache]
|
88
|
+
# Symbol.attic_vars
|
89
|
+
#end
|
90
|
+
#
|
91
|
+
## String has list of attic vars", [:gibbler_cache]
|
92
|
+
# String.attic_vars
|
93
|
+
#end
|
94
|
+
#
|
95
|
+
## Hash has list of attic vars", [:gibbler_cache]
|
96
|
+
# Hash.attic_vars
|
97
|
+
#end
|
98
|
+
|
99
|
+
# Freezing an object will update the digest
|
100
|
+
a = { :a => 1 }
|
101
|
+
pre = a.gibbler;
|
102
|
+
a[:a] = 2
|
103
|
+
post = a.freeze.gibbler
|
104
|
+
pre != post && post == a.gibbler_cache
|
105
|
+
#=> true
|
106
|
+
|
107
|
+
# works on arbitrary objects"
|
108
|
+
class ::FullHouse
|
109
|
+
include Gibbler::Complex
|
110
|
+
attr_accessor :roles
|
111
|
+
end
|
112
|
+
a = FullHouse.new
|
113
|
+
a.roles = [:jesse, :joey, :danny, :kimmy, :michelle, :dj, :stephanie]
|
114
|
+
a.gibbler
|
115
|
+
#=> "fa5f741275b6b27932537e1946042b0286286e1d"
|
116
|
+
|
117
|
+
# TODO: Update for Attic 0.4
|
118
|
+
# doesn't reveal @__gibbler_digest__ instance variable", false
|
119
|
+
a = {}
|
120
|
+
a.gibbler # We need to gibbler first so it sets a value to the instance var
|
121
|
+
val = RUBY_VERSION >= '1.9' ? :'@__gibbler_digest__' : '@__gibbler_digest__'
|
122
|
+
a.instance_variables.member? val
|
123
|
+
#=> false
|
124
|
+
|
125
|
+
# previous digest"
|
126
|
+
a = "kimmy"
|
127
|
+
a.gibbler
|
128
|
+
a.gibbler_cache
|
129
|
+
#=> 'c8027100ecc54945ab15ddac529230e38b1ba6a1'
|
130
|
+
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'gibbler'
|
2
|
+
|
3
|
+
# NOTE: JRuby requires that we use OpenSSL::Digest::SHA256
|
4
|
+
if Tryouts.sysinfo.vm == :java
|
5
|
+
require 'openssl'
|
6
|
+
Gibbler.digest_type = OpenSSL::Digest::SHA256
|
7
|
+
else
|
8
|
+
Gibbler.digest_type = Digest::SHA256
|
9
|
+
end
|
10
|
+
|
11
|
+
## A Symbol can gibbler
|
12
|
+
:anything.gibbler
|
13
|
+
#=> '754f87ca720ec256633a286d9270d68478850b2abd7b0ae65021cb769ae70c08'
|
14
|
+
|
15
|
+
## Class can gibbler
|
16
|
+
Class.gibbler
|
17
|
+
#=> 'd345c0afb4e8da0133a3946d3bd9b2622b0acdd8d6cc1237470cc637a9e4777f'
|
18
|
+
|
19
|
+
## TrueClass can gibbler
|
20
|
+
TrueClass.gibbler
|
21
|
+
#=> 'b7b874a9bff7825caa57750a900652354ac601b77497b694d313f658c69d25b4'
|
22
|
+
|
23
|
+
# Empty Hash instance
|
24
|
+
{}.gibbler
|
25
|
+
#=> '88d2bcbd68ce593fd2e0e06f276f7301357516291b95c0c53038e61a9bf091e5'
|
26
|
+
|
27
|
+
Gibbler.digest_type = Digest::SHA1
|
28
|
+
|
@@ -0,0 +1,78 @@
|
|
1
|
+
require 'gibbler'
|
2
|
+
|
3
|
+
## true can gibbler
|
4
|
+
true.gibbler
|
5
|
+
#=> 'f2b0150c84c5c834406ec9cdec989a0fa938b4ad'
|
6
|
+
|
7
|
+
# false can gibbler
|
8
|
+
false.gibbler
|
9
|
+
#=> 'abee839edf5f9c101c505c28987ca35c31c7fc8d'
|
10
|
+
|
11
|
+
# TrueClass can gibbler
|
12
|
+
TrueClass.gibbler
|
13
|
+
#=> '583fb214ec50d2c4a123cc52de0c65e801d13516'
|
14
|
+
|
15
|
+
# FalseClass can gibbler
|
16
|
+
FalseClass.gibbler
|
17
|
+
#=> '11f262be475ddf38a25888e9f6ec82f384a7c58b'
|
18
|
+
|
19
|
+
# Class can gibbler
|
20
|
+
Class.gibbler
|
21
|
+
#=> '25ac269ae3ef18cdb4143ad02ca315afb5026de9'
|
22
|
+
|
23
|
+
# Object can gibbler
|
24
|
+
Object.gibbler
|
25
|
+
#=> '5620e4a8b10ec6830fece61d33f5d3e9a349b4c2'
|
26
|
+
|
27
|
+
# Class instance can gibbler
|
28
|
+
Class.new.gibbler
|
29
|
+
#=> '083feec632e6cd5347e3fb3c7048365c3a0d710e'
|
30
|
+
|
31
|
+
# Module can gibbler
|
32
|
+
Module.gibbler
|
33
|
+
#=> '7295241e929ffd7cc974cf8d4481291e070937fc'
|
34
|
+
|
35
|
+
# Module instance can gibbler
|
36
|
+
Module.new.gibbler
|
37
|
+
#=> '6b5a192fd377dfc5c2828a3ad6105b68b6db33d5'
|
38
|
+
|
39
|
+
# Proc can gibbler"
|
40
|
+
Proc.gibbler
|
41
|
+
#=> '8640f7abcbcb80e3825ed827bf36819e26119e16'
|
42
|
+
|
43
|
+
# Range instance (..) can gibbler
|
44
|
+
(1..100).gibbler
|
45
|
+
#=> '5450635218fd16e594976e87abd0955529e28248'
|
46
|
+
|
47
|
+
# Range ... is different than ..
|
48
|
+
(1...100).gibbler != (1..100).gibbler
|
49
|
+
#=> true
|
50
|
+
|
51
|
+
# Range instance with Floats can gibbler
|
52
|
+
(0.1...1.5).gibbler
|
53
|
+
#=> '9d3cd5a21c17cfa0b4bb685730bd07994c486ba2'
|
54
|
+
|
55
|
+
# Range instance with one Float can gibbler
|
56
|
+
(0.1..1).gibbler
|
57
|
+
#=> 'c725659ca0f3fa3c9ab807bb2db4b718e2dca042'
|
58
|
+
|
59
|
+
# Range (..) doesn't equal range (...)"
|
60
|
+
('a'..'e').gibbler != ('a'...'e').gibbler
|
61
|
+
#=> true
|
62
|
+
|
63
|
+
# nil has a gibbler
|
64
|
+
nil.gibbler
|
65
|
+
#=> '06fdf26b2a64e90cd35ea9162d9cc48c9f6bb13c'
|
66
|
+
|
67
|
+
# Module can gibbler
|
68
|
+
Module.gibbler
|
69
|
+
#=> '7295241e929ffd7cc974cf8d4481291e070937fc'
|
70
|
+
|
71
|
+
# Module instance can gibbler
|
72
|
+
Module.new.gibbler
|
73
|
+
#=> '6b5a192fd377dfc5c2828a3ad6105b68b6db33d5'
|
74
|
+
|
75
|
+
# Class can gibbler
|
76
|
+
Class.gibbler
|
77
|
+
#=> '25ac269ae3ef18cdb4143ad02ca315afb5026de9'
|
78
|
+
|
data/try/15_file_try.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'tempfile'
|
2
|
+
require 'gibbler'
|
3
|
+
|
4
|
+
@tempfile = "tryouts-9000-awesome.txt"
|
5
|
+
|
6
|
+
## File can gibbler
|
7
|
+
file = File.new(File.join('.', 'CHANGES.txt'))
|
8
|
+
file.gibbler
|
9
|
+
#=> 'c052e87bd0acb7e08c98dad7f8b09b4382a08ef6'
|
10
|
+
|
11
|
+
## Gibbler is different for each path
|
12
|
+
file1 = File.new(File.join('.', 'CHANGES.txt'))
|
13
|
+
file2 = File.new(File.join('.', 'README.rdoc'))
|
14
|
+
file1.gibbler == file2.gibbler
|
15
|
+
#=> false
|
16
|
+
|
17
|
+
# TempFile can gibbler
|
18
|
+
Tempfile.new('gibbler').respond_to? :gibbler
|
19
|
+
#=> true
|
20
|
+
|
21
|
+
# TempFile digests change
|
22
|
+
Tempfile.new('gibbler').gibbler != Tempfile.new('gibbler').gibbler
|
23
|
+
#=> true
|
24
|
+
|
25
|
+
# File doesn't care about file contents
|
26
|
+
f = File.open @tempfile, 'w'
|
27
|
+
f.puts "World's Finest Number: " << "#{rand}"
|
28
|
+
f.close
|
29
|
+
File.new(@tempfile).gibbler
|
30
|
+
#=> '6d93f752fc23f36bffa5ddf9ee97d04be82efbdb'
|
31
|
+
|
32
|
+
## JRuby doesn't like to use File.new with directories
|
33
|
+
###=> '92cbcb7de73d7748b28d9e911f461013de34410f'
|
34
|
+
### "File gibbler cares about trailing slash (/tmp/)", File.new(__FILE__)
|
35
|
+
|
36
|
+
File.unlink @tempfile if File.exists? @tempfile
|
data/try/16_uri_try.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'uri'
|
2
|
+
require 'gibbler'
|
3
|
+
|
4
|
+
# "URI::HTTP can gibbler"
|
5
|
+
uri = URI.parse "http://localhost:3114/spaceship"
|
6
|
+
uri.gibbler
|
7
|
+
#=> "9efe60a5db66aecf9b5fb8655b0bab0fcc7bd0c5"
|
8
|
+
|
9
|
+
# "URI::HTTPS can gibbler"
|
10
|
+
uri = URI.parse "https://localhost:3114/spaceship"
|
11
|
+
uri.gibbler
|
12
|
+
#=> "b75d3c34e60d6feafa796ddbb51e45710f6b106d"
|
13
|
+
|
14
|
+
# "URI::HTTP is trailing slash sensitive"
|
15
|
+
uri = URI.parse "http://localhost:3114/spaceship/"
|
16
|
+
uri.gibbler
|
17
|
+
#=> "191b0072b95ca0c79ed75e6deb5b28562dd9e5b9"
|
18
|
+
|
19
|
+
# "URI::Generic can gibbler"
|
20
|
+
uri = URI.parse "localhost:3114/spaceship"
|
21
|
+
uri.gibbler
|
22
|
+
#=> "d378372934326947113489d1f36f4853bef90a65"
|
23
|
+
|
24
|
+
# "URI::FTP can gibbler"
|
25
|
+
uri = URI.parse "ftp://localhost:3114/spaceship"
|
26
|
+
uri.gibbler
|
27
|
+
#=> "9d0543b31afebac9e8d38c56a0cf12070779f790"
|
28
|
+
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'gibbler'
|
2
|
+
|
3
|
+
# arbitrary objects can specify instance variables to gibbler
|
4
|
+
class ::FullHouse
|
5
|
+
include Gibbler::Complex
|
6
|
+
attr_accessor :roles
|
7
|
+
attr_accessor :stamp
|
8
|
+
attr_accessor :ready
|
9
|
+
gibbler :roles
|
10
|
+
end
|
11
|
+
a = FullHouse.new
|
12
|
+
a.roles = [:jesse, :joey, :danny, :kimmy, :michelle, :dj, :stephanie]
|
13
|
+
a.stamp = Time.now
|
14
|
+
a.ready = true
|
15
|
+
a.gibbler
|
16
|
+
#=> "fa5f741275b6b27932537e1946042b0286286e1d"
|
17
|
+
|
18
|
+
# arbitrary objects can append more instance variables later on
|
19
|
+
class ::FullHouse
|
20
|
+
gibbler :stamp, :ready
|
21
|
+
end
|
22
|
+
a = FullHouse.new
|
23
|
+
a.roles = [:jesse, :joey, :danny, :kimmy, :michelle, :dj, :stephanie]
|
24
|
+
a.stamp = Time.parse('2009-08-25 16:43:53 UTC')
|
25
|
+
a.ready = true
|
26
|
+
a.gibbler
|
27
|
+
#=> "fbdce0d97a856e7106bec418d585c914914b8aa5"
|
data/try/18_proc_try.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'gibbler'
|
2
|
+
|
3
|
+
class ::MyProc < Proc; end
|
4
|
+
|
5
|
+
## Proc.new can gibbler
|
6
|
+
Proc.new() { }.gibbler
|
7
|
+
#=> '12075835e94be34438376cd7a54c8db7e746f15d'
|
8
|
+
|
9
|
+
# Proc can gibbler
|
10
|
+
Proc.gibbler
|
11
|
+
#=> '8640f7abcbcb80e3825ed827bf36819e26119e16'
|
12
|
+
|
13
|
+
## proc can gibbler
|
14
|
+
proc {}.gibbler
|
15
|
+
#=> '12075835e94be34438376cd7a54c8db7e746f15d'
|
16
|
+
|
17
|
+
# lambda can gibbler
|
18
|
+
lambda {}.gibbler
|
19
|
+
#=> '12075835e94be34438376cd7a54c8db7e746f15d'
|
20
|
+
|
21
|
+
# lambda gibbler is not aware of arity
|
22
|
+
lambda { |v| }.gibbler
|
23
|
+
#=> '12075835e94be34438376cd7a54c8db7e746f15d'
|
24
|
+
|
25
|
+
# proc gibbler is not aware of arity
|
26
|
+
proc { |v| }.gibbler
|
27
|
+
#=> '12075835e94be34438376cd7a54c8db7e746f15d'
|
28
|
+
|
29
|
+
# Proc gibbler is not aware of proc payload"
|
30
|
+
proc { |v| 1; }.gibbler
|
31
|
+
#=> '12075835e94be34438376cd7a54c8db7e746f15d'
|
32
|
+
|
33
|
+
# MyProc has a different digest
|
34
|
+
MyProc.new() { }.gibbler
|
35
|
+
#=> "c979a45653acaddcb9c1581a7de49c94ac96e128"
|
data/try/20_time_try.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'date'
|
2
|
+
require 'gibbler'
|
3
|
+
|
4
|
+
# "Date instance can gibbler
|
5
|
+
Date.parse('2009-08-25').gibbler
|
6
|
+
#=> 'c8403fc35481fdf7f6f4a0e7262b1c9610bdebaa'
|
7
|
+
|
8
|
+
# "Time instance can gibbler
|
9
|
+
Time.parse('2009-08-25 16:43:53 UTC').gibbler
|
10
|
+
#=> '73b4635fc63b8dd32b622776201f98a37478be90'
|
11
|
+
|
12
|
+
# "Time instance can gibbler with single digit values
|
13
|
+
Time.parse('2009-01-01 01:01:01 UTC').gibbler
|
14
|
+
#=> 'd35546d6517c02f2a219ecfa2261a5274d217cb7'
|
15
|
+
|
16
|
+
# "DateTime instance can gibbler
|
17
|
+
DateTime.parse('2009-08-25T17:00:40+00:00').gibbler
|
18
|
+
#=> 'ad64c7694a50becf55c53485dce5d0013ff65785'
|
19
|
+
|
20
|
+
# "Time digest is based on UTC
|
21
|
+
Time.parse('2009-08-25 16:43:53 UTC').gibbler
|
22
|
+
#=> Time.parse('2009-08-25 12:43:53 -04:00').gibbler
|
23
|
+
|
24
|
+
# "DateTime digest is based on UTC
|
25
|
+
DateTime.parse('2009-08-25T17:00:40+00:00').gibbler
|
26
|
+
#=> DateTime.parse('2009-08-25T13:00:40-04:00').gibbler
|
27
|
+
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'uri'
|
2
|
+
require 'gibbler'
|
3
|
+
|
4
|
+
# "Can set a sexy global secret
|
5
|
+
Gibbler.secret = 'kimmy'.gibbler
|
6
|
+
Gibbler.secret
|
7
|
+
#=> "c8027100ecc54945ab15ddac529230e38b1ba6a1"
|
8
|
+
|
9
|
+
# "When the secret is set, digests are different
|
10
|
+
'kimmy'.gibbler
|
11
|
+
#=> "62e645351505cb89a0b06a0f5df8383ea754f71d"
|
12
|
+
|
13
|
+
# "When the secret is set, digests are different (again)
|
14
|
+
Gibbler.secret = :kimmy.gibbler
|
15
|
+
'kimmy'.gibbler
|
16
|
+
#=> "e5f8a3d8e4a2dc99717984726efc910dab0c18f4"
|
17
|
+
|
18
|
+
# "Reset the secret back to nil
|
19
|
+
Gibbler.secret = nil
|
20
|
+
'kimmy'.gibbler
|
21
|
+
#=> "c8027100ecc54945ab15ddac529230e38b1ba6a1"
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'gibbler'
|
2
|
+
require 'gibbler/history'
|
3
|
+
|
4
|
+
# can convert short digest into long
|
5
|
+
a = { :magic => :original }
|
6
|
+
g = a.gibbler_commit.short
|
7
|
+
a.gibbler_find_long(g)
|
8
|
+
#=> "d7049916ddb25e6cc438b1028fb957e5139f9910"
|
9
|
+
|
10
|
+
# can return most recent stamp
|
11
|
+
a = { :magic => :original }
|
12
|
+
a.gibbler_commit
|
13
|
+
a.gibbler_stamp.class
|
14
|
+
#=> Time
|
15
|
+
|
16
|
+
# can return history
|
17
|
+
a = { :magic => :original }
|
18
|
+
a.gibbler_commit
|
19
|
+
a[:magic] = :changed
|
20
|
+
a.gibbler_commit
|
21
|
+
a.gibbler_history
|
22
|
+
#=> ["d7049916ddb25e6cc438b1028fb957e5139f9910", "0b11c377fccd44554a601e5d2b135c46dc1c4cb1"]
|
23
|
+
|
24
|
+
# can return history (short)
|
25
|
+
a = { :magic => :original }
|
26
|
+
a.gibbler_commit
|
27
|
+
a[:magic] = :changed
|
28
|
+
a.gibbler_commit
|
29
|
+
a.gibbler_history(:short)
|
30
|
+
#=> ["d7049916", "0b11c377"]
|
@@ -0,0 +1,71 @@
|
|
1
|
+
require 'gibbler'
|
2
|
+
require 'gibbler/history'
|
3
|
+
|
4
|
+
class ::Hash
|
5
|
+
include Gibbler::History
|
6
|
+
end
|
7
|
+
|
8
|
+
## "doesn't reveal self.__gibbler_history instance variable",
|
9
|
+
a = {}
|
10
|
+
a.gibbler # We need to gibbler first so it sets a value to the instance var
|
11
|
+
val = RUBY_VERSION >= '1.9' ? :'self.__gibbler_history' : 'self.__gibbler_history'
|
12
|
+
a.instance_variables.member? val
|
13
|
+
#=> false
|
14
|
+
|
15
|
+
# can take a Hash snapshot
|
16
|
+
a = { :magic => :original }
|
17
|
+
a.gibbler_commit
|
18
|
+
#=> 'd7049916ddb25e6cc438b1028fb957e5139f9910'
|
19
|
+
|
20
|
+
# "return a Hash history"
|
21
|
+
a = { :magic => :original }
|
22
|
+
a.gibbler_commit
|
23
|
+
a[:magic] = :updated
|
24
|
+
a.gibbler_commit
|
25
|
+
a.gibbler_history
|
26
|
+
#=> ['d7049916ddb25e6cc438b1028fb957e5139f9910', 'b668098e16d08898532bf3aa33ce2253a3a4150e']
|
27
|
+
|
28
|
+
# "can revert Hash"
|
29
|
+
a = { :magic => :original }
|
30
|
+
a.gibbler_commit
|
31
|
+
a[:magic] = :updated
|
32
|
+
a.gibbler_revert!
|
33
|
+
#=> 'd7049916ddb25e6cc438b1028fb957e5139f9910'
|
34
|
+
|
35
|
+
# "knows a valid gibble"
|
36
|
+
a = { :magic => :original }
|
37
|
+
a.gibbler_commit
|
38
|
+
a.gibbler_valid? 'd7049916ddb25e6cc438b1028fb957e5139f9910'
|
39
|
+
#=> true
|
40
|
+
|
41
|
+
# "knows an invalid gibble"
|
42
|
+
a = { :magic => :original }
|
43
|
+
a.gibbler_commit
|
44
|
+
a.gibbler_valid? '2222222222222222222222222222222222222222'
|
45
|
+
#=> false
|
46
|
+
|
47
|
+
# "can revert to any valid gibble"
|
48
|
+
a = { :magic => :original }
|
49
|
+
a.gibbler_commit
|
50
|
+
a[:magic] = :updated
|
51
|
+
a.gibbler_commit
|
52
|
+
a[:magic] = :changed
|
53
|
+
a.gibbler_commit
|
54
|
+
a.gibbler_revert! 'd7049916ddb25e6cc438b1028fb957e5139f9910'
|
55
|
+
a
|
56
|
+
#=> Hash[:magic => :original]
|
57
|
+
|
58
|
+
# "revert does nothing if digest is the same as current one"
|
59
|
+
a = { :magic => :original }
|
60
|
+
a.gibbler_commit
|
61
|
+
a.gibbler_revert!
|
62
|
+
a
|
63
|
+
#=> Hash[:magic => :original]
|
64
|
+
|
65
|
+
# "can revert using short gibbler_commit"
|
66
|
+
a = { :magic => :original }
|
67
|
+
a.gibbler_commit
|
68
|
+
a[:magic] = :updated
|
69
|
+
a.gibbler_revert! 'd7049916'
|
70
|
+
#=> 'd7049916ddb25e6cc438b1028fb957e5139f9910'
|
71
|
+
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'gibbler'
|
2
|
+
require 'gibbler/history'
|
3
|
+
|
4
|
+
class Array
|
5
|
+
include Gibbler::History
|
6
|
+
end
|
7
|
+
|
8
|
+
# "can take a Array snapshot"
|
9
|
+
a = [:jesse]
|
10
|
+
a.gibbler_commit
|
11
|
+
#=> 'd95fcabb498ae282f356eba63da541e4f72c6efa'
|
12
|
+
|
13
|
+
# "return an Array history"
|
14
|
+
a = [:jesse]
|
15
|
+
a.gibbler_commit
|
16
|
+
a << :joey
|
17
|
+
a.gibbler_commit
|
18
|
+
a.gibbler_history
|
19
|
+
#=> ['d95fcabb498ae282f356eba63da541e4f72c6efa', 'eebcb2e84e828b1a7207af4d588cf41fd4c6393a']
|
20
|
+
|
21
|
+
# "can revert Array"
|
22
|
+
a = [:jesse]
|
23
|
+
a.gibbler_commit
|
24
|
+
a << :joey
|
25
|
+
a.gibbler_revert!
|
26
|
+
#=> 'd95fcabb498ae282f356eba63da541e4f72c6efa'
|
27
|
+
|
28
|
+
# Raises exception when no history
|
29
|
+
begin
|
30
|
+
a = [:jesse]
|
31
|
+
a.gibbler_revert!
|
32
|
+
rescue Gibbler::NoHistory
|
33
|
+
:success
|
34
|
+
end
|
35
|
+
#=> :success
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'gibbler'
|
2
|
+
require 'gibbler/history'
|
3
|
+
|
4
|
+
class String
|
5
|
+
include Gibbler::History
|
6
|
+
end
|
7
|
+
|
8
|
+
# "can take a String snapshot"
|
9
|
+
a = "kimmy"
|
10
|
+
a.gibbler_commit
|
11
|
+
#=> 'c8027100ecc54945ab15ddac529230e38b1ba6a1'
|
12
|
+
|
13
|
+
# "return a String history"
|
14
|
+
a = "kimmy"
|
15
|
+
a.gibbler_commit
|
16
|
+
a << " gibbler"
|
17
|
+
a.gibbler_commit
|
18
|
+
a.gibbler_history
|
19
|
+
#=> ['c8027100ecc54945ab15ddac529230e38b1ba6a1', '692c05d3186baf2da36e87b7bc5fe53ef13b902e']
|
20
|
+
|
21
|
+
# "can revert String"
|
22
|
+
a = "kimmy"
|
23
|
+
a.gibbler_commit
|
24
|
+
a << " gibbler"
|
25
|
+
a.gibbler
|
26
|
+
a.gibbler_revert!
|
27
|
+
#=> 'c8027100ecc54945ab15ddac529230e38b1ba6a1'
|
28
|
+
|
29
|
+
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'gibbler'
|
2
|
+
require 'gibbler/history'
|
3
|
+
|
4
|
+
class ::FullHouse
|
5
|
+
include Gibbler::Complex
|
6
|
+
include Gibbler::History
|
7
|
+
attr_accessor :roles
|
8
|
+
end
|
9
|
+
|
10
|
+
# "can take a FullHouse snapshot"
|
11
|
+
a = FullHouse.new
|
12
|
+
a.gibbler_commit
|
13
|
+
#=> '4192d4cb59975813f117a51dcd4454ac16df6703'
|
14
|
+
|
15
|
+
# "return a FullHouse history"
|
16
|
+
a = FullHouse.new
|
17
|
+
a.gibbler_commit
|
18
|
+
a.roles = [:jesse]
|
19
|
+
a.gibbler_commit
|
20
|
+
a.gibbler_history
|
21
|
+
#=> ['4192d4cb59975813f117a51dcd4454ac16df6703', '05219bdee8ec6300b579f2ba8ce55d851d10928b']
|
22
|
+
|
23
|
+
# "can revert FullHouse"
|
24
|
+
a = FullHouse.new
|
25
|
+
a.gibbler_commit
|
26
|
+
a.roles = [:jesse]
|
27
|
+
a.gibbler
|
28
|
+
a.gibbler_revert!
|
29
|
+
#=> '4192d4cb59975813f117a51dcd4454ac16df6703'
|
30
|
+
|
31
|
+
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'gibbler'
|
2
|
+
require 'gibbler/history'
|
3
|
+
|
4
|
+
|
5
|
+
# "raises exception when reverting to unknown gibble"
|
6
|
+
begin
|
7
|
+
a = {}
|
8
|
+
a.gibbler_commit
|
9
|
+
a.gibbler_revert! '2222222222222222222222222222222222222222'
|
10
|
+
rescue Gibbler::BadDigest
|
11
|
+
:success
|
12
|
+
end
|
13
|
+
#=> :success
|
14
|
+
|
15
|
+
# "raises exception when reverting and there's no history"
|
16
|
+
begin
|
17
|
+
a = []
|
18
|
+
a.gibbler_revert!
|
19
|
+
rescue Gibbler::NoHistory
|
20
|
+
:success
|
21
|
+
end
|
22
|
+
#=> :success
|
23
|
+
|
24
|
+
# "raises exception when reverting an unsupported object"
|
25
|
+
begin
|
26
|
+
:kimmy.gibbler_revert!
|
27
|
+
rescue NoMethodError
|
28
|
+
:success
|
29
|
+
end
|
30
|
+
#=> :success
|
31
|
+
|
@@ -0,0 +1,82 @@
|
|
1
|
+
## DISABLED. Tryouts 2.0 doesn't do performance
|
2
|
+
##
|
3
|
+
#
|
4
|
+
# library :gibbler, File.dirname(__FILE__), '..', 'lib'
|
5
|
+
# group "Performance"
|
6
|
+
#
|
7
|
+
# tryouts "Speed", :benchmark do
|
8
|
+
# # NOTE: gibbler is slower when history is enabled.
|
9
|
+
# drill "Setup variables" do
|
10
|
+
# @@array = (1..1000).map { rand }
|
11
|
+
# values = (1..1000).map { rand }
|
12
|
+
# zipped = @@array.zip(values)
|
13
|
+
# @@hash = Hash[*zipped]
|
14
|
+
# end
|
15
|
+
#
|
16
|
+
# drill "Array#hash", 5 do
|
17
|
+
# @@array.hash
|
18
|
+
# end
|
19
|
+
#
|
20
|
+
#
|
21
|
+
# # dream :mean, 0.21
|
22
|
+
# drill "Array#gibbler", 5 do
|
23
|
+
# @@array.gibbler
|
24
|
+
# end
|
25
|
+
#
|
26
|
+
# drill "Hash#hash", 5 do
|
27
|
+
# @@hash.hash
|
28
|
+
# end
|
29
|
+
#
|
30
|
+
# # dream :mean, 1.4
|
31
|
+
# drill "Hash#gibbler", 5 do
|
32
|
+
# @@hash.gibbler
|
33
|
+
# end
|
34
|
+
#
|
35
|
+
# end
|
36
|
+
#
|
37
|
+
# repetitions = 10 # at 100_000 hash shows errors
|
38
|
+
# sample_size = 1..100
|
39
|
+
#
|
40
|
+
# tryouts "Uniqueness", :api do
|
41
|
+
#
|
42
|
+
# drill "Array#hash, all unique", 0 do
|
43
|
+
# seen = []
|
44
|
+
# repetitions.times do
|
45
|
+
# srand
|
46
|
+
# seen << ((sample_size).map { rand }).hash
|
47
|
+
# end
|
48
|
+
# seen.size - seen.uniq.size
|
49
|
+
# end
|
50
|
+
#
|
51
|
+
# drill "Hash#hash, all unique", 0 do
|
52
|
+
# seen = []
|
53
|
+
# repetitions.times do
|
54
|
+
# srand
|
55
|
+
# seen << Hash[*(sample_size).map { rand }.zip((sample_size).map { rand })].hash
|
56
|
+
# end
|
57
|
+
# seen.size - seen.uniq.size
|
58
|
+
# end
|
59
|
+
#
|
60
|
+
# drill "Array#gibbler, all unique", 0 do
|
61
|
+
# seen = []
|
62
|
+
# repetitions.times do
|
63
|
+
# srand
|
64
|
+
# seen << ((sample_size).map { rand }).gibbler
|
65
|
+
# end
|
66
|
+
# seen.size - seen.uniq.size
|
67
|
+
# end
|
68
|
+
#
|
69
|
+
# drill "Hash#gibbler, all unique", 0 do
|
70
|
+
# seen = []
|
71
|
+
# repetitions.times do
|
72
|
+
# srand
|
73
|
+
# seen << Hash[*(sample_size).map { rand }.zip((sample_size).map { rand })].gibbler
|
74
|
+
# end
|
75
|
+
# seen.size - seen.uniq.size
|
76
|
+
# end
|
77
|
+
#
|
78
|
+
#
|
79
|
+
#
|
80
|
+
#
|
81
|
+
#
|
82
|
+
# end
|
data/try/90_alias_try.rb
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'gibbler/aliases'
|
2
|
+
require 'gibbler/history'
|
3
|
+
|
4
|
+
|
5
|
+
# "has digest"
|
6
|
+
:kimmy.gibbler == :kimmy.digest
|
7
|
+
#=> true
|
8
|
+
|
9
|
+
# "has digest_cache", true
|
10
|
+
a = :kimmy.gibbler
|
11
|
+
a.gibbler_cache == a.digest_cache
|
12
|
+
#=> true
|
13
|
+
|
14
|
+
# "has changed?"
|
15
|
+
a = "kimmy"
|
16
|
+
a.digest
|
17
|
+
a << '+ dj'
|
18
|
+
a.gibbled?
|
19
|
+
#=> true
|
20
|
+
|
21
|
+
# "can convert short digest into long"
|
22
|
+
a = { :magic => :original }
|
23
|
+
g = a.commit.short
|
24
|
+
a.find_long g
|
25
|
+
#=> "d7049916ddb25e6cc438b1028fb957e5139f9910"
|
26
|
+
|
27
|
+
# "can return most recent stamp"
|
28
|
+
a = { :magic => :original }
|
29
|
+
a.commit
|
30
|
+
a.stamp.class
|
31
|
+
#=> Time
|
32
|
+
|
33
|
+
# "can return history"
|
34
|
+
a = { :magic => :original }
|
35
|
+
a.commit
|
36
|
+
a[:magic] = :changed
|
37
|
+
a.commit
|
38
|
+
a.history
|
39
|
+
#=> ["d7049916ddb25e6cc438b1028fb957e5139f9910", "0b11c377fccd44554a601e5d2b135c46dc1c4cb1"]
|
40
|
+
|
41
|
+
# "can return history (short)"
|
42
|
+
a = { :magic => :original }
|
43
|
+
a.commit
|
44
|
+
a[:magic] = :changed
|
45
|
+
a.commit
|
46
|
+
a.history(:short)
|
47
|
+
#=> ["d7049916", "0b11c377"]
|
metadata
CHANGED
@@ -1,7 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gibbler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
hash: 53
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 8
|
9
|
+
- 5
|
10
|
+
version: 0.8.5
|
5
11
|
platform: ruby
|
6
12
|
authors:
|
7
13
|
- Delano Mandelbaum
|
@@ -9,19 +15,25 @@ autorequire:
|
|
9
15
|
bindir: bin
|
10
16
|
cert_chain: []
|
11
17
|
|
12
|
-
date: 2010-
|
18
|
+
date: 2010-12-23 00:00:00 -05:00
|
13
19
|
default_executable:
|
14
20
|
dependencies:
|
15
21
|
- !ruby/object:Gem::Dependency
|
16
22
|
name: attic
|
17
|
-
|
18
|
-
|
19
|
-
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
20
26
|
requirements:
|
21
27
|
- - ">="
|
22
28
|
- !ruby/object:Gem::Version
|
29
|
+
hash: 15
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
- 4
|
33
|
+
- 0
|
23
34
|
version: 0.4.0
|
24
|
-
|
35
|
+
type: :runtime
|
36
|
+
version_requirements: *id001
|
25
37
|
description: "Gibbler: Git-like hashes for Ruby objects"
|
26
38
|
email: delano@solutious.com
|
27
39
|
executables: []
|
@@ -29,47 +41,70 @@ executables: []
|
|
29
41
|
extensions: []
|
30
42
|
|
31
43
|
extra_rdoc_files:
|
32
|
-
- README.rdoc
|
33
44
|
- LICENSE.txt
|
45
|
+
- README.rdoc
|
34
46
|
files:
|
35
47
|
- CHANGES.txt
|
36
48
|
- LICENSE.txt
|
37
49
|
- README.rdoc
|
38
50
|
- Rakefile
|
51
|
+
- VERSION.yml
|
39
52
|
- gibbler.gemspec
|
40
53
|
- lib/gibbler.rb
|
41
54
|
- lib/gibbler/aliases.rb
|
42
55
|
- lib/gibbler/history.rb
|
43
56
|
- lib/gibbler/mixins.rb
|
57
|
+
- try/01_mixins_try.rb
|
58
|
+
- try/02_compat_try.rb
|
59
|
+
- try/05_gibbler_digest_try.rb
|
60
|
+
- try/10_basic_try.rb
|
61
|
+
- try/11_basic_sha256_try.rb
|
62
|
+
- try/14_extended_try.rb
|
63
|
+
- try/15_file_try.rb
|
64
|
+
- try/16_uri_try.rb
|
65
|
+
- try/17_complex_object_try.rb
|
66
|
+
- try/18_proc_try.rb
|
67
|
+
- try/20_time_try.rb
|
68
|
+
- try/30_secret_try.rb
|
69
|
+
- try/50_history_try.rb
|
70
|
+
- try/51_hash_history_try.rb
|
71
|
+
- try/52_array_history_try.rb
|
72
|
+
- try/53_string_history_try.rb
|
73
|
+
- try/57_arbitrary_history_try.rb
|
74
|
+
- try/59_history_exceptions_try.rb
|
75
|
+
- try/80_performance_try.rb
|
76
|
+
- try/90_alias_try.rb
|
44
77
|
has_rdoc: true
|
45
78
|
homepage: http://github.com/delano/gibbler
|
46
79
|
licenses: []
|
47
80
|
|
48
81
|
post_install_message:
|
49
82
|
rdoc_options:
|
50
|
-
- --
|
51
|
-
- --title
|
52
|
-
- "Gibbler: Git-like hashes for Ruby objects"
|
53
|
-
- --main
|
54
|
-
- README.rdoc
|
83
|
+
- --charset=UTF-8
|
55
84
|
require_paths:
|
56
85
|
- lib
|
57
86
|
required_ruby_version: !ruby/object:Gem::Requirement
|
87
|
+
none: false
|
58
88
|
requirements:
|
59
89
|
- - ">="
|
60
90
|
- !ruby/object:Gem::Version
|
91
|
+
hash: 3
|
92
|
+
segments:
|
93
|
+
- 0
|
61
94
|
version: "0"
|
62
|
-
version:
|
63
95
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
96
|
+
none: false
|
64
97
|
requirements:
|
65
98
|
- - ">="
|
66
99
|
- !ruby/object:Gem::Version
|
100
|
+
hash: 3
|
101
|
+
segments:
|
102
|
+
- 0
|
67
103
|
version: "0"
|
68
|
-
version:
|
69
104
|
requirements: []
|
70
105
|
|
71
106
|
rubyforge_project: gibbler
|
72
|
-
rubygems_version: 1.3.
|
107
|
+
rubygems_version: 1.3.7
|
73
108
|
signing_key:
|
74
109
|
specification_version: 3
|
75
110
|
summary: "Gibbler: Git-like hashes for Ruby objects"
|