Class: Lono::Task

Inherits:
Object
  • Object
show all
Defined in:
lib/lono/task.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Task

Returns a new instance of Task.



24
25
26
27
28
29
30
31
# File 'lib/lono/task.rb', line 24

def initialize(options={})
  @options = options
  if options.empty?
    @dsl = DSL.new
  else
    @dsl = DSL.new(options)
  end
end

Class Method Details

.generate(options) ⇒ Object



20
21
22
# File 'lib/lono/task.rb', line 20

def self.generate(options)
  new(options).generate
end

.init(options = {}) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/lono/task.rb', line 3

def self.init(options={})
  project_root = options[:project_root] || '.'
  puts "Setting up lono project" unless options[:quiet]
  %w[Guardfile config/lono.rb templates/app.json.erb].each do |name|
    source = File.expand_path("../../files/#{name}", __FILE__)
    dirname = File.dirname(name)
    FileUtils.mkdir(dirname) unless File.exist?(dirname)
    dest = "#{project_root}/#{name}"

    if File.exist?(dest)
      puts "already exists: #{dest}" unless options[:quiet]
    else
      puts "creating: #{dest}" unless options[:quiet]
      FileUtils.cp(source, dest)
    end
  end
end

Instance Method Details

#generateObject



32
33
34
# File 'lib/lono/task.rb', line 32

def generate
  @dsl.run(@options)
end