Skip to content

Instantly share code, notes, and snippets.

@rscottm
Created September 9, 2011 06:09
Show Gist options
  • Select an option

  • Save rscottm/1205580 to your computer and use it in GitHub Desktop.

Select an option

Save rscottm/1205580 to your computer and use it in GitHub Desktop.
Cycle through various versions of ruboto-core and jruby-jars to collect stack information
# Make sure you've started an emulator and entered your sudo password
rvs = ["0.2.1", "0.3.3", "--pre"]
jvs = ["1.5.6", "1.6.1", "1.6.3", "1.6.4"]
rvs.each do |rv|
jvs.each do |jv|
puts `sudo gem install jruby-jars --version #{jv} --no-ri --no-rdoc`
if rv == "--pre"
puts `sudo gem install ruboto-core --pre --no-ri --no-rdoc`
puts `ruboto gen app --package org.ruboto.example.test --with-jruby`
else
puts `sudo gem install ruboto-core --version #{rv} --no-ri --no-rdoc`
puts `ruboto gen app --package org.ruboto.example.test`
end
Dir.chdir "test"
fn = File.exists?("assets/scripts/test_activity.rb") ? "assets/scripts" : "src"
fn += "/test_activity.rb"
File.open(fn, "w") do |f|
f << %Q{
Java::android.util.Log.d "RUBOTOTEST", "Ruboto: #{rv}"
Java::android.util.Log.d "RUBOTOTEST", "JRuby: #{jv}"
}
f << IO.read("../test_activity.rb")
end
puts `cat #{fn}`
puts `ant debug`
puts `adb install -r bin/Test-debug.apk`
puts `rake update_scripts`
puts `adb shell am start -a android.intent.action.MAIN -n org.ruboto.example.test/.TestActivity`
Dir.chdir ".."
puts `rm -rf test`
puts `sudo gem uninstall ruboto-core -x`
puts `sudo gem uninstall jruby-jars`
end
end
# adb logcat | grep "RUBOTOTEST"
Ruboto: 0.2.1
JRuby: 1.5.6
0:40
1:61
2:69
3:86
Ruboto: 0.2.1
JRuby: 1.6.X
0:42
1:66
2:75
3:94
Ruboto: 0.3.3
JRuby: 1.5.6
0:40
1:61
2:69
3:86
Ruboto: 0.3.3
JRuby: 1.6.X
0:42
1:66
2:75
3:94
Ruboto: --pre
JRuby: 1.5.6
0:43
1:64
2:72
3:89
Ruboto: --pre
JRuby: 1.6.X
0:45
1:69
2:78
3:97
require 'ruboto'
ruboto_import_widgets :Button, :LinearLayout, :TextView
Java::android.util.Log.d "RUBOTOTEST", "0:*#{java.lang.Thread.current_thread.count_stack_frames}"
$activity.handle_create do |bundle|
setTitle 'This is the Title'
Java::android.util.Log.d "RUBOTOTEST", "1:*#{java.lang.Thread.current_thread.count_stack_frames}"
setup_content do
Java::android.util.Log.d "RUBOTOTEST", "2:*#{java.lang.Thread.current_thread.count_stack_frames}"
linear_layout :orientation => :vertical do
Java::android.util.Log.d "RUBOTOTEST", "3:*#{java.lang.Thread.current_thread.count_stack_frames}"
@text_view = text_view :text => 'What hath Matz wrought?', :id => 42
button :text => 'M-x butterfly', :id => 43, :on_click_listener => @handle_click
end
end
@handle_click = proc do |view|
if view.text == 'M-x butterfly'
@text_view.text = 'What hath Matz wrought!'
toast 'Flipped a bit via butterfly'
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment