ircsupport 0.1.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.
@@ -0,0 +1,34 @@
1
+ # coding: utf-8
2
+
3
+ require 'test_helper'
4
+
5
+ include IRCSupport::Modes
6
+
7
+ describe "Modelines" do
8
+ it "should condense the mode line" do
9
+ condense_modes('+o-v-o-o+v-o+o+o').must_equal '+o-voo+v-o+oo'
10
+ end
11
+
12
+ it "should generate the mode changes" do
13
+ diff_modes('ailowz','i').must_equal '-alowz'
14
+ diff_modes('i','ailowz').must_equal '+alowz'
15
+ diff_modes('i','alowz').must_equal '-i+alowz'
16
+ end
17
+
18
+ it "should parse the modes" do
19
+ parse_modes('+i-m').must_equal [
20
+ { set: true, mode: 'i' },
21
+ { set: false, mode: 'm' },
22
+ ]
23
+ parse_channel_modes(['+i+k+l', 'secret', '5']).must_equal [
24
+ { set: true, mode: 'i' },
25
+ { set: true, mode: 'k', argument: 'secret' },
26
+ { set: true, mode: 'l', argument: 5 },
27
+ ]
28
+ end
29
+
30
+ it "should fail to parse the modes" do
31
+ proc { parse_channel_modes('+i-_')}.must_raise ArgumentError
32
+ end
33
+ end
34
+
@@ -0,0 +1,14 @@
1
+ # coding: utf-8
2
+
3
+ require 'test_helper'
4
+
5
+ include IRCSupport::Numerics
6
+
7
+ describe "Numerics" do
8
+ it "should recognize numeric 001" do
9
+ numeric_to_name('001').must_equal 'RPL_WELCOME'
10
+ end
11
+ it "should recognize command" do
12
+ name_to_numeric('RPL_WELCOME').must_equal '001'
13
+ end
14
+ end
@@ -0,0 +1,55 @@
1
+ # coding: utf-8
2
+
3
+ require 'test_helper'
4
+
5
+ describe "Parse" do
6
+ parser = IRCSupport::Parser.new
7
+ raw_line = ":pretend.dancer.server 005 CPAN MODES=4 CHANLIMIT=#:20 NICKLEN=16 USERLEN=10 HOSTLEN=63 TOPICLEN=450 KICKLEN=450 CHANNELLEN=30 KEYLEN=23 CHANTYPES=# PREFIX=(ov)@+ CASEMAPPING=ascii CAPAB IRCD=dancer :are available on this server"
8
+ result = parser.decompose_line(raw_line)
9
+ it "should parse the server message" do
10
+ result[:prefix].must_equal "pretend.dancer.server"
11
+ result[:command].must_equal "005"
12
+ result[:args].count.must_equal 16
13
+ result[:args][0].must_equal "CPAN"
14
+ result[:args][15].must_equal "are available on this server"
15
+ parser.isupport["MODES"].must_equal 4
16
+ end
17
+
18
+ it "should compose the server message" do
19
+ irc_line = parser.compose_line(result)
20
+ irc_line.must_equal raw_line
21
+ end
22
+
23
+ it "should fail to compose the server message" do
24
+ proc { parser.compose_line({}) }.must_raise ArgumentError
25
+ proc { parser.compose_line({ prefix: "foo" }) }.must_raise ArgumentError
26
+ proc { parser.compose_line({ command: "bar", args: ['a b', 'c'] }) }.must_raise ArgumentError
27
+ end
28
+
29
+ it "should fail to decompoes the IRC line" do
30
+ proc { parser.parse("+") }.must_raise ArgumentError
31
+ end
32
+ end
33
+
34
+ describe "CTCP" do
35
+ parser = IRCSupport::Parser.new
36
+ it "should quote the CTCP message" do
37
+ parser.ctcp_quote('ACTION', 'dances').must_equal "\x01ACTION dances\x01"
38
+ end
39
+
40
+ it "should fail to parse the CTCP message" do
41
+ invalid = ":literal!hinrik@w.nix.is PRIVMSG #foo4321 :\x01..,, dsfdsfsdfds\x01"
42
+ proc { parser.parse(invalid) }.must_output nil, "Received malformed CTCP from literal!hinrik@w.nix.is: ..,, dsfdsfsdfds\n"
43
+ end
44
+
45
+ it "should fail to parse the DCC request" do
46
+ invalid = ":literal!hinrik@w.nix.is PRIVMSG #foo4321 :\x01DCC ..,,\x01"
47
+ proc { parser.parse(invalid) }.must_output nil, "Received malformed DCC request from literal!hinrik@w.nix.is: DCC ..,,\n"
48
+ end
49
+
50
+ it "should handle unbalanced NULs" do
51
+ unbalanced = ":literal!hinrik@w.nix.is PRIVMSG #foo4321 :\x01ACTIOn jumps\x01foo\x01"
52
+ msg = parser.parse(unbalanced)
53
+ msg.message.must_equal 'jumps'
54
+ end
55
+ end
@@ -0,0 +1,8 @@
1
+ # https://github.com/rubinius/rubinius/issues/1575
2
+ if RUBY_ENGINE != "rbx"
3
+ require 'simplecov'
4
+
5
+ SimpleCov.start do
6
+ add_filter "/test/"
7
+ end
8
+ end
@@ -0,0 +1,5 @@
1
+ require 'turn/autorun'
2
+ require 'minitest/spec'
3
+ require 'ircsupport'
4
+
5
+ Turn.config.format = :dot
@@ -0,0 +1,35 @@
1
+ # coding: utf-8
2
+
3
+ require 'test_helper'
4
+
5
+ include IRCSupport::Validations
6
+
7
+ describe "ValidNickname" do
8
+ it "should say the nick is valid" do
9
+ valid_nickname?("foobar[^]").must_equal true
10
+ valid_nickname?("Foobar^1").must_equal true
11
+ valid_nickname?("Fo{}o[]ba\\r-^1").must_equal true
12
+ end
13
+ it "should say the nick is invalid" do
14
+ valid_nickname?("foobar[=]").must_equal false
15
+ valid_nickname?("0Foobar^1").must_equal false
16
+ end
17
+ end
18
+
19
+ describe "ValidChannelName" do
20
+ it "should say the channel is valid" do
21
+ valid_channel_name?("#fooBARæði123...iii").must_equal true
22
+ valid_channel_name?("#foobar").must_equal true
23
+ valid_channel_name?("#foo.bar").must_equal true
24
+ valid_channel_name?("&foobar").must_equal true
25
+ valid_channel_name?("-foobar", [ :- ]).must_equal true
26
+ end
27
+ it "should say the channel is invalid" do
28
+ valid_channel_name?("#foo,bar").must_equal false
29
+ valid_channel_name?("dfdsfdsf").must_equal false
30
+ valid_channel_name?("-dfdsfdsf").must_equal false
31
+ valid_channel_name?("#foobar", [ :k ]).must_equal false
32
+ valid_channel_name?("#chan"+"f"*200).must_equal false
33
+ end
34
+ end
35
+
metadata ADDED
@@ -0,0 +1,143 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ircsupport
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Hinrik Örn Sigurðsson
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-04-23 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rake
16
+ requirement: &23821140 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: *23821140
25
+ - !ruby/object:Gem::Dependency
26
+ name: simplecov
27
+ requirement: &23820680 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *23820680
36
+ - !ruby/object:Gem::Dependency
37
+ name: yard
38
+ requirement: &23820080 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: 0.7.5
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *23820080
47
+ - !ruby/object:Gem::Dependency
48
+ name: minitest
49
+ requirement: &23819520 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: 2.11.4
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: *23819520
58
+ - !ruby/object:Gem::Dependency
59
+ name: turn
60
+ requirement: &23819080 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ type: :development
67
+ prerelease: false
68
+ version_requirements: *23819080
69
+ description: IRCSupport provides tools for dealing with the IRC protocol.
70
+ email:
71
+ - hinrik.sig@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - .gitignore
77
+ - .travis.yml
78
+ - CHANGES.md
79
+ - Gemfile
80
+ - LICENSE.txt
81
+ - README.md
82
+ - Rakefile
83
+ - ircsupport.gemspec
84
+ - lib/ircsupport.rb
85
+ - lib/ircsupport/case.rb
86
+ - lib/ircsupport/encoding.rb
87
+ - lib/ircsupport/formatting.rb
88
+ - lib/ircsupport/masks.rb
89
+ - lib/ircsupport/message.rb
90
+ - lib/ircsupport/modes.rb
91
+ - lib/ircsupport/numerics.rb
92
+ - lib/ircsupport/parser.rb
93
+ - lib/ircsupport/validations.rb
94
+ - lib/ircsupport/version.rb
95
+ - test/case_test.rb
96
+ - test/encoding_test.rb
97
+ - test/formatting_test.rb
98
+ - test/masks_test.rb
99
+ - test/message_test.rb
100
+ - test/modes_test.rb
101
+ - test/numerics_test.rb
102
+ - test/parser_test.rb
103
+ - test/test_coverage.rb
104
+ - test/test_helper.rb
105
+ - test/validations_test.rb
106
+ homepage: https://github.com/hinrik/ircsupport
107
+ licenses:
108
+ - MIT
109
+ post_install_message:
110
+ rdoc_options: []
111
+ require_paths:
112
+ - lib
113
+ required_ruby_version: !ruby/object:Gem::Requirement
114
+ none: false
115
+ requirements:
116
+ - - ! '>='
117
+ - !ruby/object:Gem::Version
118
+ version: 1.9.1
119
+ required_rubygems_version: !ruby/object:Gem::Requirement
120
+ none: false
121
+ requirements:
122
+ - - ! '>='
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ requirements: []
126
+ rubyforge_project:
127
+ rubygems_version: 1.8.10
128
+ signing_key:
129
+ specification_version: 3
130
+ summary: An IRC protocol library
131
+ test_files:
132
+ - test/case_test.rb
133
+ - test/encoding_test.rb
134
+ - test/formatting_test.rb
135
+ - test/masks_test.rb
136
+ - test/message_test.rb
137
+ - test/modes_test.rb
138
+ - test/numerics_test.rb
139
+ - test/parser_test.rb
140
+ - test/test_coverage.rb
141
+ - test/test_helper.rb
142
+ - test/validations_test.rb
143
+ has_rdoc: yard