Class: Resulang::Exec

Inherits:
Thor
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/resulang/exec.rb

Instance Method Summary collapse

Instance Method Details

#makeObject



52
53
54
55
56
# File 'lib/resulang/exec.rb', line 52

def make
  app       = Resulang::App.new(path: File.expand_path('.'))
  processor = app.processor(output: options[:output], format: :html)
  create_file(processor.filename, force: options[:force]) { processor.process }
end

#new(name) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/resulang/exec.rb', line 10

def new(name)
  empty_directory(name)
  inside(name) do
    create_file "server.ru" do
      <<-SERVER
        require "resulang/server"
        run Resulang::Server
      SERVER
    end

    empty_directory('data')
    inside('data') do
      create_file('resume.rb') do
        options[:sections].inject([]) { |list, s| list.push("#{s} do\n\nend") }.join("\n\n")
      end

      empty_directory('sections')
      inside('sections') do
        options[:sections].each do |s|
          create_file("#{s}.rb", "class #{ActiveSupport::Inflector.camelize(s)} < Resulang::Section\n\nend")
        end
      end
    end

    empty_directory 'templates'
    inside('templates') do
      create_file('resume.html.erb')
      options[:sections].each do |s|
        create_file("_#{s}.html.erb")
      end
    end
  end
end

#serverObject



45
46
47
# File 'lib/resulang/exec.rb', line 45

def server
  run %{rackup server.ru}
end