Class: Rna::Task

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Task

Returns a new instance of Task.



28
29
30
31
# File 'lib/rna/task.rb', line 28

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

Class Method Details

.generate(options) ⇒ Object



24
25
26
# File 'lib/rna/task.rb', line 24

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
20
21
22
23
# File 'lib/rna/task.rb', line 3

def self.init(options={})
  project_root = options[:project_root] || '.'
  puts "Setting up lono project" unless options[:quiet]
  source_root = File.expand_path("../../starter_project", __FILE__)
  paths = Dir.glob("#{source_root}/**/*").
            select {|p| File.file?(p) }
  paths.each do |src|
    dest = src.gsub(%r{.*starter_project/},'')
    dest = "#{project_root}/#{dest}"

    if File.exist?(dest) and !options[:force]
      puts "already exists: #{dest}" unless options[:quiet]
    else
      puts "creating: #{dest}" unless options[:quiet]
      dirname = File.dirname(dest)
      FileUtils.mkdir_p(dirname) unless File.exist?(dirname)
      FileUtils.cp(src, dest)
    end
  end
  puts "Starter lono project created"
end

Instance Method Details

#generateObject



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

def generate
  @dsl.run
end