Class: Zine::CLI
Overview
CLI for zine
Instance Attribute Summary collapse
-
#the_site ⇒ Object
only used in testing.
Instance Method Summary collapse
- #build ⇒ Object
- #force ⇒ Object
- #notice(file) ⇒ Object
- #nuke ⇒ Object
- #post(name) ⇒ Object
- #site ⇒ Object
- #style ⇒ Object
- #version ⇒ Object
Instance Attribute Details
#the_site ⇒ Object
only used in testing
15 16 17 |
# File 'lib/zine/cli.rb', line 15 def the_site @the_site end |
Instance Method Details
#build ⇒ Object
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/zine/cli.rb', line 28 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 # } init_site @the_site.build_site puts Rainbow('Site built').green end |
#force ⇒ Object
40 41 42 43 44 |
# File 'lib/zine/cli.rb', line 40 def force init_site @the_site.build_site_forcing_writes puts Rainbow('Site built').green end |
#notice(file) ⇒ Object
47 48 49 50 51 |
# File 'lib/zine/cli.rb', line 47 def notice(file) init_site @the_site.notice(file) puts Rainbow('Site built').green end |
#nuke ⇒ Object
54 55 56 57 58 59 |
# File 'lib/zine/cli.rb', line 54 def nuke init_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
62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/zine/cli.rb', line 62 def post(name) init_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 |
#site ⇒ Object
75 76 77 78 79 80 |
# File 'lib/zine/cli.rb', line 75 def site # @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
83 84 85 86 87 88 |
# File 'lib/zine/cli.rb', line 83 def style init_site style = Zine::Style.new(['directories']) style.process(File) puts Rainbow('Stylesheet rendered').green end |
#version ⇒ Object
91 92 93 |
# File 'lib/zine/cli.rb', line 91 def version puts VERSION end |