Class: RhetButler::CommandLine

Inherits:
Thor
  • Object
show all
Defined in:
lib/rhet-butler/command-line.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.shared_optionsObject



8
9
10
11
# File 'lib/rhet-butler/command-line.rb', line 8

def self.shared_options
  method_option :sources, :type => :array
  method_option :root_slide, :type => :string
end

Instance Method Details

#authorObject



94
95
96
97
98
99
100
101
102
103
# File 'lib/rhet-butler/command-line.rb', line 94

def author
  require 'rhet-butler/web/main-app'

  file_manager = FileManager.new(options)
  app = Web::MainApp.new(file_manager)
  app.presentation_app_class = Web::PresentationApp
  app.assets_app_class = Web::AssetsApp
  app.check
  app.start
end

#checkObject



75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/rhet-butler/command-line.rb', line 75

def check
  require 'rhet-butler/web/main-app'

  file_manager = FileManager.new(options)
  app = Web::MainApp.new(file_manager)
  app.presentation_app_class = Web::MemoizedPresentationApp
  app.assets_app_class = Web::MemoizedAssetsApp
  app.check

  slide_count = app.viewer_app.root_step.each_slide.inject(0) do |count, slide|
    count + 1
  end
  say "Slides loaded and parsed"
  say "  #{slide_count} slides loaded"
  say "  Serving slides and assets found in: #{app.slides}"
end

#import(url, target) ⇒ Object



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/rhet-butler/command-line.rb', line 55

def import(url, target)
  require 'rhet-butler/resource-localizer'
  file_manager = FileManager.new(options)
  localizer = ResourceLocalizer.new

  case options[:role]
  when "presenter", "viewer"
    localizer.files = file_manager.aspect_search_path(options[:role])
  else
    localizer.files = file_manager.all_files
  end
  localizer.source_uri = url
  localizer.target_path = target
  localizer.store_log = $stderr unless options[:quiet]

  localizer.go!
end

#initObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/rhet-butler/command-line.rb', line 15

def init
  require 'fileutils'

  file_manager = FileManager.new(options)

  FileUtils.mkdir_p "assets"
  FileUtils.mkdir_p "presenter/assets"
  FileUtils.mkdir_p "viewer/assets"

  skels = file_manager.all_files.sub_set("skels")

  %w{slides.yaml}.each do |path|
    unless Dir.glob(path).empty?
      puts "Refusing to clobber existing: #{path}"
      next
    end

    File::open(path, "w") do |file|
      file.write skels.contents(path)
    end
  end
end

#serveObject



107
108
109
110
111
112
113
114
115
116
# File 'lib/rhet-butler/command-line.rb', line 107

def serve
  require 'rhet-butler/web/main-app'

  file_manager = FileManager.new(options)
  app = Web::MainApp.new(file_manager)
  app.presentation_app_class = Web::MemoizedPresentationApp
  app.assets_app_class = Web::MemoizedAssetsApp
  app.check
  app.start
end

#staticObject



42
43
44
45
46
47
48
49
50
# File 'lib/rhet-butler/command-line.rb', line 42

def static
  require 'rhet-butler/static-generator'

  file_manager = FileManager.new(options)
  generator = StaticGenerator.new(file_manager)
  generator.store_log = $stderr unless options[:quiet]

  generator.go!
end