Merge branch 'janl/master'
This commit is contained in:
commit
c488aab338
16 changed files with 81 additions and 49 deletions
|
@ -52,7 +52,7 @@ module CouchRest
|
|||
foo-project/bar-views/my-design/viewname-reduce.js
|
||||
foo-project/bar-views/my-design/noreduce-map.js
|
||||
|
||||
Pushed to => http://localhost:5984/baz-database/_design/my-design
|
||||
Pushed to => http://127.0.0.1:5984/baz-database/_design/my-design
|
||||
|
||||
And the design document:
|
||||
{
|
||||
|
|
|
@ -18,7 +18,7 @@ module CouchRest
|
|||
# than this example.
|
||||
#
|
||||
# class Article < CouchRest::Model
|
||||
# use_database CouchRest.database!('http://localhost:5984/couchrest-model-test')
|
||||
# use_database CouchRest.database!('http://127.0.0.1:5984/couchrest-model-test')
|
||||
# unique_id :slug
|
||||
#
|
||||
# view_by :date, :descending => true
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
module CouchRest
|
||||
class Server
|
||||
attr_accessor :uri, :uuid_batch_count
|
||||
def initialize server = 'http://localhost:5984', uuid_batch_count = 1000
|
||||
def initialize server = 'http://127.0.0.1:5984', uuid_batch_count = 1000
|
||||
@uri = server
|
||||
@uuid_batch_count = uuid_batch_count
|
||||
end
|
||||
|
|
|
@ -12,9 +12,10 @@ module CouchRest
|
|||
"png" => "image/png",
|
||||
"gif" => "image/gif",
|
||||
"css" => "text/css",
|
||||
"js" => "test/javascript"
|
||||
"js" => "test/javascript",
|
||||
"txt" => "text/plain"
|
||||
}
|
||||
def initialize(dbname, host="http://localhost:5984")
|
||||
def initialize(dbname, host="http://127.0.0.1:5984")
|
||||
@db = CouchRest.new(host).database(dbname)
|
||||
end
|
||||
|
||||
|
@ -37,7 +38,7 @@ module CouchRest
|
|||
@attachments[name] = {
|
||||
"data" => value,
|
||||
"content_type" => MIMES[name.split('.').last]
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
doc = @db.get(docid) rescue nil
|
||||
|
@ -152,7 +153,38 @@ module CouchRest
|
|||
|
||||
designs
|
||||
end
|
||||
|
||||
|
||||
def push_forms(forms_dir)
|
||||
designs = {}
|
||||
|
||||
Dir["#{forms_dir}/**/*.*"].each do |design_doc|
|
||||
design_doc_parts = design_doc.split('/')
|
||||
next if /^lib\..*$/.match design_doc_parts.last
|
||||
pre_normalized_view_name = design_doc_parts.last.split("-")
|
||||
form_name = pre_normalized_view_name[0..pre_normalized_view_name.length-2].join("-")
|
||||
|
||||
folder = design_doc_parts[-2]
|
||||
|
||||
designs[folder] ||= {}
|
||||
designs[folder]["forms"] ||= {}
|
||||
design_lang = design_doc_parts.last.split(".").last
|
||||
designs[folder]["language"] ||= LANGS[design_lang]
|
||||
|
||||
libs = ""
|
||||
Dir["#{forms_dir}/lib.#{design_lang}"].collect do |global_lib|
|
||||
libs << open(global_lib).read
|
||||
libs << "\n"
|
||||
end
|
||||
designs[folder]["forms"]["#{form_name}"] = read(design_doc, libs)
|
||||
end
|
||||
|
||||
designs.each do |k,v|
|
||||
create_or_update("_design/#{k}", v)
|
||||
end
|
||||
|
||||
designs
|
||||
end
|
||||
|
||||
def pull_views(view_dir)
|
||||
prefix = "_design"
|
||||
ds = db.documents(:startkey => '#{prefix}/', :endkey => '#{prefix}/ZZZZZZZZZ')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue