Class: Mkmatter::App::Classes::Tags
- Includes:
- Thor::Actions
- Defined in:
- lib/mkmatter/cli/subs/tags.rb
Instance Method Summary collapse
- #find(type) ⇒ Object
-
#gen ⇒ Object
only used for posts.
- #new_tag(tag) ⇒ Object
Instance Method Details
#find(type) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/mkmatter/cli/subs/tags.rb', line 12 def find(type) if Mkmatter::Methods.check_if_jekyll table = Terminal::Table.new table.title = type.capitalize table.style.all_separators = true table.headings = ["#{Paint['Path from Jekyll Root', 'white', :bold]}", "#{Paint['Tags', 'white', :bold]}"] front_matter = Mkmatter::Methods.find_front_matter(type, 'tags') front_matter.each do |path, | path = path.gsub(/#{Mkmatter::Methods.get_jekyll_root}(\/.*)/, '\1') table.add_row([path, "#{.join("\n")}"]) end table.align_column(1, :right) puts table else $stderr.puts "#{Paint['Error', :red, :bold]}: Not a Jekyll source directory (no '_config.yml' found in any parent directory)" end end |
#gen ⇒ Object
only used for posts
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/mkmatter/cli/subs/tags.rb', line 45 def gen # only used for posts if [:'dry-run'] if Mkmatter::Tags.has_tag_folder? front_matter = Mkmatter::Methods.find_front_matter('post', 'tags') = [] front_matter.each do |key, value| << value end = .flatten.sort.uniq Mkmatter::Tags.dry_gen else $stderr.puts "#{Paint['Error', :red, :bold]}: No tag folder" end else if Mkmatter::Tags.has_tag_folder? front_matter = Mkmatter::Methods.find_front_matter('post', 'tags') = [] front_matter.each do |key, value| << value end = .flatten.sort.uniq Mkmatter::Tags. else $stderr.puts "#{Paint['Error', :red, :bold]}: Not a Jekyll source directory (no '_config.yml' found in any parent directory)" end end end |
#new_tag(tag) ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/mkmatter/cli/subs/tags.rb', line 33 def new_tag(tag) if Mkmatter::Methods.check_if_jekyll else $stderr.puts "#{Paint['Error', :red, :bold]}: Not a Jekyll source directory (no '_config.yml' found in any parent directory)" end end |