dave.m wrote:

>
> Hy list,
>
>
> I would like to append to a ruby script a tarball and a license file.
>
> Both are in the form:
>
> # data........................................
>
> How would you convert the tarball binary data?


tar = "i6\253m\251e"    # in:  binary content
b64 = [tar].pack('m')   # out: Base64 encoded string
p b64                   #-> "aTarball\n"


>
> If I split the license text lines and then gsub(/\n/, '\n') them
> i have a bad output:

If you split on /\n/, the newline will disappear so it's
not now available to gsub.


What about this ?

# make some input data
licin = <<EOL
LIC ............A
LIC ............B
LIC ............C
EOL

licout = licin.map {|line| '# ' << line}
puts licout

# LIC ............A
# LIC ............B
# LIC ............C


daz