relaxo 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/relaxo +5 -2
- data/lib/relaxo/client.rb +1 -1
- data/lib/relaxo/{server.rb → connection.rb} +1 -1
- data/lib/relaxo/database.rb +7 -7
- data/lib/relaxo/session.rb +2 -2
- data/lib/relaxo/version.rb +1 -1
- data/lib/relaxo.rb +2 -2
- metadata +4 -3
data/bin/relaxo
CHANGED
@@ -15,7 +15,10 @@ elsif ARGV.delete('--update')
|
|
15
15
|
OPTIONS[:existing] = :update
|
16
16
|
end
|
17
17
|
|
18
|
-
$
|
18
|
+
$url = ARGV.shift
|
19
|
+
$database = Relaxo.connect($url)
|
20
|
+
$stderr.puts "Connecting to #{$url}..."
|
21
|
+
|
19
22
|
$documents = YAML::load(ARGF)
|
20
23
|
|
21
24
|
unless Array === $documents
|
@@ -30,7 +33,7 @@ $stats = {
|
|
30
33
|
|
31
34
|
$documents.each do |document|
|
32
35
|
begin
|
33
|
-
$stderr.puts "Loading #{document
|
36
|
+
$stderr.puts "Loading #{document[Relaxo::ID]}"
|
34
37
|
existing_document = nil
|
35
38
|
|
36
39
|
if document && document[Relaxo::ID]
|
data/lib/relaxo/client.rb
CHANGED
@@ -35,7 +35,7 @@ module Relaxo
|
|
35
35
|
|
36
36
|
def self.execute(request)
|
37
37
|
# Poor mans debugging:
|
38
|
-
$stderr.puts "Client: #{request[:method]} #{request[:url]}" if @@debug
|
38
|
+
$stderr.puts "Relaxo Client: #{request[:method]} #{request[:url]}" if @@debug
|
39
39
|
|
40
40
|
response = RestClient::Request.execute(request)
|
41
41
|
return JSON.parse(response)
|
data/lib/relaxo/database.rb
CHANGED
@@ -19,7 +19,7 @@
|
|
19
19
|
# THE SOFTWARE.
|
20
20
|
|
21
21
|
require 'relaxo/client'
|
22
|
-
require 'relaxo/
|
22
|
+
require 'relaxo/connection'
|
23
23
|
|
24
24
|
module Relaxo
|
25
25
|
|
@@ -60,7 +60,7 @@ module Relaxo
|
|
60
60
|
|
61
61
|
# We assume the save operation will be successful:
|
62
62
|
unless document.key? ID
|
63
|
-
@uuids << (document[ID] = @database.
|
63
|
+
@uuids << (document[ID] = @database.connection.next_uuid)
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
@@ -106,14 +106,14 @@ module Relaxo
|
|
106
106
|
end
|
107
107
|
|
108
108
|
class Database
|
109
|
-
def initialize(
|
110
|
-
@
|
109
|
+
def initialize(connection, name)
|
110
|
+
@connection = connection
|
111
111
|
@name = name
|
112
112
|
|
113
|
-
@root =
|
113
|
+
@root = connection.url + "/" + CGI.escape(name)
|
114
114
|
end
|
115
115
|
|
116
|
-
attr :
|
116
|
+
attr :connection
|
117
117
|
attr :name
|
118
118
|
attr :root
|
119
119
|
|
@@ -122,7 +122,7 @@ module Relaxo
|
|
122
122
|
end
|
123
123
|
|
124
124
|
def put(document)
|
125
|
-
Client.put document_url(document[ID] || @
|
125
|
+
Client.put document_url(document[ID] || @connection.next_uuid), document
|
126
126
|
end
|
127
127
|
|
128
128
|
def delete(document)
|
data/lib/relaxo/session.rb
CHANGED
@@ -19,7 +19,7 @@
|
|
19
19
|
# THE SOFTWARE.
|
20
20
|
|
21
21
|
require 'relaxo/client'
|
22
|
-
require 'relaxo/
|
22
|
+
require 'relaxo/connection'
|
23
23
|
|
24
24
|
module Relaxo
|
25
25
|
|
@@ -65,7 +65,7 @@ module Relaxo
|
|
65
65
|
|
66
66
|
# We assume the save operation will be successful:
|
67
67
|
unless document.key? ID
|
68
|
-
@uuids << (document[ID] = @database.
|
68
|
+
@uuids << (document[ID] = @database.connection.next_uuid)
|
69
69
|
end
|
70
70
|
end
|
71
71
|
|
data/lib/relaxo/version.rb
CHANGED
data/lib/relaxo.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: relaxo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
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-07-
|
12
|
+
date: 2012-07-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: json
|
@@ -52,8 +52,8 @@ extra_rdoc_files: []
|
|
52
52
|
files:
|
53
53
|
- bin/relaxo
|
54
54
|
- lib/relaxo/client.rb
|
55
|
+
- lib/relaxo/connection.rb
|
55
56
|
- lib/relaxo/database.rb
|
56
|
-
- lib/relaxo/server.rb
|
57
57
|
- lib/relaxo/session.rb
|
58
58
|
- lib/relaxo/version.rb
|
59
59
|
- lib/relaxo.rb
|
@@ -83,3 +83,4 @@ signing_key:
|
|
83
83
|
specification_version: 3
|
84
84
|
summary: Relaxo is a helper for loading and working with CouchDB.
|
85
85
|
test_files: []
|
86
|
+
has_rdoc:
|