Sutto-marvin 0.1.0.20081014

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.
@@ -0,0 +1,60 @@
1
+ require 'ostruct'
2
+ require 'active_support'
3
+
4
+ module Marvin
5
+ # Marvin::TestClient is a simple client used for testing
6
+ # Marvin::Base derivatives in a non-network-reliant setting.
7
+ class TestClient < AbstractClient
8
+ attr_accessor :incoming_commands, :outgoing_commands, :last_sent, :dispatched_events, :connection_open
9
+
10
+ cattr_accessor :instances
11
+ self.instances = []
12
+
13
+ DispatchedEvents = Struct.new(:name, :options)
14
+
15
+ def initialize
16
+ super
17
+ self.incoming_commands = []
18
+ self.outgoing_commands = []
19
+ self.dispatched_events = []
20
+ self.connection_open = false
21
+ self.instances << self
22
+ end
23
+
24
+ def connection_open?
25
+ self.connection_open
26
+ end
27
+
28
+ def send_line(*args)
29
+ self.outgoing_commands += args
30
+ self.last_sent = args.last
31
+ end
32
+
33
+ def test_command(name, *args)
34
+ options = args.extract_options!
35
+ host_mask = options.delete(:host_mask) || ":WiZ!jto@tolsun.oulu.fi"
36
+ name = name.to_s.upcase
37
+ args = args.flatten.compact
38
+ irc_command = "#{host_mask} #{name} #{args.join(" ").strip}"
39
+ self.receive_line irc_command
40
+ end
41
+
42
+ def dispatch_event(name, opts = {})
43
+ self.dispatched_events << [name, opts]
44
+ super(name, opts = {})
45
+ end
46
+
47
+ def self.run
48
+ self.instances.each do |i|
49
+ i.connection_open = true
50
+ end
51
+ end
52
+
53
+ def self.stop
54
+ self.instances.each do |i|
55
+ i.connection_open = false
56
+ end
57
+ end
58
+
59
+ end
60
+ end
@@ -0,0 +1,30 @@
1
+ module Marvin
2
+ class Util
3
+ class << self
4
+
5
+ # Return the channel-name version of a string by
6
+ # appending "#" to the front if it doesn't already
7
+ # start with it.
8
+ def channel_name(name)
9
+ return name.to_s[0..0] == "#" ? name.to_s : "##{name}"
10
+ end
11
+ alias chan channel_name
12
+
13
+ def arguments(input)
14
+ prefix, *ending = input.split(":")
15
+ prefix = prefix.split(" ")
16
+ prefix << ending.join(":").strip
17
+ return prefix
18
+ end
19
+
20
+ # Specifies the last parameter of a response, used to
21
+ # specify parameters which have spaces etc (for example,
22
+ # the actual message part of a response).
23
+ def last_param(section)
24
+ section && ":#{section.to_s.strip} "
25
+ end
26
+ alias lp last_param
27
+
28
+ end
29
+ end
30
+ end
data/lib/marvin.rb ADDED
@@ -0,0 +1,33 @@
1
+ $:.unshift File.dirname(__FILE__) # Append the current working dir to the front of the line.
2
+
3
+ require 'rubygems'
4
+ require 'active_support'
5
+ require 'marvin/core_ext'
6
+
7
+ # Make all exceptions available
8
+ require 'marvin/exceptions'
9
+
10
+ module Marvin
11
+ autoload :Util, 'marvin/util'
12
+ autoload :AbstractClient, 'marvin/abstract_client'
13
+ autoload :Base, 'marvin/base'
14
+ autoload :ClientMixin, 'marvin/client_mixin'
15
+ autoload :Settings, 'marvin/settings'
16
+ autoload :Logger, 'marvin/logger'
17
+ autoload :IRC, 'marvin/irc'
18
+ autoload :TestClient, 'marvin/test_client'
19
+ autoload :Loader, 'marvin/loader'
20
+ autoload :MiddleMan, 'marvin/middle_man'
21
+ autoload :DRBHandler, 'marvin/drb_handler'
22
+ autoload :DataStore, 'marvin/data_store'
23
+ autoload :ExceptionTracker, 'marvin/exception_tracker'
24
+ # Parsers
25
+ autoload :AbstractParser, 'marvin/abstract_parser'
26
+ autoload :Parsers, 'marvin/parsers.rb'
27
+
28
+ # Default Handlers
29
+ autoload :CommandHandler, 'marvin/command_handler'
30
+
31
+ Settings.setup # Load Settings etc.
32
+
33
+ end
data/script/run ADDED
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env ruby
2
+ require 'rubygems'
3
+ # Set the root of Marvin
4
+
5
+ if File.exist?(File.dirname(__FILE__) + "/../lib/marvin.rb")
6
+ $:.unshift(File.dirname(__FILE__) + "/../lib/")
7
+ end
8
+
9
+ MARVIN_ROOT = File.join(File.dirname(__FILE__), "..")
10
+ # And Require Marvin.
11
+ require 'marvin'
12
+
13
+ trap "SIGINT" do
14
+ Marvin::Loader.stop!
15
+ exit
16
+ end
17
+
18
+ Marvin::Loader.run!
metadata ADDED
@@ -0,0 +1,85 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: Sutto-marvin
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0.20081014
5
+ platform: ruby
6
+ authors:
7
+ - Darcy Laycock
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-08-05 00:00:00 -07:00
13
+ default_executable: marvin
14
+ dependencies: []
15
+
16
+ description: Marvin is a Ruby IRC library / framework for ultimate awesomeness and with an evented design.
17
+ email: sutto@sutto.net
18
+ executables:
19
+ - marvin
20
+ extensions: []
21
+
22
+ extra_rdoc_files: []
23
+
24
+ files:
25
+ - lib/marvin
26
+ - lib/marvin/abstract_client.rb
27
+ - lib/marvin/base.rb
28
+ - lib/marvin/command_handler.rb
29
+ - lib/marvin/core_ext.rb
30
+ - lib/marvin/data_store.rb
31
+ - lib/marvin/drb_handler.rb
32
+ - lib/marvin/exception_tracker.rb
33
+ - lib/marvin/exceptions.rb
34
+ - lib/marvin/irc
35
+ - lib/marvin/irc/client.rb
36
+ - lib/marvin/irc/event.rb
37
+ - lib/marvin/irc/socket_client.rb
38
+ - lib/marvin/irc.rb
39
+ - lib/marvin/loader.rb
40
+ - lib/marvin/logger.rb
41
+ - lib/marvin/middle_man.rb
42
+ - lib/marvin/settings.rb
43
+ - lib/marvin/test_client.rb
44
+ - lib/marvin/util.rb
45
+ - lib/marvin.rb
46
+ - bin/marvin
47
+ - config/settings.yml
48
+ - config/settings.yml.sample
49
+ - config/setup.rb
50
+ - handlers/hello_world.rb
51
+ - handlers/logging_handler.rb
52
+ - handlers/tweet_tweet.rb
53
+ - script/run
54
+ - lib/marvin/parsers/regexp_parser.rb
55
+ - lib/marvin/parsers.rb
56
+ - lib/marvin/irc/abstract_server.rb
57
+ - lib/marvin/abstract_parser.rb
58
+ has_rdoc: true
59
+ homepage: http://github.com/sutto/marvin
60
+ post_install_message:
61
+ rdoc_options: []
62
+
63
+ require_paths:
64
+ - lib
65
+ required_ruby_version: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: "0"
70
+ version:
71
+ required_rubygems_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: "0"
76
+ version:
77
+ requirements:
78
+ - install the eventmachine gem to get better client support
79
+ rubyforge_project:
80
+ rubygems_version: 1.2.0
81
+ signing_key:
82
+ specification_version: 2
83
+ summary: Ruby IRC Library / Framework
84
+ test_files: []
85
+