class Object

Constants

DIR_PERMISSION
DOCS_DIR
DOWNLOAD_FILE

RELEASE_HTML_DIR = “#{RELEASE_DIR}/README”

FILE_PERMISSION
MouseCount
PUBLISH_FLAG
QTBINDINGS_RELEASE_DATE
QTBINDINGS_VERSION
RELEASE_DIR
RUBOIDS_DIR
RUBOIDS_DIR_WITH_VERSION

DOCS_HTML_DIR = “#{DOCS_DIR}/README”

SERVICE_NAME
VERSION_MAJOR

Copyright © 2001 by Jim Menard <jimm@io.com>

Released under the same license as Ruby. See www.ruby-lang.org/en/LICENSE.txt.

VERSION_MINOR
VERSION_TWEAK
Version
WEB_DIR
WEB_SITE

DOCBOOK_FILE = “#{DOCS_DIR}/README.sgml”

Public Instance Methods

QT_TRANSLATE_NOOP(scope, x) click to toggle source
# File lib/Qt/qtruby4.rb, line 3183
def QT_TRANSLATE_NOOP(scope, x) x end
QT_TR_NOOP(x) click to toggle source
# File lib/Qt/qtruby4.rb, line 3182
def QT_TR_NOOP(x) x end
SIGNAL(signal) click to toggle source
# File lib/Qt/qtruby4.rb, line 3162
def SIGNAL(signal)
  if signal.kind_of? Symbol
    return "2" + signal.to_s + "()"
  else
    return "2" + signal
  end
end
SLOT(slot) click to toggle source
# File lib/Qt/qtruby4.rb, line 3170
def SLOT(slot)
  if slot.kind_of? Symbol
    return "1" + slot.to_s + "()"
  else
    return "1" + slot
  end
end
copyFiles(fromDir, toDir, match=nil) click to toggle source

Copies all files from `fromDir' into the release directory. Sets the permissions of all files to 0644.

# File examples/ruboids/release.rb, line 50
def copyFiles(fromDir, toDir, match=nil)
    Dir.foreach(fromDir) { | f |
        next if f =~ /^\.\.?/ || (!match.nil? && !(f =~ match))
        File.install("#{fromDir}/#{f}", toDir, FILE_PERMISSION)
    }
end
emit(signal) click to toggle source
# File lib/Qt/qtruby4.rb, line 3178
def emit(signal)
  return signal
end
ensureVersionInFile(fileName, regex) click to toggle source
# File examples/ruboids/release.rb, line 89
def ensureVersionInFile(fileName, regex)
    lines = File.open(fileName).grep(regex)
    found = lines.detect { | line | line =~ /#{Version}/o }
    if !found
        $stderr.puts "Warning: it looks like the #{fileName} version number" +
            " is incorrect"
    end
end
generateManifest() click to toggle source
# File examples/ruboids/generateManifest.rb, line 26
def generateManifest
    io = nil
    begin
        io = File.open('Manifest', 'w')
        recurseDirectory(io, '.', 0)
    ensure
        io.close() if io
    end
end
instance_exec(*arguments, &block) click to toggle source

See the discussion here: eigenclass.org/hiki.rb?instance_exec about implementations of the ruby 1.9 method #instance_exec(). This version is the one from Rails. It isn't thread safe, but that doesn't matter for the intended use in invoking blocks as Qt slots.

# File lib/Qt/qtruby4.rb, line 3189
def instance_exec(*arguments, &block)
  block.bind(self)[*arguments]
end
method1() click to toggle source
# File examples/qdbus/listnames/listnames.rb, line 29
def method1()
    qDebug("Method 1:")
    
    reply = Qt::DBusConnection.sessionBus.interface.registeredServiceNames
    if !reply.valid?
            qDebug("Error:" + reply.error.message)
            exit 1
    end
    reply.value.each {|name| qDebug(name)}
end
method2() click to toggle source
# File examples/qdbus/listnames/listnames.rb, line 40
def method2()
    qDebug("Method 2:")
    
    bus = Qt::DBusConnection.sessionBus
    dbus_iface = Qt::DBusInterface.new("org.freedesktop.DBus", "/org/freedesktop/DBus", 
                                       "org.freedesktop.DBus", bus)
        
    qDebug(dbus_iface.call("ListNames").arguments[0].value.inspect)
end
method3() click to toggle source
# File examples/qdbus/listnames/listnames.rb, line 50
def method3()
    qDebug("Method 3:")
    qDebug(Qt::DBusConnection.sessionBus.interface.registeredServiceNames.value.inspect)
end
recurseDirectory(io, dirName, indentLevel) click to toggle source

Copyright © 2001 by Jim Menard <jimm@io.com>

Released under the same license as Ruby. See www.ruby-lang.org/en/LICENSE.txt.

This script builds the Manifest file. It can be run stand-alone, but is normally used from within release.rb.

# File examples/ruboids/generateManifest.rb, line 12
def recurseDirectory(io, dirName, indentLevel)
    Dir.entries(dirName).sort.each { | f |
        next if f =~ /^\.\.?/
        fileName = "#{dirName}/#{f}"
        fileName.sub!(/^\.\//, '')
        if File.directory?(fileName)
            io.puts "\t" * indentLevel + fileName + '/'
            recurseDirectory(io, fileName, indentLevel + 1)
        else
            io.puts "\t" * indentLevel + f
        end
    }
end
rmDirectory(dirName) click to toggle source

Recursively removes the contents of a directory.

# File examples/ruboids/release.rb, line 58
def rmDirectory(dirName)
    return unless File.exists?(dirName)
    Dir.foreach(dirName) { | f |
        next if f =~ /^\.\.?/
        path = "#{dirName}/#{f}"
        rmDirectory(path) if File.directory?(path)
        File.delete(path) if !File.directory?(path)
    }
    
end
sendToWebSite(ftp, releaseDir, webDir) click to toggle source

Recursively sends files and directories.

# File examples/ruboids/release.rb, line 70
def sendToWebSite(ftp, releaseDir, webDir)
    ftp.chdir(webDir)
    Dir.foreach(releaseDir) { | f |
        next if f =~ /^\.\.?/
        path = "#{releaseDir}/#{f}"
        if File.directory?(path)
            begin
                ftp.mkdir(f)
            rescue Net::FTPPermError
                # ignore; it's OK if the directory already exists
            end
            sendToWebSite(ftp, path, f)
            ftp.chdir('..')
        else
            ftp.putbinaryfile(path, f)
        end
    }
end
test(str) click to toggle source
# File ext/ruby/qtruby/test/opoverloading.rb, line 10
def test(str)
   puts "#{str.ljust 25} => #{eval(str, $t)}"
end