Class: AppEngine::Admin::JRubyAppCfg
- Inherits:
-
Object
- Object
- AppEngine::Admin::JRubyAppCfg
- Defined in:
- lib/appengine-tools/appcfg.rb
Constant Summary collapse
- NO_XML_COMMANDS =
%w{version}- RUBY_COMMANDS =
%w{gem bundle help run generate_app}- COMMAND_SUMMARY =
" run: run jruby in your application environment.\n bundle: package your application for deployment.\n The 'run' command assumes the app directory is the current directory.\n"
Class Method Summary collapse
- .appcfg_command ⇒ Object
- .bundle(*args) ⇒ Object
- .bundle_help ⇒ Object
- .gem(*args) ⇒ Object
- .gem_help ⇒ Object
- .generate_app(*args) ⇒ Object
- .generate_app_help ⇒ Object
- .help(command = nil) ⇒ Object
- .main(args) ⇒ Object
- .parse_args(args) ⇒ Object
- .print_help(help, summary) ⇒ Object
- .run(*args) ⇒ Object
- .run_appcfg(args) ⇒ Object
- .run_help ⇒ Object
Class Method Details
.appcfg_command ⇒ Object
126 127 128 129 130 131 |
# File 'lib/appengine-tools/appcfg.rb', line 126 def appcfg_command plugin_jar = File.join(File.dirname(__FILE__), 'app_yaml.jar') command = %W(java -cp #{AppEngine::SDK::TOOLS_JAR}) command << "-Dcom.google.appengine.plugin.path=#{plugin_jar}" command << 'com.google.appengine.tools.admin.AppCfg' end |
.bundle(*args) ⇒ Object
76 77 78 79 80 81 82 |
# File 'lib/appengine-tools/appcfg.rb', line 76 def bundle(*args) if File.directory?(args[-1] || '') AppEngine::Admin.bundle_app(*args) else bundle_help end end |
.bundle_help ⇒ Object
84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/appengine-tools/appcfg.rb', line 84 def bundle_help help = "\#{$0} bundle [gem bundle options] app_dir\n\nBundles the gems listed in Gemfile and generates files necessary\nto run an application as a servlet. This runs automatically for you,\nbut you need to run it manually to update gems if you don't specify\na version number. Pass --update to refresh bundled gems.\n\n" end |
.gem(*args) ⇒ Object
96 97 98 |
# File 'lib/appengine-tools/appcfg.rb', line 96 def gem(*args) gem_help end |
.gem_help ⇒ Object
100 101 102 103 104 105 106 107 108 |
# File 'lib/appengine-tools/appcfg.rb', line 100 def gem_help help = "\nSorry, the 'appcfg.rb gem' option is deprecated.\nSimply update the 'Gemfile' and run 'appcfg.rb bundle .' instead.\n\n" puts help end |
.generate_app(*args) ⇒ Object
54 55 56 57 58 59 60 61 62 63 |
# File 'lib/appengine-tools/appcfg.rb', line 54 def generate_app(*args) if args and args.size > 0 appdir = args.pop webinf = File.join(appdir, 'WEB-INF') FileUtils.mkdir_p(webinf) AppEngine::Admin.bundle_app(appdir) else generate_app_help end end |
.generate_app_help ⇒ Object
65 66 67 68 69 70 71 72 73 74 |
# File 'lib/appengine-tools/appcfg.rb', line 65 def generate_app_help help = "\#{$0} generate_app app_dir\n\nGenerates a sample Rack application in app_dir.\nThe directory is created if it doesn't exist.\n\n" puts help end |
.help(command = nil) ⇒ Object
133 134 135 136 137 138 139 140 141 142 |
# File 'lib/appengine-tools/appcfg.rb', line 133 def help(command=nil) puts if command != 'help' && RUBY_COMMANDS.include?(command) puts send("#{command}_help") else java_args = appcfg_command << 'help' java_args << command if command print_help(%x{#{java_args.map{|x| x.inspect}.join(' ')}}, !command) end end |
.main(args) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/appengine-tools/appcfg.rb', line 34 def main(args) command, parsed_args = parse_args(args) if RUBY_COMMANDS.include? command send(command, *parsed_args) return end if command && !NO_XML_COMMANDS.include?(command) path = parsed_args[0] AppEngine::Admin.bundle_app(path) updater = AppEngine::Admin::UpdateCheck.new(path) updater.nag end puts "=> Running AppCfg" run_appcfg(args) end |
.parse_args(args) ⇒ Object
157 158 159 160 161 162 163 164 165 166 167 168 169 170 |
# File 'lib/appengine-tools/appcfg.rb', line 157 def parse_args(args) if RUBY_COMMANDS.include?(args[0]) return [args[0], args[1, args.length]] elsif args.empty? || !(%w(-h --help) & args).empty? return ['help', []] elsif args[-3] == 'request_logs' command = args[-3] path = args[-2] else command = args[-2] path = args[-1] end return [command, [path]] end |
.print_help(help, summary) ⇒ Object
144 145 146 147 148 149 150 151 152 153 154 155 |
# File 'lib/appengine-tools/appcfg.rb', line 144 def print_help(help, summary) help.gsub!('AppCfg', $0) count = 0 help.each_line do |line| line.chomp! if summary && line.size > 0 && line.lstrip == line count += 1 print COMMAND_SUMMARY if count == 3 end puts line end end |
.run(*args) ⇒ Object
110 111 112 113 |
# File 'lib/appengine-tools/appcfg.rb', line 110 def run(*args) AppEngine::Admin.bundle_deps('.') AppEngine::Development.boot_app('.', args) end |
.run_appcfg(args) ⇒ Object
50 51 52 |
# File 'lib/appengine-tools/appcfg.rb', line 50 def run_appcfg(args) exec *(appcfg_command + args) end |
.run_help ⇒ Object
115 116 117 118 119 120 121 122 123 124 |
# File 'lib/appengine-tools/appcfg.rb', line 115 def run_help help = "\#{$0} run [ruby args]\n\nStarts the jruby interpreter within your application's environment.\nUse `\#{$0} run -S command` to run a command such as rake or irb.\nMust be run from the application directory, after running bundle.\n\n" end |