Module: Rawfeed::Tools

Defined in:
lib/rawfeed/command/tools.rb

Overview

Tooling utilities providing specific CLI build and helper commands. Handles asset minification, cache cleaning, and jekyll lifecycle wrapping.

Class Method Summary collapse

Class Method Details

.build(*args) ⇒ void

This method returns an undefined value.

Wraps the ‘jekyll build` command and passes along any specific arguments. Overrides help text to say “rawfeed” instead of “jekyll”.

Parameters:

  • args (Array<String>)

    Build arguments to pass to Jekyll.



103
104
105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/rawfeed/command/tools.rb', line 103

def self.build(*args)
  if args.include?("--help")
    output, = Open3.capture2(*["bundle", "exec", "jekyll", "build", "--help"])
    puts output.gsub(/jekyll/, "rawfeed")
  else
    begin
      cmd = ["bundle", "exec", "jekyll", "build"] + args
      system(*cmd)
    rescue Interrupt
      puts "\n[!] Approached by the user".yellow
      exit!
    end
  end
end

.clean(*args) ⇒ void

This method returns an undefined value.

Cleans the Jekyll cache or the entire generated project.

Parameters:

  • args (Array<String>)

    Command line arguments (e.g., ‘–cache’ or ‘–all’).



17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/rawfeed/command/tools.rb', line 17

def self.clean(*args)
  if args.include?("--cache")
    Rawfeed::Build::Cleaner.clean_jekyll_cache
  elsif args.include?("--all")
    Rawfeed::Build::Cleaner.clean_project
  else
    puts "Missing argument.".red
    puts "Use one of:".yellow
    puts "  --all   → clean full project"
    puts "  --cache → clean only Jekyll cache"
    exit 1
  end
end

.helpvoid

This method returns an undefined value.

Prints the CLI help documentation to standard output. Exits cleanly.



34
35
36
37
38
39
40
41
42
43
44
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
72
73
74
75
76
77
78
# File 'lib/rawfeed/command/tools.rb', line 34

def self.help
  begin
    puts "rawfeed-jekyll - A batteries-included Jekyll framework and CLI".bold
    puts "\nUsage: rawfeed <command> [options]".yellow
    puts "\nCommands:".bold
    puts "  new <path>        Create a new rawfeed site"
    puts "                    Use '.' to create in current directory"
    puts "                    Add --force to override non-empty directory"
    puts "  install           Install dependencies (Bundle)"
    puts "  build [OPTIONS]   Build the site"
    puts "  serve [OPTIONS]   Run local development server"
    puts "  minify            Minify JS, HTML and images in _site/"
    puts "                    (requires ImageMagick for image minification)"
    puts "  backup            Create a backup of your site"
    puts "                    Options:"
    puts "                      -d, --destination PATH  Save backup to a specific directory"
    puts "                      -a, --append PATH       Add extra files/folders to backup"
    puts "  clean --cache     Clean Jekyll cache"
    puts "  clean --all       Clean entire project"
    puts "\nContent Generators:".bold
    puts "  create:draft      Create a draft for a post"
    puts "  create:page       Create a page"
    puts "  create:pixel      Create a post for pixel"
    puts "  restore:resume    Restore the resume page (CV)"
    puts "  restore:donate    Restore the donation page"
    puts "  restore:contact   Restore the contact page"
    puts "  restore:licenses  Restore the licenses page"
    puts "  post:draft        Opens a selector to move drafts to posting"
    puts "\nLayout Commands:".bold
    puts "  home:about        Set the home page as the about page"
    puts "  home:blog         Set the home page as the weblog page"
    puts "  blog:enable       Enable the Blog"
    puts "  blog:disable      Disables the Blog, leaving only the pages"
    puts "  pixels:enable     Enable the Pixels"
    puts "  pixels:disable    Disables the Pixels, leaving only the pages"
    puts "\nOptions:".bold
    puts "  For Jekyll build/serve options, run:"
    puts "    rawfeed build --help"
    puts "    rawfeed serve --help"
    puts "\nFor more info: https://rawfeed.github.io/rawfeed-jekyll".cyan
  rescue Interrupt
    puts "\n[!] Approached by the user".yellow
    exit!
  end
end

.installvoid

This method returns an undefined value.

Runs ‘bundle install` to install ruby dependencies for the generated site.



82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/rawfeed/command/tools.rb', line 82

def self.install
  puts "Installing Ruby gems...".blue
  begin
      success = system("bundle install")
  rescue Interrupt
    puts "\n[!] Approached by the user".yellow
    exit!
  end

  if success
    puts "Dependencies installed successfully!".green
  else
    puts "[!] bundle install failed".red
    exit 1
  end
end

.minifyvoid

This method returns an undefined value.

Triggers asset minification (HTML, JS, and image files) within the build site folder.



10
11
12
# File 'lib/rawfeed/command/tools.rb', line 10

def self.minify
  Rawfeed::Build::Minifier.minify_all
end

.serve(*args) ⇒ void

This method returns an undefined value.

Wraps the ‘jekyll serve` command and passes along any specific arguments. Overrides help text to say “rawfeed” instead of “jekyll”.

Parameters:

  • args (Array<String>)

    Serve arguments to pass to Jekyll.



122
123
124
125
126
127
128
129
130
131
132
133
134
135
# File 'lib/rawfeed/command/tools.rb', line 122

def self.serve(*args)
  if args.include?("--help")
    output, = Open3.capture2(*["bundle", "exec", "jekyll", "serve", "--help"])
    puts output.gsub(/jekyll/, "rawfeed")
  else
    begin
      cmd = ["bundle", "exec", "jekyll", "serve"] + args
      system(*cmd)
    rescue Interrupt
      puts "\n[!] Approached by the user".yellow
      exit!
    end
  end
end