volatiledb 0.0.4 → 1.0.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.
data/README.md CHANGED
@@ -4,7 +4,7 @@ The VolatileDB gem allows you to specify a key and an action yielding a particul
4
4
  data.
5
5
 
6
6
 
7
- This data will be stored in the /tmp folder of the file system you are currently running on. Data
7
+ This data will be stored on the file system you are currently running on. Data
8
8
  is accessible by key. Data will be read and written to storage using File.read() and File.open()
9
9
  -- that's it. It's up to the consuming application to serialize and deserialize data correctly. All
10
10
  VolatileDB does is push and pull data to the FS.
@@ -17,7 +17,7 @@ re-seeded periodically as conditions change.
17
17
  #### Usage
18
18
 
19
19
  require 'volatiledb'
20
- db = Volatile::DB.new
20
+ db = Volatile::DB.new("/tmp")
21
21
  db.put(:foo) { "acts as" }
22
22
  #=> :foo
23
23
  db.get(:foo)
data/doc/Gemfile.html CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
6
6
  <head>
7
- <meta content="text/html; charset=US-ASCII" http-equiv="Content-Type" />
7
+ <meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
8
8
 
9
9
  <title>File: Gemfile [RDoc Documentation]</title>
10
10
 
@@ -78,9 +78,9 @@
78
78
 
79
79
  <div id="documentation">
80
80
 
81
- <p>source "<a href="http://rubygems.org">rubygems.org</a>"</p>
81
+ <p>source “<a href="http://rubygems.org">rubygems.org</a>”</p>
82
82
 
83
- <p># Specify your gem's dependencies in volatiledb.gemspec gemspec</p>
83
+ <p># Specify your gems dependencies in volatiledb.gemspec gemspec</p>
84
84
 
85
85
  </div>
86
86
 
data/doc/Rakefile.html CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
6
6
  <head>
7
- <meta content="text/html; charset=US-ASCII" http-equiv="Content-Type" />
7
+ <meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
8
8
 
9
9
  <title>File: Rakefile [RDoc Documentation]</title>
10
10
 
@@ -78,7 +78,7 @@
78
78
 
79
79
  <div id="documentation">
80
80
 
81
- <p>require "bundler/gem_tasks"</p>
81
+ <p>require bundler/gem_tasks”</p>
82
82
 
83
83
  </div>
84
84
 
data/doc/Volatile.html CHANGED
@@ -1,9 +1,9 @@
1
- <?xml version="1.0" encoding="US-ASCII"?>
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
2
  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
3
3
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
4
4
  <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5
5
  <head>
6
- <meta content="text/html; charset=US-ASCII" http-equiv="Content-Type" />
6
+ <meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
7
7
 
8
8
  <title>Module: Volatile</title>
9
9
 
data/doc/Volatile/DB.html CHANGED
@@ -1,9 +1,9 @@
1
- <?xml version="1.0" encoding="US-ASCII"?>
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
2
  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
3
3
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
4
4
  <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5
5
  <head>
6
- <meta content="text/html; charset=US-ASCII" http-equiv="Content-Type" />
6
+ <meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
7
7
 
8
8
  <title>Class: Volatile::DB</title>
9
9
 
@@ -158,22 +158,22 @@ library.</p>
158
158
 
159
159
  <div class="method-heading">
160
160
  <span class="method-name">new</span><span
161
- class="method-args">()</span>
161
+ class="method-args">(path)</span>
162
162
  <span class="method-click-advice">click to toggle source</span>
163
163
  </div>
164
164
 
165
165
 
166
166
  <div class="method-description">
167
167
 
168
- <p>Constructor, nothing fancy.</p>
168
+ <p>Initializes storage to the given path.</p>
169
169
 
170
170
 
171
171
 
172
172
  <div class="method-source-code" id="new-source">
173
173
  <pre>
174
174
  <span class="ruby-comment"># File lib/volatiledb.rb, line 17</span>
175
- <span class="ruby-keyword">def</span> <span class="ruby-identifier">initialize</span>
176
- <span class="ruby-ivar">@raw</span> <span class="ruby-operator">||=</span> <span class="ruby-constant">Volatile</span><span class="ruby-operator">::</span><span class="ruby-constant">Raw</span>.<span class="ruby-identifier">new</span>
175
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">path</span>)
176
+ <span class="ruby-ivar">@raw</span> <span class="ruby-operator">||=</span> <span class="ruby-constant">Volatile</span><span class="ruby-operator">::</span><span class="ruby-constant">Raw</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">path</span>)
177
177
  <span class="ruby-ivar">@db</span> <span class="ruby-operator">||=</span> {}
178
178
  <span class="ruby-keyword">end</span></pre>
179
179
  </div><!-- new-source -->
@@ -258,7 +258,7 @@ will be read and returned.</p>
258
258
  <pre>
259
259
  <span class="ruby-comment"># File lib/volatiledb.rb, line 40</span>
260
260
  <span class="ruby-keyword">def</span> <span class="ruby-identifier">get</span>(<span class="ruby-identifier">key</span>)
261
- <span class="ruby-identifier">data</span> = <span class="ruby-ivar">@raw</span>.<span class="ruby-identifier">get</span> <span class="ruby-identifier">key</span>
261
+ <span class="ruby-identifier">data</span> = <span class="ruby-identifier">raw_get</span> <span class="ruby-identifier">key</span>
262
262
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">data</span>.<span class="ruby-identifier">nil?</span>
263
263
  <span class="ruby-identifier">sync</span> <span class="ruby-identifier">key</span>
264
264
  <span class="ruby-keyword">else</span>
@@ -1,9 +1,9 @@
1
- <?xml version="1.0" encoding="US-ASCII"?>
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
2
  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
3
3
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
4
4
  <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5
5
  <head>
6
- <meta content="text/html; charset=US-ASCII" http-equiv="Content-Type" />
6
+ <meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
7
7
 
8
8
  <title>Class: Volatile::Raw</title>
9
9
 
@@ -153,7 +153,7 @@
153
153
 
154
154
  <div class="method-heading">
155
155
  <span class="method-name">new</span><span
156
- class="method-args">()</span>
156
+ class="method-args">(path)</span>
157
157
  <span class="method-click-advice">click to toggle source</span>
158
158
  </div>
159
159
 
@@ -167,7 +167,8 @@
167
167
  <div class="method-source-code" id="new-source">
168
168
  <pre>
169
169
  <span class="ruby-comment"># File lib/volatiledb.rb, line 126</span>
170
- <span class="ruby-keyword">def</span> <span class="ruby-identifier">initialize</span>
170
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">path</span>)
171
+ <span class="ruby-ivar">@path</span> = <span class="ruby-identifier">path</span>
171
172
  <span class="ruby-ivar">@db</span> <span class="ruby-operator">||=</span> {}
172
173
  <span class="ruby-keyword">end</span></pre>
173
174
  </div><!-- new-source -->
@@ -205,10 +206,10 @@
205
206
 
206
207
  <div class="method-source-code" id="get-source">
207
208
  <pre>
208
- <span class="ruby-comment"># File lib/volatiledb.rb, line 143</span>
209
+ <span class="ruby-comment"># File lib/volatiledb.rb, line 144</span>
209
210
  <span class="ruby-keyword">def</span> <span class="ruby-identifier">get</span>(<span class="ruby-identifier">key</span>)
210
211
  <span class="ruby-identifier">handle</span> = <span class="ruby-ivar">@db</span>[<span class="ruby-identifier">key</span>]
211
- <span class="ruby-identifier">f</span> = <span class="ruby-node">&quot;/tmp/#{handle}&quot;</span>
212
+ <span class="ruby-identifier">f</span> = <span class="ruby-identifier">path</span> <span class="ruby-identifier">handle</span>
212
213
  <span class="ruby-keyword">if</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">file?</span>(<span class="ruby-identifier">f</span>)
213
214
  <span class="ruby-constant">File</span>.<span class="ruby-identifier">read</span> <span class="ruby-identifier">f</span>
214
215
  <span class="ruby-keyword">else</span>
@@ -244,10 +245,10 @@
244
245
 
245
246
  <div class="method-source-code" id="put-source">
246
247
  <pre>
247
- <span class="ruby-comment"># File lib/volatiledb.rb, line 133</span>
248
+ <span class="ruby-comment"># File lib/volatiledb.rb, line 134</span>
248
249
  <span class="ruby-keyword">def</span> <span class="ruby-identifier">put</span>(<span class="ruby-identifier">key</span>, <span class="ruby-identifier">data</span>)
249
250
  <span class="ruby-identifier">handle</span> = <span class="ruby-identifier">handle_from</span> <span class="ruby-identifier">key</span>
250
- <span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-node">&quot;/tmp/#{handle}&quot;</span>, <span class="ruby-string">&quot;w&quot;</span>) {<span class="ruby-operator">|</span><span class="ruby-identifier">f</span><span class="ruby-operator">|</span> <span class="ruby-identifier">f</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">data</span>}
251
+ <span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">path</span>(<span class="ruby-identifier">handle</span>), <span class="ruby-string">&quot;w&quot;</span>) {<span class="ruby-operator">|</span><span class="ruby-identifier">f</span><span class="ruby-operator">|</span> <span class="ruby-identifier">f</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">data</span>}
251
252
  <span class="ruby-ivar">@db</span>[<span class="ruby-identifier">key</span>] = <span class="ruby-identifier">handle</span>
252
253
  <span class="ruby-identifier">key</span>
253
254
  <span class="ruby-keyword">end</span></pre>
data/doc/created.rid CHANGED
@@ -1,5 +1,5 @@
1
- Tue, 10 Jan 2012 22:16:43 -0800
2
- ./Gemfile Tue, 03 Jan 2012 20:55:42 -0800
3
- ./lib/volatiledb/version.rb Tue, 10 Jan 2012 22:11:28 -0800
4
- ./lib/volatiledb.rb Tue, 10 Jan 2012 22:16:32 -0800
5
- ./Rakefile Tue, 03 Jan 2012 20:55:42 -0800
1
+ Tue, 10 Jan 2012 23:29:12 -0800
2
+ ./Gemfile Tue, 10 Jan 2012 23:21:03 -0800
3
+ ./lib/volatiledb/version.rb Tue, 10 Jan 2012 23:24:56 -0800
4
+ ./lib/volatiledb.rb Tue, 10 Jan 2012 23:24:37 -0800
5
+ ./Rakefile Tue, 10 Jan 2012 23:21:03 -0800
data/doc/index.html CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
6
6
  <head>
7
- <meta content="text/html; charset=US-ASCII" http-equiv="Content-Type" />
7
+ <meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
8
8
 
9
9
  <title>RDoc Documentation</title>
10
10
 
@@ -4,7 +4,7 @@
4
4
 
5
5
  <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
6
6
  <head>
7
- <meta content="text/html; charset=US-ASCII" http-equiv="Content-Type" />
7
+ <meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
8
8
 
9
9
  <title>File: version.rb [RDoc Documentation]</title>
10
10
 
@@ -24,7 +24,7 @@
24
24
  <div id="metadata">
25
25
  <dl>
26
26
  <dt class="modified-date">Last Modified</dt>
27
- <dd class="modified-date">2012-01-10 22:11:28 -0800</dd>
27
+ <dd class="modified-date">2012-01-10 23:24:56 -0800</dd>
28
28
 
29
29
 
30
30
  <dt class="requires">Requires</dt>
@@ -4,7 +4,7 @@
4
4
 
5
5
  <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
6
6
  <head>
7
- <meta content="text/html; charset=US-ASCII" http-equiv="Content-Type" />
7
+ <meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
8
8
 
9
9
  <title>File: volatiledb.rb [RDoc Documentation]</title>
10
10
 
@@ -24,7 +24,7 @@
24
24
  <div id="metadata">
25
25
  <dl>
26
26
  <dt class="modified-date">Last Modified</dt>
27
- <dd class="modified-date">2012-01-10 22:16:32 -0800</dd>
27
+ <dd class="modified-date">2012-01-10 23:24:37 -0800</dd>
28
28
 
29
29
 
30
30
  <dt class="requires">Requires</dt>
data/lib/volatiledb.rb CHANGED
@@ -12,10 +12,10 @@ module Volatile
12
12
  class DB
13
13
 
14
14
  #
15
- # Constructor, nothing fancy.
15
+ # Initializes storage to the given path.
16
16
  #
17
- def initialize
18
- @raw ||= Volatile::Raw.new
17
+ def initialize(path)
18
+ @raw ||= Volatile::Raw.new(path)
19
19
  @db ||= {}
20
20
  end
21
21
 
@@ -123,7 +123,8 @@ module Volatile
123
123
  #
124
124
  # Implementation detail.
125
125
  #
126
- def initialize
126
+ def initialize(path)
127
+ @path = path
127
128
  @db ||= {}
128
129
  end
129
130
 
@@ -132,7 +133,7 @@ module Volatile
132
133
  #
133
134
  def put(key, data)
134
135
  handle = handle_from key
135
- File.open("/tmp/#{handle}", "w") {|f| f << data}
136
+ File.open(path(handle), "w") {|f| f << data}
136
137
  @db[key] = handle
137
138
  key
138
139
  end
@@ -142,7 +143,7 @@ module Volatile
142
143
  #
143
144
  def get(key)
144
145
  handle = @db[key]
145
- f = "/tmp/#{handle}"
146
+ f = path handle
146
147
  if File.file?(f)
147
148
  File.read f
148
149
  else
@@ -156,6 +157,10 @@ module Volatile
156
157
  guid = Digest::SHA1.hexdigest("#{key}#{timestamp}")
157
158
  "#{guid}.volatiledb"
158
159
  end
160
+
161
+ def path(handle)
162
+ File.join(@path, handle)
163
+ end
159
164
  end
160
165
 
161
166
  end
@@ -3,5 +3,5 @@ module Volatile
3
3
  #
4
4
  # Ye olde version number.
5
5
  #
6
- VERSION = "0.0.4"
6
+ VERSION = "1.0.0"
7
7
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: volatiledb
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.4
5
+ version: 1.0.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - Sebastian Wittenkamp (bitops)