zircon 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -23,5 +23,13 @@ client.on_privmsg do |message|
23
23
  client.privmsg "#chatroid", ":zircon!"
24
24
  end
25
25
 
26
+ client.on_message do |message|
27
+ puts "*** `on_message` responds with all received message ***"
28
+ puts message.from
29
+ puts message.to
30
+ puts message.type
31
+ puts message.body
32
+ end
33
+
26
34
  client.run!
27
35
  ```
@@ -2,7 +2,7 @@ require "zircon/message/patterns"
2
2
 
3
3
  class Zircon
4
4
  class Message
5
- attr_reader :prefix, :command, :text
5
+ attr_reader :prefix, :command, :raw
6
6
 
7
7
  def initialize(text)
8
8
  if match = Patterns::MESSAGE_PATTERN.match(text)
@@ -11,7 +11,7 @@ class Zircon
11
11
  @command = match[2]
12
12
  @rest = match[3..-1]
13
13
  else
14
- raise ArgumentError.new("Invalid message")
14
+ raise ArgumentError.new("Invalid message: #{text}")
15
15
  end
16
16
  end
17
17
 
@@ -19,20 +19,28 @@ class Zircon
19
19
  @type ||= @command.to_s.downcase
20
20
  end
21
21
 
22
- def name
23
- @name ||= begin
22
+ def from
23
+ @from ||= begin
24
24
  @prefix && @prefix.split("!").first
25
25
  end
26
26
  end
27
27
 
28
+ def to
29
+ params[0]
30
+ end
31
+
32
+ def body
33
+ params[1]
34
+ end
35
+
28
36
  def params
29
37
  @params ||= begin
30
38
  params = []
31
39
  case
32
- when !@rest[0].blank?
40
+ when !@rest[0].empty?
33
41
  middle, trailer, = *@rest
34
42
  params = middle.split(" ")
35
- when !@rest[2].blank?
43
+ when !@rest[2].empty?
36
44
  middle, trailer, = *@rest[2, 2]
37
45
  params = middle.split(" ")
38
46
  when @rest[1]
@@ -1,3 +1,3 @@
1
1
  class Zircon
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: zircon
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:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-22 00:00:00.000000000 Z
12
+ date: 2012-09-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &70105687233900 !ruby/object:Gem::Requirement
16
+ requirement: &70119351145400 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70105687233900
24
+ version_requirements: *70119351145400
25
25
  description: Zircon is a mineral belonging to the group of nesosilicates.
26
26
  email:
27
27
  - r7kamura@gmail.com