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
13 14 15 |
# File 'lib/zine/cli.rb', line 13 def the_site @the_site end |
Instance Method Details
#build ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/zine/cli.rb', line 22 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
34 35 36 37 38 |
# File 'lib/zine/cli.rb', line 34 def force init_site @the_site.build_site_forcing_writes puts Rainbow('Site built').green end |
#notice(file) ⇒ Object
41 42 43 44 45 |
# File 'lib/zine/cli.rb', line 41 def notice(file) init_site @the_site.notice(file) puts Rainbow('Site built').green end |
#nuke ⇒ Object
48 49 50 51 52 53 |
# File 'lib/zine/cli.rb', line 48 def nuke init_site FileUtils.remove_dir @the_site.['directories']['build'], force: true puts Rainbow('Site nuked. It\'s the only way to be sure.').green end |
#post(name) ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/zine/cli.rb', line 56 def post(name) init_site = @the_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
70 71 72 73 74 75 |
# File 'lib/zine/cli.rb', line 70 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
78 79 80 81 82 83 |
# File 'lib/zine/cli.rb', line 78 def style init_site style = Zine::Style.new(@the_site.['directories']) style.process(File) puts Rainbow('Stylesheet rendered').green end |
#version ⇒ Object
86 87 88 |
# File 'lib/zine/cli.rb', line 86 def version puts VERSION end |