couchpillow 0.1 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.markdown +12 -13
- data/Rakefile +2 -1
- data/lib/couchpillow/document.rb +5 -0
- data/lib/couchpillow/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c41300228038ead4fc735a02ba3bc6f96681b4fb
|
4
|
+
data.tar.gz: b7c9503ede6474ccbcf16cbf275e7b6c708fccd4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 787c8cbb2b23b57fac2d65ec3c5a4cb0495bbd8f69a70c2d460ef100186158ef6a9eca25f68366140c75f1179718290181e1f4cbba582c08b5e968523060fcb7
|
7
|
+
data.tar.gz: 896cc7ffc04ca2647e7c997086300ad86685dcab13cb1be6c6d0526cadd333e36940f0cde57dd930d1ed3b03cb4136d0489cfaac3552f500fa5fd80100a92b00
|
data/README.markdown
CHANGED
@@ -19,11 +19,16 @@ the `set`, `delete`, `replace`, and `get` methods.
|
|
19
19
|
- Validation
|
20
20
|
|
21
21
|
|
22
|
+
## Installation
|
23
|
+
|
24
|
+
gem install couchpillow
|
25
|
+
|
26
|
+
|
22
27
|
## How To Use
|
23
28
|
|
24
|
-
|
25
|
-
|
26
|
-
|
29
|
+
require 'couchpillow'
|
30
|
+
|
31
|
+
CouchPillow.db = Couchbase.connect( bucket: 'default', host: 'localhost' )
|
27
32
|
doc = CouchPillow::Document.new( { :stuff => 'hello' }, '123' )
|
28
33
|
doc.save!
|
29
34
|
|
@@ -47,9 +52,7 @@ Overriding `CouchPillow::Document`
|
|
47
52
|
type :user
|
48
53
|
end
|
49
54
|
|
50
|
-
CouchPillow.db = Couchbase.connect(
|
51
|
-
bucket: 'default',
|
52
|
-
host: 'localhost' )
|
55
|
+
CouchPillow.db = Couchbase.connect( bucket: 'default', host: 'localhost' )
|
53
56
|
doc = User.new( { :email => 'john@email.com' } )
|
54
57
|
doc.email # 'john@email.com'
|
55
58
|
doc.save!
|
@@ -69,11 +72,9 @@ Using validation
|
|
69
72
|
validate_presence :email
|
70
73
|
end
|
71
74
|
|
72
|
-
CouchPillow.db = Couchbase.connect(
|
73
|
-
bucket: 'default',
|
74
|
-
host: 'localhost' )
|
75
|
+
CouchPillow.db = Couchbase.connect( bucket: 'default', host: 'localhost' )
|
75
76
|
doc = User.new( { :first_name => 'John' } )
|
76
|
-
doc.save!
|
77
|
+
doc.save! # raises ValidationError('email is missing')
|
77
78
|
doc.email = 'john@email.com'
|
78
79
|
doc.save! # Success!
|
79
80
|
|
@@ -85,9 +86,7 @@ Using custom validation blocks
|
|
85
86
|
validate :phone, 'is not a number', lambda { |v| v.is_a? Numeric }
|
86
87
|
end
|
87
88
|
|
88
|
-
CouchPillow.db = Couchbase.connect(
|
89
|
-
bucket: 'default',
|
90
|
-
host: 'localhost' )
|
89
|
+
CouchPillow.db = Couchbase.connect( bucket: 'default', host: 'localhost' )
|
91
90
|
doc = User.new
|
92
91
|
doc.email = 'john@email.com'
|
93
92
|
doc.first_name = 'john'
|
data/Rakefile
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'rake/testtask'
|
2
2
|
|
3
|
-
task :default => "
|
3
|
+
task :default => "test"
|
4
4
|
|
5
5
|
Rake::TestTask.new do |t|
|
6
6
|
t.description = "Run tests"
|
@@ -8,6 +8,7 @@ Rake::TestTask.new do |t|
|
|
8
8
|
t.pattern = "./test/**/*.rb"
|
9
9
|
end
|
10
10
|
|
11
|
+
desc "Build the gemfile"
|
11
12
|
task :build do
|
12
13
|
`gem build couchpillow.gemspec`
|
13
14
|
end
|
data/lib/couchpillow/document.rb
CHANGED
@@ -55,6 +55,7 @@ module CouchPillow
|
|
55
55
|
end
|
56
56
|
|
57
57
|
|
58
|
+
# Save this document to the server
|
58
59
|
def save!
|
59
60
|
validate
|
60
61
|
sort!
|
@@ -63,11 +64,15 @@ module CouchPillow
|
|
63
64
|
end
|
64
65
|
|
65
66
|
|
67
|
+
# Delete this document from the server.
|
68
|
+
#
|
66
69
|
def delete!
|
67
70
|
CouchPillow.db.delete @id
|
68
71
|
end
|
69
72
|
|
70
73
|
|
74
|
+
# Sort keys on this document.
|
75
|
+
#
|
71
76
|
def sort!
|
72
77
|
@data = @data.sort.to_h
|
73
78
|
end
|
data/lib/couchpillow/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: couchpillow
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Albert Tedja
|
@@ -73,7 +73,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
73
73
|
version: '0'
|
74
74
|
requirements: []
|
75
75
|
rubyforge_project:
|
76
|
-
rubygems_version: 2.
|
76
|
+
rubygems_version: 2.3.0
|
77
77
|
signing_key:
|
78
78
|
specification_version: 4
|
79
79
|
summary: Document wrapper for Couchbase
|