weechat 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +8 -0
- data/Rakefile +1 -1
- data/TODO +1 -1
- data/lib/weechat.rb +1 -1
- data/lib/weechat/channel.rb +2 -5
- data/lib/weechat/infolist.rb +31 -57
- data/lib/weechat/properties.rb +5 -4
- metadata +1 -1
data/ChangeLog
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
2009-12-24 Dominik Honnef <dominikho@gmx.net>
|
2
2
|
|
3
|
+
* lib/weechat.rb (Weechat): bumped version to 0.0.4
|
4
|
+
|
5
|
+
* lib/weechat/properties.rb (Weechat::Properties::InstanceMethods#get_infolist)
|
6
|
+
(Weechat::Properties::InstanceMethods#get_infolist_property)
|
7
|
+
(Weechat::Properties::InstanceMethods#valid_property): more specific infolist querying; performance tweaks
|
8
|
+
* lib/weechat/infolist.rb (Weechat::Infolist.parse): more specific infolist querying; performance tweaks
|
9
|
+
* lib/weechat/channel.rb (Weechat::IRC::Channel#get_infolist): more specific infolist querying; performance tweaks
|
10
|
+
|
3
11
|
* lib/weechat.rb (Weechat): bumped version to 0.0.3
|
4
12
|
|
5
13
|
* lib/weechat/buffer.rb (Weechat::Buffer.find): added method for finding buffers
|
data/Rakefile
CHANGED
data/TODO
CHANGED
data/lib/weechat.rb
CHANGED
data/lib/weechat/channel.rb
CHANGED
@@ -34,11 +34,8 @@ module Weechat
|
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
|
-
def get_infolist
|
38
|
-
list = Weechat::Infolist.parse("irc_channel", "", server.name)
|
39
|
-
channel[:buffer] == @ptr
|
40
|
-
}
|
41
|
-
|
37
|
+
def get_infolist(*fields)
|
38
|
+
list = Weechat::Infolist.parse("irc_channel", "", server.name, {:buffer => [:pointer, @ptr]}, *fields)
|
42
39
|
list.empty? ? [{}] : list
|
43
40
|
end
|
44
41
|
|
data/lib/weechat/infolist.rb
CHANGED
@@ -1,66 +1,40 @@
|
|
1
1
|
module Weechat
|
2
2
|
class Infolist
|
3
|
-
|
4
|
-
# def initialize(infolist)
|
5
|
-
# @ptr = Weechat.infolist_new_item(infolist.ptr)
|
6
|
-
# end
|
7
|
-
|
8
|
-
# def []=(name, value)
|
9
|
-
# type = case value
|
10
|
-
# when String
|
11
|
-
# value = value.to_s
|
12
|
-
# 'string'
|
13
|
-
# when Numeric
|
14
|
-
# 'integer'
|
15
|
-
# when Weechat::Pointer
|
16
|
-
# value = value.ptr
|
17
|
-
# 'pointer'
|
18
|
-
# when Date, Time, DateTime
|
19
|
-
# # TODO implement time
|
20
|
-
# else
|
21
|
-
# value= value.to_s
|
22
|
-
# 'string'
|
23
|
-
# end
|
24
|
-
|
25
|
-
# m = "infolist_new_var_#{type}"
|
26
|
-
# Weechat.__send__(m, name.to_s, value)
|
27
|
-
# end
|
28
|
-
# end
|
29
|
-
|
30
|
-
# attr_reader :ptr
|
31
|
-
# def initialize
|
32
|
-
# @ptr = Weechat.infolist_new
|
33
|
-
# @items = Hash.new {|hash, key| hash[key] = Infolist::Item.new(self)}
|
34
|
-
# end
|
35
|
-
|
36
|
-
# def [](item)
|
37
|
-
# @items[item]
|
38
|
-
# end
|
39
|
-
|
40
|
-
def self.parse(type, ptr="", arguments="")
|
3
|
+
def self.parse(type, ptr="", arguments="", requirements = {}, *fields)
|
41
4
|
infolist_ptr = Weechat.infolist_get(type, ptr, arguments)
|
42
5
|
ret = []
|
43
6
|
while Weechat.infolist_next(infolist_ptr) > 0
|
44
|
-
h = {
|
45
|
-
|
46
|
-
|
47
|
-
type,
|
48
|
-
|
49
|
-
when 'p'
|
50
|
-
Weechat.infolist_pointer(infolist_ptr, name)
|
51
|
-
when 'i'
|
52
|
-
Weechat.infolist_integer(infolist_ptr, name)
|
53
|
-
when 's'
|
54
|
-
Weechat.infolist_string(infolist_ptr, name)
|
55
|
-
when 'b'
|
56
|
-
# FIXME: not exposed to script API yet.
|
57
|
-
# Weechat.infolist_buffer(infolist_ptr, name)
|
58
|
-
when 't'
|
59
|
-
Weechat.infolist_time(infolist_ptr, name)
|
60
|
-
end
|
61
|
-
end
|
7
|
+
h = {}
|
8
|
+
not_matching = requirements.any? {|option, value|
|
9
|
+
type, value = value
|
10
|
+
Weechat.__send__("infolist_#{type}", infolist_ptr, option.to_s) != value
|
11
|
+
}
|
62
12
|
|
63
|
-
|
13
|
+
if not_matching
|
14
|
+
next
|
15
|
+
else
|
16
|
+
str = Weechat.infolist_fields(infolist_ptr)
|
17
|
+
str.split(/,/).each do |item|
|
18
|
+
type, name = item.split(/:/)
|
19
|
+
sname = name.to_sym
|
20
|
+
next if !fields.empty? && !fields.include?(sname)
|
21
|
+
h[sname] = case type
|
22
|
+
when 'p'
|
23
|
+
Weechat.infolist_pointer(infolist_ptr, name)
|
24
|
+
when 'i'
|
25
|
+
Weechat.infolist_integer(infolist_ptr, name)
|
26
|
+
when 's'
|
27
|
+
Weechat.infolist_string(infolist_ptr, name)
|
28
|
+
when 'b'
|
29
|
+
# FIXME: not exposed to script API yet.
|
30
|
+
# Weechat.infolist_buffer(infolist_ptr, name)
|
31
|
+
when 't'
|
32
|
+
Weechat.infolist_time(infolist_ptr, name)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
ret << h
|
37
|
+
end
|
64
38
|
end
|
65
39
|
Weechat.infolist_free(infolist_ptr)
|
66
40
|
return ret
|
data/lib/weechat/properties.rb
CHANGED
@@ -167,8 +167,8 @@ module Weechat
|
|
167
167
|
# Returns a hash representation of the associated infolist.
|
168
168
|
#
|
169
169
|
# @return [Hash{Symbol => Object}] All properties in the infolist
|
170
|
-
def get_infolist
|
171
|
-
Weechat::Infolist.parse(self.class.type, @ptr)
|
170
|
+
def get_infolist(*fields)
|
171
|
+
Weechat::Infolist.parse(self.class.type, @ptr, {}, fields)
|
172
172
|
end
|
173
173
|
|
174
174
|
# Returns a property obtained by an infolist.
|
@@ -180,7 +180,7 @@ module Weechat
|
|
180
180
|
# @see #get_integer_property
|
181
181
|
def get_infolist_property(property)
|
182
182
|
property = property.to_sym
|
183
|
-
values = get_infolist.first
|
183
|
+
values = get_infolist(property).first
|
184
184
|
raise Exception::UnknownProperty, property.to_s unless values.has_key?(property)
|
185
185
|
values[property]
|
186
186
|
end
|
@@ -268,7 +268,8 @@ module Weechat
|
|
268
268
|
when :localvar
|
269
269
|
property =~ /^localvar_.+$/
|
270
270
|
when :infolist
|
271
|
-
|
271
|
+
sproperty = property.to_sym
|
272
|
+
get_infolist(sproperty).first.has_key?(sproperty)
|
272
273
|
end
|
273
274
|
end
|
274
275
|
|