Add const Repubmark::FORMATS
This commit is contained in:
parent
be5ce87dab
commit
8a6d2ca90e
3 changed files with 11 additions and 9 deletions
|
@ -8,10 +8,10 @@ require 'bundler/setup'
|
||||||
|
|
||||||
require 'repubmark'
|
require 'repubmark'
|
||||||
|
|
||||||
FORMATS = %w[word_count html gemtext].freeze
|
format = String(ARGV[0]).to_sym
|
||||||
|
unless Repubmark::FORMATS.include? format
|
||||||
format = String(ARGV[0]).freeze
|
raise "Invalid format: #{format.inspect}"
|
||||||
raise "Invalid format: #{format.inspect}" unless FORMATS.include? format
|
end
|
||||||
|
|
||||||
template = $stdin.read.freeze
|
template = $stdin.read.freeze
|
||||||
|
|
||||||
|
@ -37,9 +37,9 @@ context.instance_eval template, __FILE__, __LINE__
|
||||||
|
|
||||||
output =
|
output =
|
||||||
case format
|
case format
|
||||||
when 'word_count' then $article.word_count
|
when :word_count then $article.word_count
|
||||||
when 'html' then $article.to_html
|
when :html then $article.to_html
|
||||||
when 'gemtext' then $article.to_gemtext
|
when :gemtext then $article.to_gemtext
|
||||||
end.to_s.strip
|
end.to_s.strip
|
||||||
|
|
||||||
puts output unless output.empty?
|
puts output unless output.empty?
|
||||||
|
|
|
@ -54,3 +54,7 @@ require_relative 'repubmark/elems/section'
|
||||||
require_relative 'repubmark/elems/special'
|
require_relative 'repubmark/elems/special'
|
||||||
require_relative 'repubmark/elems/text'
|
require_relative 'repubmark/elems/text'
|
||||||
require_relative 'repubmark/elems/link'
|
require_relative 'repubmark/elems/link'
|
||||||
|
|
||||||
|
module Repubmark
|
||||||
|
FORMATS = %i[gemtext html].freeze
|
||||||
|
end
|
||||||
|
|
|
@ -3,8 +3,6 @@
|
||||||
module Repubmark
|
module Repubmark
|
||||||
module Elems
|
module Elems
|
||||||
class CustomLogue < Base
|
class CustomLogue < Base
|
||||||
FORMATS = %i[html gemtext].freeze
|
|
||||||
|
|
||||||
parents :Article
|
parents :Article
|
||||||
|
|
||||||
def initialize(parent)
|
def initialize(parent)
|
||||||
|
|
Loading…
Reference in a new issue