Module: Ruboto::Util::Update
- Defined in:
- lib/ruboto/util/update.rb
Instance Method Summary collapse
-
#reconfigure_jruby_libs ⇒ Object
reconfigure_jruby_libs: - removes unneeded code from jruby-core - moves ruby stdlib to the root of the ruby-stdlib jar.
-
#update_jruby(force = nil) ⇒ Object
Updating components.
- #update_ruboto(force = nil) ⇒ Object
Instance Method Details
#reconfigure_jruby_libs ⇒ Object
reconfigure_jruby_libs:
- removes unneeded code from jruby-core
- moves ruby stdlib to the root of the ruby-stdlib jar
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/ruboto/util/update.rb', line 65 def reconfigure_jruby_libs jruby_core = JRubyJars::core_jar_path.split('/')[-1] log_action("Removing unneeded classes from #{jruby_core}") do Dir.mkdir "libs/tmp" Dir.chdir "libs/tmp" FileUtils.move "../#{jruby_core}", "." `jar -xf #{jruby_core}` File.delete jruby_core ['cext', 'jni', 'org/jruby/ant', 'org/jruby/compiler/ir', 'org/jruby/demo', 'org/jruby/embed/bsf', 'org/jruby/embed/jsr223', 'org/jruby/ext/ffi','org/jruby/javasupport/bsf' ].each {|i| FileUtils.remove_dir i, true} `jar -cf ../#{jruby_core} .` Dir.chdir "../.." FileUtils.remove_dir "libs/tmp", true end jruby_stdlib = JRubyJars::stdlib_jar_path.split('/')[-1] log_action("Reformatting #{jruby_stdlib}") do Dir.mkdir "libs/tmp" Dir.chdir "libs/tmp" FileUtils.move "../#{jruby_stdlib}", "." `jar -xf #{jruby_stdlib}` File.delete jruby_stdlib FileUtils.move "META-INF/jruby.home/lib/ruby/1.8", ".." Dir["META-INF/jruby.home/lib/ruby/site_ruby/1.8/*"].each do |f| next if File.basename(f) =~ /^..?$/ FileUtils.move f, "../1.8/" + File.basename(f) end Dir.chdir "../1.8" FileUtils.remove_dir "../tmp", true `jar -cf ../#{jruby_stdlib} .` Dir.chdir "../.." FileUtils.remove_dir "libs/1.8", true end end |
#update_jruby(force = nil) ⇒ Object
Updating components
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/ruboto/util/update.rb', line 9 def update_jruby(force=nil) jruby_core = Dir.glob("libs/jruby-core-*.jar")[0] jruby_stdlib = Dir.glob("libs/jruby-stdlib-*.jar")[0] new_jruby_version = JRubyJars::core_jar_path.split('/')[-1][11..-5] unless force abort "cannot find existing jruby jars in libs. Make sure you're in the root directory of your app" if (not jruby_core or not jruby_stdlib) current_jruby_version = jruby_core ? jruby_core[16..-5] : "None" abort "both jruby versions are #{new_jruby_version}. Nothing to update. Make sure you 'gem update jruby-jars' if there is a new version" if current_jruby_version == new_jruby_version puts "Current jruby version: #{current_jruby_version}" puts "New jruby version: #{new_jruby_version}" end copier = AssetCopier.new Ruboto::ASSETS, File.(".") log_action("Removing #{jruby_core}") {File.delete jruby_core} if jruby_core log_action("Removing #{jruby_stdlib}") {File.delete jruby_stdlib} if jruby_stdlib log_action("Copying #{JRubyJars::core_jar_path} to libs") {copier.copy_from_absolute_path JRubyJars::core_jar_path, "libs"} log_action("Copying #{JRubyJars::stdlib_jar_path} to libs") {copier.copy_from_absolute_path JRubyJars::stdlib_jar_path, "libs"} reconfigure_jruby_libs puts "JRuby version is now: #{new_jruby_version}" end |
#update_ruboto(force = nil) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/ruboto/util/update.rb', line 37 def update_ruboto(force=nil) verify_manifest from = File.(Ruboto::GEM_ROOT + "/assets/assets/scripts/ruboto.rb") to = File.("./assets/scripts/ruboto.rb") from_text = File.read(from) to_text = File.read(to) if File.exists?(to) unless force puts "New version: #{from_text[/\$RUBOTO_VERSION = (\d+)/, 1]}" puts "Old version: #{to_text ? to_text[/\$RUBOTO_VERSION = (\d+)/, 1] : 'none'}" abort "The ruboto.rb verion has not changed. Use --force to force update." if from_text[/\$RUBOTO_VERSION = (\d+)/, 1] == to_text[/\$RUBOTO_VERSION = (\d+)/, 1] end log_action("Copying ruboto.rb and setting the package name") do File.open(to, 'w') {|f| f << from_text.gsub("THE_PACKAGE", verify_package).gsub("ACTIVITY_NAME", verify_activity)} end end |