Module: Hector
- Defined in:
- lib/hector/boot.rb,
lib/hector/errors.rb,
lib/hector/server.rb,
lib/hector/channel.rb,
lib/hector/logging.rb,
lib/hector/request.rb,
lib/hector/service.rb,
lib/hector/session.rb,
lib/hector/version.rb,
lib/hector/identity.rb,
lib/hector/response.rb,
lib/hector/deference.rb,
lib/hector/heartbeat.rb,
lib/hector/connection.rb,
lib/hector/commands/who.rb,
lib/hector/user_session.rb,
lib/hector/commands/away.rb,
lib/hector/commands/join.rb,
lib/hector/commands/mode.rb,
lib/hector/commands/nick.rb,
lib/hector/commands/part.rb,
lib/hector/commands/ping.rb,
lib/hector/commands/pong.rb,
lib/hector/commands/quit.rb,
lib/hector/commands/names.rb,
lib/hector/commands/topic.rb,
lib/hector/commands/whois.rb,
lib/hector/commands/invite.rb,
lib/hector/commands/notice.rb,
lib/hector/commands/privmsg.rb,
lib/hector/commands/realname.rb,
lib/hector/concerns/presence.rb,
lib/hector/concerns/keep_alive.rb,
lib/hector/yaml_identity_adapter.rb,
lib/hector/concerns/authentication.rb
Defined Under Namespace
Modules: Commands, Concerns Classes: CannotSendToChannel, Channel, Connection, ErroneousNickname, Error, Heartbeat, Identity, InvalidPassword, IrcError, LoadError, NicknameInUse, NoSuchChannel, NoSuchNickOrChannel, NullLogger, Request, Response, SSLConnection, Service, Session, UserSession, YamlIdentityAdapter
Constant Summary collapse
- VERSION =
"1.0.9"
Class Attribute Summary collapse
-
.address ⇒ Object
Returns the value of attribute address.
-
.lib ⇒ Object
Returns the value of attribute lib.
-
.logger ⇒ Object
Returns the value of attribute logger.
-
.port ⇒ Object
Returns the value of attribute port.
-
.root ⇒ Object
Returns the value of attribute root.
-
.server_name ⇒ Object
Returns the value of attribute server_name.
-
.ssl_certificate_key_path ⇒ Object
Returns the value of attribute ssl_certificate_key_path.
-
.ssl_certificate_path ⇒ Object
Returns the value of attribute ssl_certificate_path.
-
.ssl_port ⇒ Object
Returns the value of attribute ssl_port.
Class Method Summary collapse
- .defer(&block) ⇒ Object
- .find_application_root_from(working_directory) ⇒ Object
- .IrcError(command, *options) ⇒ Object
- .load_application ⇒ Object
- .load_defaults ⇒ Object
- .load_root ⇒ Object
- .next_tick(&block) ⇒ Object
- .start ⇒ Object
- .start_server ⇒ Object
Class Attribute Details
.address ⇒ Object
Returns the value of attribute address.
3 4 5 |
# File 'lib/hector/server.rb', line 3 def address @address end |
.lib ⇒ Object
Returns the value of attribute lib.
6 7 8 |
# File 'lib/hector/boot.rb', line 6 def lib @lib end |
.logger ⇒ Object
Returns the value of attribute logger.
12 13 14 |
# File 'lib/hector/logging.rb', line 12 def logger @logger end |
.port ⇒ Object
Returns the value of attribute port.
3 4 5 |
# File 'lib/hector/server.rb', line 3 def port @port end |
.root ⇒ Object
Returns the value of attribute root.
6 7 8 |
# File 'lib/hector/boot.rb', line 6 def root @root end |
.server_name ⇒ Object
Returns the value of attribute server_name.
3 4 5 |
# File 'lib/hector/server.rb', line 3 def server_name @server_name end |
.ssl_certificate_key_path ⇒ Object
Returns the value of attribute ssl_certificate_key_path.
3 4 5 |
# File 'lib/hector/server.rb', line 3 def ssl_certificate_key_path @ssl_certificate_key_path end |
.ssl_certificate_path ⇒ Object
Returns the value of attribute ssl_certificate_path.
3 4 5 |
# File 'lib/hector/server.rb', line 3 def ssl_certificate_path @ssl_certificate_path end |
.ssl_port ⇒ Object
Returns the value of attribute ssl_port.
3 4 5 |
# File 'lib/hector/server.rb', line 3 def ssl_port @ssl_port end |
Class Method Details
.defer(&block) ⇒ Object
3 4 5 |
# File 'lib/hector/deference.rb', line 3 def defer(&block) EM.defer(&block) end |
.find_application_root_from(working_directory) ⇒ Object
36 37 38 39 40 |
# File 'lib/hector/boot.rb', line 36 def find_application_root_from(working_directory) dir = Pathname.new(working_directory) dir = dir.parent while dir != dir.parent && dir.basename.to_s !~ /\.hect$/ dir == dir.parent ? nil : dir end |
.IrcError(command, *options) ⇒ Object
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/hector/errors.rb', line 13 def self.IrcError(command, *) fatal = .last.is_a?(Hash) && .last.delete(:fatal) Class.new(IrcError).tap do |klass| klass.class_eval do define_method(:command) { command.dup } define_method(:options) { .dup } define_method(:fatal?) { fatal } end end end |
.load_application ⇒ Object
31 32 33 34 |
# File 'lib/hector/boot.rb', line 31 def load_application $:.unshift Hector.root.join("lib") load Hector.root.join("init.rb") end |
.load_defaults ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/hector/boot.rb', line 22 def load_defaults log_path = Hector.root.join("log/hector.log") Hector.logger = Logger.new(log_path) Hector.logger.datetime_format = "%Y-%m-%d %H:%M:%S" identities_path = Hector.root.join("config/identities.yml") Hector::Identity.adapter = Hector::YamlIdentityAdapter.new(identities_path) end |
.load_root ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/hector/boot.rb', line 14 def load_root if root = ENV["HECTOR_ROOT"] Hector.root = Pathname.new(File.(root)) else Hector.root = find_application_root_from(Dir.pwd) end end |
.next_tick(&block) ⇒ Object
7 8 9 |
# File 'lib/hector/deference.rb', line 7 def next_tick(&block) EM.next_tick(&block) end |
.start ⇒ Object
8 9 10 11 12 |
# File 'lib/hector/boot.rb', line 8 def start raise LoadError, "please specify HECTOR_ROOT" unless Hector.root load_defaults load_application end |
.start_server ⇒ Object
6 7 8 9 10 11 |
# File 'lib/hector/server.rb', line 6 def start_server EventMachine.start_server(@address, @port, Connection) EventMachine.start_server(@address, @ssl_port, SSLConnection) logger.info("Hector running on #{@address}:#{@port}") logger.info("Secure Hector running on #{@address}:#{@ssl_port}") end |