Sutto-marvin 0.4.0 → 0.8.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. data/bin/marvin +22 -156
  2. data/handlers/keiki_thwopper.rb +21 -0
  3. data/handlers/tweet_tweet.rb +1 -3
  4. data/lib/marvin/abstract_client.rb +75 -189
  5. data/lib/marvin/abstract_parser.rb +9 -11
  6. data/lib/marvin/base.rb +134 -101
  7. data/lib/marvin/client/actions.rb +104 -0
  8. data/lib/marvin/client/default_handlers.rb +97 -0
  9. data/lib/marvin/command_handler.rb +60 -49
  10. data/lib/marvin/console.rb +4 -31
  11. data/lib/marvin/core_commands.rb +30 -12
  12. data/lib/marvin/distributed/client.rb +225 -0
  13. data/lib/marvin/distributed/handler.rb +85 -0
  14. data/lib/marvin/distributed/protocol.rb +88 -0
  15. data/lib/marvin/distributed/server.rb +154 -0
  16. data/lib/marvin/distributed.rb +4 -10
  17. data/lib/marvin/dsl.rb +103 -0
  18. data/lib/marvin/exception_tracker.rb +7 -4
  19. data/lib/marvin/irc/client.rb +127 -99
  20. data/lib/marvin/irc/event.rb +14 -10
  21. data/lib/marvin/irc.rb +0 -1
  22. data/lib/marvin/middle_man.rb +1 -1
  23. data/lib/marvin/parsers/command.rb +10 -8
  24. data/lib/marvin/parsers/prefixes/host_mask.rb +12 -7
  25. data/lib/marvin/parsers/prefixes/server.rb +1 -1
  26. data/lib/marvin/parsers/ragel_parser.rb +59 -52
  27. data/lib/marvin/parsers/ragel_parser.rl +6 -7
  28. data/lib/marvin/parsers/simple_parser.rb +4 -9
  29. data/lib/marvin/parsers.rb +1 -2
  30. data/lib/marvin/settings.rb +29 -79
  31. data/lib/marvin/test_client.rb +20 -26
  32. data/lib/marvin/util.rb +10 -3
  33. data/lib/marvin.rb +42 -39
  34. data/templates/boot.erb +3 -0
  35. data/templates/connections.yml.erb +10 -0
  36. data/templates/debug_handler.erb +5 -0
  37. data/templates/hello_world.erb +10 -0
  38. data/templates/rakefile.erb +15 -0
  39. data/templates/settings.yml.erb +8 -0
  40. data/{config/setup.rb → templates/setup.erb} +8 -10
  41. data/templates/test_helper.erb +17 -0
  42. data/test/abstract_client_test.rb +63 -0
  43. data/test/parser_comparison.rb +2 -2
  44. data/test/parser_test.rb +3 -3
  45. data/test/test_helper.rb +58 -6
  46. metadata +51 -83
  47. data/README.textile +0 -105
  48. data/TUTORIAL.textile +0 -54
  49. data/VERSION.yml +0 -4
  50. data/config/boot.rb +0 -14
  51. data/config/connections.yml.sample +0 -5
  52. data/config/settings.yml.sample +0 -13
  53. data/handlers/logging_handler.rb +0 -89
  54. data/lib/marvin/core_ext.rb +0 -11
  55. data/lib/marvin/daemon.rb +0 -71
  56. data/lib/marvin/data_store.rb +0 -73
  57. data/lib/marvin/dispatchable.rb +0 -99
  58. data/lib/marvin/distributed/dispatch_handler.rb +0 -83
  59. data/lib/marvin/distributed/drb_client.rb +0 -78
  60. data/lib/marvin/distributed/ring_server.rb +0 -41
  61. data/lib/marvin/handler.rb +0 -12
  62. data/lib/marvin/irc/server/abstract_connection.rb +0 -84
  63. data/lib/marvin/irc/server/base_connection.rb +0 -66
  64. data/lib/marvin/irc/server/channel.rb +0 -115
  65. data/lib/marvin/irc/server/named_store.rb +0 -14
  66. data/lib/marvin/irc/server/remote_interface.rb +0 -77
  67. data/lib/marvin/irc/server/user/handle_mixin.rb +0 -140
  68. data/lib/marvin/irc/server/user.rb +0 -5
  69. data/lib/marvin/irc/server/user_connection.rb +0 -134
  70. data/lib/marvin/irc/server/virtual_user_connection.rb +0 -80
  71. data/lib/marvin/irc/server.rb +0 -71
  72. data/lib/marvin/loader.rb +0 -149
  73. data/lib/marvin/logger.rb +0 -86
  74. data/lib/marvin/options.rb +0 -42
  75. data/lib/marvin/parsers/regexp_parser.rb +0 -93
  76. data/lib/marvin/status.rb +0 -72
  77. data/script/client +0 -3
  78. data/script/console +0 -3
  79. data/script/distributed_client +0 -3
  80. data/script/install +0 -1
  81. data/script/ring_server +0 -4
  82. data/script/server +0 -4
  83. data/script/status +0 -3
  84. data/spec/marvin/abstract_client_test.rb +0 -38
  85. data/spec/spec_helper.rb +0 -14
@@ -1,71 +0,0 @@
1
- module Marvin
2
- module IRC
3
- module Server
4
-
5
- # Server utilities
6
- autoload :NamedStore, 'marvin/irc/server/named_store'
7
-
8
- # Store each user
9
- UserStore = NamedStore.new(:nicks, :user) do
10
-
11
- def virtual?(nick)
12
- self[nick].is_a?(Marvin::IRC::Server::VirtualUserConnection)
13
- end
14
-
15
- def reclaim(nick)
16
- if has_key?(nick) && virtual?(nick)
17
- self[nick].reclaim!
18
- end
19
- end
20
-
21
- # Nick is not taken when
22
- def nick_taken?(nick)
23
- has_key?(nick) && !virtual(nick)
24
- end
25
-
26
- def each_user_except(user)
27
- self.each_user { |u| yield u unless user == u }
28
- end
29
- end
30
-
31
- # Store each channel
32
- ChannelStore = NamedStore.new(:names, :channel)
33
-
34
- autoload :RemoteInterface, 'marvin/irc/server/remote_interface'
35
- autoload :Channel, 'marvin/irc/server/channel'
36
- # The actual network connection
37
- autoload :BaseConnection, 'marvin/irc/server/base_connection'
38
- # An our implementations of protocol-specific stuff.
39
- autoload :VirtualUserConnection, 'marvin/irc/server/virtual_user_connection'
40
- autoload :AbstractConnection, 'marvin/irc/server/abstract_connection'
41
- autoload :UserConnection, 'marvin/irc/server/user_connection'
42
- # autoload :ServerConnection, 'marvin/irc/server/server_connection'
43
- # Extensions for each part
44
- autoload :User, 'marvin/irc/server/user'
45
-
46
- # call start_server w/ the default options
47
- # and inside an EM::run block.
48
- def self.run
49
- Marvin::IRC::Server::RemoteInterface.start
50
- EventMachine::run do
51
- Marvin::Logger.info "Starting server..."
52
- start_server :bind_addr => "0.0.0.0"
53
- end
54
- end
55
-
56
- # Starts the server with a set of given options
57
- def self.start_server(opts = {})
58
- opts[:started_at] ||= Time.now
59
- opts[:host] ||= self.host_name
60
- opts[:port] ||= 6667
61
- EventMachine::start_server(opts[:bind_addr] || opts[:host], opts[:port], BaseConnection, opts)
62
- Marvin::Logger.info "Server started"
63
- end
64
-
65
- def self.host_name
66
- @@host_name ||= Socket.gethostname
67
- end
68
-
69
- end
70
- end
71
- end
data/lib/marvin/loader.rb DELETED
@@ -1,149 +0,0 @@
1
- require 'fileutils'
2
- require 'singleton'
3
-
4
- module Marvin
5
- class Loader
6
- include Singleton
7
-
8
- # A Controller is any class e.g. a client / server
9
- # which is provides the main functionality of the
10
- # current client.
11
- CONTROLLERS = {
12
- :client => Marvin::Settings.default_client,
13
- :server => Marvin::IRC::Server,
14
- :ring_server => Marvin::Distributed::RingServer,
15
- :distributed_client => Marvin::Distributed::DRbClient,
16
- :console => Marvin::Console
17
- }
18
-
19
- # For each of the known types, define a method
20
- # as Marvin::Loader.type? so we can easily do
21
- # things like conditional registers.
22
- class << self
23
- CONTROLLERS.keys.each do |type|
24
- define_method(:"#{type}?") { Marvin::Loader.type == type }
25
- end
26
- end
27
-
28
- cattr_accessor :hooks, :boot, :type
29
- self.hooks = {}
30
- self.type = :client
31
-
32
- # Old style of registering a block to be run on startup
33
- # for doing setup etc. now replaced by before_run
34
- def self.before_connecting(&blk)
35
- Marvin::Logger.warn "Marvin::Loader.before_connecting is deprecated, please use before_run instead."
36
- before_run(&blk)
37
- end
38
-
39
- # Append a hook for a given type of hook in order
40
- # to be called later on via invoke_hooks!
41
- def self.append_hook(type, &blk)
42
- self.hooks_for(type) << blk unless blk.blank?
43
- end
44
-
45
- # Return all of the existing hooks or an empty
46
- # for a given hook type.
47
- def self.hooks_for(type)
48
- (self.hooks[type.to_sym] ||= [])
49
- end
50
-
51
- # Invoke (call) all of the hooks for a given
52
- # type.
53
- def self.invoke_hooks!(type)
54
- hooks_for(type).each { |hook| hook.call }
55
- end
56
-
57
- # Append a call back to be run at a specific stage.
58
-
59
- # Register a hook to be run before the controller
60
- # has started running.
61
- def self.before_run(&blk)
62
- append_hook(:before_run, &blk)
63
- end
64
-
65
- # Register a hook to be run after the controller
66
- # has stopped. Note that this will not guarantee
67
- # all processing has completed.
68
- def self.after_stop(&blk)
69
- append_hook(:after_stop, &blk)
70
- end
71
-
72
- def self.run!(type = :client)
73
- self.type = type.to_sym
74
- self.instance.run!
75
- end
76
-
77
- def self.stop!(force = false)
78
- self.instance.stop!(force)
79
- end
80
-
81
- def run!
82
- self.register_signals
83
- Marvin::Options.parse!
84
- Marvin::Daemon.daemonize! if Marvin::Settings.daemon?
85
- Marvin::Logger.setup
86
- self.load_settings
87
- require(Marvin::Settings.root / "config" / "setup")
88
- self.load_handlers
89
- self.class.invoke_hooks! :before_run
90
- attempt_controller_action! :run
91
- end
92
-
93
- def stop!(force = false)
94
- if force || !@attempted_stop
95
- self.class.invoke_hooks! :before_stop
96
- attempt_controller_action! :stop
97
- self.class.invoke_hooks! :after_stop
98
- @attempted_stop = true
99
- end
100
- Marvin::Daemon.cleanup! if Marvin::Settings.daemon?
101
- end
102
-
103
- protected
104
-
105
- # Get the controller for the current type if
106
- # it exists and attempt to class a given action.
107
- def attempt_controller_action!(action)
108
- klass = CONTROLLERS[self.type]
109
- klass.send(action) unless klass.blank? || !klass.respond_to?(action, true)
110
- end
111
-
112
- # Load all of the handler's in the handlers subfolder
113
- # of a marvin installation.
114
- def load_handlers
115
- Dir[Marvin::Settings.root / "handlers/**/*.rb"].each { |handler| require handler }
116
- end
117
-
118
- def load_settings
119
- Marvin::Settings.setup
120
- case Marvin::Loader.type
121
- # Perform client / type specific setup.
122
- when :client
123
- Marvin::Settings.default_client.configuration = Marvin::Settings.to_hash
124
- Marvin::Settings.default_client.setup
125
- when :distributed_client
126
- Marvin::Settings.default_client = Marvin::Distributed::DRbClient
127
- end
128
- end
129
-
130
- def register_signals
131
- ["INT", "TERM"].each do |sig|
132
- trap sig do
133
- Marvin::Loader.stop!
134
- exit
135
- end
136
- end
137
- end
138
-
139
- # Register to the Marvin::DataStore methods
140
- if Marvin::Loader.client?
141
- before_run do
142
- Marvin::CoreCommands.register!
143
- Marvin::DataStore.load!
144
- end
145
- after_stop { Marvin::DataStore.dump! }
146
- end
147
-
148
- end
149
- end
data/lib/marvin/logger.rb DELETED
@@ -1,86 +0,0 @@
1
- module Marvin
2
- class Logger
3
-
4
- cattr_accessor :logger
5
-
6
- class << self
7
-
8
- def setup
9
- log_path = Marvin::Settings.root / "log/#{Marvin::Loader.type.to_s.dasherize}-#{Marvin::Settings.environment}.log"
10
- self.logger ||= new(log_path, Marvin::Settings.log_level, Marvin::Settings.verbose)
11
- end
12
-
13
- def method_missing(name, *args, &blk)
14
- self.setup # Ensure the logger is setup
15
- self.logger.send(name, *args, &blk)
16
- end
17
-
18
- end
19
-
20
- LEVELS = {
21
- :fatal => 7,
22
- :error => 6,
23
- :warn => 4,
24
- :info => 3,
25
- :debug => 0
26
- }
27
-
28
- PREFIXES = {}
29
-
30
- LEVELS.each { |k,v| PREFIXES[k] = "[#{k.to_s.upcase}]".ljust 7 }
31
-
32
- COLOURS = {
33
- :fatal => 31, # red
34
- :error => 33, # yellow
35
- :warn => 35, # magenta
36
- :info => 32, # green
37
- :debug => 34 # white
38
- }
39
-
40
- attr_accessor :level, :file, :verbose
41
-
42
- def initialize(path, level = :info, verbose = false)
43
- self.level = level.to_sym
44
- self.verbose = verbose
45
- self.file = File.open(path, "a+")
46
- end
47
-
48
- def close!
49
- self.file.close
50
- end
51
-
52
- LEVELS.each do |name, value|
53
-
54
- define_method(name) do |message|
55
- write "#{PREFIXES[name]} #{message}", name if LEVELS[self.level] <= value
56
- end
57
-
58
- define_method(:"#{name}?") do
59
- LEVELS[self.level] <= value
60
- end
61
- end
62
-
63
- def debug_exception(exception)
64
-
65
- error "Exception: #{exception}"
66
- exception.backtrace.each do |l|
67
- error ">> #{l}"
68
- end
69
-
70
- end
71
-
72
- private
73
-
74
- def write(message, level = self.level)
75
- self.file.puts message
76
- self.file.flush
77
- STDOUT.puts colourize(message, level) if self.verbose
78
- end
79
-
80
- def colourize(message, level)
81
- "\033[1;#{COLOURS[level]}m#{message}\033[0m"
82
- end
83
-
84
-
85
- end
86
- end
@@ -1,42 +0,0 @@
1
- require 'optparse'
2
-
3
- module Marvin
4
- class Options
5
-
6
- def self.parse!
7
- options = {
8
- :verbose => Marvin::Settings.verbose,
9
- :log_level => Marvin::Settings.log_level.to_s,
10
- :daemon => false
11
- }
12
-
13
- ARGV.options do |o|
14
- script_name = File.basename($0)
15
- o.set_summary_indent(' ')
16
- o.banner = "Usage: #{script_name} [OPTIONS]"
17
- o.define_head "Ruby IRC Library"
18
- o.separator ""
19
- o.separator ""
20
- o.on("-l", "--level=[level]", String, "The log level to use",
21
- "Default: #{options[:log_level]}") {|v| options[:log_level] = v}
22
- o.on("-v", "--verbose", "Be verbose (print to stdout)") {|v| options[:verbose] = v}
23
- o.on("-d", "--daemon", "Run as a daemon (drop the PID)") {|v| options[:daemon] = v}
24
- o.on("-k", "--kill", "Kill all of the current type / the running instances") do |kill|
25
- if kill
26
- Marvin::Daemon.kill_all(Marvin::Loader.type)
27
- exit
28
- end
29
- end
30
-
31
- o.separator ""
32
- o.on_tail("-h", "--help", "Show this message.") { puts o; exit }
33
- o.parse!
34
- end
35
-
36
- Marvin::Settings.daemon = options[:daemon]
37
- Marvin::Settings.log_level = options[:log_level].to_sym
38
- Marvin::Settings.verbose = options[:verbose]
39
- end
40
-
41
- end
42
- end
@@ -1,93 +0,0 @@
1
- module Marvin
2
- module Parsers
3
- class RegexpParser < Marvin::AbstractParser
4
-
5
- cattr_accessor :regexp_matchers, :events
6
- # Since we cbf implemented an ordered hash, just use regexp => event at the same
7
- # index.
8
- self.regexp_matchers = []
9
- self.events = []
10
-
11
- attr_accessor :current_line
12
-
13
- # Appends an event to the end of the the events callback
14
- # chain. It will be search in order of first-registered
15
- # when used to match a URL (hence, order matters).
16
- def self.register_event(*args)
17
- matcher = args.delete_at(1) # Extract regexp.
18
- if args.first.is_a?(Marvin::IRC::Event)
19
- event = args.first
20
- else
21
- event = Marvin::IRC::Event.new(*args)
22
- end
23
- self.regexp_matchers << matcher
24
- self.events << event
25
- end
26
-
27
-
28
- # Initialize a new RegexpParser from the given line.
29
- def initialize(line)
30
- self.current_line = line
31
- end
32
-
33
- def to_event
34
- self.regexp_matchers.each_with_index do |matcher, offset|
35
- if (match_data = matcher.match(self.current_line))
36
- event = self.events[offset].dup
37
- event.raw_arguments = match_data.to_a[1..-1]
38
- return event
39
- end
40
- end
41
- # otherwise, return nil
42
- return nil
43
- end
44
-
45
- ## The Default IRC Events
46
-
47
- # Note that some of these Regexp's are from Net::YAIL,
48
- # which apparantly sources them itself from the IRCSocket
49
- # library.
50
-
51
- register_event :invite, /^\:(.+)\!\~?(.+)\@(.+) INVITE (\S+) :?(.+?)$/i,
52
- :nick, :ident, :host, :target, :channel
53
-
54
- register_event :action, /^\:(.+)\!\~?(.+)\@(.+) PRIVMSG (\S+) :?\001ACTION (.+?)\001$/i,
55
- :nick, :ident, :host, :target, :message
56
-
57
- register_event :ctcp, /^\:(.+)\!\~?(.+)\@(.+) PRIVMSG (\S+) :?\001(.+?)\001$/i,
58
- :nick, :ident, :host, :target, :message
59
-
60
- register_event :message, /^\:(.+)\!\~?(.+)\@(.+) PRIVMSG (\S+) :?(.+?)$/i,
61
- :nick, :ident, :host, :target, :message
62
-
63
- register_event :join, /^\:(.+)\!\~?(.+)\@(.+) JOIN (\S+)/i,
64
- :nick, :ident, :host, :target
65
-
66
- register_event :part, /^\:(.+)\!\~?(.+)\@(.+) PART (\S+)\s?:?(.+?)$/i,
67
- :nick, :ident, :host, :target, :message
68
-
69
- register_event :mode, /^\:(.+)\!\~?(.+)\@(.+) MODE (\S+) :?(.+?)$/i,
70
- :nick, :ident, :host, :target, :mode
71
-
72
- register_event :kick, /^\:(.+)\!\~?(.+)\@(.+) KICK (\S+) (\S+)\s?:?(.+?)$/i,
73
- :nick, :ident, :host, :target, :channel, :reason
74
-
75
- register_event :topic, /^\:(.+)\!\~?(.+)\@(.+) TOPIC (\S+) :?(.+?)$/i,
76
- :nick, :ident, :host, :target, :topic
77
-
78
- register_event :nick, /^\:(.+)\!\~?(.+)\@(.+) NICK :?(.+?)$/i,
79
- :nick, :ident, :host, :new_nick
80
-
81
- register_event :quit, /^\:(.+)\!\~?(.+)\@(.+) QUIT :?(.+?)$/i,
82
- :nick, :ident, :host, :message
83
-
84
- register_event :ping, /^\:(.+)\!\~?(.+)\@(.+) PING (.*)$/,
85
- :nick, :ident, :host, :data
86
-
87
- register_event :ping, /PING (.*)$/, :data
88
-
89
- register_event :numeric, /^\:(\S+) ([0-9]+) (.*)$/,
90
- :server, :code, :data
91
- end
92
- end
93
- end
data/lib/marvin/status.rb DELETED
@@ -1,72 +0,0 @@
1
- module Marvin
2
- class Status
3
- CONTROLLERS = {
4
- :client => "IRC Client",
5
- :server => "IRC Server",
6
- :ring_server => "Ring Server",
7
- :distributed_client => "Distributed Client",
8
- }
9
-
10
- class << self
11
-
12
- def show!
13
- STDOUT.puts ""
14
- STDOUT.puts " Marvin Status"
15
- STDOUT.puts " ============="
16
- STDOUT.puts ""
17
- if ARGV.include?("--help") || ARGV.include?("-h")
18
- STDOUT.puts " Usage: script/status [options]\n\n"
19
- STDOUT.puts " -h, --help Show this message"
20
- STDOUT.puts " -f, --full Include distributed stats"
21
- STDOUT.puts ""
22
- exit
23
- end
24
- pids = {}
25
- CONTROLLERS.each_key { |k| pids[k] = Marvin::Daemon.pids_for_type(k) }
26
- CONTROLLERS.each do |k, v|
27
- count = pids[k].size
28
- postfix = count == 1 ? "" : "s"
29
- STDOUT.puts " #{count} running instance#{postfix} of the #{CONTROLLERS[k]}"
30
- STDOUT.puts " Pid#{postfix}: #{pids[k].join(", ")}" unless count == 0
31
- STDOUT.puts ""
32
- end
33
-
34
- if (ARGV.include?("-f") || ARGV.include?("--full")) && !pids[:ring_server].empty?
35
- require 'rinda/ring'
36
- DRb.start_service
37
- STDOUT.puts " Distributed Status"
38
- STDOUT.puts " ------------------"
39
- begin
40
- rs = Rinda::RingFinger.finger.lookup_ring(3)
41
- STDOUT.puts " Ring Server: #{rs.__drburi}"
42
- items = rs.read_all([:marvin_event, Marvin::Settings.distributed_namespace, nil, nil, nil])
43
- STDOUT.puts " Unprocessed Items: #{items.size}"
44
- STDOUT.puts ""
45
- unless items.empty?
46
- start_time = items.first[3][:dispatched_at]
47
- STDOUT.puts " Earliest Item: #{start_time ? start_time.strftime("%I:%M%p %d/%m/%y") : "Never"}"
48
- end_time = items.last[3][:dispatched_at]
49
- STDOUT.puts " Latest Item: #{end_time ? end_time.strftime("%I:%M%p %d/%m/%y") : "Never"}"
50
- mapping = {}
51
- items.each do |i|
52
- mapping[i[2].inspect] ||= 0
53
- mapping[i[2].inspect] += 1
54
- end
55
- width = mapping.keys.map { |k| k.length }.max
56
- STDOUT.puts ""
57
- STDOUT.puts " Unprocessed Message Counts:"
58
- STDOUT.puts " ---------------------------"
59
- mapping.each { |k, v| STDOUT.puts " #{k.ljust width} => #{v}" }
60
- STDOUT.puts ""
61
- end
62
- rescue
63
- STDOUT.puts " Ring server not found."
64
- STDOUT.puts ""
65
- end
66
- end
67
-
68
- end
69
-
70
- end
71
- end
72
- end
data/script/client DELETED
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require File.join(File.dirname(__FILE__), "..", "config", "boot")
3
- Marvin::Loader.run! :client
data/script/console DELETED
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require File.join(File.dirname(__FILE__), "..", "config", "boot")
3
- Marvin::Loader.run! :console
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require File.join(File.dirname(__FILE__), "..", "config", "boot")
3
- Marvin::Loader.run! :distributed_client
data/script/install DELETED
@@ -1 +0,0 @@
1
- gem uninstall marvin --quiet && rake gemspec && gem build marvin.gemspec && gem install marvin-*.gem
data/script/ring_server DELETED
@@ -1,4 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require File.join(File.dirname(__FILE__), "..", "config", "boot")
3
- Marvin::Loader.run! :ring_server
4
-
data/script/server DELETED
@@ -1,4 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require File.join(File.dirname(__FILE__), "..", "config", "boot")
3
- Marvin::Loader.run! :server
4
-
data/script/status DELETED
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require File.join(File.dirname(__FILE__), "..", "config", "boot")
3
- Marvin::Status.show!
@@ -1,38 +0,0 @@
1
- require File.dirname(__FILE__) + "/../spec_helper"
2
-
3
- # Tests the behaviour of the AbstractClient functionality
4
- # via a thin wrapper of the class via Marvin::TestClient.
5
-
6
- describe "the base Marvin::TestClient functionality" do
7
-
8
- it "should dispatch :client_connected as the first event on process_connect" do
9
- client(true).dispatched_events.should == []
10
- client.process_connect
11
- client.dispatched_events.first.should == [:client_connected, {}]
12
- end
13
-
14
- it "should dispatch :client_connected as the first event on process_connect" do
15
- client(true).dispatched_events.should == []
16
- client.process_connect
17
- Marvin::Logger.info client.outgoing_commands.inspect
18
- client.dispatched_events[-2].first.should == :outgoing_nick
19
- client.dispatched_events[-1].first.should == :outgoing_join
20
- client.outgoing_commands.length.should == 3
21
- client.outgoing_commands[0].should =~ /^USER \w+ 0 \* :\w+ \r\n$/
22
- client.outgoing_commands[1].should =~ /^NICK \w+ \r\n$/
23
- client.outgoing_commands[2].should =~ /^JOIN \#[A-Za-z0-9\-\_]+ \r\n$/
24
- end
25
-
26
- it "should dispatch :client_disconnect on process_disconnect" do
27
- client(true).dispatched_events.should == []
28
- client.process_disconnect
29
- client.dispatched_events.last.should == [:client_disconnected, {}]
30
- end
31
-
32
- it "should add an :incoming_line event for each incoming line" do
33
- client(true).dispatched_events.should == []
34
- client.receive_line "SOME RANDOM LINE THAT HAS ZERO ACTUAL USE"
35
- client.dispatched_events.first.should == [:incoming_line, {:line => "SOME RANDOM LINE THAT HAS ZERO ACTUAL USE"}]
36
- end
37
-
38
- end
data/spec/spec_helper.rb DELETED
@@ -1,14 +0,0 @@
1
- require "rubygems"
2
- require "bacon"
3
-
4
- require File.dirname(__FILE__) + "/../lib/marvin"
5
- # Now, Set everything up.
6
- Marvin::Logger.logger = Logger.new(File.dirname(__FILE__) + "/../log/test.log")
7
- Marvin::Settings.default_client = Marvin::TestClient
8
- Marvin::Loader.run!
9
-
10
- def client(force_new = false)
11
- $test_client = Marvin::TestClient.new if force_new || $test_client.nil?
12
- return $test_client
13
- end
14
-