ruboto 0.5.3 → 0.5.4

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,4 +1,5 @@
1
1
  source :rubygems
2
2
 
3
+ gem 'rake'
3
4
  gem 'main'
4
5
  gem 'jruby-jars'
data/Gemfile.lock CHANGED
@@ -11,6 +11,7 @@ GEM
11
11
  fattr (~> 2.2.0)
12
12
  map (~> 5.1.0)
13
13
  map (5.1.0)
14
+ rake (0.9.2.2)
14
15
 
15
16
  PLATFORMS
16
17
  java
@@ -19,3 +20,4 @@ PLATFORMS
19
20
  DEPENDENCIES
20
21
  jruby-jars
21
22
  main
23
+ rake
data/Rakefile CHANGED
@@ -11,17 +11,6 @@ GEM_FILE_OLD = "ruboto-core-#{Ruboto::VERSION}.gem"
11
11
  GEM_SPEC_FILE = 'ruboto.gemspec'
12
12
  GEM_SPEC_FILE_OLD = 'ruboto-core.gemspec'
13
13
 
14
- # FIXME(uwe): Remove when we stop supporting JRuby 1.5.6
15
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.8.0')
16
- gem_spec = Gem::Specification.find_by_path 'jruby-jars'
17
- else
18
- gem_spec = Gem.searcher.find('jruby-jars')
19
- end
20
- raise StandardError.new("Can't find Gem specification jruby-jars.") unless gem_spec
21
- JRUBY_JARS_VERSION = gem_spec.version
22
- ON_JRUBY_JARS_1_5_6 = JRUBY_JARS_VERSION == Gem::Version.new('1.5.6')
23
- # FIXME end
24
-
25
14
  CLEAN.include('ruboto-*.gem', 'tmp')
26
15
 
27
16
  task :default => :gem
@@ -73,7 +73,7 @@ THE_CONSTANTS
73
73
  }
74
74
  }
75
75
 
76
- // This causes JRuby to initialize and takes while
76
+ // This causes JRuby to initialize and takes a while.
77
77
  protected void prepareJRuby() {
78
78
  Script.put("$context", this);
79
79
  Script.put("$activity", this);
@@ -320,7 +320,7 @@ module Ruboto
320
320
  }
321
321
 
322
322
  option("force") {
323
- description "force and update even if the version hasn't changed"
323
+ description "force an update even if the version hasn't changed"
324
324
  }
325
325
 
326
326
  def run
@@ -134,14 +134,23 @@ EOF
134
134
  def update_jruby(force=nil)
135
135
  jruby_core = Dir.glob("libs/jruby-core-*.jar")[0]
136
136
  jruby_stdlib = Dir.glob("libs/jruby-stdlib-*.jar")[0]
137
- new_jruby_version = JRubyJars::VERSION
138
137
 
139
138
  unless force
140
139
  if !jruby_core || !jruby_stdlib
141
140
  puts "Cannot find existing jruby jars in libs. Make sure you're in the root directory of your app."
142
141
  return false
143
142
  end
143
+ end
144
+
145
+ begin
146
+ require 'jruby-jars'
147
+ rescue LoadError
148
+ puts "Could not find the jruby-jars gem. You need it to include JRuby in your app. Please install it using\n\n gem install jruby-jars\n\n"
149
+ return false
150
+ end
151
+ new_jruby_version = JRubyJars::VERSION
144
152
 
153
+ unless force
145
154
  current_jruby_version = jruby_core ? jruby_core[16..-5] : "None"
146
155
  if current_jruby_version == new_jruby_version
147
156
  puts "JRuby is up to date at version #{new_jruby_version}. Make sure you 'gem update jruby-jars' if there is a new version."
@@ -179,7 +188,7 @@ EOF
179
188
  FileUtils.rm_rf old_scripts_dir
180
189
  end
181
190
  # FIXME end
182
-
191
+
183
192
  end
184
193
 
185
194
  def update_icons(force = nil)
@@ -351,7 +360,7 @@ EOF
351
360
  # `jar -cf ../jruby-core-#{dir.gsub('/', '.')}-#{jruby_core_version}.jar #{dir}`
352
361
  # FileUtils.rm_rf dir
353
362
  #end
354
-
363
+
355
364
  `jar -cf ../#{jruby_core} .`
356
365
  end
357
366
  FileUtils.remove_dir "tmp", true
@@ -1,3 +1,3 @@
1
1
  module Ruboto
2
- VERSION = '0.5.3'
2
+ VERSION = '0.5.4'
3
3
  end
data/lib/ruboto.rb CHANGED
@@ -5,7 +5,6 @@ Ruboto.enable_objectspace
5
5
  require 'main'
6
6
  require 'fileutils'
7
7
  require 'rexml/document'
8
- require 'jruby-jars'
9
8
 
10
9
  require 'ruboto/util/main_fix'
11
10
 
data/test/test_helper.rb CHANGED
@@ -7,31 +7,24 @@ module RubotoTest
7
7
  PROJECT_DIR = File.expand_path('..', File.dirname(__FILE__))
8
8
  $LOAD_PATH << PROJECT_DIR
9
9
 
10
- # FIXME(uwe): Simplify when we stop supporting rubygems < 1.8.0
11
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.8.0')
12
- gem_spec = Gem::Specification.find_by_path 'jruby-jars'
13
- else
14
- gem_spec = Gem.searcher.find('jruby-jars')
15
- end
16
- # FIXME end
17
-
18
- raise StandardError.new("Can't find Gem specification jruby-jars.") unless gem_spec
19
- JRUBY_JARS_VERSION = gem_spec.version
20
-
21
- # FIXME(uwe): Remove when we stop supporting JRuby 1.5.6
22
- ON_JRUBY_JARS_1_5_6 = JRUBY_JARS_VERSION == Gem::Version.new('1.5.6')
23
-
24
- PACKAGE = 'org.ruboto.test_app'
25
- APP_NAME = 'RubotoTestApp'
26
- TMP_DIR = File.join PROJECT_DIR, 'tmp'
27
- APP_DIR = File.join TMP_DIR, APP_NAME
10
+ GEM_PATH = File.join PROJECT_DIR, 'tmp', 'gems'
11
+ FileUtils.mkdir_p GEM_PATH
12
+ ENV['GEM_HOME'] = GEM_PATH
13
+ ENV['GEM_PATH'] = GEM_PATH
14
+ system 'gem install bundler'
15
+ system 'bundle'
16
+
17
+ PACKAGE = 'org.ruboto.test_app'
18
+ APP_NAME = 'RubotoTestApp'
19
+ TMP_DIR = File.join PROJECT_DIR, 'tmp'
20
+ APP_DIR = File.join TMP_DIR, APP_NAME
28
21
  ANDROID_TARGET = ENV['ANDROID_TARGET'] || 'android-7'
29
22
 
30
23
  VERSION_TO_API_LEVEL = {
31
- '2.1' => 'android-7', '2.1-update1' => 'android-7', '2.2' => 'android-8',
32
- '2.3' => 'android-9', '2.3.1' => 'android-9', '2.3.2' => 'android-9',
24
+ '2.1' => 'android-7', '2.1-update1' => 'android-7', '2.2' => 'android-8',
25
+ '2.3' => 'android-9', '2.3.1' => 'android-9', '2.3.2' => 'android-9',
33
26
  '2.3.3' => 'android-10', '2.3.4' => 'android-10',
34
- '3.0' => 'android-11', '3.1' => 'android-12', '3.2' => 'android-13',
27
+ '3.0' => 'android-11', '3.1' => 'android-12', '3.2' => 'android-13',
35
28
  '4.0.1' => 'android-14', '4.0.3' => 'android-15',
36
29
  }
37
30
 
@@ -41,7 +34,7 @@ module RubotoTest
41
34
  start = Time.now
42
35
  IO.popen('adb bugreport').each_line do |line|
43
36
  if line =~ /sdk-eng (.*?) .*? .*? test-keys/
44
- version = $1
37
+ version = $1
45
38
  api_level = VERSION_TO_API_LEVEL[version]
46
39
  raise "Unknown version: #{version}" if api_level.nil?
47
40
  puts "Getting version from device/emulator took #{(Time.now - start).to_i}s"
@@ -54,6 +47,12 @@ module RubotoTest
54
47
  raise "Unable to read device/emulator apilevel"
55
48
  end
56
49
 
50
+ def install_jruby_jars_gem
51
+ system "gem install jruby-jars #{"-v #{ENV['JRUBY_JARS_VERSION']}" if ENV['JRUBY_JARS_VERSION']}"
52
+ raise "install of jruby-jars failed with return code #$?" unless $? == 0
53
+ system %Q{gem uninstall jruby-jars --all -v "!=#{ENV['JRUBY_JARS_VERSION']}"} if ENV['JRUBY_JARS_VERSION']
54
+ end
55
+
57
56
  ANDROID_OS = ENV['ANDROID_OS'] || version_from_device
58
57
  RUBOTO_CMD = "ruby -rubygems -I #{PROJECT_DIR}/lib #{PROJECT_DIR}/bin/ruboto"
59
58
 
@@ -62,6 +61,24 @@ end
62
61
 
63
62
  class Test::Unit::TestCase
64
63
  include RubotoTest
64
+ extend RubotoTest
65
+
66
+ install_jruby_jars_gem
67
+
68
+ # FIXME(uwe): Simplify when we stop supporting rubygems < 1.8.0
69
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.8.0')
70
+ gem_spec = Gem::Specification.find_by_path 'jruby-jars'
71
+ else
72
+ gem_spec = Gem.searcher.find('jruby-jars')
73
+ end
74
+ # FIXME end
75
+
76
+ raise StandardError.new("Can't find Gem specification jruby-jars.") unless gem_spec
77
+ JRUBY_JARS_VERSION = gem_spec.version
78
+
79
+ # FIXME(uwe): Remove when we stop supporting JRuby 1.5.6
80
+ ON_JRUBY_JARS_1_5_6 = JRUBY_JARS_VERSION == Gem::Version.new('1.5.6')
81
+
65
82
  alias old_run run
66
83
 
67
84
  def run(*args, &block)
@@ -91,7 +108,7 @@ class Test::Unit::TestCase
91
108
  end
92
109
 
93
110
  def generate_app(options = {})
94
- update = options.delete(:update) || false
111
+ update = options.delete(:update) || false
95
112
  excluded_stdlibs = options.delete(:excluded_stdlibs)
96
113
  raise "Unknown options: #{options.inspect}" unless options.empty?
97
114
  Dir.mkdir TMP_DIR unless File.exists? TMP_DIR
@@ -107,11 +124,13 @@ class Test::Unit::TestCase
107
124
  end
108
125
 
109
126
  FileUtils.rm_rf APP_DIR if File.exists? APP_DIR
110
- template_dir = "#{APP_DIR}_template_#{$$}#{'_updated' if update}#{"_without_#{excluded_stdlibs.map{|ed| ed.gsub(/[.\/]/, '_')}.join('_')}" if excluded_stdlibs}"
127
+ template_dir = "#{APP_DIR}_template_#{$$}#{'_updated' if update}#{"_without_#{excluded_stdlibs.map { |ed| ed.gsub(/[.\/]/, '_') }.join('_')}" if excluded_stdlibs}"
111
128
  if File.exists?(template_dir)
112
129
  puts "Copying app from template #{template_dir}"
113
130
  FileUtils.cp_r template_dir, APP_DIR, :preserve => true
114
131
  else
132
+ install_jruby_jars_gem
133
+
115
134
  if update
116
135
  Dir.chdir TMP_DIR do
117
136
  system "tar xzf #{PROJECT_DIR}/examples/RubotoTestApp_0.1.0_jruby_1.6.3.dev.tgz"
@@ -129,6 +148,10 @@ class Test::Unit::TestCase
129
148
  assert_equal 0, $?, "update app failed with return code #$?"
130
149
  end
131
150
  else
151
+ unless excluded_stdlibs
152
+ system 'gem uninstall jruby-jars --all'
153
+ assert_equal 0, $?, "uninstall of jruby-jars failed with return code #$?"
154
+ end
132
155
  puts "Generating app #{APP_DIR}"
133
156
  system "#{RUBOTO_CMD} gen app --package #{PACKAGE} --path #{APP_DIR} --name #{APP_NAME} --target #{ANDROID_TARGET}"
134
157
  if $? != 0
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruboto
3
3
  version: !ruby/object:Gem::Version
4
- hash: 13
4
+ hash: 3
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 5
9
- - 3
10
- version: 0.5.3
9
+ - 4
10
+ version: 0.5.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Daniel Jackoway
@@ -18,7 +18,7 @@ autorequire:
18
18
  bindir: bin
19
19
  cert_chain: []
20
20
 
21
- date: 2012-01-16 00:00:00 Z
21
+ date: 2012-02-10 00:00:00 Z
22
22
  dependencies:
23
23
  - !ruby/object:Gem::Dependency
24
24
  name: main