ircp 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/lib/ircp/message.rb CHANGED
@@ -19,13 +19,18 @@ module Ircp
19
19
  end
20
20
 
21
21
  def to_s
22
- return @raw unless @raw.nil?
22
+ if @raw.nil? || @raw.empty?
23
+ tokens = []
24
+ tokens << @prefix
25
+ tokens << @command
26
+ @params.each { |param| tokens << param }
27
+ msg = tokens.delete_if { |token| token.nil? || token.empty? }.join(' ')
28
+ else
29
+ msg = @raw.to_s
30
+ end
23
31
 
24
- tokens = []
25
- tokens.push @prefix unless @prefix.empty?
26
- tokens.push @command unless @command.nil?
27
- tokens.push *@params
28
- tokens.join ' '
32
+ msg << "\r\n" unless msg.end_with?("\r\n")
33
+ msg
29
34
  end
30
35
  end
31
36
  end
data/lib/ircp/prefix.rb CHANGED
@@ -21,16 +21,18 @@ module Ircp
21
21
  end
22
22
 
23
23
  def to_s
24
- return @raw unless @raw.nil?
25
-
26
- if @servername
27
- ":#{servername}"
24
+ if @raw.nil? || @raw.empty?
25
+ if @servername
26
+ ":#{servername}"
27
+ else
28
+ tokens = []
29
+ tokens << ":#{@nick}" unless @nick.nil?
30
+ tokens << "!#{@user}" unless @user.nil?
31
+ tokens << "@#{@host}" unless @host.nil?
32
+ tokens.join ''
33
+ end
28
34
  else
29
- tokens = []
30
- tokens.push ":#{@nick}" unless @nick.nil?
31
- tokens.push "!#{@user}" unless @user.nil?
32
- tokens.push "@#{@host}" unless @host.nil?
33
- tokens.join ''
35
+ @raw.to_s
34
36
  end
35
37
  end
36
38
  end
data/lib/ircp/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Ircp
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  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: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-02-15 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: treetop
16
- requirement: &12892860 !ruby/object:Gem::Requirement
16
+ requirement: &15966740 !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: *12892860
24
+ version_requirements: *15966740
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rake
27
- requirement: &12892440 !ruby/object:Gem::Requirement
27
+ requirement: &15966320 !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: *12892440
35
+ version_requirements: *15966320
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rspec
38
- requirement: &12892020 !ruby/object:Gem::Requirement
38
+ requirement: &15965900 !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: *12892020
46
+ version_requirements: *15965900
47
47
  description: irc parser
48
48
  email:
49
49
  - mail@mashiro.org