Class: Zine::CLI

Inherits:
Thor
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/zine/cli.rb

Overview

CLI for zine

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#siteObject

only used in testing



15
16
17
# File 'lib/zine/cli.rb', line 15

def site
  @site
end

Instance Method Details

#buildObject



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

#forceObject



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

#nukeObject



65
66
67
68
69
70
# File 'lib/zine/cli.rb', line 65

def nuke
  site
  FileUtils.remove_dir options['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 = options['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 = options['templates']['new_post']
  template new_post_name,
           File.join(Dir.pwd, option_dir['posts'], file)
end

#skeletonObject



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

#styleObject



94
95
96
97
98
99
# File 'lib/zine/cli.rb', line 94

def style
  site
  style = Zine::Style.new(options['directories'])
  style.process(File)
  puts Rainbow('Stylesheet rendered').green
end

#versionObject



102
103
104
# File 'lib/zine/cli.rb', line 102

def version
  puts VERSION
end