Class: Zine::CLI
Overview
CLI for zine
Instance Attribute Summary collapse
-
#site ⇒ Object
only used in testing.
Instance Method Summary collapse
- #build ⇒ Object
- #force ⇒ Object
- #notice(file) ⇒ Object
- #nuke ⇒ Object
- #post(name) ⇒ Object
- #skeleton ⇒ Object
- #style ⇒ Object
- #version ⇒ Object
Instance Attribute Details
#site ⇒ Object
only used in testing
15 16 17 |
# File 'lib/zine/cli.rb', line 15 def site @site end |
Instance Method Details
#build ⇒ Object
39 40 41 42 43 44 45 46 47 48 |
# File 'lib/zine/cli.rb', line 39 def build # set_trace_func proc { |event, file, line, id, _binding, classname| # if event == 'call' && classname.name.split('::').first == 'Zine' # printf "%25s\#%s\t\t\t%s:%-2d\n", classname, id, file, line # end # } site @site.build_site puts Rainbow('Site built').green end |
#force ⇒ Object
51 52 53 54 55 |
# File 'lib/zine/cli.rb', line 51 def force site @site.build_site_forcing_writes puts Rainbow('Site built').green end |
#notice(file) ⇒ Object
58 59 60 61 62 |
# File 'lib/zine/cli.rb', line 58 def notice(file) site @site.notice(file) puts Rainbow('Site built').green end |
#nuke ⇒ Object
65 66 67 68 69 70 |
# File 'lib/zine/cli.rb', line 65 def nuke site FileUtils.remove_dir ['directories']['build'], force: true puts Rainbow('Site nuked. It\'s the only way to be sure.').green end |
#post(name) ⇒ Object
73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/zine/cli.rb', line 73 def post(name) site option_dir = ['directories'] Zine::CLI.source_root option_dir['templates'] @date = DateTime.now @name = name file = "#{@date.strftime('%Y-%m-%d')}-#{Zine::Page.slug(name)}.md" new_post_name = ['templates']['new_post'] template new_post_name, File.join(Dir.pwd, option_dir['posts'], file) end |
#skeleton ⇒ Object
86 87 88 89 90 91 |
# File 'lib/zine/cli.rb', line 86 def skeleton # @skeleton_dir ? skeleton_dir = File.join File.dirname(__FILE__), 'skeleton', '/.' FileUtils.cp_r skeleton_dir, Dir.pwd puts Rainbow('New skeleton site created').green end |
#style ⇒ Object
94 95 96 97 98 99 |
# File 'lib/zine/cli.rb', line 94 def style site style = Zine::Style.new(['directories']) style.process(File) puts Rainbow('Stylesheet rendered').green end |
#version ⇒ Object
102 103 104 |
# File 'lib/zine/cli.rb', line 102 def version puts VERSION end |