persist 0.0.3 → 0.0.4
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/.gitignore +1 -0
- data/LICENSE +1 -1
- data/README.md +1 -1
- data/lib/persist/version.rb +1 -1
- data/lib/persist.rb +18 -1
- data/persist.gemspec +5 -5
- data/test/helper.rb +3 -0
- data/test/test_persist.rb +70 -0
- metadata +8 -4
- data/Rakefile +0 -2
data/.gitignore
CHANGED
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -48,7 +48,7 @@ Persist[:pie]
|
|
48
48
|
#=> ["Key Lime", "Strawberry Rhubarb", "Blackberry Cobbler"]
|
49
49
|
```
|
50
50
|
|
51
|
-
TODO: Document Persist.db's other public methods such as #transaction, #delete, and #keys. The best documentation in the meanwhile is in the code itself: https://github.com/Havenwood/persist/blob/master/lib/persist.rb
|
51
|
+
TODO: Document Persist.db's other public methods such as #transaction, #delete, #key? and #keys. The best documentation in the meanwhile is in the code itself: https://github.com/Havenwood/persist/blob/master/lib/persist.rb
|
52
52
|
|
53
53
|
## Contributing
|
54
54
|
|
data/lib/persist/version.rb
CHANGED
data/lib/persist.rb
CHANGED
@@ -56,7 +56,24 @@ module Persist
|
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
59
|
-
|
59
|
+
# Public: Determine whether a particular persistent store root table exists.
|
60
|
+
#
|
61
|
+
# Examples
|
62
|
+
#
|
63
|
+
# Persist.key? :author
|
64
|
+
# # => true
|
65
|
+
#
|
66
|
+
# Persist.key? :this_does_not_exist
|
67
|
+
# # => false
|
68
|
+
#
|
69
|
+
# Returns true or false.
|
70
|
+
def key? table
|
71
|
+
# Open a read-only transaction.
|
72
|
+
@store.transaction(true) do
|
73
|
+
#Return a list of all tables in the persistent store.
|
74
|
+
@store.root? table
|
75
|
+
end
|
76
|
+
end
|
60
77
|
|
61
78
|
# Public: Fetch a particular table from the persistent store.
|
62
79
|
#
|
data/persist.gemspec
CHANGED
@@ -2,16 +2,16 @@
|
|
2
2
|
require File.expand_path('../lib/persist/version', __FILE__)
|
3
3
|
|
4
4
|
Gem::Specification.new do |gem|
|
5
|
-
gem.authors = [
|
6
|
-
gem.email = [
|
5
|
+
gem.authors = ['Shannon']
|
6
|
+
gem.email = ['shannonskipper@gmail.com']
|
7
7
|
gem.description = %q{A DSL for storing Ruby Objects transactionally in a persistent NoSQL database}
|
8
8
|
gem.summary = %q{Persist.db is a DSL implemented around Ruby Standard Library's PStore to facilitate simple file-persistant storage of Ruby objects in a transactional NoSQL database.}
|
9
|
-
gem.homepage =
|
9
|
+
gem.homepage = 'https://github.com/Havenwood/persist'
|
10
10
|
|
11
11
|
gem.files = `git ls-files`.split($\)
|
12
12
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
13
13
|
gem.test_files = gem.files.grep(%r{^test/})
|
14
|
-
gem.name =
|
15
|
-
gem.require_paths = [
|
14
|
+
gem.name = 'persist'
|
15
|
+
gem.require_paths = ['lib', 'test']
|
16
16
|
gem.version = Persist::VERSION
|
17
17
|
end
|
data/test/helper.rb
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
require_relative 'helper'
|
2
|
+
|
3
|
+
describe Persist do
|
4
|
+
before do
|
5
|
+
@db = Persist.db
|
6
|
+
Persist[:author] = {first_name: 'Shannon', last_name: 'Skipper'}
|
7
|
+
end
|
8
|
+
|
9
|
+
describe "initializing the persistent store with Persist.db" do
|
10
|
+
it "returns a PStore object" do
|
11
|
+
assert_equal PStore, @db.class
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe "getting a list of root keys with Persist.keys" do
|
16
|
+
it "returns an Array" do
|
17
|
+
assert_kind_of Array, Persist.keys
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe "getting true or false if key exists with Persist.key?(:key)" do
|
22
|
+
it "returns true if key exists" do
|
23
|
+
assert Persist.key?(:author)
|
24
|
+
end
|
25
|
+
|
26
|
+
it "returns false if the key does't exist" do
|
27
|
+
refute Persist.key?(:this_does_not_exist)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe "getting a particular key's value with Persist[:key]" do
|
32
|
+
it "returns a value if the key exists" do
|
33
|
+
assert_equal "Shannon", Persist[:author][:first_name]
|
34
|
+
end
|
35
|
+
|
36
|
+
it "returns nil if the key doesn't exist" do
|
37
|
+
assert_nil Persist[:this_does_not_exist]
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe "setting a perticular key's value with Persist[:key] = value" do
|
42
|
+
before do
|
43
|
+
Persist[:trees] = ['oak', 'pine', 'cedar']
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should add the key to the persistent store" do
|
47
|
+
assert Persist.key?(:trees)
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should be set to the expected value" do
|
51
|
+
assert_equal ["oak", "pine", "cedar"], Persist[:trees]
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
describe "setting multiple key's values with Persist.transaction do ..." do
|
56
|
+
it "blends" do
|
57
|
+
assert true #TODO: test.
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
describe "deleting a root key" do
|
62
|
+
before do
|
63
|
+
Persist.delete :author
|
64
|
+
end
|
65
|
+
|
66
|
+
it "returns nil because the key no longer exists" do
|
67
|
+
assert_nil Persist[:author]
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: persist
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-05-
|
12
|
+
date: 2012-05-22 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: A DSL for storing Ruby Objects transactionally in a persistent NoSQL
|
15
15
|
database
|
@@ -23,16 +23,18 @@ files:
|
|
23
23
|
- Gemfile
|
24
24
|
- LICENSE
|
25
25
|
- README.md
|
26
|
-
- Rakefile
|
27
26
|
- lib/persist.rb
|
28
27
|
- lib/persist/version.rb
|
29
28
|
- persist.gemspec
|
29
|
+
- test/helper.rb
|
30
|
+
- test/test_persist.rb
|
30
31
|
homepage: https://github.com/Havenwood/persist
|
31
32
|
licenses: []
|
32
33
|
post_install_message:
|
33
34
|
rdoc_options: []
|
34
35
|
require_paths:
|
35
36
|
- lib
|
37
|
+
- test
|
36
38
|
required_ruby_version: !ruby/object:Gem::Requirement
|
37
39
|
none: false
|
38
40
|
requirements:
|
@@ -53,5 +55,7 @@ specification_version: 3
|
|
53
55
|
summary: Persist.db is a DSL implemented around Ruby Standard Library's PStore to
|
54
56
|
facilitate simple file-persistant storage of Ruby objects in a transactional NoSQL
|
55
57
|
database.
|
56
|
-
test_files:
|
58
|
+
test_files:
|
59
|
+
- test/helper.rb
|
60
|
+
- test/test_persist.rb
|
57
61
|
has_rdoc:
|
data/Rakefile
DELETED