Class: Pliny::Commands::Creator

Inherits:
Object
  • Object
show all
Defined in:
lib/pliny/commands/creator.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}, opts = {}, stream = $stdout) ⇒ Creator

Returns a new instance of Creator.



16
17
18
19
20
# File 'lib/pliny/commands/creator.rb', line 16

def initialize(args = {}, opts = {}, stream = $stdout)
  @args = args
  @opts = opts
  @stream = stream
end

Instance Attribute Details

#argsObject

Returns the value of attribute args.



10
11
12
# File 'lib/pliny/commands/creator.rb', line 10

def args
  @args
end

#optsObject

Returns the value of attribute opts.



10
11
12
# File 'lib/pliny/commands/creator.rb', line 10

def opts
  @opts
end

#streamObject

Returns the value of attribute stream.



10
11
12
# File 'lib/pliny/commands/creator.rb', line 10

def stream
  @stream
end

Class Method Details

.run(args, opts = {}, stream = $stdout) ⇒ Object



12
13
14
# File 'lib/pliny/commands/creator.rb', line 12

def self.run(args, opts = {}, stream = $stdout)
  new(args, opts, stream).run!
end

Instance Method Details

#run!Object



22
23
24
25
26
27
28
29
30
# File 'lib/pliny/commands/creator.rb', line 22

def run!
  abort("#{name} already exists") if File.exist?(app_dir)

  FileUtils.copy_entry template_dir, app_dir
  FileUtils.rm_rf("#{app_dir}/.git")
  parse_erb_files
  display 'Pliny app created. To start, run:'
  display "cd #{app_dir} && bin/setup"
end