relaxo 0.4.3 → 0.4.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.
- checksums.yaml +4 -4
- data/.simplecov +9 -0
- data/README.md +4 -3
- data/Rakefile +8 -0
- data/lib/relaxo/attachments.rb +1 -5
- data/lib/relaxo/version.rb +1 -1
- data/relaxo.gemspec +5 -4
- data/spec/relaxo/connection_spec.rb +29 -0
- data/spec/relaxo/database_spec.rb +52 -0
- data/spec/relaxo/spec_helper.rb +4 -0
- data/{test/test_transactions.rb → spec/relaxo/transaction_spec.rb} +10 -10
- metadata +51 -41
- data/lib/relaxo/base64-1.8.rb +0 -8
- data/rakefile.rb +0 -9
- data/test/README.md +0 -5
- data/test/helper.rb +0 -19
- data/test/test_attachments.rb +0 -36
- data/test/test_connection.rb +0 -29
- data/test/test_database.rb +0 -34
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 64d93992b8989b3da2ea1d3538d65bec9803a556
|
4
|
+
data.tar.gz: e559ca748c9c1b13acf35980fa31d8152a2a456d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: efd8db9bc3dc670ff3db9f44a517bb2c64a786b9a07363bcb2f232c49060fef0b1b393d8e37437a3cbc7f554238486e1dd9ef0a2945a0942965c60308b1e2ddd
|
7
|
+
data.tar.gz: 7d37db1c92596301d4ef68121b05cd162c20fb2d9ab6fe46a93117f3b7a79fa6e0ca1bcc70c0649a80d4f2cbb3a6c4f5159126f6b95455a2c23d535ad96f947e
|
data/.simplecov
ADDED
data/README.md
CHANGED
@@ -3,7 +3,8 @@
|
|
3
3
|
Relaxo provides a set of tools and interfaces for interacting with CouchDB. It aims to be as simple and efficient as possible while still improving the usability of various CouchDB features.
|
4
4
|
|
5
5
|
[](http://travis-ci.org/ioquatix/relaxo)
|
6
|
-
|
6
|
+
[](https://codeclimate.com/github/ioquatix/relaxo)
|
7
|
+
[](https://coveralls.io/r/ioquatix/relaxo)
|
7
8
|
## Installation
|
8
9
|
|
9
10
|
Add this line to your application's Gemfile:
|
@@ -57,7 +58,7 @@ Sessions support a very similar interface to the main database class and can for
|
|
57
58
|
|
58
59
|
All documents will allocated UUIDs appropriately and at the end of the session block they will be updated (saved or deleted) using CouchDB `_bulk_save`. The Transactions interface doesn't support any kind of interaction with the server and thus views won't be updated until after the transaction is complete.
|
59
60
|
|
60
|
-
To abort the session, either raise an exception or call `
|
61
|
+
To abort the session, either raise an exception or call `transaction.abort!` which is equivalent to `throw :abort`.
|
61
62
|
|
62
63
|
### Loading Data
|
63
64
|
|
@@ -110,7 +111,7 @@ If your requirements are more complex, consider writing a custom script either t
|
|
110
111
|
|
111
112
|
Released under the MIT license.
|
112
113
|
|
113
|
-
Copyright,
|
114
|
+
Copyright, 2015, by [Samuel G. D. Williams](http://www.codeotaku.com/samuel-williams).
|
114
115
|
|
115
116
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
116
117
|
of this software and associated documentation files (the "Software"), to deal
|
data/Rakefile
ADDED
data/lib/relaxo/attachments.rb
CHANGED
data/lib/relaxo/version.rb
CHANGED
data/relaxo.gemspec
CHANGED
@@ -21,10 +21,11 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
22
22
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
23
23
|
spec.require_paths = ["lib"]
|
24
|
-
|
25
|
-
spec.add_development_dependency "bundler", "~> 1.3"
|
26
|
-
spec.add_development_dependency "rake"
|
27
24
|
|
28
|
-
spec.add_dependency "json", "~> 1.
|
25
|
+
spec.add_dependency "json", "~> 1.8"
|
29
26
|
spec.add_dependency "rest-client"
|
27
|
+
|
28
|
+
spec.add_development_dependency "rspec", "~> 3.1.0"
|
29
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
30
|
+
spec.add_development_dependency "rake"
|
30
31
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require_relative 'spec_helper'
|
4
|
+
|
5
|
+
require 'relaxo'
|
6
|
+
|
7
|
+
RSpec.describe Relaxo::Connection do
|
8
|
+
before :all do
|
9
|
+
@connection = Relaxo::Connection.new(TEST_DATABASE_HOST)
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should provide connection information hash" do
|
13
|
+
expect(@connection.info).to be_kind_of Hash
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should create test database" do
|
17
|
+
database = Relaxo::Database.new(@connection, TEST_DATABASE_NAME)
|
18
|
+
|
19
|
+
if database.exist?
|
20
|
+
expect(database.delete!).to be == Relaxo::SUCCESS
|
21
|
+
end
|
22
|
+
|
23
|
+
expect(database.create!).to be == Relaxo::SUCCESS
|
24
|
+
|
25
|
+
expect(@connection.databases).to be_include TEST_DATABASE_NAME
|
26
|
+
|
27
|
+
expect(database.delete!).to be == Relaxo::SUCCESS
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'relaxo'
|
4
|
+
require 'relaxo/attachments'
|
5
|
+
|
6
|
+
require_relative 'spec_helper'
|
7
|
+
|
8
|
+
RSpec.describe Relaxo::Database do
|
9
|
+
before :all do
|
10
|
+
@connection = Relaxo::Connection.new(TEST_DATABASE_HOST)
|
11
|
+
@database = Relaxo::Database.new(@connection, TEST_DATABASE_NAME)
|
12
|
+
|
13
|
+
if @database.exist?
|
14
|
+
@database.delete!
|
15
|
+
end
|
16
|
+
|
17
|
+
@database.create!
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should connect and add a document" do
|
21
|
+
expect(@database.id?('foobar')).to be false
|
22
|
+
|
23
|
+
document = {'animal' => 'Cat', 'name' => 'Seifa'}
|
24
|
+
|
25
|
+
@database.save(document)
|
26
|
+
|
27
|
+
id = document[Relaxo::ID]
|
28
|
+
expect(@database.id?(id)).to be true
|
29
|
+
|
30
|
+
copy = @database.get(id)
|
31
|
+
document.each do |key, value|
|
32
|
+
expect(copy[key]).to be == value
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should save an attachment" do
|
37
|
+
document = {
|
38
|
+
Relaxo::ATTACHMENTS => {
|
39
|
+
"foo.txt" => {
|
40
|
+
"content_type" => "text\/plain",
|
41
|
+
"data" => "VGhpcyBpcyBhIGJhc2U2NCBlbmNvZGVkIHRleHQ="
|
42
|
+
}
|
43
|
+
}
|
44
|
+
}
|
45
|
+
|
46
|
+
result = @database.save(document)
|
47
|
+
expect(result['ok']).to be true
|
48
|
+
|
49
|
+
document = @database.get(document[Relaxo::ID])
|
50
|
+
expect(document[Relaxo::ATTACHMENTS].size).to be == 1
|
51
|
+
end
|
52
|
+
end
|
@@ -1,12 +1,12 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
|
3
|
+
require_relative 'spec_helper'
|
4
4
|
|
5
5
|
require 'relaxo'
|
6
6
|
require 'relaxo/transaction'
|
7
7
|
|
8
|
-
|
9
|
-
|
8
|
+
RSpec.describe Relaxo::Transaction do
|
9
|
+
before :all do
|
10
10
|
@connection = Relaxo::Connection.new(TEST_DATABASE_HOST)
|
11
11
|
@database = Relaxo::Database.new(@connection, TEST_DATABASE_NAME)
|
12
12
|
|
@@ -17,7 +17,7 @@ class TransactionTest < Test::Unit::TestCase
|
|
17
17
|
@database.create!
|
18
18
|
end
|
19
19
|
|
20
|
-
|
20
|
+
it "should create some documents" do
|
21
21
|
documents = @database.transaction do |txn|
|
22
22
|
10.times do |i|
|
23
23
|
txn.save({:i => i})
|
@@ -25,10 +25,10 @@ class TransactionTest < Test::Unit::TestCase
|
|
25
25
|
end
|
26
26
|
|
27
27
|
# We got 10 document IDs back
|
28
|
-
|
28
|
+
expect(documents.size).to be == 10
|
29
29
|
end
|
30
30
|
|
31
|
-
|
31
|
+
it "should abort transaction" do
|
32
32
|
all_documents = @database.documents
|
33
33
|
|
34
34
|
documents = @database.transaction do |txn|
|
@@ -39,11 +39,11 @@ class TransactionTest < Test::Unit::TestCase
|
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
|
-
|
43
|
-
|
42
|
+
expect(documents).to be nil
|
43
|
+
expect(all_documents).to be == @database.documents
|
44
44
|
end
|
45
45
|
|
46
|
-
|
46
|
+
it "should delete some documents" do
|
47
47
|
documents = @database.transaction do |txn|
|
48
48
|
3.times do |i|
|
49
49
|
txn.save({:i => i})
|
@@ -57,7 +57,7 @@ class TransactionTest < Test::Unit::TestCase
|
|
57
57
|
end
|
58
58
|
|
59
59
|
documents.each do |document|
|
60
|
-
|
60
|
+
expect(@database.id?(document[Relaxo::ID])).to be false
|
61
61
|
end
|
62
62
|
end
|
63
63
|
end
|
metadata
CHANGED
@@ -1,69 +1,83 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: relaxo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-04-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: json
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '1.
|
20
|
-
type: :
|
19
|
+
version: '1.8'
|
20
|
+
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '1.
|
26
|
+
version: '1.8'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: rest-client
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
|
-
type: :
|
34
|
+
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - ~>
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 1.
|
48
|
-
type: :
|
47
|
+
version: 3.1.0
|
48
|
+
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - ~>
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 1.
|
54
|
+
version: 3.1.0
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: bundler
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.3'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.3'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
60
74
|
- !ruby/object:Gem::Version
|
61
75
|
version: '0'
|
62
|
-
type: :
|
76
|
+
type: :development
|
63
77
|
prerelease: false
|
64
78
|
version_requirements: !ruby/object:Gem::Requirement
|
65
79
|
requirements:
|
66
|
-
- -
|
80
|
+
- - ">="
|
67
81
|
- !ruby/object:Gem::Version
|
68
82
|
version: '0'
|
69
83
|
description: "\t\tRelaxo provides a set of tools and interfaces for interacting with
|
@@ -77,29 +91,27 @@ executables:
|
|
77
91
|
extensions: []
|
78
92
|
extra_rdoc_files: []
|
79
93
|
files:
|
80
|
-
- .gitignore
|
81
|
-
- .
|
94
|
+
- ".gitignore"
|
95
|
+
- ".simplecov"
|
96
|
+
- ".travis.yml"
|
82
97
|
- Gemfile
|
83
98
|
- README.md
|
99
|
+
- Rakefile
|
84
100
|
- bin/relaxo
|
85
101
|
- bin/relaxo-admin
|
86
102
|
- lib/relaxo.rb
|
87
103
|
- lib/relaxo/attachments.rb
|
88
|
-
- lib/relaxo/base64-1.8.rb
|
89
104
|
- lib/relaxo/client.rb
|
90
105
|
- lib/relaxo/connection.rb
|
91
106
|
- lib/relaxo/database.rb
|
92
107
|
- lib/relaxo/json.rb
|
93
108
|
- lib/relaxo/transaction.rb
|
94
109
|
- lib/relaxo/version.rb
|
95
|
-
- rakefile.rb
|
96
110
|
- relaxo.gemspec
|
97
|
-
-
|
98
|
-
-
|
99
|
-
-
|
100
|
-
-
|
101
|
-
- test/test_database.rb
|
102
|
-
- test/test_transactions.rb
|
111
|
+
- spec/relaxo/connection_spec.rb
|
112
|
+
- spec/relaxo/database_spec.rb
|
113
|
+
- spec/relaxo/spec_helper.rb
|
114
|
+
- spec/relaxo/transaction_spec.rb
|
103
115
|
homepage: ''
|
104
116
|
licenses:
|
105
117
|
- MIT
|
@@ -110,24 +122,22 @@ require_paths:
|
|
110
122
|
- lib
|
111
123
|
required_ruby_version: !ruby/object:Gem::Requirement
|
112
124
|
requirements:
|
113
|
-
- -
|
125
|
+
- - ">="
|
114
126
|
- !ruby/object:Gem::Version
|
115
127
|
version: '0'
|
116
128
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
117
129
|
requirements:
|
118
|
-
- -
|
130
|
+
- - ">="
|
119
131
|
- !ruby/object:Gem::Version
|
120
132
|
version: '0'
|
121
133
|
requirements: []
|
122
134
|
rubyforge_project:
|
123
|
-
rubygems_version: 2.
|
135
|
+
rubygems_version: 2.2.2
|
124
136
|
signing_key:
|
125
137
|
specification_version: 4
|
126
138
|
summary: Relaxo is a helper for loading and working with CouchDB.
|
127
139
|
test_files:
|
128
|
-
-
|
129
|
-
-
|
130
|
-
-
|
131
|
-
-
|
132
|
-
- test/test_database.rb
|
133
|
-
- test/test_transactions.rb
|
140
|
+
- spec/relaxo/connection_spec.rb
|
141
|
+
- spec/relaxo/database_spec.rb
|
142
|
+
- spec/relaxo/spec_helper.rb
|
143
|
+
- spec/relaxo/transaction_spec.rb
|
data/lib/relaxo/base64-1.8.rb
DELETED
data/rakefile.rb
DELETED
data/test/README.md
DELETED
data/test/helper.rb
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
|
2
|
-
$LOAD_PATH.unshift File.expand_path("../../lib/", __FILE__)
|
3
|
-
|
4
|
-
require 'rubygems'
|
5
|
-
require 'test/unit'
|
6
|
-
|
7
|
-
TEST_DATABASE_NAME = 'relaxo-test-database'
|
8
|
-
TEST_DATABASE_HOST = 'localhost:5984'
|
9
|
-
|
10
|
-
class Test::Unit::TestCase
|
11
|
-
# Why isn't this in rails?
|
12
|
-
def assert_includes(elem, array, message = nil)
|
13
|
-
message = build_message message, '<?> is not found in <?>.', elem, array
|
14
|
-
|
15
|
-
assert_block message do
|
16
|
-
array.include? elem
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
data/test/test_attachments.rb
DELETED
@@ -1,36 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'helper'
|
4
|
-
|
5
|
-
require 'relaxo'
|
6
|
-
require 'relaxo/attachments'
|
7
|
-
|
8
|
-
class DatabaseTest < Test::Unit::TestCase
|
9
|
-
def setup
|
10
|
-
@connection = Relaxo::Connection.new(TEST_DATABASE_HOST)
|
11
|
-
@database = Relaxo::Database.new(@connection, TEST_DATABASE_NAME)
|
12
|
-
|
13
|
-
if @database.exist?
|
14
|
-
@database.delete!
|
15
|
-
end
|
16
|
-
|
17
|
-
@database.create!
|
18
|
-
end
|
19
|
-
|
20
|
-
def test_attachments
|
21
|
-
document = {
|
22
|
-
Relaxo::ATTACHMENTS => {
|
23
|
-
"foo.txt" => {
|
24
|
-
"content_type" => "text\/plain",
|
25
|
-
"data" => "VGhpcyBpcyBhIGJhc2U2NCBlbmNvZGVkIHRleHQ="
|
26
|
-
}
|
27
|
-
}
|
28
|
-
}
|
29
|
-
|
30
|
-
result = @database.save(document)
|
31
|
-
assert result['ok']
|
32
|
-
|
33
|
-
document = @database.get(document[Relaxo::ID])
|
34
|
-
assert_equal 1, document[Relaxo::ATTACHMENTS].size
|
35
|
-
end
|
36
|
-
end
|
data/test/test_connection.rb
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'helper'
|
4
|
-
|
5
|
-
require 'relaxo'
|
6
|
-
|
7
|
-
class ConnectionTest < Test::Unit::TestCase
|
8
|
-
def setup
|
9
|
-
@connection = Relaxo::Connection.new(TEST_DATABASE_HOST)
|
10
|
-
end
|
11
|
-
|
12
|
-
def test_info
|
13
|
-
assert_equal Hash, @connection.info.class
|
14
|
-
end
|
15
|
-
|
16
|
-
def test_create_database
|
17
|
-
database = Relaxo::Database.new(@connection, TEST_DATABASE_NAME)
|
18
|
-
|
19
|
-
if database.exist?
|
20
|
-
assert_equal Relaxo::SUCCESS, database.delete!
|
21
|
-
end
|
22
|
-
|
23
|
-
assert_equal Relaxo::SUCCESS, database.create!
|
24
|
-
|
25
|
-
assert_includes TEST_DATABASE_NAME, @connection.databases
|
26
|
-
|
27
|
-
assert_equal Relaxo::SUCCESS, database.delete!
|
28
|
-
end
|
29
|
-
end
|
data/test/test_database.rb
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'helper'
|
4
|
-
|
5
|
-
require 'relaxo'
|
6
|
-
|
7
|
-
class DatabaseTest < Test::Unit::TestCase
|
8
|
-
def setup
|
9
|
-
@connection = Relaxo::Connection.new(TEST_DATABASE_HOST)
|
10
|
-
@database = Relaxo::Database.new(@connection, TEST_DATABASE_NAME)
|
11
|
-
|
12
|
-
if @database.exist?
|
13
|
-
@database.delete!
|
14
|
-
end
|
15
|
-
|
16
|
-
@database.create!
|
17
|
-
end
|
18
|
-
|
19
|
-
def test_adding_document
|
20
|
-
assert_equal false, @database.id?('foobar')
|
21
|
-
|
22
|
-
document = {'animal' => 'Cat', 'name' => 'Seifa'}
|
23
|
-
|
24
|
-
@database.save(document)
|
25
|
-
|
26
|
-
id = document[Relaxo::ID]
|
27
|
-
assert_equal true, @database.id?(id)
|
28
|
-
|
29
|
-
copy = @database.get(id)
|
30
|
-
document.each do |key, value|
|
31
|
-
assert_equal value, copy[key]
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|