appengine-tools 0.0.14 → 0.0.15.pre

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -3,11 +3,15 @@ require 'rake/gempackagetask'
3
3
  require 'rubygems/specification'
4
4
  require 'date'
5
5
  require 'spec/rake/spectask'
6
+ require 'appengine-sdk'
6
7
 
7
8
  GEM = "appengine-tools"
8
- GEM_VERSION = "0.0.14"
9
+ GEM_VERSION = "0.0.15.pre"
9
10
  HOMEPAGE = "http://code.google.com/p/appengine-jruby"
10
11
 
12
+ PLUGIN_SOURCE = 'src/com/google/appengine/jruby/JRubyYamlPlugin.java'
13
+ JAR_FILE = 'lib/appengine-tools/app_yaml.jar'
14
+
11
15
  spec = Gem::Specification.new do |s|
12
16
  s.name = GEM
13
17
  s.version = GEM_VERSION
@@ -25,7 +29,7 @@ EOF
25
29
 
26
30
  s.require_path = 'lib'
27
31
  s.files = %w(COPYING LICENSE README.rdoc Rakefile) +
28
- Dir.glob("{lib,spec}/**/*.{rb,class}")
32
+ Dir.glob("{lib,spec}/**/*.{rb,class}") + [JAR_FILE]
29
33
  s.executables = [ 'appcfg.rb', 'dev_appserver.rb' ]
30
34
  s.add_dependency('appengine-rack')
31
35
  s.add_dependency('appengine-sdk')
@@ -56,3 +60,15 @@ task :make_spec do
56
60
  file.puts spec.to_ruby
57
61
  end
58
62
  end
63
+
64
+ def sh!(*args)
65
+ sh(*args) do |ok, res|
66
+ raise "Error #{res} from `#{args.join ' '}`" unless ok
67
+ end
68
+ end
69
+
70
+ file JAR_FILE => PLUGIN_SOURCE do
71
+ path = AppEngine::SDK::TOOLS_JAR
72
+ sh! "javac -cp #{path} #{PLUGIN_SOURCE}"
73
+ sh! "jar cf #{JAR_FILE} META-INF -C src com"
74
+ end
Binary file
@@ -22,61 +22,6 @@ require 'yaml'
22
22
 
23
23
  module AppEngine
24
24
  module Admin
25
- if defined? Java
26
- AppCfg = AppEngine::SDK.load_appcfg
27
- import Java.ComGoogleAppengineToolsAdmin.AppAdminFactory
28
- import Java.ComGoogleAppengineToolsUtil.Logging
29
-
30
- $CLASSPATH << File.dirname(__FILE__)
31
- import Java.ComGoogleAppengineJruby.AppVersionUploadDelegate
32
- import Java.ComGoogleAppengineJruby.JRubyAppVersionUpload
33
-
34
- class UploadDelegate
35
- include AppVersionUploadDelegate
36
-
37
- def index_yaml(app)
38
- indexes = merge_indexes(app)
39
- if indexes
40
- return indexes.to_yaml
41
- end
42
- ''
43
- end
44
-
45
- def cron_yaml(app)
46
- cron = File.join(app.path, 'cron.yaml')
47
- if File.exists?(cron)
48
- return IO.read(cron)
49
- end
50
- end
51
-
52
- def queue_yaml(app)
53
- queue = File.join(app.path, 'queue.yaml')
54
- if File.exists?(queue)
55
- return IO.read(queue)
56
- end
57
- end
58
-
59
- def merge_indexes(app)
60
- if app.indexes_xml
61
- indexes = YAML.load(app.indexes_xml.to_yaml)['indexes']
62
- end
63
- indexes ||= []
64
- index_yaml = File.join(app.path, 'index.yaml')
65
- if File.exist?(index_yaml)
66
- manual_indexes = YAML.load_file(index_yaml)['indexes'] || []
67
- manual_indexes.each do |index|
68
- indexes << index unless indexes.include?(index)
69
- end
70
- end
71
- if indexes.size > 0
72
- {'indexes' => indexes}
73
- else
74
- nil
75
- end
76
- end
77
- end
78
- end
79
-
80
25
  class JRubyAppCfg
81
26
  NO_XML_COMMANDS = %w{version}
82
27
  RUBY_COMMANDS = %w{gem bundle help run generate_app}
@@ -95,22 +40,15 @@ EOF
95
40
  if command && !NO_XML_COMMANDS.include?(command)
96
41
  path = parsed_args[0]
97
42
  AppEngine::Admin.bundle_app(path)
98
- AppEngine::Development.boot_jruby
99
43
  updater = AppEngine::Admin::UpdateCheck.new(path)
100
44
  updater.nag
101
- else
102
- AppEngine::Development.boot_jruby
103
45
  end
104
46
  puts "=> Running AppCfg"
105
47
  run_appcfg(args)
106
48
  end
107
-
49
+
108
50
  def run_appcfg(args)
109
- JRubyAppVersionUpload.set_delegate(UploadDelegate.new)
110
- factory = AppAdminFactory.new
111
- factory.setAppVersionUploadClass(JRubyAppVersionUpload.java_class)
112
- Logging.initializeLogging
113
- AppCfg.new(factory, args.to_java(java.lang.String))
51
+ exec *(appcfg_command + args)
114
52
  end
115
53
 
116
54
  def generate_app(*args)
@@ -158,7 +96,7 @@ EOF
158
96
  def gem(*args)
159
97
  gem_help
160
98
  end
161
-
99
+
162
100
  def gem_help
163
101
  help = <<EOF
164
102
 
@@ -168,12 +106,12 @@ Simply update the 'Gemfile' and run 'appcfg.rb bundle .' instead.
168
106
  EOF
169
107
  puts help
170
108
  end
171
-
109
+
172
110
  def run(*args)
173
111
  AppEngine::Admin.bundle_deps('.')
174
112
  AppEngine::Development.boot_app('.', args)
175
113
  end
176
-
114
+
177
115
  def run_help
178
116
  help = <<EOF
179
117
  #{$0} run [ruby args]
@@ -185,19 +123,24 @@ Must be run from the application directory, after running bundle.
185
123
  EOF
186
124
  end
187
125
 
126
+ def appcfg_command
127
+ plugin_jar = File.join(File.dirname(__FILE__), 'app_yaml.jar')
128
+ command = %W(java -cp #{AppEngine::SDK::TOOLS_JAR})
129
+ command << "-Dcom.google.appengine.plugin.path=#{plugin_jar}"
130
+ command << 'com.google.appengine.tools.admin.AppCfg'
131
+ end
132
+
188
133
  def help(command=nil)
189
134
  puts
190
135
  if command != 'help' && RUBY_COMMANDS.include?(command)
191
136
  puts send("#{command}_help")
192
137
  else
193
- java_args = %W(java -cp #{AppEngine::SDK::TOOLS_JAR})
194
- java_args << 'com.google.appengine.tools.admin.AppCfg'
195
- java_args << 'help'
138
+ java_args = appcfg_command << 'help'
196
139
  java_args << command if command
197
140
  print_help(%x{#{java_args.map{|x| x.inspect}.join(' ')}}, !command)
198
141
  end
199
142
  end
200
-
143
+
201
144
  def print_help(help, summary)
202
145
  help.gsub!('AppCfg', $0)
203
146
  count = 0
@@ -18,38 +18,10 @@ require 'appengine-sdk'
18
18
 
19
19
  module AppEngine
20
20
  module Development
21
-
21
+
22
22
  BOOT_APP_RB = File.join(File.dirname(__FILE__), 'boot_app.rb')
23
23
 
24
24
  class << self
25
- def boot_jruby(root=nil, options={})
26
- unless defined?(JRUBY_VERSION)
27
- require 'jruby-jars'
28
-
29
- jars = [
30
- JRubyJars.core_jar_path,
31
- JRubyJars.stdlib_jar_path,
32
- AppEngine::SDK::TOOLS_JAR,
33
- ]
34
-
35
- args = options[:args] || ARGV
36
- should_exec = options[:exec]
37
- should_exec ||= should_exec.nil?
38
-
39
- # TODO This is really ugly. We should just be using -I
40
- # for the paths we need (appengine-tools and it's deps)
41
- ENV['GEM_HOME'] = Gem.dir
42
- ENV['GEM_PATH'] = Gem.path.compact.join(File::SEPARATOR)
43
- appcfg = [File.expand_path(File.join(File.dirname($0),
44
- 'appcfg.rb'))]
45
- if should_exec
46
- exec_jruby(root, jars, appcfg + args)
47
- else
48
- run_jruby(root, jars, appcfg + args)
49
- end
50
- end
51
- end
52
-
53
25
  def boot_app(root, args)
54
26
  root = File.expand_path(root)
55
27
 
@@ -61,7 +33,7 @@ module AppEngine
61
33
  ENV.delete 'GEM_HOME'
62
34
  exec_jruby(root, jars, jruby_args)
63
35
  end
64
-
36
+
65
37
  def build_command(root, jars, args)
66
38
  app_jars = root ? Dir.glob("#{root}/WEB-INF/lib/*.jar") : []
67
39
  classpath = (app_jars + jars).join(File::PATH_SEPARATOR)
@@ -72,18 +44,11 @@ module AppEngine
72
44
  end
73
45
  command
74
46
  end
75
-
47
+
76
48
  def exec_jruby(root, jars, args)
77
49
  java_command = build_command(root, jars, args)
78
50
  exec *java_command
79
51
  end
80
-
81
- def run_jruby(root, jars, args)
82
- java_command = build_command(root, jars, args)
83
- if !system(*java_command)
84
- puts 'Error executing jruby'
85
- end
86
- end
87
52
  end
88
53
  end
89
54
  end
@@ -18,8 +18,6 @@
18
18
  require 'appengine-rack'
19
19
  require 'appengine-tools/boot'
20
20
  require 'appengine-tools/gem_bundler'
21
- require 'appengine-tools/web-xml'
22
- require 'appengine-tools/xml-formatter'
23
21
  require 'fileutils'
24
22
  require 'yaml'
25
23
 
@@ -65,16 +63,8 @@ module AppEngine
65
63
  path('config.ru')
66
64
  end
67
65
 
68
- def web_xml
69
- path('WEB-INF', 'web.xml')
70
- end
71
-
72
- def aeweb_xml
73
- path('WEB-INF', 'appengine-web.xml')
74
- end
75
-
76
- def build_status
77
- path('WEB-INF', 'appengine-generated', 'build_status.yaml')
66
+ def app_yaml
67
+ path('app.yaml')
78
68
  end
79
69
 
80
70
  def bundled_jars
@@ -82,7 +72,13 @@ module AppEngine
82
72
  end
83
73
 
84
74
  def public_root
85
- path(AppEngine::Rack.app.public_root) if AppEngine::Rack.app.public_root
75
+ @public_root ||= begin
76
+ if File.exist?(app_yaml)
77
+ app = YAML.load(IO.read(app_yaml))
78
+ return path(app['public_root']) if app['public_root']
79
+ end
80
+ path('public')
81
+ end
86
82
  end
87
83
 
88
84
  def favicon_ico
@@ -92,11 +88,6 @@ module AppEngine
92
88
  def robots_txt
93
89
  File.join(public_root ? public_root : @root, 'robots.txt')
94
90
  end
95
-
96
- def rack_app
97
- AppEngine::Rack.app
98
- end
99
-
100
91
  end
101
92
 
102
93
  class AppBundler
@@ -108,7 +99,9 @@ module AppEngine
108
99
 
109
100
  def bundle(args=[])
110
101
  bundle_deps(args)
111
- convert_config_ru
102
+ generate_config_ru
103
+ generate_app_yaml
104
+ create_public
112
105
  end
113
106
 
114
107
  def bundle_deps(args=[])
@@ -118,7 +111,6 @@ module AppEngine
118
111
  end
119
112
 
120
113
  def bundle_gems(args)
121
- return if defined? JRUBY_VERSION
122
114
  gem_bundler = AppEngine::Admin::GemBundler.new(app.root)
123
115
  gem_bundler.bundle(args)
124
116
  end
@@ -128,11 +120,10 @@ module AppEngine
128
120
  end
129
121
 
130
122
  def confirm_appdir
131
- unless File.exists?(app.config_ru) or
132
- File.exists?(app.gemfile) or File.exists?(app.webinf)
123
+ unless File.exists?(app.app_yaml)or File.exists?(app.webinf)
133
124
  puts ""
134
125
  puts "Oops, this does not look like an application directory."
135
- puts "You need a #{app.gemfile} or #{app.config_ru} file."
126
+ puts "You need to create #{app.app_yaml}."
136
127
  puts ""
137
128
  puts "Run 'appcfg.rb generate_app #{app.path}'"
138
129
  puts "to generate a skeleton application."
@@ -147,7 +138,6 @@ module AppEngine
147
138
  end
148
139
 
149
140
  def create_public
150
- return unless defined? JRUBY_VERSION
151
141
  if app.public_root and !File.exists?(app.public_root)
152
142
  Dir.mkdir(app.public_root)
153
143
  end
@@ -155,23 +145,26 @@ module AppEngine
155
145
  FileUtils.touch(app.robots_txt) unless File.exists?(app.robots_txt)
156
146
  end
157
147
 
158
- def convert_config_ru
148
+ def generate_config_ru
159
149
  unless File.exists?(app.config_ru)
160
150
  puts "=> Generating rackup"
151
+ stock_rackup = "run lambda {Rack::Response.new('Hello').finish}\n"
152
+ File.open(app.config_ru, 'w') {|f| f.write(stock_rackup) }
153
+ end
154
+ end
155
+
156
+ def generate_app_yaml
157
+ unless File.exists?(app.app_yaml)
158
+ puts "=> Generating app.yaml"
161
159
  app_id = File.basename(File.expand_path(app.path)).
162
160
  downcase.gsub('_', '-').gsub(/[^-a-z0-9]/, '')
163
- stock_rackup = <<EOF
164
- require 'appengine-rack'
165
- AppEngine::Rack.configure_app(
166
- :application => "#{app_id}",
167
- :precompilation_enabled => true,
168
- :version => "1")
169
- run lambda { ::Rack::Response.new("Hello").finish }
161
+ stock_yaml = <<EOF
162
+ application: #{app_id}
163
+ version: 1
164
+ runtime: jruby
170
165
  EOF
171
- File.open(app.config_ru, 'w') {|f| f.write(stock_rackup) }
166
+ File.open(app.app_yaml, 'w') {|f| f.write(stock_yaml)}
172
167
  end
173
- generate_xml
174
- create_public
175
168
  end
176
169
 
177
170
  private
@@ -213,57 +206,6 @@ EOF
213
206
  end
214
207
  FileUtils.rm_f(paths)
215
208
  end
216
-
217
- def valid_build
218
- return false unless File.exists? app.build_status
219
- return false unless File.exists? app.web_xml
220
- return false unless File.exists? app.aeweb_xml
221
- yaml = YAML.load_file app.build_status
222
- return false unless yaml.is_a? Hash
223
- return false unless File.stat(app.config_ru).mtime.eql? yaml[:config_ru]
224
- return false unless File.stat(app.web_xml).mtime.eql? yaml[:web_xml]
225
- return false unless File.stat(app.aeweb_xml).mtime.eql? yaml[:aeweb_xml]
226
- true
227
- end
228
-
229
- def generate_xml
230
- return if valid_build
231
- if defined? JRUBY_VERSION
232
- puts "=> Generating configuration files"
233
- Dir.glob("#{app.webinf_lib}/*.jar").each do |path|
234
- $: << path
235
- end
236
- app_root = app.root
237
- builder = WebXmlBuilder.new do
238
- # First read the user's rackup file
239
- Dir.chdir(app_root) do
240
- require File.join(".gems", "bundler_gems",
241
- TARGET_ENGINE, TARGET_VERSION, "environment")
242
- eval IO.read('config.ru'), nil, 'config.ru', 1
243
- end
244
-
245
- # Now configure the basic jruby-rack settings.
246
- add_jruby_rack_defaults
247
- end
248
- open(app.web_xml, 'w') do |webxml|
249
- xml = AppEngine::Rack::XmlFormatter.format(builder.to_xml)
250
- webxml.write(xml)
251
- end
252
- open(app.aeweb_xml, 'w') do |aeweb|
253
- xml = AppEngine::Rack::XmlFormatter.format(app.rack_app.to_xml)
254
- aeweb.write(xml)
255
- end
256
- yaml = {
257
- :config_ru => File.stat(app.config_ru).mtime,
258
- :aeweb_xml => File.stat(app.aeweb_xml).mtime,
259
- :web_xml => File.stat(app.web_xml).mtime }
260
- open(app.build_status, 'w') { |f| YAML.dump(yaml, f) }
261
- else
262
- AppEngine::Development.boot_jruby(app.root,
263
- :args => ['bundle', app.root],
264
- :exec => false)
265
- end
266
- end
267
209
  end
268
210
 
269
211
  def self.bundle_app(*args)
@@ -15,7 +15,6 @@
15
15
  # limitations under the License.
16
16
 
17
17
  require 'appengine-sdk'
18
- require 'appengine-tools/boot'
19
18
  require 'appengine-tools/bundler'
20
19
  require 'appengine-tools/update_check'
21
20
 
@@ -27,15 +26,15 @@ module AppEngine
27
26
  def run(args)
28
27
  path, java_args, server_args = parse_argv(ARGV)
29
28
  if path and File::directory?(path)
30
- puts "=> Booting DevAppServer"
31
- puts "=> Press Ctrl-C to shutdown server"
32
29
  AppEngine::Admin.bundle_app(path)
33
30
  updater = AppEngine::Admin::UpdateCheck.new(path)
34
31
  updater.nag if updater.can_nag?
32
+ puts "=> Booting DevAppServer"
33
+ puts "=> Press Ctrl-C to shutdown server"
35
34
  end
36
35
  start_java(path, java_args, server_args)
37
36
  end
38
-
37
+
39
38
  def parse_argv(argv)
40
39
  java_args = []
41
40
  server_args = []
@@ -59,7 +58,7 @@ module AppEngine
59
58
  end
60
59
  return server_args[-1], java_args, server_args
61
60
  end
62
-
61
+
63
62
  def start_java(path, java_args, server_args)
64
63
  if path
65
64
  jruby_home = get_jruby_home(path)
@@ -70,10 +69,13 @@ module AppEngine
70
69
  server_args.unshift '--disable_update_check'
71
70
  ENV.delete 'GEM_HOME'
72
71
  ENV.delete 'GEM_PATH'
72
+ plugin_jar = File.join(File.dirname(__FILE__), 'app_yaml.jar')
73
+
73
74
  java_args << '-classpath'
74
75
  java_args << AppEngine::SDK::TOOLS_JAR
75
76
  java_args << '-Djava.util.logging.config.file=' +
76
77
  AppEngine::SDK::SDK_ROOT + '/config/sdk/logging.properties'
78
+ java_args << "-Dcom.google.appengine.plugin.path=#{plugin_jar}"
77
79
  if defined? AppEngine::SDK::AGENT_JAR
78
80
  java_args << '-javaagent:' + AppEngine::SDK::AGENT_JAR
79
81
  end
@@ -83,7 +85,7 @@ module AppEngine
83
85
  end
84
86
  exec(*command)
85
87
  end
86
-
88
+
87
89
  def get_jruby_home(path)
88
90
  return unless path
89
91
  Dir.chdir("#{path}/WEB-INF/lib") do
@@ -118,7 +118,7 @@ disable_rubygems
118
118
  bundle_path ".gems/bundler_gems"
119
119
 
120
120
  # List gems to bundle here:
121
- gem "appengine-rack"
121
+ gem 'appengine-rack', '0.0.11.pre'
122
122
  EOF
123
123
  File.open(app.gemfile,'w') {|f| f.write(stock_gemfile) }
124
124
  end
@@ -29,13 +29,13 @@ module AppEngine
29
29
  NAG_FILE = "~/.appcfg_rb_nag"
30
30
  MAX_NAG_FREQUENCY = 60 * 60 * 24 * 7
31
31
  DEFAULT_URL = 'http://appengine-jruby.googlecode.com/hg/updatecheck'
32
-
32
+
33
33
  def initialize(approot, url=nil, nag_file=nil)
34
34
  @url = url || DEFAULT_URL
35
35
  @approot = approot
36
36
  @nag_file = nag_file || File.expand_path(NAG_FILE)
37
37
  end
38
-
38
+
39
39
  def local_versions
40
40
  sdk_version = Gem::Version.new(AppEngine::VERSION) rescue nil
41
41
  {
@@ -44,7 +44,7 @@ module AppEngine
44
44
  'dm-appengine' => find_gem_version('dm-appengine'),
45
45
  }
46
46
  end
47
-
47
+
48
48
  def find_gem_version(name)
49
49
  IO.foreach("#{@approot}/.gems/bundler_gems/environment.rb") do |line|
50
50
  if line =~ %r(/gems/#{name}-(\w+\.\w+.\w+)[/"])
@@ -53,7 +53,7 @@ module AppEngine
53
53
  end rescue nil
54
54
  nil
55
55
  end
56
-
56
+
57
57
  def remote_versions
58
58
  versions = YAML.load(open(@url).read)
59
59
  versions.inject({}) do |versions, (name, version)|
@@ -83,7 +83,7 @@ module AppEngine
83
83
  end
84
84
  end
85
85
  end
86
-
86
+
87
87
  def parse_nag_file
88
88
  @nag ||= if File.exist?(@nag_file)
89
89
  YAML.load_file(@nag_file)
@@ -91,13 +91,13 @@ module AppEngine
91
91
  {'opt_in' => true, 'timestamp' => 0}
92
92
  end
93
93
  end
94
-
94
+
95
95
  def write_nag_file(options)
96
96
  open(@nag_file, 'w') do |file|
97
97
  file.write(YAML.dump(options))
98
98
  end
99
99
  end
100
-
100
+
101
101
  def nag
102
102
  nag = parse_nag_file
103
103
  return if Time.now.to_i - nag['timestamp'] < MAX_NAG_FREQUENCY
@@ -108,7 +108,7 @@ module AppEngine
108
108
  # check_for_updates will raise an error if we're not online
109
109
  # just ignore it, and don't update the nag timestamp.
110
110
  end
111
-
111
+
112
112
  def can_nag?
113
113
  parse_nag_file['opt_in']
114
114
  end
@@ -10,7 +10,7 @@ describe AppEngine::Admin::UpdateCheck do
10
10
  before :each do
11
11
  @update_check = AppEngine::Admin::UpdateCheck.new('approot', 'url', 'nag')
12
12
  end
13
-
13
+
14
14
  def versions(sdk, apis, dm)
15
15
  keys = ['google-appengine', 'appengine-apis', 'dm-appengine']
16
16
  hash = {}
@@ -19,27 +19,20 @@ describe AppEngine::Admin::UpdateCheck do
19
19
  end
20
20
  hash
21
21
  end
22
-
22
+
23
23
  it 'should expand path' do
24
24
  File.should_receive(:expand_path).with(
25
25
  AppEngine::Admin::UpdateCheck::NAG_FILE)
26
26
  uc = AppEngine::Admin::UpdateCheck.new('/')
27
27
  end
28
-
28
+
29
29
  it 'should support local_versions' do
30
30
  expected = versions('3.2.1', '1.2.3', nil)
31
31
  @update_check.should_receive(:find_gem_version).twice.and_return(
32
32
  Gem::Version.new("1.2.3"), nil)
33
33
  @update_check.local_versions.should == expected
34
34
  end
35
-
36
- it 'should support find_gem_version' do
37
- Dir.should_receive(:glob).and_return(
38
- ['appengine-apis-0.0.20.gemspec','appengine-apis-0.0.3.gemspec'])
39
- @update_check.find_gem_version("appengine-apis").should ==
40
- Gem::Version.new('0.0.20')
41
- end
42
-
35
+
43
36
  it 'should support remote_versions' do
44
37
  expected = versions('3.2.2', '1.2.4', '2.3.4')
45
38
  io = StringIO.new(YAML.dump(expected))
@@ -47,13 +40,13 @@ describe AppEngine::Admin::UpdateCheck do
47
40
  @update_check.should_receive(:open).with("url").and_return(io)
48
41
  @update_check.remote_versions.should == expected
49
42
  end
50
-
43
+
51
44
  describe 'check_for_updates' do
52
45
  before :each do
53
46
  @update_check.stub!(:puts)
54
47
  end
55
-
56
-
48
+
49
+
57
50
  def expect_puts(*messages)
58
51
  length = messages.length
59
52
  @update_check.should_receive(:puts) do |arg|
@@ -64,62 +57,62 @@ describe AppEngine::Admin::UpdateCheck do
64
57
  it 'should skip check if no sdk version' do
65
58
  @update_check.should_receive(:local_versions).and_return(
66
59
  versions(nil, nil, nil))
67
- expect_puts("Skipping update check")
60
+ expect_puts("=> Skipping update check")
68
61
  @update_check.check_for_updates
69
62
  end
70
-
63
+
71
64
  it 'should warn about old sdk' do
72
65
  @update_check.should_receive(:local_versions).and_return(
73
66
  versions('0.0.1', nil, nil))
74
67
  @update_check.should_receive(:remote_versions).and_return(
75
68
  versions('0.0.2', '0.0.2', '0.0.2'))
76
69
  expect_puts(
77
- "There is a new version of google-appengine: 0.0.2 (You have 0.0.1)",
78
- "Please run sudo gem update google-appengine."
70
+ "=> There is a new version of google-appengine: 0.0.2 (You have 0.0.1)",
71
+ "=> Please run sudo gem update google-appengine."
79
72
  )
80
73
  @update_check.check_for_updates
81
74
  end
82
-
75
+
83
76
  it 'should warn about old apis' do
84
77
  @update_check.should_receive(:local_versions).and_return(
85
78
  versions('0.0.2', '0.0.2', '0.0.2'))
86
79
  @update_check.should_receive(:remote_versions).and_return(
87
80
  versions('0.0.2', '0.0.4', '0.0.2'))
88
81
  expect_puts(
89
- "There is a new version of appengine-apis: 0.0.4 (You have 0.0.2)",
90
- "Please run appcfg.rb gem update appengine-apis."
82
+ "=> There is a new version of appengine-apis: 0.0.4 (You have 0.0.2)",
83
+ "=> Please update your Gemfile."
91
84
  )
92
85
  @update_check.check_for_updates
93
86
  end
94
-
87
+
95
88
  it 'should warn about old dm adapter' do
96
89
  @update_check.should_receive(:local_versions).and_return(
97
90
  versions('0.0.2', '0.0.2', '0.0.2'))
98
91
  @update_check.should_receive(:remote_versions).and_return(
99
92
  versions('0.0.2', '0.0.2', '0.0.3'))
100
93
  expect_puts(
101
- "There is a new version of dm-appengine: 0.0.3 (You have 0.0.2)",
102
- "Please run appcfg.rb gem update dm-appengine."
94
+ "=> There is a new version of dm-appengine: 0.0.3 (You have 0.0.2)",
95
+ "=> Please update your Gemfile."
103
96
  )
104
- @update_check.check_for_updates
97
+ @update_check.check_for_updates
105
98
  end
106
99
 
107
-
100
+
108
101
  it 'should warn about multiple old gems' do
109
102
  @update_check.should_receive(:local_versions).and_return(
110
103
  versions('0.0.1', '0.0.3', '0.0.5'))
111
104
  @update_check.should_receive(:remote_versions).and_return(
112
105
  versions('0.0.2', '0.0.4', '0.0.5'))
113
106
  expect_puts(
114
- "There is a new version of google-appengine: 0.0.2 (You have 0.0.1)",
115
- "Please run sudo gem update google-appengine.",
116
- "There is a new version of appengine-apis: 0.0.4 (You have 0.0.3)",
117
- "Please run appcfg.rb gem update appengine-apis."
107
+ "=> There is a new version of google-appengine: 0.0.2 (You have 0.0.1)",
108
+ "=> Please run sudo gem update google-appengine.",
109
+ "=> There is a new version of appengine-apis: 0.0.4 (You have 0.0.3)",
110
+ "=> Please update your Gemfile."
118
111
  )
119
- @update_check.check_for_updates
112
+ @update_check.check_for_updates
120
113
  end
121
114
  end
122
-
115
+
123
116
  describe 'parse_nag_file' do
124
117
  it 'should support missing file' do
125
118
  File.should_receive(:exist?).with('nag').and_return(false)
@@ -128,14 +121,14 @@ describe AppEngine::Admin::UpdateCheck do
128
121
  'timestamp' => 0
129
122
  }
130
123
  end
131
-
124
+
132
125
  it 'should parse existing file' do
133
126
  File.should_receive(:exist?).with('nag').and_return(true)
134
127
  YAML.should_receive(:load_file).with('nag').and_return("parsed_yaml")
135
128
  @update_check.parse_nag_file.should == "parsed_yaml"
136
129
  end
137
130
  end
138
-
131
+
139
132
  describe 'nag' do
140
133
  it 'should nag if old timestamp' do
141
134
  @update_check.should_receive(:parse_nag_file).and_return({
@@ -146,7 +139,7 @@ describe AppEngine::Admin::UpdateCheck do
146
139
  @update_check.should_receive(:write_nag_file)
147
140
  @update_check.nag
148
141
  end
149
-
142
+
150
143
  it 'should not nag if new timestamp' do
151
144
  @update_check.should_receive(:parse_nag_file).and_return({
152
145
  'opt_in' => true,
@@ -155,7 +148,7 @@ describe AppEngine::Admin::UpdateCheck do
155
148
  @update_check.nag
156
149
  end
157
150
  end
158
-
151
+
159
152
  describe 'can_nag?' do
160
153
  it 'should return true of opted in' do
161
154
  @update_check.should_receive(:parse_nag_file).and_return({
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: appengine-tools
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
4
+ prerelease: true
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 14
9
- version: 0.0.14
8
+ - 15
9
+ - pre
10
+ version: 0.0.15.pre
10
11
  platform: ruby
11
12
  authors:
12
13
  - Ryan Brown
@@ -95,15 +96,9 @@ files:
95
96
  - lib/appengine-tools/dev_appserver.rb
96
97
  - lib/appengine-tools/gem_bundler.rb
97
98
  - lib/appengine-tools/update_check.rb
98
- - lib/appengine-tools/web-xml.rb
99
- - lib/appengine-tools/xml-formatter.rb
100
- - lib/jruby-rack-jar.rb
101
- - lib/appengine-tools/com/google/appengine/jruby/AppVersionUploadDelegate.class
102
- - lib/appengine-tools/com/google/appengine/jruby/JRubyAppVersionUpload.class
103
- - spec/rack_spec.rb
104
99
  - spec/spec_helper.rb
105
100
  - spec/update_check_spec.rb
106
- - spec/web-xml_spec.rb
101
+ - lib/appengine-tools/app_yaml.jar
107
102
  has_rdoc: true
108
103
  homepage: http://code.google.com/p/appengine-jruby
109
104
  licenses: []
@@ -122,11 +117,13 @@ required_ruby_version: !ruby/object:Gem::Requirement
122
117
  version: "0"
123
118
  required_rubygems_version: !ruby/object:Gem::Requirement
124
119
  requirements:
125
- - - ">="
120
+ - - ">"
126
121
  - !ruby/object:Gem::Version
127
122
  segments:
128
- - 0
129
- version: "0"
123
+ - 1
124
+ - 3
125
+ - 1
126
+ version: 1.3.1
130
127
  requirements: []
131
128
 
132
129
  rubyforge_project:
@@ -1,98 +0,0 @@
1
- #!/usr/bin/ruby1.8 -w
2
- #
3
- # Copyright:: Copyright 2009 Google Inc.
4
- # Original Author:: Ryan Brown (mailto:ribrdb@google.com)
5
- #
6
- # Licensed under the Apache License, Version 2.0 (the "License");
7
- # you may not use this file except in compliance with the License.
8
- # You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing, software
13
- # distributed under the License is distributed on an "AS IS" BASIS,
14
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- # See the License for the specific language governing permissions and
16
- # limitations under the License.
17
-
18
- require 'rack'
19
- require 'rexml/document'
20
- require 'uri'
21
-
22
- require 'appengine-rack/java'
23
-
24
- class WebXmlBuilder < Rack::Builder
25
- DUMMY_APP = Proc.new{|env|}
26
-
27
- def initialize(&block)
28
- @path = "/"
29
- @paths = Hash.new {|h, k| h[k] = []}
30
- @skip_defaults = false
31
- @mime_mapping = {}
32
- instance_eval(&block) if block_given?
33
- end
34
-
35
- def add_mime_mapping(doc)
36
- @mime_mapping.each_pair do |key,val|
37
- mime = doc.add_element('mime-mapping')
38
- mime.add_element('extension').add_text(key.to_s)
39
- mime.add_element('mime-type').add_text(val)
40
- end
41
- end
42
-
43
- def add_jruby_rack_defaults
44
- unless @skip_defaults
45
- use JavaServletFilter, 'org.jruby.rack.RackFilter',
46
- { :name => 'RackFilter', :wildcard => true }
47
- end
48
- use JavaContextListener, 'com.google.appengine.jruby.LazyContextListener'
49
- end
50
-
51
- def use(middleware, *args, &block)
52
- if middleware.respond_to? :append_xml
53
- @paths[@path] << [middleware, args, block]
54
- else
55
- @paths[@path] << [middleware.new(DUMMY_APP, *args, &block)]
56
- end
57
- end
58
-
59
- def map(path, &block)
60
- if URI.parse(path).scheme.nil? # we can only natively support path matching
61
- saved_path = @path
62
- @path = [@path, path].join('/').squeeze('/')
63
- begin
64
- instance_eval(&block) if block_given?
65
- ensure
66
- @path = saved_path
67
- end
68
- end
69
- end
70
-
71
- def run(app)
72
- @paths[@path] << [app, [], nil]
73
- end
74
-
75
- def to_xml
76
- doc = REXML::Document.new.add_element('web-app')
77
- doc.add_attribute("xmlns", "http://java.sun.com/xml/ns/javaee")
78
- doc.add_attribute("version", "2.5")
79
- each_path do |path, objects|
80
- pattern = path.chomp('/')
81
- pattern = '/' if pattern.empty?
82
- objects.each do |object, args, block|
83
- if object.respond_to? :append_xml
84
- object.append_xml(doc, pattern, *args, &block)
85
- end
86
- end
87
- end
88
- add_mime_mapping(doc)
89
- doc
90
- end
91
-
92
- private
93
- def each_path
94
- @paths.sort {|a, b| b[0].length - a[0].length}.each do |path, value|
95
- yield path, value
96
- end
97
- end
98
- end
@@ -1,40 +0,0 @@
1
- #!/usr/bin/ruby1.8 -w
2
- #
3
- # Copyright:: Copyright 2009 Google Inc.
4
- # Original Author:: Ryan Brown (mailto:ribrdb@google.com)
5
- #
6
- # Licensed under the Apache License, Version 2.0 (the "License");
7
- # you may not use this file except in compliance with the License.
8
- # You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing, software
13
- # distributed under the License is distributed on an "AS IS" BASIS,
14
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- # See the License for the specific language governing permissions and
16
- # limitations under the License.
17
-
18
- require 'rexml/formatters/pretty'
19
-
20
- module AppEngine
21
- module Rack
22
- class XmlFormatter < REXML::Formatters::Pretty
23
- def initialize
24
- @compact = true
25
- super
26
- end
27
-
28
- def write_text( node, output )
29
- output << node.to_s()
30
- end
31
-
32
- def self.format(xml)
33
- @formatter ||= XmlFormatter.new
34
- output = ''
35
- @formatter.write(xml, output)
36
- return output
37
- end
38
- end
39
- end
40
- end
@@ -1,26 +0,0 @@
1
- #!/usr/bin/ruby
2
- # Copyright:: Copyright 2010 Google Inc.
3
- # Original Author:: John Woodell (mailto:woodie@google.com)
4
- #
5
- # Licensed under the Apache License, Version 2.0 (the "License");
6
- # you may not use this file except in compliance with the License.
7
- # You may obtain a copy of the License at
8
- #
9
- # http://www.apache.org/licenses/LICENSE-2.0
10
- #
11
- # Unless required by applicable law or agreed to in writing, software
12
- # distributed under the License is distributed on an "AS IS" BASIS,
13
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- # See the License for the specific language governing permissions and
15
- # limitations under the License.
16
-
17
- module AppEngine
18
- module JRubyJars
19
- JRUBYRACK_VERSION = '0.9.6'
20
-
21
- def self.jrubyrack_jar
22
- File.join(File.dirname(__FILE__), "jruby-rack-#{JRUBYRACK_VERSION}.jar")
23
- end
24
-
25
- end
26
- end
data/spec/rack_spec.rb DELETED
@@ -1,31 +0,0 @@
1
- # Copyright:: Copyright 2009 Google Inc.
2
- # Original Author:: Ryan Brown (mailto:ribrdb@google.com)
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
12
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- # See the License for the specific language governing permissions and
14
- # limitations under the License.
15
-
16
- require File.dirname(__FILE__) + '/spec_helper.rb'
17
- require 'appengine-rack'
18
- require 'appengine-tools/web-xml'
19
- require 'appengine-tools/xml-formatter'
20
-
21
- describe AppEngine::Rack do
22
- it "should generate correct xml" do
23
- rackup = IO.read("#{File.dirname(__FILE__)}/config.ru")
24
- builder = WebXmlBuilder.new do
25
- add_jruby_rack_defaults
26
- eval rackup, nil, "#{File.dirname(__FILE__)}/config.ru", 1
27
- end
28
- xml = AppEngine::Rack::XmlFormatter.format(AppEngine::Rack.app.to_xml)
29
- xml.should == IO.read("#{File.dirname(__FILE__)}/appengine-web.xml")
30
- end
31
- end
data/spec/web-xml_spec.rb DELETED
@@ -1,30 +0,0 @@
1
- # Copyright:: Copyright 2009 Google Inc.
2
- # Original Author:: Ryan Brown (mailto:ribrdb@google.com)
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
12
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- # See the License for the specific language governing permissions and
14
- # limitations under the License.
15
-
16
- require File.dirname(__FILE__) + '/spec_helper.rb'
17
- require 'appengine-tools/web-xml'
18
- require 'appengine-tools/xml-formatter'
19
-
20
- describe WebXmlBuilder do
21
- it "should generate correct xml" do
22
- rackup = IO.read("#{File.dirname(__FILE__)}/config.ru")
23
- builder = WebXmlBuilder.new do
24
- add_jruby_rack_defaults
25
- eval rackup, nil, "#{File.dirname(__FILE__)}/config.ru", 1
26
- end
27
- xml = AppEngine::Rack::XmlFormatter.format(builder.to_xml)
28
- xml.should == IO.read("#{File.dirname(__FILE__)}/web.xml")
29
- end
30
- end