Class: GoScript::Template

Inherits:
Object
  • Object
show all
Defined in:
lib/go_script/template.rb

Class Method Summary collapse

Class Method Details

.endObject

rubocop:enable MethodLength



90
91
92
# File 'lib/go_script/template.rb', line 90

def self.end
  "execute_command ARGV\n"
end

.preambleObject

rubocop:disable MethodLength



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/go_script/template.rb', line 6

def self.preamble
  "#! /usr/bin/env ruby\n#\n# The preamble down to the check_ruby_version line was generated by version\n# \#{VERSION} of the go_script gem. This preamble tries to load bundler state\n# from Gemfile.lock if present, then the go_script gem for core functionality.\n#\n# This means the ./go script will run `gem install` or `bundle install` as\n# necessary when invoked for the first time, or when dependencies change. It\n# also means that commands invoked within the ./go script do not need to be\n# prefixed with `bundle exec`.\n\nrequire 'English'\n\nDir.chdir File.dirname(__FILE__)\n\n# If a require statement fails, the script calls try_command_and_restart to\n# try to install the necessary gems before re-executing itself with the\n# original arguments.\ndef try_command_and_restart(command)\n  exit $CHILD_STATUS.exitstatus unless system command\n\n  # If the RUBYOPT environment variable is set, bundler will presume that it\n  # has already run. Hence, filtering out RUBYOPT forces bundler to load its\n  # state during the re-execution.\n  env = {}.merge(ENV)\n  env.delete('RUBYOPT')\n  exec(env, RbConfig.ruby, *[$PROGRAM_NAME].concat(ARGV))\nend\n\nbegin\n  require 'bundler/setup' if File.exist? 'Gemfile'\nrescue LoadError\n  try_command_and_restart 'gem install bundler'\nrescue SystemExit\n  try_command_and_restart 'bundle install'\nend\n\nbegin\n  require 'go_script'\nrescue LoadError\n  try_command_and_restart 'gem install go_script' unless File.exist? 'Gemfile'\n  abort \"Please add \\\\\\\"gem 'go_script'\\\\\\\" to your Gemfile\"\nend\n\nextend GoScript\ncheck_ruby_version '\#{RUBY_VERSION}'\n\n# END go_script \#{VERSION} GENERATED CONTENT\n\n"
end

.standard_dev_commandsObject

rubocop:disable MethodLength



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/go_script/template.rb', line 62

def self.standard_dev_commands
  "command_group :dev, 'Development commands'\n\ndef_command :init, 'Set up the development environment' do\nend\n\ndef_command :update_gems, 'Update Ruby gems' do |gems|\n  update_gems gems\nend\n\ndef_command :update_js, 'Update JavaScript components' do\n  update_node_modules\nend\n\ndef_command :test, 'Execute automated tests' do |args|\n  exec_cmd \"rake test \\\#{args_to_string args}\"\nend\n\ndef_command :lint, 'Run style-checking tools' do |files|\n  lint_ruby files  # uses rubocop\n  lint_javascript Dir.pwd, files  # uses node_modules/eslint\nend\n\n"
end