Class: Nrb::Commands::Script

Inherits:
Thor::Group
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/nrb/commands/script.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.source_rootObject



18
19
20
# File 'lib/nrb/commands/script.rb', line 18

def self.source_root
  File.expand_path('..', __dir__)
end

Instance Method Details

#bootObject



52
53
54
# File 'lib/nrb/commands/script.rb', line 52

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

#bundle_installObject



73
74
75
76
77
78
79
# File 'lib/nrb/commands/script.rb', line 73

def bundle_install
  return unless options[:bundle]

  inside target, verbose: true do
    run 'bundle install'
  end
end

#config_nrbObject



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

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

#db_configObject



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

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

#directoriesObject



46
47
48
49
50
# File 'lib/nrb/commands/script.rb', line 46

def directories
  Nrb.config.directories.each do |dir|
    create_file target("#{dir}/.keep")
  end
end

#gemfileObject



32
33
34
35
# File 'lib/nrb/commands/script.rb', line 32

def gemfile
  template 'templates/Gemfile.tt', target('Gemfile'),
    version: Nrb::VERSION
end

#gitignoreObject



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

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

#initialize_repoObject



65
66
67
68
69
70
71
# File 'lib/nrb/commands/script.rb', line 65

def initialize_repo
  return unless options[:repo]

  inside target, verbose: true do
    run 'git init'
  end
end

#rakefileObject



37
38
39
# File 'lib/nrb/commands/script.rb', line 37

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

#readmeObject



26
27
28
29
30
# File 'lib/nrb/commands/script.rb', line 26

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

#script_fileObject



61
62
63
# File 'lib/nrb/commands/script.rb', line 61

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