Class: Bhook::MdFile
Constant Summary collapse
- PAGE_TEMPLATE =
T.let(File.read(Bhook::PAGE_TEMPLATE_PATH), String)
- AFTER_H1_TEMPLATE =
T.let(File.read(Bhook::AFTER_H1_TEMPLATE_PATH), String)
Instance Attribute Summary collapse
-
#md ⇒ Object
readonly
Returns the value of attribute md.
-
#out_file_path ⇒ Object
readonly
Returns the value of attribute out_file_path.
-
#src_file_date ⇒ Object
readonly
Returns the value of attribute src_file_date.
-
#src_file_path ⇒ Object
readonly
Returns the value of attribute src_file_path.
-
#src_file_sha ⇒ Object
readonly
Returns the value of attribute src_file_sha.
-
#src_file_url ⇒ Object
readonly
Returns the value of attribute src_file_url.
Instance Method Summary collapse
-
#initialize(src_file_path, out_path, git, config) ⇒ MdFile
constructor
A new instance of MdFile.
- #write!(theme) ⇒ Object
Constructor Details
#initialize(src_file_path, out_path, git, config) ⇒ MdFile
Returns a new instance of MdFile.
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/bhook/md_file.rb', line 21 def initialize(src_file_path, out_path, git, config) L.debug "Reading: #{src_file_path}" @md = T.let(File.read(src_file_path), String) @src_file_path = src_file_path @out_path = out_path @git = git @config = config @out_file_path = T.let(@out_path.join(out_file_name), Pathname) initialize_file_details end |
Instance Attribute Details
#md ⇒ Object (readonly)
Returns the value of attribute md.
18 19 20 |
# File 'lib/bhook/md_file.rb', line 18 def md @md end |
#out_file_path ⇒ Object (readonly)
Returns the value of attribute out_file_path.
12 13 14 |
# File 'lib/bhook/md_file.rb', line 12 def out_file_path @out_file_path end |
#src_file_date ⇒ Object (readonly)
Returns the value of attribute src_file_date.
15 16 17 |
# File 'lib/bhook/md_file.rb', line 15 def src_file_date @src_file_date end |
#src_file_path ⇒ Object (readonly)
Returns the value of attribute src_file_path.
12 13 14 |
# File 'lib/bhook/md_file.rb', line 12 def src_file_path @src_file_path end |
#src_file_sha ⇒ Object (readonly)
Returns the value of attribute src_file_sha.
15 16 17 |
# File 'lib/bhook/md_file.rb', line 15 def src_file_sha @src_file_sha end |
#src_file_url ⇒ Object (readonly)
Returns the value of attribute src_file_url.
15 16 17 |
# File 'lib/bhook/md_file.rb', line 15 def src_file_url @src_file_url end |
Instance Method Details
#write!(theme) ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/bhook/md_file.rb', line 33 def write!(theme) L.debug "Processing: #{@src_file_sha || 'unversioned'} #{@src_file_path}" rendered_page = theme.render_page(@md, @src_file_sha, @src_file_date, @src_file_url) L.debug "Writing: #{@src_file_sha} #{out_file_path}" File.write(@out_file_path, rendered_page) end |