couch-warmer 1.0.5 → 2.0.0
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.
- data/README.rdoc +1 -1
- data/VERSION +1 -1
- data/bin/couch-warmer +1 -2
- data/couch-warmer.gemspec +2 -2
- data/lib/couch-warmer.rb +21 -0
- metadata +5 -5
data/README.rdoc
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
2.0.0
|
data/bin/couch-warmer
CHANGED
@@ -8,7 +8,6 @@ opts = Trollop::options do
|
|
8
8
|
opt :host, "Host addr", :default => '127.0.0.1'
|
9
9
|
opt :port, "Port", :default => '5984'
|
10
10
|
opt :dbname, "Database", :type => String
|
11
|
-
opt :name, "View name", :type => String
|
12
11
|
opt :suffix, "Warm suffix", :type => String
|
13
12
|
end
|
14
13
|
|
@@ -16,4 +15,4 @@ db = "http://#{opts[:host]}:#{opts[:port]}/#{opts[:dbname]}"
|
|
16
15
|
puts db
|
17
16
|
|
18
17
|
warmer = CouchWarmer.new(db)
|
19
|
-
warmer.
|
18
|
+
warmer.warm_all(opts[:suffix])
|
data/couch-warmer.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "couch-warmer"
|
8
|
-
s.version = "
|
8
|
+
s.version = "2.0.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Mathieu Elie"]
|
12
|
-
s.date = "2012-02-
|
12
|
+
s.date = "2012-02-09"
|
13
13
|
s.description = "couchdb view generation could take a while. you could build temp views, then copy them in one shot"
|
14
14
|
s.email = "mathieuelie@gmail.com"
|
15
15
|
s.executables = ["couch-warmer"]
|
data/lib/couch-warmer.rb
CHANGED
@@ -6,6 +6,20 @@ class CouchWarmer
|
|
6
6
|
@db = CouchRest.database(database)
|
7
7
|
end
|
8
8
|
|
9
|
+
def warm_all(suffix)
|
10
|
+
puts "warming all with suffix #{suffix}"
|
11
|
+
designs = get_all_design_docs suffix
|
12
|
+
|
13
|
+
designs.each do |design|
|
14
|
+
puts "warming #{design}"
|
15
|
+
begin
|
16
|
+
warm(design.gsub(suffix, ''), suffix)
|
17
|
+
rescue RestClient::InternalServerError => e
|
18
|
+
puts "error 500 on warming #{design} ..... -> next!"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
9
23
|
# name with suffix, suffix
|
10
24
|
def warm(name, suffix)
|
11
25
|
puts "warming.. #{name} from #{name}#{suffix}"
|
@@ -42,6 +56,7 @@ class CouchWarmer
|
|
42
56
|
|
43
57
|
def is_active?
|
44
58
|
tasks = CouchRest.get(@db.server.uri + '/_active_tasks')
|
59
|
+
tasks.reject! { |t| t['type'] != 'View Group Indexer' }
|
45
60
|
tasks.map! { |t| t['task'] + ' ' + t['status'] }
|
46
61
|
!tasks.empty?
|
47
62
|
end
|
@@ -50,5 +65,11 @@ class CouchWarmer
|
|
50
65
|
design_info = CouchRest.get(@db.server.uri + '/' + @db.name + '/_design/' + design_doc)
|
51
66
|
design_info["views"].keys.first
|
52
67
|
end
|
68
|
+
|
69
|
+
def get_all_design_docs(suffix)
|
70
|
+
designs = CouchRest.get(@db.server.uri + '/' + @db.name + '/_all_docs?startkey=%22_design/%22&endkey=%22_design0%22&include_docs=true')
|
71
|
+
designs["rows"].map {|d| d["id"].gsub '_design/', '' }.grep /#{suffix}$/
|
72
|
+
end
|
73
|
+
|
53
74
|
end
|
54
75
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: couch-warmer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 15
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
|
-
-
|
7
|
+
- 2
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version:
|
9
|
+
- 0
|
10
|
+
version: 2.0.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Mathieu Elie
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-02-
|
18
|
+
date: 2012-02-09 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
requirement: &id001 !ruby/object:Gem::Requirement
|