summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorazul <azul@riseup.net>2013-12-22 06:33:56 -0800
committerazul <azul@riseup.net>2013-12-22 06:33:56 -0800
commit12dbeefe693e5432416ec8019368e591c526736b (patch)
tree8b93ddc237aef26f4a68557259f5f63250b1a694 /lib
parent41dee6ee7242a731763bb1b75e12cc97403aa4a4 (diff)
parentc1e6eea1eb2a9fbdb92e806929806acef32ed8dc (diff)
Merge pull request #6 from azul/deploy-design-docs
Deploy design docs
Diffstat (limited to 'lib')
-rw-r--r--lib/tapicero.rb2
-rw-r--r--lib/tapicero/user_database.rb20
-rw-r--r--lib/tapicero/version.rb2
-rw-r--r--lib/tapicero_daemon.rb1
4 files changed, 23 insertions, 2 deletions
diff --git a/lib/tapicero.rb b/lib/tapicero.rb
index aba9fad..3923c65 100644
--- a/lib/tapicero.rb
+++ b/lib/tapicero.rb
@@ -1,5 +1,5 @@
unless defined? BASE_DIR
- BASE_DIR = File.expand_path('../..', __FILE__)
+ BASE_DIR = Pathname.new(__FILE__) + '../..'
end
unless defined? TAPICERO_CONFIG
TAPICERO_CONFIG = '/etc/leap/tapicero.yaml'
diff --git a/lib/tapicero/user_database.rb b/lib/tapicero/user_database.rb
index 8f461ef..efd723a 100644
--- a/lib/tapicero/user_database.rb
+++ b/lib/tapicero/user_database.rb
@@ -23,6 +23,22 @@ module Tapicero
CouchRest.put security_url, security
end
+ def add_design_docs
+ pattern = BASE_DIR + 'designs' + '*.json'
+ Tapicero.logger.debug "looking for design docs in #{pattern}"
+ Pathname.glob(pattern).each do |file|
+ upload_design_doc(file)
+ end
+ end
+
+ def upload_design_doc(file)
+ url = design_url(file.basename('.json'))
+ CouchRest.put url, JSON.parse(file.read)
+ Tapicero.logger.debug "uploaded design doc #{file.basename} to #{url}"
+ rescue RestClient::Conflict
+ end
+
+
def destroy
db = CouchRest.new(host).database(name)
db.delete! if db
@@ -40,6 +56,10 @@ module Tapicero
"#{host}/#{name}/_security"
end
+ def design_url(doc_name)
+ "#{host}/#{name}/_design/#{doc_name}"
+ end
+
attr_reader :host, :name
end
end
diff --git a/lib/tapicero/version.rb b/lib/tapicero/version.rb
index 3688f62..2c4bc00 100644
--- a/lib/tapicero/version.rb
+++ b/lib/tapicero/version.rb
@@ -1,4 +1,4 @@
module Tapicero
- VERSION = "0.2.0"
+ VERSION = "0.3.0"
REQUIRE_PATHS = ['lib']
end
diff --git a/lib/tapicero_daemon.rb b/lib/tapicero_daemon.rb
index 9020fa2..67eee88 100644
--- a/lib/tapicero_daemon.rb
+++ b/lib/tapicero_daemon.rb
@@ -15,6 +15,7 @@ module Tapicero
db = user_database(hash['id'])
db.create
db.secure(config.options[:security])
+ db.add_design_docs
end
users.deleted do |hash|