ruboto-core 0.4.0 → 0.4.1.rc.4

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.
data/Gemfile.lock CHANGED
@@ -4,7 +4,7 @@ GEM
4
4
  arrayfields (4.7.4)
5
5
  chronic (0.6.2)
6
6
  fattr (2.2.0)
7
- jruby-jars (1.6.3)
7
+ jruby-jars (1.6.4)
8
8
  main (4.7.3)
9
9
  arrayfields (~> 4.7.4)
10
10
  chronic (~> 0.6.2)
data/Rakefile CHANGED
@@ -1,9 +1,12 @@
1
1
  require 'rexml/document'
2
+ require 'lib/ruboto/version'
2
3
 
3
4
  PLATFORM_PROJECT = File.expand_path('tmp/RubotoCore', File.dirname(__FILE__))
4
5
  PLATFORM_DEBUG_APK = "#{PLATFORM_PROJECT}/bin/RubotoCore-debug.apk"
5
6
  PLATFORM_RELEASE_APK = "#{PLATFORM_PROJECT}/bin/RubotoCore-release.apk"
6
7
  MANIFEST_FILE = "AndroidManifest.xml"
8
+ GEM_FILE = "ruboto-core-#{Ruboto::VERSION}.gem"
9
+ GEM_SPEC_FILE = 'ruboto-core.gemspec'
7
10
 
8
11
  # FIXME(uwe): Remove when we stop supporting JRuby 1.5.6
9
12
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.8.0')
@@ -20,12 +23,18 @@ ON_JRUBY_JARS_1_5_6 = JRUBY_JARS_VERSION == Gem::Version.new('1.5.6')
20
23
  task :default => :gem
21
24
 
22
25
  desc "Generate a gem"
23
- task :gem do
24
- `gem build ruboto-core.gemspec`
26
+ task :gem => GEM_FILE
27
+
28
+ file GEM_FILE => GEM_SPEC_FILE do
29
+ puts "Generating #{GEM_FILE}"
30
+ `gem build #{GEM_SPEC_FILE}`
25
31
  end
26
32
 
27
33
  desc "Push the gem to RubyGems"
28
- task :release do
34
+ task :release => :gem do
35
+ output = `git status --porcelain`
36
+ raise "Workspace not clean!\n#{output}" unless output.empty?
37
+ sh "git tag #{Ruboto::VERSION}"
29
38
  sh "gem push #{Dir['ruboto-core-*.gem'][-1]}"
30
39
  end
31
40
 
@@ -50,12 +59,13 @@ namespace :platform do
50
59
  sh "ruby -rubygems -I#{File.expand_path('lib', File.dirname(__FILE__))} bin/ruboto gen app --package org.ruboto.core --name RubotoCore --with-jruby #{'--with-psych' unless ON_JRUBY_JARS_1_5_6} --path #{PLATFORM_PROJECT}"
51
60
  Dir.chdir(PLATFORM_PROJECT) do
52
61
  manifest = REXML::Document.new(File.read(MANIFEST_FILE))
53
- manifest.root.attributes['android:versionCode'] = '2'
54
- manifest.root.attributes['android:versionName'] = '0.4.1'
62
+ manifest.root.attributes['android:versionCode'] = '405'
63
+ manifest.root.attributes['android:versionName'] = '0.4.5'
55
64
  manifest.root.attributes['android:installLocation'] = 'auto' # or 'preferExternal' ?
56
65
  manifest.root.elements['uses-sdk'].attributes['android:targetSdkVersion'] = '8'
57
66
  File.open(MANIFEST_FILE, 'w') { |f| manifest.document.write(f, 4) }
58
67
  File.open('default.properties', 'w'){|f| f << "target=android-8\n"}
68
+ File.open('Gemfile.apk', 'w'){|f| f << "source :rubygems\n\ngem 'activerecord-jdbc-adapter'\n"}
59
69
  keystore_file = File.expand_path('~/android_market.keystore')
60
70
  if File.exists?(keystore_file)
61
71
  File.open('local.properties', 'a'){|f| f << "key.store=#{keystore_file}\nkey.alias=android_market\n"}
data/assets/Rakefile CHANGED
@@ -9,6 +9,7 @@ def app_files_path() @app_files_path ||= "/data/data/#{package}/files" end
9
9
  require 'rake/clean'
10
10
  require 'rexml/document'
11
11
 
12
+ PROJECT_DIR = Dir.getwd
12
13
  UPDATE_MARKER_FILE = File.expand_path(File.join('tmp', 'LAST_UPDATE'), File.dirname(__FILE__))
13
14
  BUNDLE_JAR = File.expand_path 'libs/bundle.jar'
14
15
  BUNDLE_PATH = File.expand_path 'tmp/bundle'
@@ -16,12 +17,14 @@ MANIFEST_FILE = File.expand_path 'AndroidManifest.xml'
16
17
  RUBOTO_CONFIG_FILE = File.expand_path 'ruboto.yml'
17
18
  GEM_FILE = File.expand_path('Gemfile.apk')
18
19
  GEM_LOCK_FILE = File.expand_path('Gemfile.apk.lock')
20
+ RELEASE_APK_FILE = File.expand_path "bin/#{build_project_name}-release.apk"
19
21
  APK_FILE = File.expand_path "bin/#{build_project_name}-debug.apk"
20
22
  TEST_APK_FILE = File.expand_path "test/bin/#{build_project_name}Test-debug.apk"
21
23
  JRUBY_JARS = Dir[File.expand_path 'libs/jruby-*.jar']
22
24
  RESOURCE_FILES = Dir[File.expand_path 'res/**/*']
23
25
  JAVA_SOURCE_FILES = Dir[File.expand_path 'src/**/*.java']
24
26
  RUBY_SOURCE_FILES = Dir[File.expand_path 'src/**/*.rb']
27
+ APK_DEPENDENCIES = [MANIFEST_FILE, RUBOTO_CONFIG_FILE, BUNDLE_JAR] + JRUBY_JARS + JAVA_SOURCE_FILES + RESOURCE_FILES + RUBY_SOURCE_FILES
25
28
 
26
29
  CLEAN.include('tmp', 'bin')
27
30
 
@@ -50,7 +53,7 @@ task :debug => APK_FILE
50
53
  namespace :debug do
51
54
  desc 'build debug package if compiled files have changed'
52
55
  task :quick => [MANIFEST_FILE, RUBOTO_CONFIG_FILE, BUNDLE_JAR] + JRUBY_JARS + JAVA_SOURCE_FILES + RESOURCE_FILES do |t|
53
- build_apk(t)
56
+ build_apk(t, false)
54
57
  end
55
58
  end
56
59
 
@@ -69,8 +72,10 @@ namespace :install do
69
72
  end
70
73
  end
71
74
 
72
- task :release do
73
- sh 'ant release'
75
+ task :release => RELEASE_APK_FILE
76
+
77
+ file RELEASE_APK_FILE => APK_DEPENDENCIES do |t|
78
+ build_apk(t, true)
74
79
  end
75
80
 
76
81
  task :tag => :release do
@@ -102,11 +107,11 @@ task :emulator do
102
107
  end
103
108
 
104
109
  task :start do
105
- `adb shell am start -a android.intent.action.MAIN -n #{package}/.#{main_activity}`
110
+ start_app
106
111
  end
107
112
 
108
113
  task :stop do
109
- `adb shell ps | grep #{package} | awk '{print $2}' | xargs adb shell kill`
114
+ raise "Unable to stop app. Only available on emulator." unless stop_app
110
115
  end
111
116
 
112
117
  desc 'Restart the application'
@@ -119,31 +124,26 @@ end
119
124
  file MANIFEST_FILE
120
125
  file RUBOTO_CONFIG_FILE
121
126
 
122
- file APK_FILE => [MANIFEST_FILE, RUBOTO_CONFIG_FILE, BUNDLE_JAR] + JRUBY_JARS + JAVA_SOURCE_FILES + RESOURCE_FILES + RUBY_SOURCE_FILES do |t|
123
- build_apk(t)
127
+ file APK_FILE => APK_DEPENDENCIES do |t|
128
+ build_apk(t, false)
124
129
  end
125
130
 
126
131
  desc 'Copy scripts to emulator or device'
127
132
  task :update_scripts => ['install:quick'] do
128
- `adb shell mkdir -p #{scripts_path}` if !device_path_exists?(scripts_path)
129
- puts "Pushing files to apk public file area."
130
- last_update = File.exists?(UPDATE_MARKER_FILE) ? Time.parse(File.read(UPDATE_MARKER_FILE)) : Time.parse('1970-01-01T00:00:00')
131
- # TODO(uwe): Use `adb sync src` instead?
132
- Dir.chdir('src') do
133
- Dir["**/*.rb"].each do |script_file|
134
- next if File.directory? script_file
135
- next if File.mtime(script_file) < last_update
136
- next if script_file =~ /~$/
137
- print "#{script_file}: "; $stdout.flush
138
- `adb push #{script_file} #{scripts_path}/#{script_file}`
139
- end
140
- end
141
- mark_update
133
+ update_scripts
142
134
  end
143
135
 
144
136
  namespace :update_scripts do
145
137
  desc 'Copy scripts to emulator and restart the app'
146
- task :restart => [:stop, :update_scripts, :start]
138
+ task :restart => APK_DEPENDENCIES do |t|
139
+ if stop_app
140
+ update_scripts
141
+ else
142
+ build_apk(t, false)
143
+ install_apk
144
+ end
145
+ start_app
146
+ end
147
147
  end
148
148
 
149
149
  task :test => :uninstall do
@@ -168,51 +168,49 @@ file GEM_FILE
168
168
  file GEM_LOCK_FILE
169
169
 
170
170
  desc 'Generate bundle jar from Gemfile'
171
+ task :bundle => BUNDLE_JAR
172
+
171
173
  file BUNDLE_JAR => [GEM_FILE, GEM_LOCK_FILE] do
172
174
  next unless File.exists? GEM_FILE
173
175
  puts "Generating #{BUNDLE_JAR}"
174
176
 
175
177
  FileUtils.mkdir_p BUNDLE_PATH
176
178
  sh "bundle install --gemfile #{GEM_FILE} --path=#{BUNDLE_PATH}"
179
+ gem_path = Dir["#{BUNDLE_PATH}/*ruby/1.8/gems"][0]
177
180
 
178
- # FIXME(uwe): Should not be necessary. ARJDBC should not offer the same files as AR.
181
+ if package != 'org.ruboto.core' && JRUBY_JARS.none? { |f| File.exists? f }
182
+ Dir.chdir gem_path do
183
+ Dir['activerecord-jdbc-adapter-*'].each do |g|
184
+ puts "Removing #{g} gem since it is included in the RubotoCore platform apk."
185
+ FileUtils.rm_rf g
186
+ end
187
+ end
188
+ end
179
189
 
180
- Dir.chdir "#{BUNDLE_PATH}/ruby/1.8/gems" do
190
+ # Remove duplicate files
191
+ Dir.chdir gem_path do
181
192
  scanned_files = []
193
+ source_files = RUBY_SOURCE_FILES.map{|f| f.gsub("#{PROJECT_DIR}/src/", '')}
182
194
  Dir["*/lib/**/*"].each do |f|
195
+ next if File.directory? f
183
196
  raise "Malformed file name" unless f =~ %r{^(.*?)/lib/(.*)$}
184
197
  gem_name, lib_file = $1, $2
185
- if existing_file = scanned_files.find{|sf| sf =~ %r{(.*?)/lib/#{lib_file}}}
186
- puts "Removing duplicate of file #{lib_file} in gem #{gem_name}"
198
+ if scanned_files.find{|sf| sf =~ %r{(.*?)/lib/#{lib_file}}}
199
+ puts "Removing duplicate file #{lib_file} in gem #{gem_name}"
187
200
  puts "Already present in gem #{$1}"
201
+ FileUtils.rm f
202
+ elsif source_files.include? lib_file
203
+ puts "Removing duplicate file #{lib_file} in gem #{gem_name}"
204
+ puts "Already present in project source src/#{lib_file}"
205
+ FileUtils.rm f
206
+ else
207
+ scanned_files << f
188
208
  end
189
209
  end
190
210
  end
191
211
 
192
- # FIXME(uwe): Remove when directory listing in apk subdirectories work.
193
- # FIXME(uwe): http://jira.codehaus.org/browse/JRUBY-5775
194
- Dir["#{BUNDLE_PATH}/ruby/1.8/gems/activesupport-*/lib/active_support/core_ext.rb"].each do |faulty_file|
195
- faulty_code = <<-'EOF'
196
- Dir["#{File.dirname(__FILE__)}/core_ext/*.rb"].sort.each do |path|
197
- require "active_support/core_ext/#{File.basename(path, '.rb')}"
198
- end
199
- EOF
200
- replace_faulty_code(faulty_file, faulty_code)
201
- end
202
-
203
- Dir["#{BUNDLE_PATH}/ruby/1.8/gems/activemodel-*/lib/active_model/validations.rb"].each do |faulty_file|
204
- faulty_code = <<-EOF
205
- Dir[File.dirname(__FILE__) + "/validations/*.rb"].sort.each do |path|
206
- filename = File.basename(path)
207
- require "active_model/validations/\#{filename}"
208
- end
209
- EOF
210
- replace_faulty_code(faulty_file, faulty_code)
211
- end
212
- # FIXME end
213
-
214
212
  # Expand JARs
215
- Dir.chdir "#{BUNDLE_PATH}/ruby/1.8/gems" do
213
+ Dir.chdir gem_path do
216
214
  Dir['*'].each do |gem_lib|
217
215
  Dir.chdir "#{gem_lib}/lib" do
218
216
  Dir['**/*.jar'].each do |jar|
@@ -239,12 +237,10 @@ Java::arjdbc.jdbc.AdapterJavaService.new.basicLoad(JRuby.runtime)
239
237
 
240
238
 
241
239
  FileUtils.rm_f BUNDLE_JAR
242
- Dir["#{BUNDLE_PATH}/ruby/1.8/gems/*"].each_with_index do |gem_dir, i|
240
+ Dir["#{gem_path}/*"].each_with_index do |gem_dir, i|
243
241
  `jar #{i == 0 ? 'c' : 'u'}f #{BUNDLE_JAR} -C #{gem_dir}/lib .`
244
242
  end
245
243
  FileUtils.rm_rf BUNDLE_PATH
246
-
247
- Rake::Task['install'].invoke
248
244
  end
249
245
 
250
246
  # Methods
@@ -314,7 +310,7 @@ def replace_faulty_code(faulty_file, faulty_code)
314
310
  end
315
311
  end
316
312
 
317
- def build_apk(t)
313
+ def build_apk(t, release)
318
314
  if File.exist?(APK_FILE)
319
315
  changed_prereqs = t.prerequisites.select do |p|
320
316
  File.file?(p) && !Dir[p].empty? && Dir[p].map{|f| File.mtime(f)}.max > File.mtime(APK_FILE)
@@ -323,7 +319,11 @@ def build_apk(t)
323
319
  changed_prereqs.each{|f| puts "#{f} changed."}
324
320
  puts "Forcing rebuild of #{APK_FILE}."
325
321
  end
326
- sh 'ant debug'
322
+ if release
323
+ sh 'ant release'
324
+ else
325
+ sh 'ant debug'
326
+ end
327
327
  end
328
328
 
329
329
  def install_apk
@@ -347,3 +347,29 @@ def uninstall_apk
347
347
  exit $?
348
348
  end
349
349
  end
350
+
351
+ def update_scripts
352
+ `adb shell mkdir -p #{scripts_path}` if !device_path_exists?(scripts_path)
353
+ puts "Pushing files to apk public file area."
354
+ last_update = File.exists?(UPDATE_MARKER_FILE) ? Time.parse(File.read(UPDATE_MARKER_FILE)) : Time.parse('1970-01-01T00:00:00')
355
+ # TODO(uwe): Use `adb sync src` instead?
356
+ Dir.chdir('src') do
357
+ Dir["**/*.rb"].each do |script_file|
358
+ next if File.directory? script_file
359
+ next if File.mtime(script_file) < last_update
360
+ next if script_file =~ /~$/
361
+ print "#{script_file}: "; $stdout.flush
362
+ `adb push #{script_file} #{scripts_path}/#{script_file}`
363
+ end
364
+ end
365
+ mark_update
366
+ end
367
+
368
+ def start_app
369
+ `adb shell am start -a android.intent.action.MAIN -n #{package}/.#{main_activity}`
370
+ end
371
+
372
+ def stop_app
373
+ output = `adb shell ps | grep #{package} | awk '{print $2}' | xargs adb shell kill`
374
+ return output !~ /Operation not permitted/
375
+ end
@@ -1,5 +1,6 @@
1
1
  package THE_PACKAGE;
2
2
 
3
+ import java.io.File;
3
4
  import java.io.IOException;
4
5
 
5
6
  import org.ruboto.Script;
@@ -138,6 +139,9 @@ public class InheritingActivity extends org.ruboto.RubotoActivity {
138
139
  }).start();
139
140
  }
140
141
 
142
+ private static final String RUBOTO_APK = "RubotoCore-release.apk";
143
+ private static final String RUBOTO_URL = "https://github.com/downloads/ruboto/ruboto-core/" + RUBOTO_APK;
144
+
141
145
  // Called when buton is pressed.
142
146
  public void getRubotoCore(View view) {
143
147
  try {
@@ -145,7 +149,9 @@ public class InheritingActivity extends org.ruboto.RubotoActivity {
145
149
  } catch (android.content.ActivityNotFoundException anfe) {
146
150
  try {
147
151
  TextView textView = (TextView) findViewById(Class.forName(getPackageName() + ".R$id").getField("text").getInt(null));
148
- textView.setText("Could not find the Android Market App. You will have to install Ruboto Core manually. Bummer!");
152
+ Intent intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(RUBOTO_URL));
153
+ intent.setDataAndType(Uri.fromFile(new File(getCacheDir(), RUBOTO_APK)), "application/vnd.android.package-archive");
154
+ startActivity(intent);
149
155
  } catch (Exception e) {}
150
156
  }
151
157
  }
@@ -325,7 +325,7 @@ module Ruboto
325
325
  argument("what") {
326
326
  required
327
327
  validate {|i| %w(jruby app ruboto).include?(i)}
328
- description "What do you want to update: 'jruby', 'app', or 'ruboto'"
328
+ description "What do you want to update: 'app', 'jruby', or 'ruboto'"
329
329
  }
330
330
 
331
331
  option("force") {
@@ -339,8 +339,6 @@ module Ruboto
339
339
 
340
340
  def run
341
341
  case params['what'].value
342
- when "jruby" then
343
- update_jruby(params['force'].value, params['with-psych'].value) || abort
344
342
  when "app" then
345
343
  force = params['force'].value
346
344
  update_test force
@@ -352,6 +350,9 @@ module Ruboto
352
350
  update_build_xml
353
351
  update_manifest nil, nil, force
354
352
  update_core_classes "exclude"
353
+ update_bundle
354
+ when "jruby" then
355
+ update_jruby(params['force'].value, params['with-psych'].value) || abort
355
356
  when "ruboto" then
356
357
  update_ruboto(params['force'].value) || abort
357
358
  end
@@ -139,7 +139,7 @@ EOF
139
139
  # FIXME(uwe): Remove when we stop supporting upgrades from ruboto-core 0.3.3 and older
140
140
  old_scripts_dir = 'assets/scripts'
141
141
  if File.exists? old_scripts_dir
142
- FileUtils.mv Dir["#{old_scripts_dir}/**/*"], SCRIPTS_DIR
142
+ FileUtils.mv Dir["#{old_scripts_dir}/*"], SCRIPTS_DIR
143
143
  FileUtils.rm_rf old_scripts_dir
144
144
  end
145
145
  # FIXME end
@@ -377,6 +377,13 @@ EOF
377
377
  File.open('build.xml', 'w'){|f| f << ant_script}
378
378
  end
379
379
 
380
+ def update_bundle
381
+ if File.exist?('Gemfile.apk') && File.exists?('libs/bundle.jar')
382
+ FileUtils.rm 'libs/bundle.jar'
383
+ system 'rake bundle'
384
+ end
385
+ end
386
+
380
387
  end
381
388
  end
382
389
  end
@@ -1,3 +1,3 @@
1
1
  module Ruboto
2
- VERSION = '0.4.0'
2
+ VERSION = '0.4.1.rc.4'
3
3
  end
@@ -14,7 +14,6 @@ test('stack depth') do |activity|
14
14
  os_offset = {13 => 1}[android.os.Build::VERSION::SDK_INT].to_i
15
15
  jruby_offset = {
16
16
  '1.5.6' => [-2, -5, -6, -8],
17
- '1.7.0.dev' => [ 0, 2, 5, 5],
18
17
  }[org.jruby.runtime.Constants::VERSION] || [0,0,0,0]
19
18
  version_message ="ANDROID: #{android.os.Build::VERSION::SDK_INT}, JRuby: #{org.jruby.runtime.Constants::VERSION}"
20
19
  assert_equal 44 + os_offset + jruby_offset[0], activity.find_view_by_id(42).text.to_i, version_message
@@ -11,6 +11,7 @@ module AppTestMethods
11
11
  end
12
12
 
13
13
  assert_code 'ReadSourceFile', "File.read(__FILE__)"
14
+ assert_code 'DirListsFilesInApk', 'Dir["#{File.dirname(__FILE__)}/*"].each{|f| raise "File #{f.inspect} not found" unless File.exists?(f)}'
14
15
 
15
16
  Dir[File.expand_path('activity/*_test.rb', File.dirname(__FILE__))].each do |test_src|
16
17
  snake_name = test_src.chomp('_test.rb')
metadata CHANGED
@@ -1,13 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruboto-core
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
5
- prerelease:
4
+ hash: 15424085
5
+ prerelease: 6
6
6
  segments:
7
7
  - 0
8
8
  - 4
9
- - 0
10
- version: 0.4.0
9
+ - 1
10
+ - rc
11
+ - 4
12
+ version: 0.4.1.rc.4
11
13
  platform: ruby
12
14
  authors:
13
15
  - Daniel Jackoway
@@ -18,7 +20,7 @@ autorequire:
18
20
  bindir: bin
19
21
  cert_chain: []
20
22
 
21
- date: 2011-09-19 00:00:00 Z
23
+ date: 2011-10-08 00:00:00 Z
22
24
  dependencies:
23
25
  - !ruby/object:Gem::Dependency
24
26
  name: main
@@ -138,12 +140,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
138
140
  required_rubygems_version: !ruby/object:Gem::Requirement
139
141
  none: false
140
142
  requirements:
141
- - - ">="
143
+ - - ">"
142
144
  - !ruby/object:Gem::Version
143
- hash: 3
145
+ hash: 25
144
146
  segments:
145
- - 0
146
- version: "0"
147
+ - 1
148
+ - 3
149
+ - 1
150
+ version: 1.3.1
147
151
  requirements: []
148
152
 
149
153
  rubyforge_project: ruboto-core