lib/giblish/docinfo.rb in giblish-0.3.1 vs lib/giblish/docinfo.rb in giblish-0.4.0
- old
+ new
@@ -10,34 +10,49 @@
attr_accessor :author
attr_accessor :message
end
attr_accessor :converted
- attr_accessor :title
attr_accessor :doc_id
attr_accessor :purpose_str
attr_accessor :status
attr_accessor :history
attr_accessor :error_msg
attr_accessor :stderr
- # these two members can have encoding issues when
- # running in a mixed Windows/Linux setting.
- # that is why the explicit utf-8 read methods are
- # provided.
- attr_accessor :rel_path
- attr_accessor :src_file
- def relPath_utf8
- return nil if @rel_path.nil?
- @rel_path.to_s.encode("utf-8")
+ # 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
+ def title
+ @title
end
-
- def srcFile_utf8
- return nil if @src_file.nil?
- @src_file.to_s.encode("utf-8")
+ def title=(rhs)
+ @title = rhs.nil? ? nil : rhs.encode("utf-8")
end
+ def rel_path
+ @rel_path
+ end
+ # attr_accessor :rel_path
+ def src_file
+ @src_file
+ end
+ def src_file=(rhs)
+ @src_file = rhs.nil? ? nil : rhs.encode("utf-8")
+ end
+ # attr_accessor :src_file
+ # 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
+
def initialize(adoc: nil, dst_root_abs: nil, adoc_stderr: "")
@src_file = nil
@history = []
@converted = true
@stderr = adoc_stderr
@@ -46,17 +61,17 @@
# 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"]
- @src_file = d_attr["docfile"]
- @title = adoc.doctitle
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']}"
+ "#{d_attr['outdir']}/#{d_attr['docname']}#{d_attr['docfilesuffix']}".encode("utf-8")
).relative_path_from(dst_root_abs)
end
def to_s
"DocInfo: title: #{@title} src_file: #{@src_file}"
\ No newline at end of file