Class: Octodown::Renderer::GithubMarkdown
- Inherits:
-
Object
- Object
- Octodown::Renderer::GithubMarkdown
- Includes:
- HTML, Renderable
- Defined in:
- lib/octodown/renderer/github_markdown.rb
Instance Attribute Summary collapse
-
#file ⇒ Object
readonly
Returns the value of attribute file.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #content ⇒ Object
-
#initialize(file, options = {}) ⇒ GithubMarkdown
constructor
A new instance of GithubMarkdown.
Methods included from Renderable
Constructor Details
#initialize(file, options = {}) ⇒ GithubMarkdown
Returns a new instance of GithubMarkdown.
16 17 18 19 20 |
# File 'lib/octodown/renderer/github_markdown.rb', line 16 def initialize(file, = {}) @file = file @options = @logger = [:logger] end |
Instance Attribute Details
#file ⇒ Object (readonly)
Returns the value of attribute file.
14 15 16 |
# File 'lib/octodown/renderer/github_markdown.rb', line 14 def file @file end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
14 15 16 |
# File 'lib/octodown/renderer/github_markdown.rb', line 14 def logger @logger end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
14 15 16 |
# File 'lib/octodown/renderer/github_markdown.rb', line 14 def @options end |
Instance Method Details
#content ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/octodown/renderer/github_markdown.rb', line 22 def content if file == STDIN buffer = file.read else begin File.open(file.path, 'r') { |f| buffer = f.read } rescue Errno::ENOENT logger.warn 'Something went wrong when trying to open the file' end end pipeline.call(buffer ||= 'could not read changes')[:output].to_s end |