public
Description: CouchDB-resident app framework
Homepage:
Clone URL: git://github.com/atduskgreg/couchengine.git
commit  095f8aa03c46b64f226ff6e737e2aea92b6f3b31
tree    ace11a1d11ad453268b6e1406d6d110dc1f10f5c
parent  8d3c809e5339f07cc3d3ae6f7061841c5919978c
couchengine / Rakefile.template
100644 43 lines (33 sloc) 1.165 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
require 'rake'
require 'json'
 
 
namespace :views do
  
  desc "Pull views from coucdb into subdirs of app/views"
  task :pull => :read_config do
    raise "Can't pull without valid db in config.json" unless @config["db"]
    `cd app; ruby ../vendor/couchrest/script/couchview pull #{@config["db"]}`
  end
  
  desc "Push views for app/views into couchdb"
  task :push => :read_config do
    raise "Can't push without valid db in config.json" unless @config["db"]
    `cd app; ruby ../vendor/couchrest/script/couchview push #{@config["db"]}`
  end
end
 
 
namespace :autosave do
  desc "Start autosave capacity to load views, controllers, and public docs into couch on save."
  task :start => :read_config do
    raise "Can't start autosave without valid db in config.json" unless @config["db"]
    @pid = fork do
      exec "/usr/bin/ruby vendor/autosave.rb public #{@config["db"]}"
    end
    File.open("log/autosave.pid", "w"){|f| f << @pid}
  end
  
  desc "stop autosave"
  task :stop do
    `kill -9 #{open("log/autosave.pid").read}`
    FileUtils.rm("log/autosave.pid")
  end
  
end
 
# utils:
 
task :read_config do
  @config = JSON.load open("config.json")
end