push forms/ into _design/$this/forms
This commit is contained in:
parent
5f65f9d8ab
commit
6b4913e9e8
1 changed files with 46 additions and 2 deletions
|
@ -154,6 +154,50 @@ 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
|
||||
Dir["#{forms_dir}/#{folder}/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
|
||||
end
|
||||
|
||||
# # cleanup empty maps and reduces
|
||||
# designs.each do |name, props|
|
||||
# props["forms"].each do |view, funcs|
|
||||
# next unless view.include?("reduce")
|
||||
# props["forms"].delete(view) unless funcs.keys.include?("reduce")
|
||||
# end
|
||||
# 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…
Reference in a new issue