thrash 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/thrash/thrash.rb +8 -0
- data/lib/thrash/version.rb +1 -1
- data/readme.md +2 -2
- data/thrash.gemspec +55 -0
- metadata +3 -2
data/lib/thrash/thrash.rb
CHANGED
@@ -6,11 +6,17 @@ class Thrash
|
|
6
6
|
create_buffer!
|
7
7
|
end
|
8
8
|
|
9
|
+
# add object to bucket
|
10
|
+
# check if bucket is full and if it is
|
11
|
+
# write out and flush
|
9
12
|
def add(bucket, obj)
|
10
13
|
@buffer[bucket] << obj
|
11
14
|
check_and_write bucket
|
12
15
|
end
|
13
16
|
|
17
|
+
# I'm not sure which one to use
|
18
|
+
alias :write :add
|
19
|
+
|
14
20
|
# write and flush remaining buckets
|
15
21
|
def finalize
|
16
22
|
@buffer.each_key do |bucket|
|
@@ -22,6 +28,8 @@ class Thrash
|
|
22
28
|
|
23
29
|
private
|
24
30
|
|
31
|
+
# instantiates a new buffer which for now is
|
32
|
+
# just a hash
|
25
33
|
def create_buffer!
|
26
34
|
@buffer = Hash.new { |h, k| h[k] = Array.new }
|
27
35
|
end
|
data/lib/thrash/version.rb
CHANGED
data/readme.md
CHANGED
@@ -6,8 +6,8 @@ Randomly write to many, many files. Inspired by desperation.
|
|
6
6
|
|
7
7
|
thrasher = Thrash.new
|
8
8
|
|
9
|
-
|
10
|
-
thrasher
|
9
|
+
1_000_000.times do |x|
|
10
|
+
thrasher.add "thrash-#{(0..10000).to_a.sample}", ">:|\n"
|
11
11
|
end
|
12
12
|
|
13
13
|
thrasher.finalize
|
data/thrash.gemspec
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = "thrash"
|
8
|
+
s.version = "1.0.1"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Austin G. Davis-Richardson"]
|
12
|
+
s.date = "2012-10-23"
|
13
|
+
s.description = "Randomly write to many, many files using an in-memory buffer"
|
14
|
+
s.email = "harekrishna@gmail.com"
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE.txt"
|
17
|
+
]
|
18
|
+
s.files = [
|
19
|
+
".rspec",
|
20
|
+
"Gemfile",
|
21
|
+
"LICENSE.txt",
|
22
|
+
"Rakefile",
|
23
|
+
"lib/thrash.rb",
|
24
|
+
"lib/thrash/thrash.rb",
|
25
|
+
"lib/thrash/version.rb",
|
26
|
+
"readme.md",
|
27
|
+
"spec/spec_helper.rb",
|
28
|
+
"spec/thrash_spec.rb",
|
29
|
+
"thrash.gemspec"
|
30
|
+
]
|
31
|
+
s.homepage = "http://github.com/audy/thrash"
|
32
|
+
s.licenses = ["MIT"]
|
33
|
+
s.require_paths = ["lib"]
|
34
|
+
s.rubygems_version = "1.8.24"
|
35
|
+
s.summary = "Randomly write to many, many files"
|
36
|
+
|
37
|
+
if s.respond_to? :specification_version then
|
38
|
+
s.specification_version = 3
|
39
|
+
|
40
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
41
|
+
s.add_development_dependency(%q<bundler>, [">= 0"])
|
42
|
+
s.add_development_dependency(%q<jeweler>, [">= 0"])
|
43
|
+
s.add_development_dependency(%q<rspec>, [">= 0"])
|
44
|
+
else
|
45
|
+
s.add_dependency(%q<bundler>, [">= 0"])
|
46
|
+
s.add_dependency(%q<jeweler>, [">= 0"])
|
47
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
48
|
+
end
|
49
|
+
else
|
50
|
+
s.add_dependency(%q<bundler>, [">= 0"])
|
51
|
+
s.add_dependency(%q<jeweler>, [">= 0"])
|
52
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: thrash
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -76,6 +76,7 @@ files:
|
|
76
76
|
- readme.md
|
77
77
|
- spec/spec_helper.rb
|
78
78
|
- spec/thrash_spec.rb
|
79
|
+
- thrash.gemspec
|
79
80
|
homepage: http://github.com/audy/thrash
|
80
81
|
licenses:
|
81
82
|
- MIT
|
@@ -91,7 +92,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
91
92
|
version: '0'
|
92
93
|
segments:
|
93
94
|
- 0
|
94
|
-
hash: -
|
95
|
+
hash: -87477105119268361
|
95
96
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
96
97
|
none: false
|
97
98
|
requirements:
|