Class: Mkmatter::Tags
- Includes:
- Thor::Actions
- Defined in:
- lib/mkmatter/cli/tags.rb
Constant Summary collapse
- HILINE =
HighLine.new($stdin, $stderr, 80)
Class Method Summary collapse
-
.dry_gen(tags) ⇒ Boolean
Whether generation was successful.
- .gen_post_tags(tags) ⇒ Object
- .get_tags ⇒ Object
- .has_tag_folder? ⇒ Boolean
Class Method Details
.dry_gen(tags) ⇒ Boolean
Returns whether generation was successful.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/mkmatter/cli/tags.rb', line 24 def Tags.dry_gen() if Mkmatter::Methods.check_if_jekyll if Tags.has_tag_folder? .each do |tag| file = "#{Mkmatter::Methods.get_jekyll_root}/tag/#{tag}.md" puts <<-PUTS.strip_heredoc --- title: #{tag.titleize} tag: #{tag} --- PUTS end else end end end |
.gen_post_tags(tags) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/mkmatter/cli/tags.rb', line 42 def Tags.() if Mkmatter::Methods.check_if_jekyll if Tags.has_tag_folder? .each do |tag| file = "#{Mkmatter::Methods.get_jekyll_root}/tag/#{tag}.md" self.new.create_file file do <<-PUTS --- #{tag_index unless tag_index.nil?} title: #{tag.titleize} tag: #{tag} --- PUTS end end else end end end |
.get_tags ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/mkmatter/cli/tags.rb', line 62 def Tags. yaml_loader = ->(string) {YAML.load(string)} files = [] front_matter = {} Find.find(Pathname(Methods.get_jekyll_root).join('_posts').to_path) do |path| files << path if path =~ /.*(\.html|\.md)$/ end files.each do |ele| yaml = FrontMatterParser::Parser.parse_file(ele, syntax_parser: :md, loader: yaml_loader).front_matter front_matter[ele] = yaml['tags'] if yaml['tags'] front_matter[ele] = yaml['tag'] if yaml['tag'] end front_matter.select! {|k, v| !v.nil?} front_matter end |
.has_tag_folder? ⇒ Boolean
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/mkmatter/cli/tags.rb', line 10 def Tags.has_tag_folder? if Mkmatter::Methods.check_if_jekyll if Mkmatter::Methods.get_jekyll_root.join('tag/').exist? true else false end else false end end |