2009-09-18

Opening an Excel file that needs updating

The syntax for this was not obvious to me but is shown here by David Mullet.  So here is a worked example for Excel and updatelinks when opening a spreadsheet.

#----------Open excel sheet that needs updating
require 'win32ole'
xl = WIN32OLE.new('Excel.Application')
xl.Visible = true
#workbook = xl.Workbooks.Open('C:\Flash.xls')
workbook = xl.Workbooks.Open( { 'FileName' => 'C:\Flash.xls', 'UpdateLinks' => 3 } )

Creating Windows Exe

Just to note that I have migrated to using OCRA for packaging Ruby.  It is a bit slow unpacking and starting compared to EXERB but is more widely supported.  I had a problem packaging Watir which was resolved with OCRA.  It works really nicely and will work with Ruby 1.9. 

I used to use rubyscript2exe but that has ossified although it had wonderful documentation.

2009-09-10

IP utilities

Just came across www.robotex.com which has a very nice DNS search and reporting system.

2009-09-03

Exerb Reference Recipes for Ruby translated from Japanese by Google and tidied by me

Exerb Project 4.20
Welcome to "Reference Recipes
Reference Recipes

Contents


    1. Overview
    2. YAML format
          1. Array
          2. Hashing
          3. Combination
    3. Recipes for file blocks
          1. General block
          2. Path blocked
          3. Resource block
          4. File blocks

1. Overview


Recipe file (.EXY) is a text file describing the various files needed to generate the executable. YAML (YAML Ain't Markup Language) format is used and the character encoding is UTF-8.

The simplest example of a recipe file is as follows:

general:
   startup: hello.rb
file:
   hello.rb:

2.YAML format simple introduction

In YAML, and indent using some symbols to represent data structures. The data structure is a broad, there are two types of arrays and hashes.
With the following example to describe the symbol more ,"#=>", Ruby in the data in both the above.

2.1. Array


Array is then written in the form below.
- Value
Described as follows by the representation of the array.
- Array
- String
- 123
# => [ "Array", "String", 123]
Ruby is treated as an object on the Array.

2.2. Hashing

The hash is then written in the form below.
Key: value
Described as follows by the representation of the hash.
Type: Hash
String: ABC
Number: 123
# => ( "Type" => "Hash", "String" => "ABC", "Number" => 123)
Ruby is treated as an object on the Hash. Therefore, the order of the keys will not be saved.

2.3. Combination


Arrays and hashes can be combined, respectively. By indentation indicates the parent-child relationship. Spaces to indent, you can use a tab character, recommends that you use two letter spaces.
Combination of cases among an array is as follows.
--
   - 1x1
   - 1x2
--
   - 2x1
   - 2x2
# => [[ "1x1", "1x2"], [ "2x1", "2x2"]]
Hash together a combination of cases is as follows.
Key1:
   Type: String
   Value: ABC
Key2:
   Type: Number
   Value: 123
# => ( "Key1" => ( "Type" => "String", "Value" => "ABC"),
      "Key2" => ( "Type" => "Number", "Value" => 123))
Combination of hash and array is as follows.
String:
   - A
   - B
   - C
Number:
   - 1
   - 2
   - 3
# => ( "String" => [ "A", "B", "C"], "Number" => [1, 2, 3])

3. Recipe File Blocks


The following recipe file blocks (hash structure) is composed. Order description of each block is optional, we recommend that you write in the following order.
    1. General block (required)
    2. Path blocked
    3. Resource block
    4. File block (required)
Please use UTF-8 encoded to include other languages such as Japanese.

Block 3.1.general (Required)


Specify the basic information about the executable file to be generated. This block is required.
general:
   startup: foo.rb
   output: bar.exe
   core: cui
   kcode: sjis
startup key when you start the executable, you first run the Ruby script file name. This key is required.
key output specifies the output file name of the executable file to be generated. If omitted, the file name is used recipes. Recipe file extension "exy" If the extension "exe" file name substitution, and otherwise ". Exe" file that uses the name appended. If the output file name is specified in the command options are given priority by the command options.
core key is used to generate the executable file that specifies the core Exerb. Defined name, specify the name or file. If the core is specified in the command options are given priority by the command options.
kcode key, Ruby script to specify the character code. corresponds to the ruby command-K option. If the character code specified in the command options are given priority by the command options. Letter codes, please specify the following one.
Means the value specified
Any none (default)
euc EUC
sjis Shift-JIS
utf8 UTF-8

Block 3.2.path


Ruby script to specify the search path for libraries and other extensions. Absolute path to relative path described in the recipe file or directory exists.
path:
   - .. \ Lib \ so
   - C: \ ruby \ lib
   - C: \ ruby

Block 3.3.resource


Specifies the information to generate the executable file resources.
This block specifies the block and icon resources icon of the executable file, which specifies the version is the version information resource blocks.

Block 3.3.1.icon


Specifies the icon resources. If this block is omitted, the default icon is used that is included in the core. Multiple sizes, you can specify the icon for the number of colors, other than to specify the icon resources Meinaikon not.
resource:
   icon:
     --
       width: 16
       height: 16
       color: 4
       file: file.ico
key width, the number of pixels in the horizontal direction of the icon (W) is specified.
key height, the number of vertical pixels of the icon (height) is specified.
key color, you specify the number of bits of color depth of icons. For example, if 16-bit color 4.
key file, specify the above three files that contain a single icon for the specified key.複数のサイズ、色数が含まれているアイコンファイルを指定することができますが、アイコンリソースとして使用されるのは、上記3つのキーで指定したアイコンのみです。

Block 3.3.2.version


Specifies the version information resource. If this block is omitted, the default will use the information contained in the version of the core.
resource:
   version:
     file_version_number: 1.2.3.4
     product_version_number: 5.6.7.8
     comments: comment
     company_name: Company
     legal_copyright: Copyright Information
     legal_trademarks: Trademark Information
     file_version: File Version (text)
     product_version: product version (string)
     product_name: Product
     file_description: description of the file
     internal_name: Internal name
     original_filename: official file
     private_build: Puraibetobirudo Information
     special_build: Supesharubirudo Information
file_version_number key, product_version_number the keys, file versions, respectively, separated by a dot-product version 4 specifies two numbers. Each figures, can be used from 0 to 65535 range.
Other key specifies the contents of each string. If you use Japanese text is a recipe file to UTF-8 encoding please.

Block 3.4.file (Required)

Specify the files that need to be included in the genereated EXE file. This block is required.

file:
   foo.so:
     file: foo / foo.so
     type: extension-library

The key name to specify a file name. This file name is called the internal file name, require reading the file is used by the method. The internal file name to be compared as a single string, including path separator character, "require" .. / foo / bar.so "" Please be careful and not interpret it correctly. The above method calls require ".. / foo / bar.so" internal file names that are searched.
key file specifies the actual file name. If the same internal file name, or you can search from the search path can be omitted.
key type specifies the type of file. If omitted, the type is determined based on the file extension.

Describes the extension type
. rb script
(Ruby script) Ruby script written text. require can be read at.
. so extension-library
(Library extensions) C library extensions written in languages such as (dynamic). require can be read at.
. dll dynamic-library
(Dynamic) dynamic link library used by the extension. If requested by the extension library is loaded automatically. Can not be loaded explicitly.
. res resource-library
(Library resources) that contains only dynamic resource. Exerb resource data can be read using a runtime module.
. dat data
(Data) binaries, images, data files and databases. Exerb can be read using a runtime module. Can not write.
Runtime module-Class Reference, please refer to.


Copyright (C) 2001-2006 All rights reserved.

Exerb Command reference for Ruby translated from Japanese by Google and tidied by me

Exerb Project 4.20

Welcome to "Command Reference

Command Reference

Contents

  1. Overview
  2. command exerb
    1. Parameters
    2. Options
  3. command mkexy
    1. Parameters
    2. Options

1. Overview

Exerb to include two single command. Exerb command to generate an executable file to generate a recipe file mkexy command.

2. Exerb command

Ruby script file, or specify a recipe file to generate an executable file.

exerb [option] (Ruby script file | files) recipe

1. Parameter

Ruby script to specify a file name or recipe. Can not specify multiple file names. The file name extension "rb" as if the Ruby script file, otherwise it is treated as a recipe file.

Ruby script file is specified, Ruby will generate an executable file that contains only the script. Ruby single software consists of a simple script that will be used to convert the executable.

Recipe file is specified, the executable file is generated according to the information contained in the recipe. Multiple Ruby script, a software library that consists of extended and used to convert the executable. File formats Recipes Reference, please refer to the recipe.

2. Options

You can specify the following options. If the same item at the specified recipe file and command options, command option will take precedence.

Options
Description

-c
-- corename
Specifies the name defined in the core. If -C option is specified at the same time,-C is the preferred option.

-C
-- corefile
Specifies the core file path.  -c option is specified at the same time,-C is the preferred option.

-o
-- outfile
Specifies the output file name.

-k
-- kcode
Specifies the character code. none, euc, sjis, utf8 Please specify one of them.

-a -a
--archive
Generates only archive. Executable file is not generated.

-v -v
-- verbose
Redundant information to display.

-e -e
-- execute
Run the executable file generated.

-i
-- config
Displays various settings.

-V
-- version
Displays version information.

-h
-- help
Displays the help message.

3. Mkexy command

Ruby is running the script automatically generates a recipe file. Please start one of the following ways.

mkexy [option] Ruby Script File Parameters

ruby-r exerb / mkexy [option] Ruby Script File Parameters

1. Parameter

"Ruby script file" in the recipe file is generated for the specified Ruby script. Ruby is running the specified script file is generated at the end of recipes.

"Parameters" in the recipe file to be created to specify the arguments passed to the Ruby script.

2. Options

Will ruby option to accept commands.

Copyright (C) 2001-2006 All rights reserved.

Creating Ruby exes using FX ruby

Just wanted to note this post for creating a single exe.  First using exerb  http://lylejohnson.name/blog/2008/12/30/building-standalone-fxruby-applications-with-exerb/  I tried withrubyscript2exe but something went wrong and I just quickly tried exerb.  This worked although the exe files are huge at 9MB.

The key part is

1) creating the recipe file .exy

ruby -r exerb/mkexy hello2.rb

2) Converting the recipe file to an .exe

exerb hello2.rb

I ran into a problem with gruff as it seemed to have too many files.  I am trying to work out a solution.

Part of the block looked like this:

RMagick.rb:
  file: c:/ruby/lib/ruby/gems/1.8/gems/rmagick-2.9.0-x86-mswin32/lib/RMagick.rb
c:/ruby/lib/ruby/gems/1.8/gems/gruff-0.3.4/lib/gruff/deprecated.rb:
c:/ruby/lib/ruby/gems/1.8/gems/gruff-0.3.4/lib/gruff/base.rb:
c:/ruby/lib/ruby/gems/1.8/gems/gruff-0.3.4/lib/gruff/area.rb:
c:/ruby/lib/ruby/gems/1.8/gems/gruff-0.3.4/lib/gruff/bar_conversion.rb:
c:/ruby/lib/ruby/gems/1.8/gems/gruff-0.3.4/lib/gruff/bar.rb:
c:/ruby/lib/ruby/gems/1.8/gems/gruff-0.3.4/lib/gruff/line.rb:
c:/ruby/lib/ruby/gems/1.8/gems/gruff-0.3.4/lib/gruff/pie.rb:
c:/ruby/lib/ruby/gems/1.8/gems/gruff-0.3.4/lib/gruff/spider.rb:
c:/ruby/lib/ruby/gems/1.8/gems/gruff-0.3.4/lib/gruff/net.rb:
c:/ruby/lib/ruby/gems/1.8/gems/gruff-0.3.4/lib/gruff/stacked_mixin.rb:
c:/ruby/lib/ruby/gems/1.8/gems/gruff-0.3.4/lib/gruff/stacked_area.rb:
c:/ruby/lib/ruby/gems/1.8/gems/gruff-0.3.4/lib/gruff/stacked_bar.rb:
c:/ruby/lib/ruby/gems/1.8/gems/gruff-0.3.4/lib/gruff/side_bar.rb:
c:/ruby/lib/ruby/gems/1.8/gems/gruff-0.3.4/lib/gruff/side_stacked_bar.rb:
c:/ruby/lib/ruby/gems/1.8/gems/gruff-0.3.4/lib/gruff/a_b.rb:
c:/ruby/lib/ruby/gems/1.8/gems/gruff-0.3.4/lib/gruff/accumulator_bar.rb:
c:/ruby/lib/ruby/gems/1.8/gems/gruff-0.3.4/lib/gruff/scene.rb:
c:/ruby/lib/ruby/gems/1.8/gems/gruff-0.3.4/lib/gruff/mini/legend.rb:
c:/ruby/lib/ruby/gems/1.8/gems/gruff-0.3.4/lib/gruff/mini/bar.rb:
c:/ruby/lib/ruby/gems/1.8/gems/gruff-0.3.4/lib/gruff/mini/pie.rb:
c:/ruby/lib/ruby/gems/1.8/gems/gruff-0.3.4/lib/gruff/mini/side_bar.rb:
gruff.rb:
  file: c:/ruby/lib/ruby/gems/1.8/gems/gruff-0.3.4/lib/gruff.rb

 

and I converted it to:

RMagick.rb:
   file: c:/ruby/lib/ruby/gems/1.8/gems/rmagick-2.9.0-x86-mswin32/lib/RMagick.rb
./gruff/deprecated.rb:
   file: c:/ruby/lib/ruby/gems/1.8/gems/gruff-0.3.4/lib/gruff/deprecated.rb
./gruff/base.rb:
   file: c:/ruby/lib/ruby/gems/1.8/gems/gruff-0.3.4/lib/gruff/base.rb
./gruff/area.rb:
   file: c:/ruby/lib/ruby/gems/1.8/gems/gruff-0.3.4/lib/gruff/area.rb
./gruff/bar_conversion.rb:
   file: c:/ruby/lib/ruby/gems/1.8/gems/gruff-0.3.4/lib/gruff/bar_conversion.rb
./gruff/bar.rb:
   file: c:/ruby/lib/ruby/gems/1.8/gems/gruff-0.3.4/lib/gruff/bar.rb
./gruff/line.rb:
   file: c:/ruby/lib/ruby/gems/1.8/gems/gruff-0.3.4/lib/gruff/line.rb
./gruff/pie.rb:
   file: c:/ruby/lib/ruby/gems/1.8/gems/gruff-0.3.4/lib/gruff/pie.rb
./gruff/spider.rb:
   file: c:/ruby/lib/ruby/gems/1.8/gems/gruff-0.3.4/lib/gruff/spider.rb
./gruff/net.rb:
   file: c:/ruby/lib/ruby/gems/1.8/gems/gruff-0.3.4/lib/gruff/net.rb
./gruff/stacked_mixin.rb:
   file: c:/ruby/lib/ruby/gems/1.8/gems/gruff-0.3.4/lib/gruff/stacked_mixin.rb
./gruff/stacked_area.rb:
   file: c:/ruby/lib/ruby/gems/1.8/gems/gruff-0.3.4/lib/gruff/stacked_area.rb
./gruff/stacked_bar.rb:
   file: c:/ruby/lib/ruby/gems/1.8/gems/gruff-0.3.4/lib/gruff/stacked_bar.rb
./gruff/side_bar.rb:
   file: c:/ruby/lib/ruby/gems/1.8/gems/gruff-0.3.4/lib/gruff/side_bar.rb
./gruff/side_stacked_bar.rb:
   file: c:/ruby/lib/ruby/gems/1.8/gems/gruff-0.3.4/lib/gruff/side_stacked_bar.rb
./gruff/accumulator_bar.rb:
   file: c:/ruby/lib/ruby/gems/1.8/gems/gruff-0.3.4/lib/gruff/accumulator_bar.rb
./gruff/scene.rb:
   file: c:/ruby/lib/ruby/gems/1.8/gems/gruff-0.3.4/lib/gruff/scene.rb
./gruff/mini/legend.rb:
   file: c:/ruby/lib/ruby/gems/1.8/gems/gruff-0.3.4/lib/gruff/mini/legend.rb
./gruff/mini/bar.rb:
   file: c:/ruby/lib/ruby/gems/1.8/gems/gruff-0.3.4/lib/gruff/mini/bar.rb
./gruff/mini/pie.rb:
   file: c:/ruby/lib/ruby/gems/1.8/gems/gruff-0.3.4/lib/gruff/mini/pie.rb
./gruff/mini/side_bar.rb:
   file: c:/ruby/lib/ruby/gems/1.8/gems/gruff-0.3.4/lib/gruff/mini/side_bar.rb
gruff.rb:
   file: c:/ruby/lib/ruby/gems/1.8/gems/gruff-0.3.4/lib/gruff.rb

 

It is still missing some DLL's that are needed so I will have to package those up separately.

A longer more detailed post is required on this.