ircp 1.0.0 → 1.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.
- data/.gitignore +1 -0
- data/lib/ircp/message.rb +1 -1
- data/lib/ircp/version.rb +1 -1
- data/spec/ircp/message_spec.rb +31 -0
- data/spec/ircp/parser_spec.rb +0 -24
- data/spec/ircp/prefix_spec.rb +33 -0
- data/spec/support/shared_helpers.rb +29 -0
- metadata +11 -8
data/.gitignore
CHANGED
data/lib/ircp/message.rb
CHANGED
data/lib/ircp/version.rb
CHANGED
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Ircp::Message do
|
4
|
+
describe '#initialize' do
|
5
|
+
context 'with args' do
|
6
|
+
include_context 'initialize message', 'secretpasswordhere', :command => 'PASS'
|
7
|
+
its(:command) { should eq 'PASS' }
|
8
|
+
it_should_behave_like 'prefix for', nil
|
9
|
+
it_should_behave_like 'params for', 'secretpasswordhere'
|
10
|
+
end
|
11
|
+
|
12
|
+
context 'with params' do
|
13
|
+
include_context 'initialize message', :command => 'PASS', :params => ['secretpasswordhere']
|
14
|
+
its(:command) { should eq 'PASS' }
|
15
|
+
it_should_behave_like 'prefix for', nil
|
16
|
+
it_should_behave_like 'params for', 'secretpasswordhere'
|
17
|
+
end
|
18
|
+
|
19
|
+
context 'with args and params' do
|
20
|
+
include_context 'initialize message', 'foo', :command => 'PRIVMSG', :params => ['hello']
|
21
|
+
its(:command) { should eq 'PRIVMSG' }
|
22
|
+
it_should_behave_like 'prefix for', nil
|
23
|
+
it_should_behave_like 'params for', 'foo', 'hello'
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe '#to_s' do
|
28
|
+
include_context 'initialize message', :command => 'TEST', :params => ['foo', 'bar', 'buzz']
|
29
|
+
its(:to_s) { should eq "TEST foo bar buzz\r\n" }
|
30
|
+
end
|
31
|
+
end
|
data/spec/ircp/parser_spec.rb
CHANGED
@@ -1,29 +1,5 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
shared_context 'parse text' do |text|
|
4
|
-
before { @result = Ircp.parse(text) }
|
5
|
-
subject { @result }
|
6
|
-
let(:result) { @result }
|
7
|
-
end
|
8
|
-
|
9
|
-
shared_examples_for 'prefix for' do |options|
|
10
|
-
subject { result.prefix }
|
11
|
-
if options.nil?
|
12
|
-
it { should be_nil }
|
13
|
-
else
|
14
|
-
options.each do |key, value|
|
15
|
-
its(key) { should eq value }
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
shared_examples_for 'params for' do |*args|
|
21
|
-
subject { result.params }
|
22
|
-
args.each.with_index do |arg, index|
|
23
|
-
its([index]) { should eq arg }
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
3
|
describe Ircp::Parser do
|
28
4
|
describe '#parse' do
|
29
5
|
context 'PASS secretpasswordhere' do
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Ircp::Prefix do
|
4
|
+
describe '#initialize' do
|
5
|
+
context 'with servername' do
|
6
|
+
before { @prefix = Ircp::Prefix.new(:servername => 'example.com') }
|
7
|
+
subject { @prefix }
|
8
|
+
its(:servername) { should eq 'example.com' }
|
9
|
+
end
|
10
|
+
|
11
|
+
context 'with nick, user and host' do
|
12
|
+
before { @prefix = Ircp::Prefix.new(:nick => 'foo', :user => 'bar', :host => 'example.com') }
|
13
|
+
subject { @prefix }
|
14
|
+
its(:nick) { should eq 'foo' }
|
15
|
+
its(:user) { should eq 'bar' }
|
16
|
+
its(:host) { should eq 'example.com' }
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe '#to_s' do
|
21
|
+
context 'with servername' do
|
22
|
+
before { @prefix = Ircp::Prefix.new(:servername => 'example.com') }
|
23
|
+
subject { @prefix }
|
24
|
+
its(:to_s) { should eq ':example.com' }
|
25
|
+
end
|
26
|
+
|
27
|
+
context 'with nick, user and host' do
|
28
|
+
before { @prefix = Ircp::Prefix.new(:nick => 'foo', :user => 'bar', :host => 'example.com') }
|
29
|
+
subject { @prefix }
|
30
|
+
its(:to_s) { should eq ':foo!bar@example.com' }
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
shared_context 'parse text' do |text|
|
2
|
+
before { @result = Ircp.parse(text) }
|
3
|
+
subject { @result }
|
4
|
+
let(:result) { @result }
|
5
|
+
end
|
6
|
+
|
7
|
+
shared_context 'initialize message' do |*args|
|
8
|
+
before { @result = Ircp::Message.new(*args) }
|
9
|
+
subject { @result }
|
10
|
+
let(:result) { @result }
|
11
|
+
end
|
12
|
+
|
13
|
+
shared_examples_for 'prefix for' do |options|
|
14
|
+
subject { result.prefix }
|
15
|
+
if options.nil?
|
16
|
+
it { should be_nil }
|
17
|
+
else
|
18
|
+
options.each do |key, value|
|
19
|
+
its(key) { should eq value }
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
shared_examples_for 'params for' do |*args|
|
25
|
+
subject { result.params }
|
26
|
+
args.each.with_index do |arg, index|
|
27
|
+
its([index]) { should eq arg }
|
28
|
+
end
|
29
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ircp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-02
|
12
|
+
date: 2012-03-02 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: treetop
|
16
|
-
requirement: &
|
16
|
+
requirement: &22104100 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *22104100
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rake
|
27
|
-
requirement: &
|
27
|
+
requirement: &22103640 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *22103640
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rspec
|
38
|
-
requirement: &
|
38
|
+
requirement: &22063060 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *22063060
|
47
47
|
description: IRC minimal parser
|
48
48
|
email:
|
49
49
|
- mail@mashiro.org
|
@@ -65,8 +65,11 @@ files:
|
|
65
65
|
- lib/ircp/parser/message_node_classes.rb
|
66
66
|
- lib/ircp/prefix.rb
|
67
67
|
- lib/ircp/version.rb
|
68
|
+
- spec/ircp/message_spec.rb
|
68
69
|
- spec/ircp/parser_spec.rb
|
70
|
+
- spec/ircp/prefix_spec.rb
|
69
71
|
- spec/spec_helper.rb
|
72
|
+
- spec/support/shared_helpers.rb
|
70
73
|
homepage: https://github.com/mashiro/ircp-ruby
|
71
74
|
licenses: []
|
72
75
|
post_install_message:
|