Top Level Namespace

Includes:
Cerberus::Utils, Jabber

Defined Under Namespace

Modules: Cerberus, ERBMetaMixin, Enumerable, Errno, FavoriteSpecMixin, FileOperations, HookScriptAPI, Jabber, Kernel, REXML, Test, TimeParse, Twitter, XMLRPC Classes: AdventureMUC, BasicClient, CallbacksTest, ChatWindow, ClientTest, ConfigTable, ConnectionErrorTest, DataFormsTest, Download, ErrorTest, FileServe, Hash, HashWithIndifferentAccess, IBBTest, IO, IdGeneratorTest, Installer, IqQueryTest, IqTest, IqVcardTest, JIDTest, MUC, MUCClientTest, MUCOwnerTest, Marshmallow, MessageTest, MockListener, Place, Player, PresenceTest, REXMLTest, Room, SOCKS5BytestreamsTest, ServerErrorTest, SetupError, SetupWindow, Shell, SimpleMUCClientTest, StreamComponentTest, StreamParserTest, StreamSendTest, StreamTest, String, Thing, Time, ToplevelInstaller, ToplevelInstallerMulti, Transfer, Upload, VcardCache, WebController, World, XDelayTest, XMPPStanzaTest

Constant Summary collapse

EXCLUDED_FILES =

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

[]
VERSION_LIST =
[Twitter::Version::MAJOR, Twitter::Version::MINOR, Twitter::Version::REVISION]
EXPECTED_VERSION =
VERSION_LIST.join('.')
EXPECTED_NAME =
VERSION_LIST.join('_')
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=

Methods included from Cerberus::Utils

#dump_yml, #exec_successful?, #interpret_state, #load_yml, #os, #say, #silence_stream

Instance Method Details

#__execObject



71
# File 'lib/cerberus/utils.rb', line 71

alias __exec `

#`(cmd) ⇒ Object



72
73
74
75
76
77
78
# File 'lib/cerberus/utils.rb', line 72

def `(cmd)
  begin
    __exec(cmd)
  rescue Exception => e           
    raise "Unable to execute: #{cmd}"
  end
end

#glob_files(*path_elements) ⇒ Object



3
4
5
# File 'lib/vendor/twitter/spec/twitter/meta_spec.rb', line 3

def glob_files(*path_elements)
  Dir.glob(File.join(*path_elements))
end

#human_readable(num) ⇒ Object



11
12
13
14
15
16
17
18
19
# File 'lib/vendor/xmpp4r/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

#load_erb_yaml(path, context) ⇒ Object



7
8
9
10
# File 'lib/vendor/twitter/spec/twitter/meta_spec.rb', line 7

def load_erb_yaml(path, context)
  ryaml = ERB.new(File.read(path), 0)
  YAML.load(ryaml.result(context))
end

#mprofilerObject

Main loop



116
# File 'lib/vendor/xmpp4r/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/vendor/xmpp4r/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/vendor/xmpp4r/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_local(suffix) ⇒ Object



6
7
8
# File 'lib/vendor/twitter/lib/twitter.rb', line 6

def require_local(suffix)
  require(File.expand_path(File.join(File.dirname(__FILE__), suffix)))
end

#setup_rb_error(msg) ⇒ Object

Raises:



1573
1574
1575
# File 'lib/vendor/xmpp4r/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/vendor/xmpp4r/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/vendor/xmpp4r/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