xrc 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b31b9a7b49a61d43f5f8c53d425021824e57373d
4
- data.tar.gz: e83f49bd09cdf177462a15b1aeb3dd195f8109c7
3
+ metadata.gz: 6952d0813b9d1b9159181d4d8532b7b556c8a7a7
4
+ data.tar.gz: e32e5ac214c774fee8faf60f14a47233febf2745
5
5
  SHA512:
6
- metadata.gz: f5b135b98116a4e5cfdfac6df4ba5e0572af92ffce209fb19215cffd87535e2ff50074fbe0ce45eee32c99d97f576b759ea2297fa451ac5f180c3ef723cded08
7
- data.tar.gz: 29a72be6d8bce6544e823bc29bfae05485c5bd74663b4af5abecd22f47444c767221860366b98e102850ed73ff83f3bbaad2a74c978afa45a25878b1292cebe9
6
+ metadata.gz: cbeaea3dd1cc0676183945d0b223983c7079d3619fc4780920b30a5447b4a2da869a1f68e067db8521ea7f7ad7d69c1c56b309081a4f3e7296d20d8babd17519
7
+ data.tar.gz: 728fd2d5273d1b3396a451e7e5be53e2619211a148e749c6cce29d3e0994eecfd9f2dfe6462081d892edf565762a831226249c82de75682813b88f28659afc85
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## 0.0.5
2
+ * Add attr_writer for Xrc::Jid's attributes
3
+
1
4
  ## 0.0.4
2
5
  * Unescape HTML entities in message body
3
6
 
data/lib/xrc/jid.rb CHANGED
@@ -2,34 +2,45 @@ module Xrc
2
2
  class Jid
3
3
  PATTERN = /\A(?:([^@]*)@)??([^@\/]*)(?:\/(.*?))?\z/
4
4
 
5
+ attr_writer :node, :domain, :resource
6
+
5
7
  attr_reader :raw
6
8
 
9
+ # @param [String] raw Jabber ID
10
+ # @example
11
+ # Xrc::Jid.new("alice@example.com/bot")
7
12
  def initialize(raw)
8
13
  @raw = raw
9
14
  end
10
15
 
16
+ # @return [String] Node section (e.g. alice in alice@example.com/bot)
11
17
  def node
12
- sections[0]
18
+ @node ||= sections[0]
13
19
  end
14
20
 
21
+ # @return [String] Domain section (e.g. example.com in alice@example.com/bot)
15
22
  def domain
16
- sections[1]
23
+ @domain ||= sections[1]
17
24
  end
18
25
 
26
+ # @return [String, nil] Resource section, which can be omitted (e.g. bot in alice@example.com/bot)
19
27
  def resource
20
- sections[2]
28
+ @resource ||= sections[2]
21
29
  end
22
30
 
31
+ # @return [String] Jabber ID without resource section
23
32
  def strip
24
33
  "#{node}@#{domain}"
25
34
  end
26
35
 
36
+ # @return [String] Jabber ID, including resource section if any
27
37
  def to_s
28
38
  str = strip
29
39
  str << "/#{resource}" if resource
30
40
  str
31
41
  end
32
42
 
43
+ # @return [true, false] True if given Jabber ID is same with self Jabber ID
33
44
  def ==(jid)
34
45
  jid = Jid.new(jid) unless jid.is_a?(Jid)
35
46
  to_s == jid.to_s || strip == jid.strip
data/lib/xrc/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Xrc
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xrc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryo Nakamura
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-13 00:00:00.000000000 Z
11
+ date: 2014-05-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport