marklogic 0.0.9 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/marklogic/app_server.rb +1 -1
- data/lib/marklogic/collection.rb +3 -3
- data/lib/marklogic/connection.rb +9 -2
- data/lib/marklogic/database.rb +1 -1
- data/lib/marklogic/version.rb +1 -1
- data/spec/marklogic/collection_spec.rb +10 -0
- 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: 87bd426930f793bd0a6ef2a7e77f5042f2306ccf
|
4
|
+
data.tar.gz: 7dee1ac42e4dc21379104adb37ca2066cf2e6c9e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4fa300d7932ac6e93262e4cdf74a3f73104f618a9310675d09a0315a0160080b845a9cb94c6dfd8964ea0528c86e77fcb4aaecee170a140cbc14fc91b08e3681
|
7
|
+
data.tar.gz: b851de036f1a96e4217723c9f5b5591668a9796c80679b85d1e171dae2772b8fcae7cdc5264b0203719114a31ee0666f3e9977b9389291e4e8b184189fd8da87
|
data/lib/marklogic/app_server.rb
CHANGED
data/lib/marklogic/collection.rb
CHANGED
@@ -28,7 +28,7 @@ module MarkLogic
|
|
28
28
|
if (doc.is_a?(Array))
|
29
29
|
docs = {}
|
30
30
|
doc.each do |d|
|
31
|
-
docs[doc_uri(d)] =
|
31
|
+
docs[doc_uri(d)] = ::Oj.dump(d, mode: :compat)
|
32
32
|
end
|
33
33
|
body = build_multipart_body(docs)
|
34
34
|
response = @database.connection.post_multipart("/v1/documents", body)
|
@@ -36,7 +36,7 @@ module MarkLogic
|
|
36
36
|
else
|
37
37
|
uri = doc_uri(doc)
|
38
38
|
url = "/v1/documents?uri=#{uri}&format=json&collection=#{collection}"
|
39
|
-
json =
|
39
|
+
json = ::Oj.dump(doc, mode: :compat)
|
40
40
|
response = @database.connection.put(url, json)
|
41
41
|
raise Exception.new("Invalid response: #{response.code.to_i}, #{response.body}\n") unless [201, 204].include? response.code.to_i
|
42
42
|
doc[:_id] || doc[:id] || doc['_id'] || doc['id']
|
@@ -253,7 +253,7 @@ module MarkLogic
|
|
253
253
|
tmp = ""
|
254
254
|
|
255
255
|
# collection
|
256
|
-
metadata =
|
256
|
+
metadata = ::Oj.dump({ collections: [ collection ]}, mode: :compat)
|
257
257
|
tmp << %Q{--#{boundary}\r\n}
|
258
258
|
tmp << %Q{Content-Type: application/json\r\n}
|
259
259
|
tmp << %Q{Content-Disposition: inline; category=metadata\r\n}
|
data/lib/marklogic/connection.rb
CHANGED
@@ -126,6 +126,8 @@ module MarkLogic
|
|
126
126
|
@host
|
127
127
|
end
|
128
128
|
|
129
|
+
attr_accessor :verbose
|
130
|
+
|
129
131
|
def initialize(host, port, username = nil, password = nil, options = {})
|
130
132
|
@host = host
|
131
133
|
@port = port
|
@@ -133,6 +135,7 @@ module MarkLogic
|
|
133
135
|
@password = password || self.class.default_password
|
134
136
|
@request_retries = options[:request_retries] || 3
|
135
137
|
@http = Net::HTTP::Persistent.new 'marklogic'
|
138
|
+
@verbose = options[:verbose] == true || false
|
136
139
|
end
|
137
140
|
|
138
141
|
def run_query(query, type = "javascript", options = {})
|
@@ -143,6 +146,8 @@ module MarkLogic
|
|
143
146
|
headers = {
|
144
147
|
'content-type' => 'application/x-www-form-urlencoded'
|
145
148
|
}
|
149
|
+
|
150
|
+
logger.debug(%Q{MarkLogic (#{type}): #{query}})
|
146
151
|
response = request('/eval', 'post', headers, params)
|
147
152
|
|
148
153
|
# :xquery => options[:query],
|
@@ -168,7 +173,7 @@ module MarkLogic
|
|
168
173
|
end
|
169
174
|
|
170
175
|
def post_json(url, params = nil, headers = {})
|
171
|
-
request(url, 'post', headers, ::
|
176
|
+
request(url, 'post', headers, ::Oj.dump(params, mode: :compat))
|
172
177
|
end
|
173
178
|
|
174
179
|
def post_multipart(url, body = nil, headers = {}, boundary = "BOUNDARY")
|
@@ -319,7 +324,9 @@ module MarkLogic
|
|
319
324
|
response = @http.request full_url, request
|
320
325
|
end
|
321
326
|
|
322
|
-
|
327
|
+
if @verbose
|
328
|
+
logger.debug("MarkLogic: #{response.code} : #{verb.upcase} => ://#{@host}:#{@port}#{url} :: #{body} #{params}")
|
329
|
+
end
|
323
330
|
|
324
331
|
split_multipart(response)
|
325
332
|
response
|
data/lib/marklogic/database.rb
CHANGED
@@ -182,7 +182,7 @@ module MarkLogic
|
|
182
182
|
|
183
183
|
def update
|
184
184
|
url = %Q{/manage/v2/databases/#{database_name}/properties?format=json}
|
185
|
-
r = manage_connection.put(url,
|
185
|
+
r = manage_connection.put(url, ::Oj.dump(to_json, mode: :compat))
|
186
186
|
end
|
187
187
|
|
188
188
|
def reset_indexes
|
data/lib/marklogic/version.rb
CHANGED
@@ -42,6 +42,16 @@ describe MarkLogic::Collection do
|
|
42
42
|
@collection.save( {:_id => "123", :name => "John", :age => 33, :stuff => "junk"} )
|
43
43
|
expect(@collection.count).to eq 1
|
44
44
|
end
|
45
|
+
|
46
|
+
it "save with a Time object" do
|
47
|
+
expect(@collection.count).to eq 0
|
48
|
+
current_time = Time.now
|
49
|
+
@collection.save( {:_id => "123", :name => "John", :age => 33, created_at: current_time} )
|
50
|
+
|
51
|
+
tdoc = @collection.load('123')
|
52
|
+
expect(tdoc).to eq({"_id" => "123", "name" => "John", "age" => 33, "created_at" => current_time.as_json })
|
53
|
+
expect(@collection.count).to eq 1
|
54
|
+
end
|
45
55
|
end
|
46
56
|
|
47
57
|
describe "#save multiples" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: marklogic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paxton Hare
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-04-
|
11
|
+
date: 2015-04-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: net-http-persistent
|