Class: Lbp::Collection
- Inherits:
-
Object
- Object
- Lbp::Collection
- Defined in:
- lib/lbp/collection.rb
Instance Method Summary collapse
- #citation_lists_dir ⇒ Object
- #confighash ⇒ Object
-
#git_clone(username: nil, password: nil) ⇒ Object
need test.
- #git_repo ⇒ Object
-
#initialize(projectfile) ⇒ Collection
constructor
attr_reader :confighash.
- #item(fs) ⇒ Object
- #item_filestems ⇒ Object
- #item_titles ⇒ Object
- #items ⇒ Object
- #items_fs_title_hash ⇒ Object
- #local_texts_dir ⇒ Object
- #title ⇒ Object
- #xslt_dirs ⇒ Object
Constructor Details
#initialize(projectfile) ⇒ Collection
attr_reader :confighash
9 10 11 12 13 |
# File 'lib/lbp/collection.rb', line 9 def initialize(projectfile) #@confighash = self.confighash #@projectdatafile_dir = @confighash[:projectdatafile_dir] @projectfile = projectfile end |
Instance Method Details
#citation_lists_dir ⇒ Object
24 25 26 27 |
# File 'lib/lbp/collection.rb', line 24 def citation_lists_dir file = Nokogiri::XML(File.read(@projectfile)) citationlistdir = file.xpath(("//header/citationListsDirectory")).text end |
#confighash ⇒ Object
74 75 76 77 78 79 80 |
# File 'lib/lbp/collection.rb', line 74 def confighash confighash = { local_texts_dir: self.local_texts_dir, citation_lists_dir: self.citation_lists_dir, xslt_dirs: self.xslt_dirs, git_repo: self.git_repo} end |
#git_clone(username: nil, password: nil) ⇒ Object
need test
33 34 35 36 37 |
# File 'lib/lbp/collection.rb', line 33 def git_clone(username: nil, password: nil) self.items.each do |item| item.git_clone(username: username, password: password) end end |
#git_repo ⇒ Object
28 29 30 31 |
# File 'lib/lbp/collection.rb', line 28 def git_repo file = Nokogiri::XML(File.read(@projectfile)) gitrepo = file.xpath("//header/git_repo").text end |
#item(fs) ⇒ Object
90 91 92 |
# File 'lib/lbp/collection.rb', line 90 def item(fs) Item.new(@projectfile, fs) end |
#item_filestems ⇒ Object
94 95 96 97 98 99 100 101 102 |
# File 'lib/lbp/collection.rb', line 94 def item_filestems file = Nokogiri::XML(File.read(@projectfile)) result = file.xpath("//div[@id='body']//item/fileName/@filestem") fs_array = result.map do |fs| fs.value end return fs_array end |
#item_titles ⇒ Object
104 105 106 107 108 109 110 111 112 |
# File 'lib/lbp/collection.rb', line 104 def item_titles file = Nokogiri::XML(File.read(@projectfile)) result = file.xpath("//div[@id='body']//item/title") title_array = result.map do |title| title.text end return title_array end |
#items ⇒ Object
82 83 84 85 86 87 88 89 |
# File 'lib/lbp/collection.rb', line 82 def items file = Nokogiri::XML(File.read(@projectfile)) result = file.xpath("//div[@id='body']//item/fileName/@filestem") fs_array = result.map do |fs| Item.new(@projectfile, fs.value) end return fs_array end |
#items_fs_title_hash ⇒ Object
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
# File 'lib/lbp/collection.rb', line 114 def items_fs_title_hash file = Nokogiri::XML(File.read(@projectfile)) result = file.xpath("//div[@id='body']//item") fs_title_hash = Hash.new result.each do |item| title = item.children.find {|child| child.name == "title"}.text fs = item.children.find {|child| child.name == "fileName"}.attributes["filestem"].value fs_title_hash[fs] = title end return fs_title_hash end |
#local_texts_dir ⇒ Object
19 20 21 22 |
# File 'lib/lbp/collection.rb', line 19 def local_texts_dir file = Nokogiri::XML(File.read(@projectfile)) textdir = file.xpath(("//header/localTextsDirectory")).text end |
#title ⇒ Object
15 16 17 18 |
# File 'lib/lbp/collection.rb', line 15 def title file = Nokogiri::XML(File.read(@projectfile)) title = file.xpath(("//header/collectionTitle")).text end |
#xslt_dirs ⇒ Object
39 40 41 42 43 44 45 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 |
# File 'lib/lbp/collection.rb', line 39 def xslt_dirs #test change to hash @xslthash = Hash.new file = Nokogiri::XML(File.read(@projectfile)) schemas = file.xpath("//header/xsltDirectories/schema") schemas.each do |schema| schema_number = schema.attributes["version"].value schema_default = schema.attributes["default"].value @xslthash["#{schema_number}"] = { critical: schema.children.find {|child| child.name == "critical"}.text, documentary: schema.children.find {|child| child.name == "documentary"}.text, main_view: schema.children.find {|child| child.name == "main_view"}.text, index_view: schema.children.find {|child| child.name == "index_view"}.text, clean_view: schema.children.find {|child| child.name == "clean_view"}.text, plain_text: schema.children.find {|child| child.name == "plain_text"}.text, toc: schema.children.find {|child| child.name == "toc"}.text } if schema_default == 'true' @xslthash["default"] = { critical: schema.children.find {|child| child.name == "critical"}.text, documentary: schema.children.find {|child| child.name == "documentary"}.text, main_view: schema.children.find {|child| child.name == "main_view"}.text, index_view: schema.children.find {|child| child.name == "index_view"}.text, clean_view: schema.children.find {|child| child.name == "clean_view"}.text, plain_text: schema.children.find {|child| child.name == "plain_text"}.text, toc: schema.children.find {|child| child.name == "toc"}.text } end end return @xslthash end |