Class: Giblish::DocInfo

Inherits:
Object
  • Object
show all
Defined in:
lib/giblish/docinfo.rb

Overview

Container class for bundling together the data we cache for each asciidoc file we come across

Defined Under Namespace

Classes: DocHistory

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(adoc: nil, dst_root_abs: nil, adoc_stderr: "") ⇒ DocInfo

def relPath_utf8

return nil if @rel_path.nil?
@rel_path.to_s.encode("utf-8")

end

def srcFile_utf8

return nil if @src_file.nil?
@src_file.to_s.encode("utf-8")

end



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/giblish/docinfo.rb', line 54

def initialize(adoc: nil, dst_root_abs: nil, adoc_stderr: "")
  @src_file = nil
  @history = []
  @converted = true
  @stderr = adoc_stderr
  return unless adoc

  # Get the purpose info if it exists
  @purpose_str = get_purpose_info adoc

  # fill in doc meta data
  d_attr = adoc.attributes
  self.src_file=(d_attr["docfile"])
  self.title=(adoc.doctitle)
  @doc_id = d_attr["docid"]
  return if dst_root_abs.nil?

  # Get the relative path beneath the root dir to the doc
  @rel_path = Pathname.new(
      "#{d_attr['outdir']}/#{d_attr['docname']}#{d_attr['docfilesuffix']}".encode("utf-8")
  ).relative_path_from(dst_root_abs)
end

Instance Attribute Details

#convertedObject

Returns the value of attribute converted.



14
15
16
# File 'lib/giblish/docinfo.rb', line 14

def converted
  @converted
end

#doc_idObject

Returns the value of attribute doc_id.



15
16
17
# File 'lib/giblish/docinfo.rb', line 15

def doc_id
  @doc_id
end

#error_msgObject

Returns the value of attribute error_msg.



19
20
21
# File 'lib/giblish/docinfo.rb', line 19

def error_msg
  @error_msg
end

#historyObject

Returns the value of attribute history.



18
19
20
# File 'lib/giblish/docinfo.rb', line 18

def history
  @history
end

#purpose_strObject

Returns the value of attribute purpose_str.



16
17
18
# File 'lib/giblish/docinfo.rb', line 16

def purpose_str
  @purpose_str
end

#statusObject

Returns the value of attribute status.



17
18
19
# File 'lib/giblish/docinfo.rb', line 17

def status
  @status
end

#stderrObject

Returns the value of attribute stderr.



20
21
22
# File 'lib/giblish/docinfo.rb', line 20

def stderr
  @stderr
end

Instance Method Details

#rel_pathObject



32
33
34
# File 'lib/giblish/docinfo.rb', line 32

def rel_path
  @rel_path
end

#src_fileObject

attr_accessor :rel_path



36
37
38
# File 'lib/giblish/docinfo.rb', line 36

def src_file
  @src_file
end

#src_file=(rhs) ⇒ Object



39
40
41
# File 'lib/giblish/docinfo.rb', line 39

def src_file=(rhs)
  @src_file = rhs.nil? ? nil : rhs.encode("utf-8")
end

#titleObject

these members can have encoding issues when running in a mixed Windows/Linux setting. that is why we explicitly encodes them when writing to them



26
27
28
# File 'lib/giblish/docinfo.rb', line 26

def title
  @title
end

#title=(rhs) ⇒ Object



29
30
31
# File 'lib/giblish/docinfo.rb', line 29

def title=(rhs)
  @title = rhs.nil? ? nil : rhs.encode("utf-8")
end

#to_sObject



77
78
79
# File 'lib/giblish/docinfo.rb', line 77

def to_s
  "DocInfo: title: #{@title} src_file: #{@src_file}"
end