Top Level Namespace

Includes:
Jabber

Defined Under Namespace

Modules: Enumerable, Errno, FileOperations, Functional, HookScriptAPI, Jabber, Mack, REXML, Spec, TMail, Test, Validatable, XMLRPC Classes: AdventureMUC, Array, BasicClient, CallbacksTest, ChatWindow, ClientTest, ConfigTable, ConnectionErrorTest, DataFormsTest, Download, ErrorTest, FalseClass, FileServe, Hash, IBBTest, IdGeneratorTest, Installer, IqQueryTest, IqTest, IqVcardTest, JIDTest, JabberSimpleTest, MUC, MUCClientTest, MUCOwnerTest, MessageTest, MockListener, NilClass, NotifierGenerator, Numeric, Object, Place, Player, PresenceTest, REXMLTest, Room, SOCKS5BytestreamsTest, ServerErrorTest, SetupError, SetupWindow, Shell, SimpleMUCClientTest, StreamComponentTest, StreamParserTest, StreamSendTest, StreamTest, String, StringInput, StringOutput, Thing, ToplevelInstaller, ToplevelInstallerMulti, Transfer, TrueClass, Upload, VcardCache, WebController, World, XDelayTest, XMPPStanzaTest

Constant Summary collapse

EXCLUDED_FILES =

List files’ basenames, not full path! EXCLUDED_FILES = [ ‘tc_muc_simplemucclient.rb’ ]

[]
BOTHOLD =
"Hi, you are subscribed to my presence. I just changed my JID. The new one is #{jidto.strip}. You might want to update your roster. Thank you, and sorry for the inconvenience !"
BOTHNEW =
"Hi, you are subscribed to the presence of my previous JID : #{jidfrom.strip}. I just changed my JID, and this is the new one. You might want to update your roster. Thank you, and sorry for the inconvenience !"
HTTP_PORT =
ARGV.shift.to_i
JID =
ARGV.shift
PASSWORD =
ARGV.shift
STATUS_MESSAGE =
ARGV.shift
MAX_ITEMS =
50

Constants included from Jabber

Jabber::XMPP4R_VERSION

Instance Method Summary collapse

Methods included from Jabber

debug, debug=, debuglog, logger, logger=

Instance Method Details

#delivered_notifiersObject

Used for testing this method will return any emails that have been ‘sent’ using Mack::Notifier::DeliveryHandlers::Test. These emails will get ‘flushed’ after each test.



5
6
7
# File 'lib/mack-notifier/testing.rb', line 5

def delivered_notifiers
  Mack::Notifier::DeliveryHandlers::Test::NotifierRegistry.registered_items
end

#human_readable(num) ⇒ Object



11
12
13
14
15
16
17
18
19
# File 'lib/gems/xmpp4r-0.4/data/doc/xmpp4r/examples/advanced/fileserve.rb', line 11

def human_readable(num)
  unit = ''
  units = %w(K M G T P E)
  while num > 10240 and units.size > 0
    num /= 1024
    unit = units.shift
  end
  "#{num} #{unit}B"
end

#mprofilerObject

Main loop



116
# File 'lib/gems/xmpp4r-0.4/data/doc/xmpp4r/examples/advanced/xmpping.rb', line 116

require 'mprofiler'

Print a line formatted depending on time.nil?



13
14
15
16
17
18
19
# File 'lib/gems/xmpp4r-0.4/data/doc/xmpp4r/examples/basic/mucsimplebot.rb', line 13

def print_line(time, line)
  if time.nil?
    puts line
  else
    puts "#{time.strftime('%I:%M')} #{line}"
  end
end

Reply printer



90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/gems/xmpp4r-0.4/data/doc/xmpp4r/examples/advanced/xmpping.rb', line 90

def print_reply(iq, roundtrip)
  roundtrip_s = ((roundtrip * 100).round / 100.0).to_s + " sec"
  output = "Received a #{iq.query.namespace} #{iq.type} (id: #{iq.id}) from #{iq.from} (#{roundtrip_s}): "

  if iq.query.kind_of?(Jabber::Version::IqQueryVersion)
    output += "#{iq.query.iname}-#{iq.query.version} #{iq.query.os}"
  elsif iq.query.namespace == 'jabber:iq:time'
    output += "#{iq.query.first_element_text('display')} (#{iq.query.first_element_text('tz')})"
  elsif iq.query.kind_of?(Jabber::Discovery::IqQueryDiscoInfo)
    identity = iq.query.identity
    if identity
      output += "#{identity.iname} (#{identity.category} #{identity.type})"
    else
      output += "<identity/> missing"
    end
  else
    output += iq.query.to_s
  end

  puts output
end

#require_arch(fname) ⇒ Object

Attempts to require anative extension. Falls back to pure-ruby version, if it fails.

This uses Config::CONFIG from rbconfig.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/gems/tmail-1.2.3.1/lib/tmail/require_arch.rb', line 9

def require_arch(fname)
  arch = Config::CONFIG['arch']
  begin
    path = File.join("tmail", arch, fname)
    require path
  rescue LoadError => e
    # try pre-built Windows binaries
    if arch =~ /mswin/
      require File.join("tmail", 'mswin32', fname)
    else
      raise e
    end
  end
end

#setup_rb_error(msg) ⇒ Object

Raises:



1573
1574
1575
# File 'lib/gems/xmpp4r-0.4/setup.rb', line 1573

def setup_rb_error(msg)
  raise SetupError, msg
end

#with_status(str, &block) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/gems/xmpp4r-0.4/data/doc/xmpp4r/examples/basic/change_password.rb', line 12

def with_status(str, &block)
  print "#{str}..."
  $stdout.flush
  begin
    yield
    puts " Ok"
  rescue Exception => e
    puts " Exception: #{e.to_s}"
    raise e
  end
end

#xml_namespaces(filename, excludes = []) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/gems/xmpp4r-0.4/data/doc/xmpp4r/examples/advanced/pep-aggregator/pep-aggregator.rb', line 17

def xml_namespaces(filename, excludes=[])
  namespaces_recursive = nil
  namespaces_recursive = lambda { |element|
    namespaces = element.namespaces
    element.each_element { |child|
      namespaces.merge!(namespaces_recursive.call(child))
    }
    namespaces
  }

  root = REXML::Document.new(File.new(filename)).root
  all = namespaces_recursive.call(root)
  res = {}
  all.each { |prefix,uri|
    res[prefix] = uri unless excludes.include? prefix
  }
  res
end