diff options
Diffstat (limited to 'lib/tapicero')
-rw-r--r-- | lib/tapicero/user_database.rb | 20 | ||||
-rw-r--r-- | lib/tapicero/version.rb | 2 |
2 files changed, 21 insertions, 1 deletions
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 |