ruboto 0.13.0.rc.0 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,9 +1,10 @@
1
- require 'pty'
2
1
  require 'ruboto/sdk_versions'
2
+ require 'ruboto/util/verify'
3
3
 
4
4
  module Ruboto
5
5
  module Util
6
6
  module Setup
7
+ include Ruboto::Util::Verify
7
8
  REPOSITORY_BASE = 'https://dl-ssl.google.com/android/repository'
8
9
  REPOSITORY_URL = "#{REPOSITORY_BASE}/repository-8.xml"
9
10
 
@@ -14,7 +15,7 @@ module Ruboto
14
15
 
15
16
  def setup_ruboto(accept_all, api_levels = [SdkVersions::DEFAULT_TARGET_SDK])
16
17
  @platform_sdk_loc = {}
17
- api_levels = [read_project_api_level, *api_levels].compact.uniq
18
+ api_levels = [project_api_level, *api_levels].compact.uniq
18
19
  install_all(accept_all, api_levels) unless check_all(api_levels)
19
20
  config_path(accept_all)
20
21
  end
@@ -63,14 +64,6 @@ module Ruboto
63
64
  end
64
65
  end
65
66
 
66
- def read_project_api_level
67
- begin
68
- return $1 if File.read('project.properties') =~ /target=(.*)/
69
- rescue
70
- # ignored
71
- end
72
- end
73
-
74
67
  def path_setup_file
75
68
  case RbConfig::CONFIG['host_os']
76
69
  when /^darwin(.*)/ then
@@ -429,7 +422,7 @@ module Ruboto
429
422
  a = STDIN.gets.chomp.upcase
430
423
  end
431
424
  if accept_all || a == 'Y' || a.empty?
432
- update_cmd = "android --silent update sdk --no-ui --filter #{api_level},sysimg-#{api_level.slice(/\d+$/)} --all"
425
+ update_cmd = "android update sdk --no-ui --filter #{api_level},sysimg-#{api_level.slice(/\d+$/)} --all"
433
426
  update_sdk(update_cmd, accept_all)
434
427
  check_for_android_platform(api_level)
435
428
  end
@@ -437,26 +430,22 @@ module Ruboto
437
430
 
438
431
  def update_sdk(update_cmd, accept_all)
439
432
  if accept_all
440
- begin
441
- PTY.spawn(update_cmd) do |stdin, stdout, pid|
442
- begin
443
- output = ''
444
- question_pattern = /.*Do you accept the license '[a-z-]+-[0-9a-f]{8}' \[y\/n\]: /m
445
- STDOUT.sync = true
446
- stdin.each_char do |text|
447
- print text
448
- output << text
449
- if output =~ question_pattern
450
- stdout.puts 'y'
451
- output.sub! question_pattern, ''
452
- end
433
+ IO.popen(update_cmd, 'r+') do |cmd_io|
434
+ begin
435
+ output = ''
436
+ question_pattern = /.*Do you accept the license '[a-z-]+-[0-9a-f]{8}' \[y\/n\]: /m
437
+ STDOUT.sync = true
438
+ cmd_io.each_char do |text|
439
+ print text
440
+ output << text
441
+ if output =~ question_pattern
442
+ cmd_io.puts 'y'
443
+ output.sub! question_pattern, ''
453
444
  end
454
- rescue Errno::EIO
455
- # This probably just means that the process has finished giving output.
456
445
  end
446
+ rescue Errno::EIO
447
+ # This probably just means that the process has finished giving output.
457
448
  end
458
- rescue PTY::ChildExited
459
- puts 'The child process exited!'
460
449
  end
461
450
  else
462
451
  system update_cmd
@@ -88,6 +88,26 @@ module Ruboto
88
88
  File.open('ruboto.yml', 'w') {|f| f << YAML.dump(verify_ruboto_config)}
89
89
  end
90
90
 
91
+ def verify_project_properties
92
+ return @project_properties if project_properties
93
+ abort "cannot find your #{properties_file_name} to extract info from it. Make sure you're in the root directory of your app." unless File.exists? properties_file_name
94
+ end
95
+
96
+ def project_properties
97
+ return @project_properties if @project_properties
98
+ properties_file_name = 'project.properties'
99
+ return nil unless File.exists? properties_file_name
100
+ @project_properties = File.read(properties_file_name)
101
+ end
102
+
103
+ def project_api_level
104
+ begin
105
+ return $1 if project_properties =~ /^target=(.*)$/
106
+ rescue
107
+ # ignored
108
+ end
109
+ end
110
+
91
111
  end
92
112
  end
93
113
  end
@@ -1,4 +1,4 @@
1
1
  module Ruboto
2
- VERSION = '0.13.0.rc.0'
2
+ VERSION = '0.13.0'
3
3
  UPDATE_VERSION_LIMIT = '0.7.0'
4
4
  end
@@ -1,7 +1,7 @@
1
1
  require 'ruboto/activity'
2
2
  require 'ruboto/widget'
3
3
 
4
- ruboto_import_widgets :Button, :LinearLayout, :TextView
4
+ ruboto_import_widgets :Button, :LinearLayout, :ScrollView, :TextView
5
5
 
6
6
  class NavigationActivity
7
7
  def onCreate(bundle)
@@ -12,14 +12,19 @@ class NavigationActivity
12
12
  linear_layout :orientation => :vertical, :gravity => :center_horizontal do
13
13
  text_view :text => 'Navigation', :id => 42, :width => :match_parent,
14
14
  :gravity => :center, :text_size => 48.0
15
- button :text => 'Java backed by Java class', :width => :match_parent, :id => 43, :on_click_listener => proc { java_backed_by_java_class }
16
- button :text => 'Java backed by Ruby class', :width => :match_parent, :id => 44, :on_click_listener => proc { java_backed_by_ruby_class }
17
- button :text => 'Java backed by script name', :width => :match_parent, :id => 45, :on_click_listener => proc { java_backed_by_script_name }
18
- button :text => 'Inline block', :width => :match_parent, :id => 46, :on_click_listener => proc { start_inline_activity }
19
- button :text => 'Inline block with options', :width => :match_parent, :id => 47, :on_click_listener => proc { start_inline_activity_with_options }
20
- button :text => 'Infile class', :width => :match_parent, :id => 48, :on_click_listener => proc { start_infile_activity }
21
- button :text => 'Ruby file activity', :width => :match_parent, :id => 49, :on_click_listener => proc { start_ruby_file_activity }
22
- button :text => 'RubotoActivity no config', :width => :match_parent, :id => 50, :on_click_listener => proc { start_ruboto_activity_no_config }
15
+ scroll_view :layout => {:weight= => 1} do
16
+ linear_layout :orientation => :vertical do
17
+ button :text => 'Java backed by Java class', :width => :match_parent, :id => 43, :on_click_listener => proc { java_backed_by_java_class }
18
+ button :text => 'Java backed by Ruby class', :width => :match_parent, :id => 44, :on_click_listener => proc { java_backed_by_ruby_class }
19
+ button :text => 'Java backed by script name', :width => :match_parent, :id => 45, :on_click_listener => proc { java_backed_by_script_name }
20
+ button :text => 'Inline block', :width => :match_parent, :id => 46, :on_click_listener => proc { start_inline_activity }
21
+ button :text => 'Inline block with options', :width => :match_parent, :id => 47, :on_click_listener => proc { start_inline_activity_with_options }
22
+ button :text => 'Infile class', :width => :match_parent, :id => 48, :on_click_listener => proc { start_infile_activity }
23
+ button :text => 'Ruby file activity', :width => :match_parent, :id => 49, :on_click_listener => proc { start_ruby_file_activity }
24
+ button :text => 'RubotoActivity no config', :width => :match_parent, :id => 50, :on_click_listener => proc { start_ruboto_activity_no_config }
25
+ button :text => 'RubotoActivity', :width => :match_parent, :id => 51, :on_click_listener => proc { start_ruboto_activity('RubyFileActivity') }
26
+ end
27
+ end
23
28
  end
24
29
  end
25
30
 
@@ -34,18 +39,14 @@ class NavigationActivity
34
39
  def java_backed_by_ruby_class
35
40
  i = android.content.Intent.new
36
41
  i.setClassName($package_name, 'org.ruboto.RubotoActivity')
37
- config_bundle = android.os.Bundle.new
38
- config_bundle.put_string('ClassName', 'NavigationTargetActivity')
39
- i.putExtra('Ruboto Config', config_bundle)
42
+ i.putExtra(Ruboto::CLASS_NAME_KEY, 'NavigationTargetActivity')
40
43
  startActivity(i)
41
44
  end
42
45
 
43
46
  def java_backed_by_script_name
44
47
  i = android.content.Intent.new
45
48
  i.setClassName($package_name, 'org.ruboto.RubotoActivity')
46
- config_bundle = android.os.Bundle.new
47
- config_bundle.put_string('Script', 'navigation_target_activity.rb')
48
- i.putExtra('Ruboto Config', config_bundle)
49
+ i.putExtra(Ruboto::SCRIPT_NAME_KEY, 'navigation_target_activity.rb')
49
50
  startActivity(i)
50
51
  end
51
52
 
@@ -80,18 +81,14 @@ class NavigationActivity
80
81
  def start_infile_activity
81
82
  i = android.content.Intent.new
82
83
  i.setClassName($package_name, 'org.ruboto.RubotoActivity')
83
- config_bundle = android.os.Bundle.new
84
- config_bundle.put_string('ClassName', 'InfileActivity')
85
- i.putExtra('Ruboto Config', config_bundle)
84
+ i.putExtra(Ruboto::CLASS_NAME_KEY, 'InfileActivity')
86
85
  startActivity(i)
87
86
  end
88
87
 
89
88
  def start_ruby_file_activity
90
89
  i = android.content.Intent.new
91
90
  i.setClassName($package_name, 'org.ruboto.RubotoActivity')
92
- config_bundle = android.os.Bundle.new
93
- config_bundle.put_string('ClassName', 'RubyFileActivity')
94
- i.putExtra('Ruboto Config', config_bundle)
91
+ i.putExtra(Ruboto::CLASS_NAME_KEY, 'RubyFileActivity')
95
92
  startActivity(i)
96
93
  end
97
94
 
@@ -54,8 +54,25 @@ test('start ruby file activity again', :ui => false) do |activity|
54
54
  end
55
55
 
56
56
  test('start ruboto activity without config', :ui => false) do |activity|
57
- a = start_activity_by_button activity, 50
58
- assert_equal 'Ruboto Test App', a.title
57
+ begin
58
+ a = start_activity_by_button activity, 50
59
+ assert_equal 'Ruboto Test App', a.title
60
+ ensure
61
+ if a
62
+ finish_at = Time.now
63
+ finished = false
64
+ a.run_on_ui_thread { a.finish; finished = true }
65
+ loop do
66
+ break if finished || (Time.now - finish_at > 10)
67
+ puts 'wait for finish'
68
+ sleep 0.1
69
+ end
70
+ end
71
+ end
72
+ end
73
+
74
+ test('start ruboto activity with class name', :ui => false) do |activity|
75
+ button_activity_text 51, activity, 42, 'This is a Ruby file activity.'
59
76
  end
60
77
 
61
78
  def start_activity_by_button(activity, button_id, activity_class_name = 'org.ruboto.RubotoActivity')
data/test/rake_test.rb CHANGED
@@ -34,10 +34,10 @@ class RakeTest < Test::Unit::TestCase
34
34
 
35
35
  def test_that_apk_is_built_if_only_one_ruby_source_file_has_changed
36
36
  Dir.chdir APP_DIR do
37
- system 'rake install'
37
+ system 'rake debug'
38
38
  apk_timestamp = File.ctime("bin/#{APP_NAME}-debug.apk")
39
39
  FileUtils.touch 'src/ruboto_test_app_activity.rb'
40
- system 'rake install'
40
+ system 'rake debug'
41
41
  assert_not_equal apk_timestamp, File.ctime("bin/#{APP_NAME}-debug.apk"), 'APK should have been rebuilt'
42
42
  end
43
43
  end
@@ -0,0 +1,27 @@
1
+ require File.expand_path('test_helper', File.dirname(__FILE__))
2
+
3
+ class RubotoActivityTest < Test::Unit::TestCase
4
+ def setup
5
+ generate_app
6
+ end
7
+
8
+ def teardown
9
+ cleanup_app
10
+ end
11
+
12
+ def test_ruboto_activity_as_entry_point
13
+ check_platform_installation
14
+ Dir.chdir APP_DIR do
15
+ #java_source_file = 'src/org/ruboto/test_app/RubotoTestAppActivity.java'
16
+ #source = File.read(java_source_file)
17
+ #assert source.gsub!(/extends org.ruboto.EntryPointActivity/, 'extends org.ruboto.RubotoActivity')
18
+ #File.open(java_source_file, 'w') { |f| f << source }
19
+ system 'rake install'
20
+ #system "adb shell am start -a android.intent.action.MAIN -n org.ruboto.example_test_app/.RubotoActivity"
21
+ system "adb shell am start -n org.ruboto.test_app/org.ruboto.RubotoActivity -e ClassName RubotoTestAppActivity"
22
+ assert_equal 0, $?, "tests failed with return code #$?"
23
+ # FIXME(uwe): Assert that the activity was started correctly.
24
+ end
25
+ end
26
+
27
+ end
data/test/test_helper.rb CHANGED
@@ -254,10 +254,6 @@ class Test::Unit::TestCase
254
254
  end
255
255
 
256
256
  def run_app_tests
257
- if [7, 8].include? ANDROID_OS
258
- puts "Skipping instrumentation tests on #{ANDROID_OS} since they don't work."
259
- return
260
- end
261
257
  check_platform_installation
262
258
  Dir.chdir APP_DIR do
263
259
  system 'rake test:quick'
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruboto
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.0.rc.0
5
- prerelease: 7
4
+ version: 0.13.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Daniel Jackoway
@@ -12,50 +11,55 @@ authors:
12
11
  autorequire:
13
12
  bindir: bin
14
13
  cert_chain: []
15
- date: 2013-05-25 00:00:00.000000000 Z
14
+ date: 2013-06-09 00:00:00.000000000 Z
16
15
  dependencies:
17
16
  - !ruby/object:Gem::Dependency
18
17
  name: main
19
18
  requirement: !ruby/object:Gem::Requirement
20
- none: false
21
19
  requirements:
22
- - - ! '>='
20
+ - - '>='
23
21
  - !ruby/object:Gem::Version
24
22
  version: 4.7.2
25
23
  type: :runtime
26
24
  prerelease: false
27
25
  version_requirements: !ruby/object:Gem::Requirement
28
- none: false
29
26
  requirements:
30
- - - ! '>='
27
+ - - '>='
31
28
  - !ruby/object:Gem::Version
32
29
  version: 4.7.2
33
30
  - !ruby/object:Gem::Dependency
34
31
  name: rake
35
32
  requirement: !ruby/object:Gem::Requirement
36
- none: false
37
33
  requirements:
38
- - - ! '>='
34
+ - - '>='
39
35
  - !ruby/object:Gem::Version
40
36
  version: '0'
41
37
  type: :runtime
42
38
  prerelease: false
43
39
  version_requirements: !ruby/object:Gem::Requirement
44
- none: false
45
40
  requirements:
46
- - - ! '>='
41
+ - - '>='
47
42
  - !ruby/object:Gem::Version
48
43
  version: '0'
49
- description: ! 'Ruboto (JRuby on Android) is a platform for developing full stand-alone
50
- apps for
51
-
44
+ - !ruby/object:Gem::Dependency
45
+ name: jruby-jars
46
+ requirement: !ruby/object:Gem::Requirement
47
+ requirements:
48
+ - - '>='
49
+ - !ruby/object:Gem::Version
50
+ version: '0'
51
+ type: :runtime
52
+ prerelease: false
53
+ version_requirements: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - '>='
56
+ - !ruby/object:Gem::Version
57
+ version: '0'
58
+ description: |
59
+ Ruboto (JRuby on Android) is a platform for developing full stand-alone apps for
52
60
  Android using the Ruby language and libraries. It includes support libraries
53
-
54
61
  and generators for creating projects, classes, tests, and more. The complete
55
-
56
62
  APIs of Android, Java, and Ruby are available to you using the Ruby language.
57
-
58
- '
59
63
  email: ruboto@googlegroups.com
60
64
  executables:
61
65
  - ruboto
@@ -65,15 +69,21 @@ files:
65
69
  - Gemfile
66
70
  - Gemfile.lock
67
71
  - LICENSE
68
- - Rakefile
69
72
  - README.md
70
- - assets/libs/dx.jar
73
+ - RELEASE_CANDICATE_DOC
74
+ - RELEASE_DOC
75
+ - Rakefile
76
+ - assets/.DS_Store
77
+ - assets/.gitignore
71
78
  - assets/Rakefile
79
+ - assets/libs/dx.jar
72
80
  - assets/rakelib/ruboto.rake
73
- - assets/res/drawable/get_ruboto_core.png
81
+ - assets/res/.DS_Store
74
82
  - assets/res/drawable-hdpi/ic_launcher.png
75
83
  - assets/res/drawable-ldpi/ic_launcher.png
76
84
  - assets/res/drawable-mdpi/ic_launcher.png
85
+ - assets/res/drawable/.DS_Store
86
+ - assets/res/drawable/get_ruboto_core.png
77
87
  - assets/res/layout/get_ruboto_core.xml
78
88
  - assets/samples/sample_activity.rb
79
89
  - assets/samples/sample_activity_test.rb
@@ -87,6 +97,9 @@ files:
87
97
  - assets/src/InheritingBroadcastReceiver.java
88
98
  - assets/src/InheritingClass.java
89
99
  - assets/src/InheritingService.java
100
+ - assets/src/RubotoActivity.java
101
+ - assets/src/RubotoBroadcastReceiver.java
102
+ - assets/src/RubotoService.java
90
103
  - assets/src/org/ruboto/EntryPointActivity.java
91
104
  - assets/src/org/ruboto/JRubyAdapter.java
92
105
  - assets/src/org/ruboto/Log.java
@@ -106,18 +119,12 @@ files:
106
119
  - assets/src/ruboto/util/stack.rb
107
120
  - assets/src/ruboto/util/toast.rb
108
121
  - assets/src/ruboto/widget.rb
109
- - assets/src/RubotoActivity.java
110
- - assets/src/RubotoBroadcastReceiver.java
111
- - assets/src/RubotoService.java
112
122
  - assets/test/src/test_helper.rb
113
- - assets/.DS_Store
114
- - assets/.gitignore
115
- - assets/res/.DS_Store
116
- - assets/res/drawable/.DS_Store
117
123
  - bin/ruboto
118
124
  - lib/DalvikProxyClassFactory.java
119
125
  - lib/DexClient.java
120
126
  - lib/java_class_gen/android_api.xml
127
+ - lib/ruboto.rb
121
128
  - lib/ruboto/api.rb
122
129
  - lib/ruboto/commands/base.rb
123
130
  - lib/ruboto/core_ext/array.rb
@@ -129,6 +136,7 @@ files:
129
136
  - lib/ruboto/util/asset_copier.rb
130
137
  - lib/ruboto/util/build.rb
131
138
  - lib/ruboto/util/code_formatting.rb
139
+ - lib/ruboto/util/emulator.rb
132
140
  - lib/ruboto/util/log_action.rb
133
141
  - lib/ruboto/util/main_fix.rb
134
142
  - lib/ruboto/util/objectspace.rb
@@ -138,7 +146,6 @@ files:
138
146
  - lib/ruboto/util/verify.rb
139
147
  - lib/ruboto/util/xml_element.rb
140
148
  - lib/ruboto/version.rb
141
- - lib/ruboto.rb
142
149
  - test/activity/call_super_activity.rb
143
150
  - test/activity/call_super_activity_test.rb
144
151
  - test/activity/dir_and_file_activity.rb
@@ -177,6 +184,7 @@ files:
177
184
  - test/gem_test.rb
178
185
  - test/minimal_app_test.rb
179
186
  - test/rake_test.rb
187
+ - test/ruboto_activity_test.rb
180
188
  - test/ruboto_gen_test.rb
181
189
  - test/ruboto_update_test.rb
182
190
  - test/service_test.rb
@@ -187,26 +195,25 @@ files:
187
195
  homepage: http://ruboto.org/
188
196
  licenses:
189
197
  - MIT
198
+ metadata: {}
190
199
  post_install_message:
191
200
  rdoc_options: []
192
201
  require_paths:
193
202
  - lib
194
203
  required_ruby_version: !ruby/object:Gem::Requirement
195
- none: false
196
204
  requirements:
197
- - - ! '>='
205
+ - - '>='
198
206
  - !ruby/object:Gem::Version
199
207
  version: '0'
200
208
  required_rubygems_version: !ruby/object:Gem::Requirement
201
- none: false
202
209
  requirements:
203
- - - ! '>'
210
+ - - '>='
204
211
  - !ruby/object:Gem::Version
205
- version: 1.3.1
212
+ version: '0'
206
213
  requirements: []
207
214
  rubyforge_project: ruboto/ruboto
208
- rubygems_version: 1.8.25
215
+ rubygems_version: 2.0.3
209
216
  signing_key:
210
- specification_version: 3
217
+ specification_version: 4
211
218
  summary: A platform for developing apps using JRuby on Android.
212
219
  test_files: []