Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

* Bumped version to 0.9.0 for development.

* Included dx.jar to try Java subclassing.
* Set system property jruby.class.cache.path to enable JRuby proxy class generation on Dalvik.
* Added test for subclassing.
* Added Rake task to fetch download stats.
  • Loading branch information...
commit 994e6daf6bbad4c314909cf2dbe40905c9a47b0c 1 parent 50c0e2b
@donv donv authored
View
74 Rakefile
@@ -142,6 +142,80 @@ task :release_docs do
puts "* https://github.com/ruboto/ruboto/issues?state=closed&milestone=#{milestone}\n\n"
end
+desc 'Fetch download stats form rubygems.org'
+task :stats do
+ require 'rubygems'
+ require 'uri'
+ require 'net/http'
+ require 'net/https'
+ require 'openssl'
+ require 'yaml'
+ host = 'rubygems.org'
+ base_uri = "https://#{host}/api/v1"
+ https = Net::HTTP.new(host, 443)
+ https.use_ssl = true
+ https.verify_mode = OpenSSL::SSL::VERIFY_NONE
+
+ counts_per_month = Hash.new{|h, k| h[k] = Hash.new{|mh,mk| mh[mk] = 0 }}
+ total = 0
+
+ %w{ruboto-core ruboto}.each do |gem|
+ versions_uri = URI("#{base_uri}/versions/#{gem}.yaml")
+ req = Net::HTTP::Get.new(versions_uri.request_uri)
+ res = https.start { |http| http.request(req) }
+ versions = YAML.load(res.body).sort_by { |v| Gem::Version.new(v['number']) }
+ puts "\n#{gem}:\n#{versions.map { |v| "#{'%10s' % v['number']} #{v['downloads_count']}" }.join("\n")}"
+
+ versions.each do |v|
+ downloads_uri = URI("#{base_uri}/versions/#{gem}-#{v['number']}/downloads/search.yaml?from=2010-08-01&to=#{Date.today}")
+ req = Net::HTTP::Get.new(downloads_uri.request_uri)
+ res = https.start { |http| http.request(req) }
+ counts = YAML.load(res.body)
+ counts.each do |date_str, count|
+ date = Date.parse(date_str)
+ counts_per_month[date.year][date.month] += count
+ total += count
+ end
+ print '.' ; STDOUT.flush
+ end
+ puts
+ end
+
+ puts "\nDownloads statistics per month:"
+ years = counts_per_month.keys
+ puts "\n #{years.map{|year| '%6s:' % year}.join(' ')}"
+ (1..12).each do |month|
+ print "#{'%2d' % month}:"
+ years.each do |year|
+ count = counts_per_month[year][month]
+ print count > 0 ? '%8d' % count : ' ' * 8
+ end
+ puts
+ end
+
+ puts "\nTotal: #{total}\n\n"
+
+ puts "\nRubyGems download statistics per month:"
+ years = counts_per_month.keys
+ puts ' ' + years.map{|year| '%-12s' % year}.join
+ (0..20).each do |l|
+ print (l % 10 == 0) ? '%4d' % ((20-l) * 100) : ' '
+ years.each do |year|
+ (1..12).each do |month|
+ count = counts_per_month[year][month]
+ if [year, month] == [Date.today.year, Date.today.month]
+ count *= (Date.new(Date.today.year, Date.today.month, -1).day.to_f / Date.today.day).to_i
+ end
+ print count > ((20-l) * 100) ? '*' : ' '
+ end
+ end
+ puts
+ end
+ puts ' ' + years.map{|year| '%-12s' % year}.join
+
+ puts "\nTotal: #{total}\n\n"
+end
+
desc "Push the gem to RubyGems"
task :release => [:clean, :gem] do
output = `git status --porcelain`
View
BIN  assets/libs/dx.jar
Binary file not shown
View
3  assets/src/org/ruboto/JRubyAdapter.java
@@ -253,6 +253,9 @@ public static synchronized boolean setUpJRuby(Context appContext, PrintStream ou
// System.setProperty("jruby.debug.loadService", "true");
// System.setProperty("jruby.debug.loadService.timing", "true");
+ // Used to enable JRuby to generate proxy classes
+ System.setProperty("jruby.class.cache.path", appContext.getDir("dex", 0).getAbsolutePath());
+
ClassLoader classLoader;
Class<?> scriptingContainerClass;
String apkName = null;
View
3  lib/ruboto/util/update.rb
@@ -400,7 +400,8 @@ def reconfigure_jruby_core(jruby_core_version)
if jruby_core_version >= '1.7.0'
excluded_core_packages = [
'META-INF', 'cext',
- 'com/headius',
+ # 'com/headius', included since we are trying to use DexClient
+ 'com/headius/invokebinder',
'com/kenai/constantine', 'com/kenai/jffi', 'com/martiansoftware', 'ext', 'java',
'jline', 'jni',
'jnr/constants/platform/darwin', 'jnr/constants/platform/fake', 'jnr/constants/platform/freebsd',
View
2  lib/ruboto/version.rb
@@ -1,4 +1,4 @@
module Ruboto
- VERSION = '0.8.1'
+ VERSION = '0.9.0.dev'
UPDATE_VERSION_LIMIT = '0.5.2'
end
View
34 test/activity/subclass_activity.rb
@@ -0,0 +1,34 @@
+require 'ruboto/activity'
+require 'ruboto/widget'
+require 'ruboto/generate'
+
+ruboto_import_widgets :LinearLayout, :ListView, :TextView
+
+class SubclassOfArrayAdapter < Java::AndroidWidget::ArrayAdapter
+ def get_view(position, convert_view, parent)
+ puts "IN get_view!!!"
+ @inflater ||= context.getSystemService(Context::LAYOUT_INFLATER_SERVICE)
+ row = convert_view ? convert_view : @inflater.inflate(mResource, nil)
+ row.findViewById(mFieldId).text = get_item(position)
+ row
+ rescue Exception
+ puts "Exception getting list item view: #$!"
+ puts $!.backtrace.join("\n")
+ convert_view
+ end
+end
+
+class SubclassActivity
+ def on_create(bundle)
+ super
+ setTitle File.basename(__FILE__).chomp('_activity.rb').split('_').map { |s| "#{s[0..0].upcase}#{s[1..-1]}" }.join(' ')
+
+ adapter = SubclassOfArrayAdapter.new(self, android.R.layout.simple_list_item_1 , AndroidIds::text1, ['Record one', 'Record two'])
+
+ self.content_view =
+ linear_layout :orientation => LinearLayout::VERTICAL do
+ @text_view_margins = text_view :text => 'What hath Matz wrought?', :id => 42
+ @list_view = list_view :adapter => adapter, :id => 43
+ end
+ end
+end
View
17 test/activity/subclass_activity_test.rb
@@ -0,0 +1,17 @@
+activity Java::org.ruboto.test_app.SubclassActivity
+
+setup do |activity|
+ start = Time.now
+ loop do
+ @text_view = activity.findViewById(42)
+ @list_view = activity.findViewById(43)
+ break if (@text_view && @list_view) || (Time.now - start > 60)
+ sleep 1
+ end
+ assert @text_view
+ assert @list_view
+end
+
+test("activity starts") do |activity|
+ assert true
+end
View
3  test/test_helper.rb
@@ -1,4 +1,5 @@
-$:.unshift('lib') unless $:.include?('lib')
+lib = File.dirname(File.dirname(__FILE__)) + '/lib'
+$:.unshift(lib) unless $:.include?(lib)
require 'test/unit'
require 'rubygems'
require 'fileutils'
Please sign in to comment.
Something went wrong with that request. Please try again.