cinch 0.3.5 → 1.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 (82) hide show
  1. data/LICENSE +20 -0
  2. data/README.md +192 -0
  3. data/Rakefile +53 -43
  4. data/examples/basic/autovoice.rb +32 -0
  5. data/examples/basic/google.rb +35 -0
  6. data/examples/basic/hello.rb +15 -0
  7. data/examples/basic/join_part.rb +38 -0
  8. data/examples/basic/memo.rb +39 -0
  9. data/examples/basic/msg.rb +16 -0
  10. data/examples/basic/seen.rb +36 -0
  11. data/examples/basic/urban_dict.rb +35 -0
  12. data/examples/basic/url_shorten.rb +35 -0
  13. data/examples/plugins/autovoice.rb +40 -0
  14. data/examples/plugins/custom_prefix.rb +23 -0
  15. data/examples/plugins/google.rb +37 -0
  16. data/examples/plugins/hello.rb +22 -0
  17. data/examples/plugins/join_part.rb +42 -0
  18. data/examples/plugins/memo.rb +50 -0
  19. data/examples/plugins/msg.rb +22 -0
  20. data/examples/plugins/multiple_matches.rb +41 -0
  21. data/examples/plugins/seen.rb +45 -0
  22. data/examples/plugins/urban_dict.rb +30 -0
  23. data/examples/plugins/url_shorten.rb +32 -0
  24. data/lib/cinch.rb +7 -20
  25. data/lib/cinch/ban.rb +41 -0
  26. data/lib/cinch/bot.rb +479 -0
  27. data/lib/cinch/callback.rb +11 -0
  28. data/lib/cinch/channel.rb +419 -0
  29. data/lib/cinch/constants.rb +369 -0
  30. data/lib/cinch/exceptions.rb +25 -0
  31. data/lib/cinch/helpers.rb +21 -0
  32. data/lib/cinch/irc.rb +344 -38
  33. data/lib/cinch/isupport.rb +96 -0
  34. data/lib/cinch/logger/formatted_logger.rb +80 -0
  35. data/lib/cinch/logger/logger.rb +44 -0
  36. data/lib/cinch/logger/null_logger.rb +18 -0
  37. data/lib/cinch/mask.rb +46 -0
  38. data/lib/cinch/message.rb +183 -0
  39. data/lib/cinch/message_queue.rb +62 -0
  40. data/lib/cinch/plugin.rb +205 -0
  41. data/lib/cinch/rubyext/infinity.rb +1 -0
  42. data/lib/cinch/rubyext/module.rb +18 -0
  43. data/lib/cinch/rubyext/queue.rb +19 -0
  44. data/lib/cinch/rubyext/string.rb +24 -0
  45. data/lib/cinch/syncable.rb +55 -0
  46. data/lib/cinch/user.rb +325 -0
  47. data/spec/bot_spec.rb +5 -0
  48. data/spec/channel_spec.rb +5 -0
  49. data/spec/cinch_spec.rb +5 -0
  50. data/spec/irc_spec.rb +5 -0
  51. data/spec/message_spec.rb +5 -0
  52. data/spec/plugin_spec.rb +5 -0
  53. data/spec/{helper.rb → spec_helper.rb} +0 -0
  54. data/spec/user_spec.rb +5 -0
  55. metadata +69 -51
  56. data/README.rdoc +0 -195
  57. data/examples/autovoice.rb +0 -32
  58. data/examples/custom_patterns.rb +0 -19
  59. data/examples/custom_prefix.rb +0 -25
  60. data/examples/google.rb +0 -31
  61. data/examples/hello.rb +0 -13
  62. data/examples/join_part.rb +0 -26
  63. data/examples/memo.rb +0 -40
  64. data/examples/msg.rb +0 -14
  65. data/examples/named-param-types.rb +0 -19
  66. data/examples/seen.rb +0 -41
  67. data/examples/urban_dict.rb +0 -31
  68. data/examples/url_shorten.rb +0 -34
  69. data/lib/cinch/base.rb +0 -368
  70. data/lib/cinch/irc/message.rb +0 -135
  71. data/lib/cinch/irc/parser.rb +0 -141
  72. data/lib/cinch/irc/socket.rb +0 -329
  73. data/lib/cinch/names.rb +0 -54
  74. data/lib/cinch/rules.rb +0 -171
  75. data/spec/base_spec.rb +0 -94
  76. data/spec/irc/helper.rb +0 -8
  77. data/spec/irc/message_spec.rb +0 -61
  78. data/spec/irc/parser_spec.rb +0 -103
  79. data/spec/irc/socket_spec.rb +0 -90
  80. data/spec/names_spec.rb +0 -393
  81. data/spec/options_spec.rb +0 -45
  82. data/spec/rules_spec.rb +0 -109
@@ -1,45 +0,0 @@
1
- require File.dirname(__FILE__) + '/helper'
2
-
3
- describe "Cinch::Base options" do
4
- before do
5
- @base = Cinch::Base
6
- end
7
-
8
- it "should set options via a hash" do
9
- base = @base.new(:server => 'irc.foobar.org')
10
- base.options.server.should == "irc.foobar.org"
11
- end
12
-
13
- it "should set options via a block" do
14
- base = @base.new do
15
- server "irc.foobar.org"
16
- end
17
- base.options.server.should == "irc.foobar.org"
18
- end
19
-
20
- it "should set options via setters" do
21
- base = @base.new
22
- base.options.server = "irc.foobar.org"
23
- base.options.server.should == "irc.foobar.org"
24
- end
25
-
26
- it "should set specific default values" do
27
- defaults = {
28
- :port => 6667,
29
- :nick => 'Cinch',
30
- :nick_suffix => '_',
31
- :username => 'cinch',
32
- :realname => 'Cinch IRC Bot Building Framework',
33
- :usermode => 0,
34
- :prefix => '!',
35
- :password => nil,
36
- }
37
-
38
- base = @base.new
39
- defaults.each do |k, v|
40
- base.options.send(k).should == v
41
- end
42
- end
43
-
44
- end
45
-
@@ -1,109 +0,0 @@
1
- require File.dirname(__FILE__) + '/helper'
2
-
3
- describe "Cinch::Rules" do
4
- before do
5
- @rules = Cinch::Rules.new
6
- @rules.add_rule('foo', [], {}, Proc.new{})
7
- end
8
-
9
- describe "::new" do
10
- it "should define an empty set of rules" do
11
- Cinch::Rules.new.empty?.should == true
12
- end
13
- end
14
-
15
- describe "#add_rule" do
16
- it "should add a new rule" do
17
- @rules.add_rule('bar', [], {}, Proc.new{})
18
- @rules.all.should include 'foo'
19
- end
20
-
21
- it "should replace an existing rule" do
22
- @rules.add_rule('foo', [], {}, Proc.new{})
23
- @rules.count.should == 1
24
- end
25
- end
26
-
27
- describe "#get_rule" do
28
- it "should return a Cinch::Rule" do
29
- @rules.get_rule('foo').should be_kind_of Cinch::Rule
30
- end
31
- end
32
-
33
- describe "#remove_rule" do
34
- it "should remove a rule" do
35
- @rules.remove_rule('foo')
36
- @rules.include?('foo').should == false
37
- @rules.count.should == 0
38
- end
39
- end
40
-
41
- describe "#add_callback" do
42
- it "should add a callback for a rule" do
43
- @rules.add_callback('foo', Proc.new{})
44
- rule = @rules.get_rule('foo')
45
- rule.callbacks.size.should == 2
46
- end
47
- end
48
-
49
- describe "#add_option" do
50
- it "should add an option for a rule" do
51
- @rules.add_option('foo', :nick, 'injekt')
52
- rule = @rules.get('foo')
53
- rule.options.should include :nick
54
- rule.options[:nick].should == 'injekt'
55
- end
56
- end
57
-
58
- describe "#merge_options" do
59
- it "should merge rule options" do
60
- @rules.merge_options('foo', {:bar => 'baz'})
61
- rule = @rules['foo']
62
- rule.options.should == {:bar => 'baz'}
63
- end
64
- end
65
-
66
- describe "#include?" do
67
- it "should check if a rule exists" do
68
- @rules.include?('foo').should == true
69
- end
70
- end
71
-
72
- describe "#clear" do
73
- it "should clear all rules" do
74
- @rules.clear
75
- @rules.empty?.should == true
76
- end
77
- end
78
-
79
- describe "#empty?" do
80
- it "should check if any rules exist" do
81
- @rules.empty?.should == false
82
- @rules.clear
83
- @rules.empty?.should == true
84
- end
85
- end
86
-
87
- describe "#count" do
88
- it "should show how many rules exist" do
89
- @rules.count.should == 1
90
- @rules.add_rule('bar', [], {}, Proc.new{})
91
- @rules.count.should == 2
92
- end
93
- end
94
-
95
- describe "#all" do
96
- it "should return a Hash of all rules" do
97
- @rules.all.should be_kind_of Hash
98
- @rules.all.should include 'foo'
99
- end
100
- end
101
-
102
- describe "#to_a" do
103
- it "should return an Array of rules" do
104
- @rules.to_a.should be_kind_of Array
105
- @rules.to_a.include?('foo').should == true
106
- end
107
- end
108
- end
109
-