Class: AdminModule::Guideline
- Inherits:
-
Object
- Object
- AdminModule::Guideline
- Defined in:
- lib/admin_module/guideline.rb
Instance Attribute Summary collapse
-
#page_factory ⇒ Object
readonly
Returns the value of attribute page_factory.
Instance Method Summary collapse
- #deploy(srcdir, comments = nil) ⇒ Object
- #deploy_file(xmlfile, comments = nil) ⇒ Object
- #download(gdlname, xmlfile) ⇒ Object
-
#initialize(page_factory) ⇒ Guideline
constructor
A new instance of Guideline.
- #version(gdls, comments = nil) ⇒ Object
Constructor Details
#initialize(page_factory) ⇒ Guideline
17 18 19 |
# File 'lib/admin_module/guideline.rb', line 17 def initialize(page_factory) @page_factory = page_factory end |
Instance Attribute Details
#page_factory ⇒ Object (readonly)
Returns the value of attribute page_factory.
15 16 17 |
# File 'lib/admin_module/guideline.rb', line 15 def page_factory @page_factory end |
Instance Method Details
#deploy(srcdir, comments = nil) ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/admin_module/guideline.rb', line 21 def deploy srcdir, comments = nil files = Pathname(srcdir).each_child.select { |f| f.file? && f.extname == '.xml' } files.each do |file| deploy_file file, comments end end |
#deploy_file(xmlfile, comments = nil) ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'lib/admin_module/guideline.rb', line 29 def deploy_file xmlfile, comments = nil gdlname = mapped_guideline(xmlfile) page = guidelines_page .open_guideline(gdlname) .add_version .upload(xmlfile., comments_or_default(comments)) end |
#download(gdlname, xmlfile) ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/admin_module/guideline.rb', line 38 def download gdlname, xmlfile xmlfile = Pathname(xmlfile) page = guidelines_page .open_guideline(gdlname) .download(xmlfile.) end |
#version(gdls, comments = nil) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/admin_module/guideline.rb', line 46 def version gdls, comments = nil gdls = Array(gdls) page = guidelines_page .version_all gdl_list = page.get_guidelines version_list = [] not_found_list = [] gdls.each do |gdl| if gdl_list.include? gdl version_list << gdl else mapped_name = mapped_guideline gdl if mapped_name.nil? not_found_list << gdl else version_list << mapped_name end end end if not_found_list.count > 0 puts "Can't find the following guidelines in the available list:" not_found_list.each do |nf| puts " #{nf}" end return page end page.version(version_list, comments_or_default(comments)) end |