ruboto 0.8.0 → 0.8.1

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.
Files changed (57) hide show
  1. data/Rakefile +35 -11
  2. data/assets/rakelib/ruboto.rake +2 -0
  3. data/assets/samples/sample_activity.rb +1 -0
  4. data/assets/samples/sample_class.rb +2 -0
  5. data/assets/samples/sample_class_test.rb +1 -0
  6. data/assets/src/InheritingActivity.java +1 -1
  7. data/assets/src/InheritingBroadcastReceiver.java +2 -1
  8. data/assets/src/InheritingClass.java +15 -7
  9. data/assets/src/InheritingService.java +1 -2
  10. data/assets/src/RubotoActivity.java +20 -110
  11. data/assets/src/RubotoBroadcastReceiver.java +16 -62
  12. data/assets/src/RubotoService.java +13 -89
  13. data/assets/src/org/ruboto/EntryPointActivity.java +1 -1
  14. data/assets/src/org/ruboto/JRubyAdapter.java +23 -23
  15. data/assets/src/org/ruboto/RubotoComponent.java +8 -0
  16. data/assets/src/org/ruboto/Script.java +10 -5
  17. data/assets/src/org/ruboto/ScriptInfo.java +53 -0
  18. data/assets/src/org/ruboto/ScriptLoader.java +143 -0
  19. data/assets/src/org/ruboto/test/ActivityTest.java +15 -8
  20. data/assets/src/org/ruboto/test/InstrumentationTestRunner.java +11 -6
  21. data/assets/src/ruboto/activity.rb +43 -17
  22. data/assets/src/ruboto/base.rb +7 -1
  23. data/assets/src/ruboto/generate.rb +6 -2
  24. data/assets/src/ruboto/legacy.rb +1 -1
  25. data/assets/src/ruboto/menu.rb +4 -4
  26. data/assets/src/ruboto/widget.rb +4 -11
  27. data/lib/ruboto/commands/base.rb +21 -7
  28. data/lib/ruboto/util/build.rb +6 -3
  29. data/lib/ruboto/util/code_formatting.rb +2 -2
  30. data/lib/ruboto/util/update.rb +58 -58
  31. data/lib/ruboto/util/xml_element.rb +14 -11
  32. data/lib/ruboto/version.rb +2 -1
  33. data/test/activity/generate_activity.rb +35 -0
  34. data/test/activity/generate_activity_test.rb +17 -0
  35. data/test/activity/image_button_activity.rb +1 -0
  36. data/test/activity/image_button_and_button_activity.rb +1 -0
  37. data/test/activity/margins_activity.rb +1 -0
  38. data/test/activity/navigation_activity.rb +20 -5
  39. data/test/activity/navigation_activity_test.rb +43 -4
  40. data/test/activity/option_menu_activity.rb +1 -0
  41. data/test/activity/psych_activity.rb +2 -1
  42. data/test/activity/stack_activity.rb +1 -0
  43. data/test/activity/stack_activity_test.rb +11 -5
  44. data/test/block_def_activity/margins_activity.rb +2 -1
  45. data/test/block_def_activity/psych_activity.rb +1 -1
  46. data/test/block_def_activity/stack_activity_test.rb +1 -1
  47. data/test/handle_activity/psych_activity.rb +1 -1
  48. data/test/handle_activity/stack_activity_test.rb +17 -9
  49. data/test/minimal_app_test.rb +2 -2
  50. data/test/rake_test.rb +1 -1
  51. data/test/ruboto_gen_test.rb +162 -34
  52. data/test/service_test.rb +1 -2
  53. data/test/sqldroid_test.rb +87 -0
  54. data/test/test_helper.rb +19 -12
  55. data/test/update_test_methods.rb +29 -44
  56. data/test/view_constants_test.rb +1 -2
  57. metadata +12 -4
data/Rakefile CHANGED
@@ -78,26 +78,47 @@ end
78
78
 
79
79
  desc 'Generate release docs for a given milestone'
80
80
  task :release_docs do
81
- # require 'rubygems'
82
- # require 'highline/import'
83
- print 'user name: ' ; user = STDIN.gets.chomp # ask('login : ') { |q| q.echo = true }
84
- print 'password : ' ; pass = STDIN.gets.chomp # ask('password: ') { |q| q.echo = '*' }
85
- print 'milestone: ' ; milestone = STDIN.gets.chomp # ask('milestone: ', Integer) { |q| q.echo = true }
81
+ raise "\n This task requires Ruby 1.9 or newer to parse JSON as YAML.\n\n" if RUBY_VERSION == '1.8.7'
82
+ begin
83
+ require 'rubygems'
84
+ require 'highline/import'
85
+ user = ask('login : ') { |q| q.echo = true }
86
+ pass = ask('password: ') { |q| q.echo = '*' }
87
+ rescue
88
+ print 'user name: ' ; user = STDIN.gets.chomp
89
+ print 'password : ' ; pass = STDIN.gets.chomp
90
+ end
86
91
  require 'uri'
87
92
  require 'net/http'
88
93
  require 'net/https'
89
94
  require 'openssl'
90
95
  require 'yaml'
91
- uri = URI(%Q{https://api.github.com/repos/ruboto/ruboto/issues?milestone=#{milestone}&state=closed&per_page=1000})
92
- https = Net::HTTP.new(uri.host, uri.port)
96
+ host = 'api.github.com'
97
+ base_uri = "https://#{host}/repos/ruboto/ruboto"
98
+ https = Net::HTTP.new(host, 443)
93
99
  https.use_ssl = true
94
100
  https.verify_mode = OpenSSL::SSL::VERIFY_NONE
101
+
102
+ milestone_uri = URI("#{base_uri}/milestones")
103
+ req = Net::HTTP::Get.new(milestone_uri.request_uri)
104
+ req.basic_auth(user, pass)
105
+ res = https.start { |http| http.request(req) }
106
+ milestones = YAML.load(res.body).sort_by { |i| Date.parse(i['due_on']) }
107
+ puts milestones.map{|m| "#{'%2d' % m['number']} #{m['title']}"}.join("\n")
108
+
109
+ if defined? ask
110
+ milestone = ask('milestone: ', Integer) { |q| q.echo = true }
111
+ else
112
+ print 'milestone: ' ; milestone = STDIN.gets.chomp
113
+ end
114
+
115
+ uri = URI("#{base_uri}/issues?milestone=#{milestone}&state=closed&per_page=1000")
95
116
  req = Net::HTTP::Get.new(uri.request_uri)
96
117
  req.basic_auth(user, pass)
97
118
  res = https.start { |http| http.request(req) }
98
119
  issues = YAML.load(res.body).sort_by { |i| i['number'] }
99
120
  milestone_name = issues[0] ? issues[0]['milestone']['title'] : "No issues for milestone #{milestone}"
100
- categories = {'Features' => 'feature', 'Bugfixes' => 'bug', 'Internal' => 'internal', 'Support' => 'support', 'Documentation' => 'documentation', 'Other' => nil}
121
+ categories = {'Features' => 'feature', 'Bugfixes' => 'bug', 'Internal' => 'internal', 'Support' => 'support', 'Documentation' => 'documentation', 'Pull requests' => nil, 'Other' => nil}
101
122
  grouped_issues = issues.group_by do |i|
102
123
  labels = i['labels'].map { |l| l['name']}
103
124
  cat = nil
@@ -107,7 +128,9 @@ task :release_docs do
107
128
  break
108
129
  end
109
130
  end
110
- cat || 'Other'
131
+ cat ||= i['pull_request'] && 'Pull requests'
132
+ cat ||= 'Other'
133
+ cat
111
134
  end
112
135
  puts "\nNew in version #{milestone_name}:\n\n"
113
136
  (categories.keys & grouped_issues.keys).each do |cat|
@@ -127,10 +150,11 @@ task :release => [:clean, :gem] do
127
150
  sh "git push --tags"
128
151
  sh "gem push #{GEM_FILE}"
129
152
 
153
+ examples_glob = "#{EXAMPLE_FILE.slice(/^.*?_\d+\.\d+\.\d+/)}*"
154
+ sh "git rm #{examples_glob}" unless Dir[examples_glob].empty?
130
155
  Rake::Task[:example].invoke
131
156
  sh "git add #{EXAMPLE_FILE}"
132
- sh "git rm #{EXAMPLE_FILE.slice(/^\d+\.\d+\.\d+/)}.*"
133
- sh "git commit -m '* Added example app for Ruboto #{Ruboto::VERSION} tools r#{Ruboto::SdkVersions::ANDROID_TOOLS_REVISION}' #{EXAMPLE_FILE}"
157
+ sh "git commit -m '* Added example app for Ruboto #{Ruboto::VERSION} tools r#{Ruboto::SdkVersions::ANDROID_TOOLS_REVISION}' \"#{examples_glob}\""
134
158
  sh "git push"
135
159
  end
136
160
 
@@ -128,10 +128,12 @@ task :emulator do
128
128
  sh 'emulator -partition-size 1024 -avd Android_3.0'
129
129
  end
130
130
 
131
+ desc 'Start the application on the device/emulator.'
131
132
  task :start do
132
133
  start_app
133
134
  end
134
135
 
136
+ desc 'Stop the application on the device/emulator (requires emulator or rooted device).'
135
137
  task :stop do
136
138
  raise "Unable to stop app. Only available on emulator." unless stop_app
137
139
  end
@@ -7,6 +7,7 @@ ruboto_import_widgets :Button, :LinearLayout, :TextView
7
7
 
8
8
  class SampleActivity
9
9
  def on_create(bundle)
10
+ super
10
11
  set_title 'Domo arigato, Mr Ruboto!'
11
12
 
12
13
  self.content_view =
@@ -0,0 +1,2 @@
1
+ class SampleClass
2
+ end
@@ -0,0 +1 @@
1
+ # TODO
@@ -4,7 +4,7 @@ import android.os.Bundle;
4
4
 
5
5
  public class InheritingActivity extends org.ruboto.EntryPointActivity {
6
6
  public void onCreate(Bundle bundle) {
7
- setRubyClassName(getClass().getSimpleName());
7
+ getScriptInfo().setRubyClassName(getClass().getSimpleName());
8
8
  super.onCreate(bundle);
9
9
  }
10
10
  }
@@ -1,6 +1,7 @@
1
1
  package THE_PACKAGE;
2
2
 
3
3
  import org.ruboto.JRubyAdapter;
4
+ import org.ruboto.ScriptLoader;
4
5
 
5
6
  public class InheritingBroadcastReceiver extends org.ruboto.RubotoBroadcastReceiver {
6
7
  private boolean scriptLoaded = false;
@@ -15,7 +16,7 @@ public class InheritingBroadcastReceiver extends org.ruboto.RubotoBroadcastRecei
15
16
  public void onReceive(android.content.Context context, android.content.Intent intent) {
16
17
  if (!scriptLoaded) {
17
18
  if (JRubyAdapter.setUpJRuby(context)) {
18
- loadScript();
19
+ ScriptLoader.loadScript(this);
19
20
  scriptLoaded = true;
20
21
  } else {
21
22
  // FIXME(uwe): What to do if the Ruboto Core platform is missing?
@@ -5,21 +5,29 @@ package THE_PACKAGE;
5
5
  import org.ruboto.JRubyAdapter;
6
6
  import org.ruboto.Log;
7
7
  import org.ruboto.Script;
8
+ import org.ruboto.ScriptInfo;
9
+ import org.ruboto.ScriptLoader;
8
10
 
9
11
  public class THE_RUBOTO_CLASS THE_ACTION THE_ANDROID_CLASS {
10
12
  THE_CONSTANTS
11
13
 
12
- private String rubyClassName = "THE_RUBOTO_CLASS";
13
- private String scriptName = "THE_RUBOTO_CLASS";
14
- private Object rubyInstance = this;
15
- private Object[] callbackProcs = new Object[CONSTANTS_COUNT];
14
+ private final ScriptInfo scriptInfo = new ScriptInfo(CONSTANTS_COUNT);
15
+ {
16
+ scriptInfo.setRubyClassName(getClass().getSimpleName());
17
+ ScriptLoader.loadScript(this);
18
+ }
16
19
 
17
20
  THE_CONSTRUCTORS
18
21
 
19
- public void setCallbackProc(int id, Object obj) {
20
- callbackProcs[id] = obj;
22
+ public ScriptInfo getScriptInfo() {
23
+ return scriptInfo;
21
24
  }
22
-
25
+
26
+ // FIXME(uwe): Only used for block based primary activities. Remove if we remove support for such.
27
+ public void onCreateSuper() {
28
+ // Do nothing
29
+ }
30
+
23
31
  THE_METHODS
24
32
 
25
33
  }
@@ -2,8 +2,7 @@ package THE_PACKAGE;
2
2
 
3
3
  public class InheritingService extends org.ruboto.RubotoService {
4
4
  public void onCreate() {
5
- System.out.println("InheritingService.onCreate()");
6
- setScriptName("sample_service.rb");
5
+ getScriptInfo().setRubyClassName(getClass().getSimpleName());
7
6
  super.onCreate();
8
7
  }
9
8
 
@@ -10,18 +10,11 @@ import android.os.Bundle;
10
10
  public class THE_RUBOTO_CLASS THE_ACTION THE_ANDROID_CLASS {
11
11
  THE_CONSTANTS
12
12
 
13
- private String rubyClassName;
14
- private String scriptName;
15
- private Object rubyInstance;
16
- private Object[] callbackProcs = new Object[CONSTANTS_COUNT];
13
+ private final ScriptInfo scriptInfo = new ScriptInfo(CONSTANTS_COUNT);
17
14
  private String remoteVariable = null;
18
- private Object[] args;
15
+ Bundle[] args;
19
16
  private Bundle configBundle = null;
20
17
 
21
- public void setCallbackProc(int id, Object obj) {
22
- callbackProcs[id] = obj;
23
- }
24
-
25
18
  public THE_RUBOTO_CLASS setRemoteVariable(String var) {
26
19
  remoteVariable = var;
27
20
  return this;
@@ -31,23 +24,28 @@ THE_CONSTANTS
31
24
  return (remoteVariable == null ? "" : (remoteVariable + ".")) + call;
32
25
  }
33
26
 
34
- public void setRubyClassName(String name) {
35
- rubyClassName = name;
36
- }
37
-
38
- public void setScriptName(String name) {
39
- scriptName = name;
27
+ public ScriptInfo getScriptInfo() {
28
+ return scriptInfo;
40
29
  }
41
30
 
42
31
  /****************************************************************************************
43
32
  *
44
33
  * Activity Lifecycle: onCreate
45
34
  */
46
-
35
+
36
+ // FIXME(uwe): Only used for block based primary activities. Remove if we remove support for such.
37
+ public void onCreateSuper() {
38
+ super.onCreate((Bundle) args[0]);
39
+ }
40
+
47
41
  @Override
48
42
  public void onCreate(Bundle bundle) {
49
43
  System.out.println("RubotoActivity onCreate(): " + getClass().getName());
50
- args = new Object[1];
44
+ if (ScriptLoader.isCalledFromJRuby()) {
45
+ super.onCreate(bundle);
46
+ return;
47
+ }
48
+ args = new Bundle[1];
51
49
  args[0] = bundle;
52
50
 
53
51
  configBundle = getIntent().getBundleExtra("RubotoActivity Config");
@@ -58,32 +56,25 @@ THE_CONSTANTS
58
56
  }
59
57
  if (configBundle.containsKey("ClassName")) {
60
58
  if (this.getClass().getName() == RubotoActivity.class.getName()) {
61
- setRubyClassName(configBundle.getString("ClassName"));
59
+ scriptInfo.setRubyClassName(configBundle.getString("ClassName"));
62
60
  } else {
63
61
  throw new IllegalArgumentException("Only local Intents may set class name.");
64
62
  }
65
63
  }
66
64
  if (configBundle.containsKey("Script")) {
67
65
  if (this.getClass().getName() == RubotoActivity.class.getName()) {
68
- setScriptName(configBundle.getString("Script"));
66
+ scriptInfo.setScriptName(configBundle.getString("Script"));
69
67
  } else {
70
68
  throw new IllegalArgumentException("Only local Intents may set script name.");
71
69
  }
72
70
  }
73
71
  }
74
72
 
75
- if (rubyClassName == null && scriptName != null) {
76
- rubyClassName = Script.toCamelCase(scriptName);
77
- }
78
- if (scriptName == null && rubyClassName != null) {
79
- setScriptName(Script.toSnakeCase(rubyClassName) + ".rb");
80
- }
81
-
82
- super.onCreate(bundle);
83
-
84
73
  if (JRubyAdapter.isInitialized()) {
85
74
  prepareJRuby();
86
- loadScript();
75
+ ScriptLoader.loadScript(this, (Object[]) args);
76
+ } else {
77
+ super.onCreate(bundle);
87
78
  }
88
79
  }
89
80
 
@@ -97,87 +88,6 @@ THE_CONSTANTS
97
88
  }
98
89
  // TODO end
99
90
 
100
- protected void loadScript() {
101
- try {
102
- if (scriptName != null) {
103
- System.out.println("Looking for Ruby class: " + rubyClassName);
104
- Object rubyClass = JRubyAdapter.get(rubyClassName);
105
- Script rubyScript = new Script(scriptName);
106
- if (rubyScript.exists()) {
107
- String script = rubyScript.getContents();
108
- if (script.matches("(?s).*class " + rubyClassName + ".*")) {
109
- if (!rubyClassName.equals(getClass().getSimpleName())) {
110
- System.out.println("Script defines methods on meta class");
111
- // FIXME(uwe): Simplify when we stop support for RubotoCore 0.4.7
112
- if (JRubyAdapter.isJRubyPreOneSeven() || JRubyAdapter.isRubyOneEight()) {
113
- JRubyAdapter.put("$java_instance", this);
114
- JRubyAdapter.put(rubyClassName, JRubyAdapter.runScriptlet("class << $java_instance; self; end"));
115
- } else if (JRubyAdapter.isJRubyOneSeven() && JRubyAdapter.isRubyOneNine()) {
116
- JRubyAdapter.runScriptlet("Java::" + getClass().getName() + ".__persistent__ = true");
117
- JRubyAdapter.put(rubyClassName, JRubyAdapter.runRubyMethod(this, "singleton_class"));
118
- } else {
119
- throw new RuntimeException("Unknown JRuby/Ruby version: " + JRubyAdapter.get("JRUBY_VERSION") + "/" + JRubyAdapter.get("RUBY_VERSION"));
120
- }
121
- }
122
- }
123
- if (rubyClass == null) {
124
- System.out.println("Loading script: " + scriptName);
125
- if (script.matches("(?s).*class " + rubyClassName + ".*")) {
126
- System.out.println("Script contains class definition");
127
- if (rubyClassName.equals(getClass().getSimpleName())) {
128
- System.out.println("Script has separate Java class");
129
- // FIXME(uwe): Simplify when we stop support for JRuby < 1.7.0
130
- if (!JRubyAdapter.isJRubyPreOneSeven()) {
131
- JRubyAdapter.runScriptlet("Java::" + getClass().getName() + ".__persistent__ = true");
132
- }
133
- JRubyAdapter.put(rubyClassName, JRubyAdapter.runScriptlet("Java::" + getClass().getName()));
134
- }
135
- System.out.println("Set class: " + JRubyAdapter.get(rubyClassName));
136
- }
137
- JRubyAdapter.setScriptFilename(scriptName);
138
- JRubyAdapter.runScriptlet(script);
139
- rubyClass = JRubyAdapter.get(rubyClassName);
140
- }
141
- rubyInstance = this;
142
- } else if (rubyClass != null) {
143
- // We have a predefined Ruby class without corresponding Ruby source file.
144
- System.out.println("Create separate Ruby instance for class: " + rubyClass);
145
- rubyInstance = JRubyAdapter.runRubyMethod(rubyClass, "new");
146
- JRubyAdapter.runRubyMethod(rubyInstance, "instance_variable_set", "@ruboto_java_instance", this);
147
- } else {
148
- // Neither script file nor predefined class
149
- throw new RuntimeException("Either script or predefined class must be present.");
150
- }
151
- if (rubyClass != null) {
152
- System.out.println("Call on_create on: " + rubyInstance + ", " + JRubyAdapter.get("JRUBY_VERSION"));
153
- // FIXME(uwe): Simplify when we stop support for RubotoCore 0.4.7
154
- if (JRubyAdapter.isJRubyPreOneSeven()) {
155
- JRubyAdapter.put("$ruby_instance", rubyInstance);
156
- JRubyAdapter.runScriptlet("$ruby_instance.on_create($bundle)");
157
- } else if (JRubyAdapter.isJRubyOneSeven()) {
158
- JRubyAdapter.runRubyMethod(rubyInstance, "on_create", args[0]);
159
- } else {
160
- throw new RuntimeException("Unknown JRuby version: " + JRubyAdapter.get("JRUBY_VERSION"));
161
- }
162
- }
163
- } else if (configBundle != null) {
164
- // FIXME(uwe): Simplify when we stop support for RubotoCore 0.4.7
165
- if (JRubyAdapter.isJRubyPreOneSeven()) {
166
- JRubyAdapter.runScriptlet("$activity.initialize_ruboto");
167
- JRubyAdapter.runScriptlet("$activity.on_create($bundle)");
168
- } else if (JRubyAdapter.isJRubyOneSeven()) {
169
- JRubyAdapter.runRubyMethod(this, "initialize_ruboto");
170
- JRubyAdapter.runRubyMethod(this, "on_create", args[0]);
171
- } else {
172
- throw new RuntimeException("Unknown JRuby version: " + JRubyAdapter.get("JRUBY_VERSION"));
173
- }
174
- }
175
- } catch(IOException e){
176
- e.printStackTrace();
177
- ProgressDialog.show(this, "Script failed", "Something bad happened", true, true);
178
- }
179
- }
180
-
181
91
  public boolean rubotoAttachable() {
182
92
  return true;
183
93
  }
@@ -2,19 +2,18 @@ package THE_PACKAGE;
2
2
 
3
3
  import java.io.IOException;
4
4
 
5
+ import org.ruboto.ScriptLoader;
6
+
5
7
  public class THE_RUBOTO_CLASS THE_ACTION THE_ANDROID_CLASS {
6
- private String rubyClassName;
7
- private String scriptName;
8
- private Object rubyInstance;
9
- private Object[] callbackProcs = new Object[CONSTANTS_COUNT];
8
+ private final ScriptInfo scriptInfo = new ScriptInfo(CONSTANTS_COUNT);
10
9
 
11
10
  public void setCallbackProc(int id, Object obj) {
12
11
  // Error: no callbacks
13
12
  throw new RuntimeException("RubotoBroadcastReceiver does not accept callbacks");
14
13
  }
15
14
 
16
- public void setScriptName(String name){
17
- scriptName = name;
15
+ public ScriptInfo getScriptInfo() {
16
+ return scriptInfo;
18
17
  }
19
18
 
20
19
  public THE_RUBOTO_CLASS() {
@@ -25,69 +24,24 @@ public class THE_RUBOTO_CLASS THE_ACTION THE_ANDROID_CLASS {
25
24
  super();
26
25
 
27
26
  if (name != null) {
28
- setScriptName(name);
27
+ scriptInfo.setScriptName(name);
29
28
 
30
29
  if (JRubyAdapter.isInitialized()) {
31
- loadScript();
32
- }
33
- }
34
- }
35
-
36
- protected void loadScript() {
37
- rubyInstance = this;
30
+ // TODO(uwe): Only needed for non-class-based definitions
31
+ // Can be removed if we stop supporting non-class-based definitions
32
+ JRubyAdapter.put("$broadcast_receiver", this);
33
+ // TODO end
38
34
 
39
- // TODO(uwe): Only needed for non-class-based definitions
40
- // Can be removed if we stop supporting non-class-based definitions
41
- JRubyAdapter.put("$broadcast_receiver", this);
42
- // TODO end
43
-
44
- try {
45
- if (scriptName != null) {
46
- String rubyClassName = Script.toCamelCase(scriptName);
47
- System.out.println("Looking for Ruby class: " + rubyClassName);
48
- Object rubyClass = null;
49
- String script = new Script(scriptName).getContents();
50
- if (script.matches("(?s).*class " + rubyClassName + ".*")) {
51
- if (!rubyClassName.equals(getClass().getSimpleName())) {
52
- System.out.println("Script defines methods on meta class");
53
- // FIXME(uwe): Simplify when we stop support for RubotoCore 0.4.7
54
- if (JRubyAdapter.isJRubyPreOneSeven() || JRubyAdapter.isRubyOneEight()) {
55
- JRubyAdapter.put("$java_instance", this);
56
- JRubyAdapter.put(rubyClassName, JRubyAdapter.runScriptlet("class << $java_instance; self; end"));
57
- } else if (JRubyAdapter.isJRubyOneSeven() && JRubyAdapter.isRubyOneNine()) {
58
- JRubyAdapter.put(rubyClassName, JRubyAdapter.runRubyMethod(this, "singleton_class"));
59
- } else {
60
- throw new RuntimeException("Unknown JRuby/Ruby version: " + JRubyAdapter.get("JRUBY_VERSION") + "/" + JRubyAdapter.get("RUBY_VERSION"));
61
- }
62
- }
63
- } else {
64
- rubyClass = JRubyAdapter.get(rubyClassName);
65
- }
66
- if (rubyClass == null) {
67
- System.out.println("Loading script: " + scriptName);
68
- if (script.matches("(?s).*class " + rubyClassName + ".*")) {
69
- System.out.println("Script contains class definition");
70
- if (rubyClassName.equals(getClass().getSimpleName())) {
71
- System.out.println("Script has separate Java class");
72
-
73
- // TODO(uwe): Why doesnt this work?
74
- // JRubyAdapter.put(rubyClassName, JRubyAdapter.runScriptlet("Java::" + getClass().getName()));
75
-
76
- // TODO(uwe): Workaround...
77
- JRubyAdapter.runScriptlet(rubyClassName + " = Java::" + getClass().getName());
78
- }
79
- // System.out.println("Set class: " + JRubyAdapter.get(rubyClassName));
80
- }
81
- JRubyAdapter.setScriptFilename(scriptName);
82
- JRubyAdapter.runScriptlet(script);
83
- rubyClass = JRubyAdapter.get(rubyClassName);
84
- }
35
+ ScriptLoader.loadScript(this);
85
36
  }
86
- } catch(IOException e) {
87
- throw new RuntimeException("IOException loading broadcast receiver script", e);
88
37
  }
89
38
  }
90
39
 
40
+ // FIXME(uwe): Only used for block based primary activities. Remove if we remove support for such.
41
+ public void onCreateSuper() {
42
+ // Do nothing
43
+ }
44
+
91
45
  public void onReceive(android.content.Context context, android.content.Intent intent) {
92
46
  try {
93
47
  Log.d("onReceive: " + this);