EzDevInfo.com

ocra

One-Click Ruby Application Builder ocra-1.2.0 Documentation

Bundling RMagick with Ocra

I'm trying to create a portable version of a Ruby script with Ocra. The script depends upon rmagick which requires ImageMagick to be installed as well.

The produced executable works on my computer but it fails on every other computer unless the end user installs ImageMagick manually. I would like to create a fully portable EXE file that runs on any Windows system and doesn't require the end user to install ImageMagick manually.

Is there a way to force Ocra to bundle the ImageMagick DLL files into the EXE as well? If not, how do you create portable Ruby scripts that require rmagick?

I'm not fluent in Ruby at all so any help would be appreciated.


Source: (StackOverflow)

Ruby Savon Gem Invalid HTTPI Adapter

I am using savon ruby gem 2.4.0 on ruby 2.0.0 to call some wsdl web service and everything runs perfectly but if fails after compiling it as an .exe with ocra 1.3.1.

Invalid HTTPI adapter: [:httpclient, :curb, :em_http, :excon, :net_http, :net_http_persistent]

What configuration is missing on the savon client ruby file since for now i am just providing the wsdl url.


Source: (StackOverflow)

Advertisements

Ruby, Tk and Ocra - very slow startup

I'd like to deploy my Ruby application as an .exe file, for windows users. The application uses Tk for the GUI part.

Since I simply couldn't manage to succeed with rubyscript2exe I opted for ocra. Ocra works fine and builds a reasonable sized .exe. HOWEVER the application takes probably 10 seconds to start up. Even though it's really a quite simple tool.

Is there any way to improve startup-times? My guess is that the main issue is uncompressing the tk-libs on every startup...


Source: (StackOverflow)

Ruby -- Get User Input outside of the Command Line using Ocra

So I have a very simple single file script:

puts "Enter the file name"
file = gets.chomp
puts "What do you want to replace it with?"
replace = gets.chomp

which then changes some files with the user-inputs. I packaged it up with Ocra, but I was hoping it would open up the command line when it was run and ask for the user inputs or something, or a pop-up window maybe. I need this to be very simple since my users won't know to go to the command line and run the .exe from there with arguments, so is there a way to to get a window to pop-up that takes in user input every time the .exe file is run? I've tried it in both .rb and .rbw formats.


Source: (StackOverflow)

Executable created with OCRA on Windows 64-bit can't run on Windows 32-bit

I have created an .EXE from a Ruby script using OCRA. When I try to run it on a different PC I get:

FATAL ERROR: Failed to create process (some path\ruby.exe): 216

I read somewhere that this might be related to the fact that my PC is running Windows 7 64-bit and the other PC is 32-bit, yet I can't find any information on how to compile the script to 32-bit.

I ran the .EXE on an other 64-bit machine without Ruby installed, and it ran perfectly so it's definitely the issue.

The question remains - How can I make OCRA create a 32-bit executable on a 64-bit machine?

Any suggestions?


Source: (StackOverflow)

Ocra does not keep the folder structure

I have my source files in lib folder. And a main script. Main script looks for classes in lib folder.

When i build the exe with something like this ocra main.rb lib/foo.rb lib/foo/bar.rb temp file contains main.rb, foo.rb and bar.rb in the src folder. There is no folder structure.

How can i prevent this?


Source: (StackOverflow)

I can't include images using orca ruby

Language: Ruby
Libraries (gems): Guso, Ocra
Brief description: I see a black screen when I package the application as .exe file and use it in a place other than project root directory (Resource loading/packaging fails)
Long description: So I was spending the last few hours trying to figure out around the internet (and here on stack overflow) how to properly include image files (.bmp .png) using ocra while working on a game with guso I tried to pass the command with every releated argument but with no success, I tried changing the image paths, puting all files in one directory, using different methods to load the files etc. but with no success everything goes normally when packaging and no error is thrown when including the files like so:
ocra --windows /src/subdir/img.png/scripts/script.rb etc. here is the code NOTE: files are in a folder hierarchy see code below:

main.rb require_relative 'scripts/gameWindow'

window = GameWindow.new
window.show
window.close

gameWindow.rb

require 'gosu'
require_relative 'player'

class GameWindow < Gosu::Window 
    def initialize
        super 640, 480
        self.caption = "Gosu Tutorial Game"

        begin
            name = "bg_01"      
            @background_image = Gosu::Image.new('resources/backgrounds/bg_01.png', :tileable => true)
        rescue
            puts "ERROR: Image \"#{name}\" loading failed, file may not exist."
        else
            puts "LOAD: Image \"#{name}\" was successfuly loaded."
        end 

        @player = Player.new
        @player.warp(320, 240)  
    end

    def update
        if Gosu::button_down? Gosu::KbLeft or Gosu::button_down? Gosu::GpLeft then
            @player.turn_left
        end     
        if Gosu::button_down? Gosu::KbRight or Gosu::button_down? Gosu::GpRight then
            @player.turn_right
        end
        if Gosu::button_down? Gosu::KbUp or Gosu::button_down? Gosu::GpButton0 then
            @player.accelerate
        end
        @player.move
    end

    def draw
        begin
            @player.draw
            @background_image.draw(0, 0, 0)
        rescue
            puts "ERROR: Image could not be drawn, file loading failed."
        end
    end

    def button_down(id)
        if id == Gosu::KbEscape
            close
        end
    end
end

player.rb

require 'gosu'

class Player
  def initialize
    begin
        name = "player"
        @image = Gosu::Image.new("resources/characters/char_01.bmp")
    rescue
        puts "ERROR: Image \"#{name}\" loading failed, file may not exist."
    else
        puts "LOAD: Image \"#{name}\" was successfuly loaded."
    end
    @x = @y = @vel_x = @vel_y = @angle = 0.0
    @score = 0
  end

  def warp(x, y)
    @x, @y = x, y
  end

  def turn_left
    @angle -= 4.5
  end

  def turn_right
    @angle += 4.5
  end

  def accelerate
    @vel_x += Gosu::offset_x(@angle, 0.5)
    @vel_y += Gosu::offset_y(@angle, 0.5)
  end

  def move
    @x += @vel_x
    @y += @vel_y
    @x %= 640
    @y %= 480

    @vel_x *= 0.95
    @vel_y *= 0.95
  end

  def draw
    @image.draw_rot(@x, @y, 1, @angle)
  end
end

Help would be really appreciated.


Source: (StackOverflow)

Is there a correct way to deploy a Ruby/Gtk3 App in Windows?

I need a small application made for windows (xp and later) desktops, with a system tray icon that stays there. I want to make it in Ruby (somehow, after i started using Ruby, i can't stay focused when i try to use something else, either .net or Java based languages seem weird and unreadable), so i tried qtbindings (4.8 Qt), JRuby and now Gtk. Gtk seems the way to do it, documentation is good, it's being developed very actively, and everything works in windows as intended (i couldn't get jruby 9000 to work, and qtbindings is a bit outdated, with no documentation at all).

The problem is this: when i use ocra to make the exe, it packages all the dependencies of my app (ruby - Gtk), creating either a zipped exe of 95MB that takes 35 seconds to boot (as it has to unzip it before starting the actual app), or a 495MB file unzipped exe (using the --no-lzma option), that still takes some time to load (24 seconds), but this size is not acceptable, we are talking about a Hello World app here of less than a KB.

Your take on this? Can i have a user download gtk and not include it in the exe? Or can i make an installer (i saw InnoSetup option in ocra github) that does the needed installations?


Source: (StackOverflow)

how to reduce amount of time to open ruby executable that contains a GUI?

I've been using ocra to convert my ruby files to a window executable, but I notice that it takes a very long time if I use ruby GUI like fxruby or green_shoes. Is there any way to reduce the amount of time it takes for the program to pop up? My current fxruby and green_shoes file is very simple, but it takes about a minute for the compiled exe file to run.

Here is my fxruby.rb file:

require 'fox16'

include Fox 

theApp = FXApp.new

theMainWindow = FXMainWindow.new(theApp, "Hello")
theButton = FXButton.new(theMainWindow, "Hello, world!")
theButton.connect(SEL_COMMAND) do |sender, selector, data|
    exit
end
theApp.create

theMainWindow.show

theApp.run

and here is my green_shoes.rb:

require 'green_shoes'

Shoes.app do
    button "OK!"
    button "Are you sure?"
end

Any strategies to get these to run faster? Or maybe another ruby GUI option that would be faster? thank you!!


Source: (StackOverflow)

How to get an ocra application to be accepted by antiviruses

Alright, so judging by the title (if you practice Ruby), you should know what Ocra is. If you don't, here's a brief explanation:

Ocra is a command added to the command prompt in order to convert ruby programs to executable. So .rb to .exe.

In order for one to convert a ruby program to executable, they would type in the command prompt:

cd <locationOfFile>
ocra rubyProgram.rb

and then ocra would run the program and when that's done, it runs some scripts which completes the program. Then afterwards the executable version of the program would be in the same directory as the original ruby version and the same name.

So recently I noticed that my antiviruses are removing the program from my computer telling me it's a bloodhound. It's getting really annoying and I'm getting tired of having to use ocra over and over again just to remake a program.

I have two antiviruses: McAffee and Symnatec; so that means double the security. What can I change so that my antiviruses ignore the program?


Source: (StackOverflow)

Unable to create an EXE file from Ruby script

I am unable to create an EXE file from Ruby script.

require 'socket'

class Server
  def initialize(ip, port)
    @server = TCPServer.open(ip, port)
    @clients = Array.new
    run
  end

  def run
    loop {
      Thread.start(@server.accept) do |client|
        @clients << client
        client.puts 'Connection established'
        listen_user_messages(client)
      end
    }.join
  end

  def listen_user_messages(client)
    loop {
      msg = client.gets.chomp
      @clients.each do |other_client|
        if other_client != client
          other_client.puts "#{msg}"
        end
      end
    }
  end
end

Server.new('localhost', 19937)

I'm trying to run the following command:

ocra server.rb

but it freezes on the message

=== Loading script to check dependencies

I've also tried to use exerb:

ruby exerb server.rb

It builds an exe file, but I am unable to use it:

server.rb:1:in `require': No such file to load -- socket (LoadError) from server.rb:1


Source: (StackOverflow)

ruby ocra wont compile scripts with business_time gem

Trying to compile a ruby script to a Windows executable using ocra. For some reason since adding business_time to the script, it refuses to compile. If I remove the require 'business_time' it will compile. So I created a script for just business_time and it works but will not compile. Struggling to see what the issue is from the ERROR message.

Thanks in advance.

require 'rubygems'
require 'business_time'

puts 1.business_day.ago.strftime("%Y%m%d") 
puts 1.business_day.ago.strftime("%m/%d/%Y")

C:/Ruby/lib/ruby/gems/1.9.1/gems/ocra-1.3.0/bin/ocra:467: Use RbConfig instead o f obsolete and deprecated Config. C:/Ruby/lib/ruby/gems/1.9.1/gems/i18n-0.6.1/lib/i18n/tests/basics.rb:8:in test' : unknown command 'a' (ArgumentError) from C:/Ruby/lib/ruby/gems/1.9.1/gems/i18n-0.6.1/lib/i18n/tests/basics.r b:8:in' from C:/Ruby/lib/ruby/gems/1.9.1/gems/i18n-0.6.1/lib/i18n/tests/basics.r b:3:in <module:Tests>' from C:/Ruby/lib/ruby/gems/1.9.1/gems/i18n-0.6.1/lib/i18n/tests/basics.r b:2:in' from C:/Ruby/lib/ruby/gems/1.9.1/gems/i18n-0.6.1/lib/i18n/tests/basics.r b:1:in <top (required)>' from C:/Ruby/lib/ruby/gems/1.9.1/gems/ocra-1.3.0/bin/ocra:467:inconst_ get' from C:/Ruby/lib/ruby/gems/1.9.1/gems/ocra-1.3.0/bin/ocra:467:in block (3 levels) in attempt_load_autoload' from C:/Ruby/lib/ruby/gems/1.9.1/gems/ocra-1.3.0/bin/ocra:464:ineach' from C:/Ruby/lib/ruby/gems/1.9.1/gems/ocra-1.3.0/bin/ocra:464:in block (2 levels) in attempt_load_autoload' from C:/Ruby/lib/ruby/gems/1.9.1/gems/ocra-1.3.0/bin/ocra:462:ineach' from C:/Ruby/lib/ruby/gems/1.9.1/gems/ocra-1.3.0/bin/ocra:462:in block in attempt_load_autoload' from C:/Ruby/lib/ruby/gems/1.9.1/gems/ocra-1.3.0/bin/ocra:456:inloop' from C:/Ruby/lib/ruby/gems/1.9.1/gems/ocra-1.3.0/bin/ocra:456:in attemp t_load_autoload' from C:/Ruby/lib/ruby/gems/1.9.1/gems/ocra-1.3.0/bin/ocra:679:inbuild_ exe' from C:/Ruby/lib/ruby/gems/1.9.1/gems/ocra-1.3.0/bin/ocra:1138:in `block in '

C:\Ruby>

Source: (StackOverflow)

Error generating INNOSetup installer with ocra and sqlite

I am trying to package a ruby + qtruby + sqlite3 application with ocra into a windows installer.

Everithing goes well, until I add the code that connects to the database.

Here is the snippet:

require 'Qt4'
require 'rubygems'
require 'active_record'

dbconfig = YAML::load(File.open('src/config/database.yml'))['development']
ActiveRecord::Base.establish_connection(
:adapter => dbconfig['adapter'],
:database => dbconfig['database']
)

class Category < ActiveRecord::Base
end

Category.find(:all)

exit if Object.const_defined?(:Ocra)
...

This code runs and ocra is able to create the single executable file, but if I try to create a setup file this is the error I get:

=== Running InnoSetup compiler ISCC                                                                                       
Error in D:\Workspaces\Ruby\TestGui\ocratemp.iss: Impossibile accedere al file. Il file Þ utilizzato da un altro processo.
Compile aborted.                                                                                                          
ERROR: InnoSetup installer creation failed: ISCC failed to run. Is the InnoSetup directory in your PATH?                  
rake aborted!                                                                                                             

The error is in Italian, sorry, but it translates to "Cannot access the file. The file is currently used by another process"

This is the command used to generate the installer:

ocra --chdir-first --no-lzma --no-autoload --innosetup testGui.iss gui.rb src/db/development.db src/config/database.yml 

If I comment away the block of code that connects to sqlite, the installer is created correctly and I can use on a test machine correctly. If I move the exit if... block before connecting to sqlite the resulting executable/installer lacks the sqlite libraries and in the target machine I can not execute it.

I think the error is related to the connection to sqlite not being closed, but perhaps I am missing something else.

Thanks


Source: (StackOverflow)

Viewing the source code of an executable made by OCRA

Quick question,

Let's say that I received a ruby executable that was generated by OCRA (one click ruby application).

Is there a way to view the ruby source code of the executable? If so, how? Thank you in advanced for any and all help; I've searched high and low but my google-fu has failed me.


Source: (StackOverflow)

gem ocra generates huge files

I created a simple ruby script

require 'gtk3'

def destroy( widget )
   Gtk.main_quit
end

Gtk.init
window = Gtk::Window.new :toplevel
window.set_title( "helloworld.rb" )
window.set_border_width( 10 )

window.signal_connect( "delete_event" ) {
   destroy(nil)
}

button = Gtk::Button.new :label => "Button"
window.add( button )
button.show
window.show
Gtk.main

This script creates a very simple GUI with a button. If I use ocra gem to create script.exe with command

ocra script.rbw

is generated a file of 70 mb, size too large for a simple window with button. What am I doing wrong? What can I do to aggirarare this obstacle? Ocra output is this (output with command "ocra script.rb" and not "ocra script.rbw", but the process is the same)

=== Loading script to check dependencies
=== Attempting to trigger autoload of Gem::ConfigFile
=== Attempting to trigger autoload of Gem::DependencyList
=== Attempting to trigger autoload of Gem::DependencyResolver
=== Attempting to trigger autoload of Gem::Installer
=== Attempting to trigger autoload of Gem::RequestSet
=== Attempting to trigger autoload of Gem::Source
=== Attempting to trigger autoload of Gem::SourceList
=== Attempting to trigger autoload of Gem::SpecFetcher
=== Attempting to trigger autoload of CGI::HtmlExtension
=== Detected gem ocra-1.3.4 (loaded, files)
===     6 files, 191218 bytes
=== Detected gem pkg-config-1.1.6 (loaded, files)
===     3 files, 29263 bytes
=== Detected gem cairo-1.14.1-x64-mingw32 (loaded, files)
===     572 files, 80204194 bytes
=== Detected gem glib2-2.2.4-x64-mingw32 (loaded, files)
===     2115 files, 104593625 bytes
=== Detected gem gobject-introspection-2.2.4-x64-mingw32 (loaded, files)
===     231 files, 13768036 bytes
=== Detected gem gio2-2.2.4-x64-mingw32 (loaded, files)
===     3 files, 49152 bytes
=== Detected gem atk-2.2.4-x64-mingw32 (loaded, files)
===     208 files, 4281497 bytes
=== Detected gem pango-2.2.4-x64-mingw32 (loaded, files)
===     465 files, 95081429 bytes
=== Detected gem gdk_pixbuf2-2.2.4-x64-mingw32 (loaded, files)
===     188 files, 5588250 bytes
=== Detected gem cairo-gobject-2.2.4-x64-mingw32 (loaded, files)
===     5 files, 95261 bytes
=== Detected gem gdk3-2.2.4-x64-mingw32 (loaded, files)
===     3841 files, 114129504 bytes
=== Detected gem gtk3-2.2.4-x64-mingw32 (loaded, files)
===     42 files, 2942499 bytes
=== Detected gem io-console-0.4.2 (loaded, files)
=== WARNING: Gem io-console-0.4.2 root folder was not found, skipping
=== Including 53 encoding support files (3576320 bytes, use --no-enc to exclude)

DL is deprecated, please use Fiddle
=== Building example.exe
=== Adding user-supplied source files
=== Adding ruby executable ruby.exe
=== Adding detected DLL C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/cairo-1.14.1-x64-
mingw32/vendor/local/bin/libcairo-2.dll
=== Adding detected DLL C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/cairo-1.14.1-x64-
......
=== Adding detected DLL C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/gdk_pixbuf2-2.2.4
-x64-mingw32/vendor/local/bin/libgdk_pixbuf-2.0-0.dll
=== Adding detected DLL C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/gdk3-2.2.4-x64-mi
ngw32/vendor/local/bin/libgdk-3-0.dll
=== Adding detected DLL C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/gdk3-2.2.4-x64-mi
ngw32/vendor/local/bin/libgtk-3-0.dll
=== Adding detected DLL C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/pango-2.2.4-x64-m
ingw32/vendor/local/lib/pango/1.8.0/modules/pango-basic-win32.dll
=== Adding detected DLL C:/Ruby21-x64/bin/LIBEAY32.dll
=== Adding detected DLL C:/Ruby21-x64/bin/SSLEAY32.dll
=== Adding library files
=== Compressing 519431948 bytes
=== Finished building example.exe (95218080 bytes)

I try the same process with a cli script.rb

puts "Hello World"

Result : 2,6 Mb only to print Hello World. What can i do?


Source: (StackOverflow)