Skip to content
This repository

Here is the place to hacking the source code.

ruboto gen command

when using 'ruboto gen' it goes to gem dir/bin/ruboto.rb!

require 'ruboto/commands/base'

but where is commands dir??? A: lib/ruboto/commands/base ....

base -> require 'ruboto' -> goes to the base dir/ruboto.....Here the code is bad...

let's sumarize: bin/ruboto.rb -> lib/ruboto/commands/base.rb -> lib/ruboto.rb

In lib/ruboto.rb

require 'main'
require 'fileutils'
require 'rexml/document'
require 'jruby-jars'

require 'ruboto/util/main_fix'

module Ruboto
  GEM_ROOT = File.dirname(File.dirname(__FILE__))
  ASSETS = File.join(GEM_ROOT, "assets")
end

what is main??? what is jruby-jars!!!?? wtf!!!! .....Thay are ruboto required gems: found in the gem file:

  s.add_dependency('main', '~>4.4.0')
  s.add_dependency('jruby-jars', '> 1.5.0')

main: a class factory and dsl for generating command line programs real quick processing cmd-line, very good tool!!!! jruby-jars: I don't know what is this gem to do...

then i stopped here:

        Main {
          mode "gen" do

Don't know Main { usage..

When you use ruboto app gen xxx it will make a file using the asset dir.

                Dir.chdir root do
                  update_test true
                  update_assets true
                  update_classes true
                  update_jruby true
                  update_ruboto true
                  update_manifest min_sdk[/\d+/], target[/\d+/], true
                  update_core_classes true

                  log_action("Generating the default Activity and script") do
                    generate_inheriting_file "Activity", activity, package, "#{underscore(activity)}.rb", path
                  end

update means copy..... why not change the name

objectspace.rb

module Ruboto
  # Enable ObjectSpace if running in JRuby, for the "main" lib
  def self.enable_objectspace
    **require 'jruby'**
    JRuby.objectspace = true
  rescue LoadError
  end
end

require 'jruby'??

jruby-1.6.1 :005 > JRuby.methods - Object.methods => ["classloader_resources", "parse", "reference", "objectspace", "dereference", "gc", "ast_for", "compile", "with_current_runtime_as_global", "objectspace=", "runtime", "initialize_copy"]

after you require 'jruby', you get JRuby class.

sample_activity.rb

assets/scripts/ruboto.rb

if $activity
  java_import "org.ruboto.RubotoActivity"
  setup_activity
  ruboto_configure_activity(RubotoActivity)
  ruboto_setup(RubotoActivity)
  setup_view
end

java_import "org.ruboto.RubotoActivity" Usage of java_import, please visit java_import

$activity

let us see how $activity gened: it is in RubotoActivity.java:

  private void backgroundCreate() {
    getRuby();
    Script.defineGlobalVariable("$activity", this);
    Script.defineGlobalVariable("$bundle", args[0]);
  }

rake commmand

let us see how 'rake' command works:

ant_import if ant_loaded

check rake-and-ant-together ant_import src

generated_libs     = 'generated_libs'
jars = Dir['libs/*.jar']
stdlib             = jars.grep(/stdlib/).first #libs/jruby-stdlib-VERSION.jar
jruby_jar          = jars.grep(/core/).first   #libs/jruby-core-VERSION.jar
stdlib_precompiled = File.join(generated_libs, 'jruby-stdlib-precompiled.jar')
jruby_ruboto_jar   = File.join(generated_libs, 'jruby-ruboto.jar')
ant.property :name=>'external.libs.dir', :value => generated_libs if ant_loaded
dirs = ['tmp/ruby', 'tmp/precompiled', generated_libs]
dirs.each { |d| directory d }

directory is a method ???

task :generate_libs => [generated_libs, jruby_ruboto_jar] do
  cp stdlib, generated_libs
end

Q: where is the generated_libs task?? A: ...

Base on 0.3.3

desc 'build debug package'
task :debug => APK_FILE


file APK_FILE => [MANIFEST_FILE, RUBOTO_CONFIG_FILE, BUNDLE_JAR] + JRUBY_JARS + JAVA_SOURCE_FILES + RESOURCE_FILES do |t|
  if File.exist?(APK_FILE)
    changed_prereqs = t.prerequisites.select do |p|
      File.exist?(p) && !Dir[p].empty? && Dir[p].map{|f| File.mtime(f)}.max > File.mtime(APK_FILE)
    end

    if changed_prereqs.empty?
      puts
      puts 'skipping'
      puts
      next
    end
    changed_prereqs.each{|f| puts "#{f} changed."}
    puts "Forcing rebuild of #{APK_FILE}."
  end
  sh 'ant debug'
end

when you type rake, it will run ant debug in shell.

Something went wrong with that request. Please try again.