Class: Nrb::Commands::Script

Inherits:
Base
  • Object
show all
Includes:
ScriptGenerator
Defined in:
lib/nrb/commands/script.rb

Overview

This command generates a new script scaffold.

Instance Method Summary collapse

Methods inherited from Base

#opts, source_root

Instance Method Details

#bootObject



40
41
42
# File 'lib/nrb/commands/script.rb', line 40

def boot
  template 'templates/config/boot.rb.tt', target('config/boot.rb'), opts
end

#bundle_installObject



61
62
63
64
65
66
67
68
69
# File 'lib/nrb/commands/script.rb', line 61

def bundle_install
  return unless options[:bundle_install]

  inside target, opts do
    Bundler.with_clean_env do
      try_loud_command('bundle install')
    end
  end
end

#config_nrbObject



29
30
31
32
# File 'lib/nrb/commands/script.rb', line 29

def config_nrb
  template 'templates/config/nrb.rb.tt', target('config/nrb.rb'),
    opts.merge(resources: Nrb.resources)
end

#db_configObject



44
45
46
47
# File 'lib/nrb/commands/script.rb', line 44

def db_config
  template 'templates/db/config.yml.tt', target('db/config.yml'),
    opts.merge(db: name)
end

#gemfileObject



20
21
22
23
# File 'lib/nrb/commands/script.rb', line 20

def gemfile
  template 'templates/Gemfile.tt', target('Gemfile'),
    opts.merge(nrb_gem: nrb_gem)
end

#gitignoreObject



11
12
13
# File 'lib/nrb/commands/script.rb', line 11

def gitignore
  template 'templates/.gitignore.tt', target('.gitignore'), opts
end

#initialize_repoObject



53
54
55
56
57
58
59
# File 'lib/nrb/commands/script.rb', line 53

def initialize_repo
  return unless options[:init_repo]

  inside target, opts do
    try_loud_command('git init')
  end
end

#rakefileObject



25
26
27
# File 'lib/nrb/commands/script.rb', line 25

def rakefile
  template 'templates/Rakefile.tt', target('Rakefile'), opts
end

#readmeObject



15
16
17
18
# File 'lib/nrb/commands/script.rb', line 15

def readme
  template 'templates/README.md.tt', target('README.md'),
    opts.merge(title: name, version: Nrb::VERSION)
end

#resourcesObject



34
35
36
37
38
# File 'lib/nrb/commands/script.rb', line 34

def resources
  Nrb.resources.each do |dir|
    create_file target("#{dir}/.keep"), opts
  end
end

#script_fileObject



49
50
51
# File 'lib/nrb/commands/script.rb', line 49

def script_file
  template 'templates/script.rb.tt', "#{target(name)}.rb", opts
end