dolly 0.7.1 → 0.7.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/dolly/query.rb +4 -0
- data/lib/dolly/version.rb +1 -1
- data/lib/tasks/db.rake +28 -28
- data/test/dummy/log/test.log +0 -65364
- metadata +26 -28
- data/test/dummy/config/initializers/filter_parameter_logging.rb +0 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 018a9bd659e968422dd5b822ebfc43dd72838307
|
4
|
+
data.tar.gz: 645e49f46d0e2246e12501e69c39a154d73e8885
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8996310eaabdf5dfbbb50e8eebc8b4a98a3fcea0cbf723da3919e948341ed555163a4def8c0f8b599580890fcda11f02ed30f559fc572bfed3a663b25ade8c52
|
7
|
+
data.tar.gz: bda2f0a5b092e2975b2ec0d3be5ed23a19b2bb1115c52cf0bc443743a1574ee18611e09c1eb48d017a319aacf5eadf86eb970a9e5fcfc21d7f8c3a6288c83c06
|
data/lib/dolly/query.rb
CHANGED
@@ -61,6 +61,10 @@ module Dolly
|
|
61
61
|
database.get doc, options
|
62
62
|
end
|
63
63
|
|
64
|
+
def raw_view doc, view, opts = {}
|
65
|
+
JSON.parse database.get "_design/#{doc}/_view/#{view}", opts
|
66
|
+
end
|
67
|
+
|
64
68
|
def timestamps!
|
65
69
|
%i/created_at updated_at/.each do |method|
|
66
70
|
define_method(method){ @doc[method.to_s] ||= DateTime.now }
|
data/lib/dolly/version.rb
CHANGED
data/lib/tasks/db.rake
CHANGED
@@ -7,51 +7,51 @@ namespace :db do
|
|
7
7
|
|
8
8
|
desc "Will update design document with what is on db/designs/*.coffee"
|
9
9
|
task design: :environment do
|
10
|
-
|
11
|
-
files = Dir.glob
|
12
|
-
|
13
|
-
filters = {}
|
10
|
+
design_dir = Rails.root.join 'db', 'designs'
|
11
|
+
files = Dir.glob File.join design_dir, '**', '*.coffee'
|
12
|
+
data = {}
|
14
13
|
|
15
14
|
files.each do |filename|
|
15
|
+
parts = filename[design_dir.to_s.length+1..-1].split '/'
|
16
|
+
design_doc_name = parts.count == 1 ? Dolly::Document.design_doc : "_design/#{parts.first}"
|
17
|
+
|
16
18
|
name, key = File.basename(filename).sub(/.coffee/i, '').split(/\./)
|
17
19
|
key ||= 'map'
|
18
|
-
|
20
|
+
source = File.read filename
|
21
|
+
|
22
|
+
vd = data[design_doc_name] ||= { 'views' => {}, 'filters' => {} }
|
19
23
|
|
20
24
|
if key == 'filter'
|
21
|
-
filters[name]
|
25
|
+
vd['filters'][name] = source
|
22
26
|
else
|
23
|
-
views[name] ||= {}
|
24
|
-
|
27
|
+
v = vd['views'][name] ||= {}
|
28
|
+
v[key] = source
|
25
29
|
end
|
26
30
|
end
|
27
31
|
|
28
|
-
|
29
|
-
'_id' =>
|
30
|
-
'language' => 'coffeescript',
|
31
|
-
'views' => views,
|
32
|
-
'filters' => filters
|
33
|
-
}
|
32
|
+
data.each do |design_doc_name, view_doc|
|
33
|
+
view_doc.merge!( '_id' => design_doc_name, 'language' => 'coffeescript')
|
34
34
|
|
35
|
-
|
36
|
-
|
35
|
+
begin
|
36
|
+
hash_doc = JSON::parse Dolly::Document.database.get(view_doc["_id"]).parsed_response
|
37
37
|
|
38
|
-
|
38
|
+
rev = hash_doc.delete('_rev')
|
39
39
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
40
|
+
if hash_doc == view_doc
|
41
|
+
puts 'everything up to date'
|
42
|
+
else
|
43
|
+
view_doc["_rev"] = rev
|
44
|
+
puts "Updating #{design_doc_name}"
|
45
|
+
will_save = true
|
46
|
+
end
|
47
|
+
|
48
|
+
rescue Dolly::ResourceNotFound
|
49
|
+
puts "Creating design doc: #{design_doc_name}"
|
46
50
|
will_save = true
|
47
51
|
end
|
48
52
|
|
49
|
-
|
50
|
-
puts 'creating design document'
|
51
|
-
will_save = true
|
53
|
+
Dolly::Document.database.put design_doc_name, view_doc.to_json if will_save
|
52
54
|
end
|
53
|
-
|
54
|
-
Dolly::Document.database.put Dolly::Document.design_doc, view_doc.to_json if will_save
|
55
55
|
end
|
56
56
|
|
57
57
|
end
|