Pulse 1.3.2 → 1.3.3
Sign up to get free protection for your applications and to get access to all the features.
- data/library/pulse/script.rb +9 -3
- data/library/pulse/script/cache.rb +2 -1
- data/library/pulse/script/timer.rb +18 -0
- metadata +11 -10
data/library/pulse/script.rb
CHANGED
@@ -2,11 +2,10 @@
|
|
2
2
|
|
3
3
|
module Pulse
|
4
4
|
class Script < Module
|
5
|
-
|
6
5
|
attr_accessor :name, :author, :version, :path
|
7
6
|
|
8
7
|
def initialize path, client
|
9
|
-
@path, @client = path, client
|
8
|
+
@path, @client, @timers = path, client, []
|
10
9
|
@loaded = false
|
11
10
|
|
12
11
|
evaluate_script
|
@@ -45,11 +44,18 @@ module Pulse
|
|
45
44
|
|
46
45
|
def cache; @cache ||= Cache.new self end
|
47
46
|
|
47
|
+
def timer options = {}, &block
|
48
|
+
Timer.new(options, &block).tap do |this|
|
49
|
+
@timers << this
|
50
|
+
this.start
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
48
54
|
private
|
49
55
|
|
50
56
|
def evaluate_script
|
51
57
|
@loaded = true if module_eval File.read(@path), File.basename(@path), 0
|
52
|
-
rescue
|
58
|
+
rescue Exception
|
53
59
|
puts "Parse error: #{$!.message}"
|
54
60
|
end
|
55
61
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
3
|
module Pulse
|
4
|
-
class Script
|
4
|
+
class Script < Module
|
5
5
|
class Cache
|
6
6
|
def initialize script
|
7
7
|
@script = script
|
@@ -24,6 +24,7 @@ module Pulse
|
|
24
24
|
end
|
25
25
|
rescue
|
26
26
|
puts "The cache is corrupted. Removing."
|
27
|
+
|
27
28
|
File.unlink path
|
28
29
|
end
|
29
30
|
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Pulse
|
4
|
+
class Script < Module
|
5
|
+
class Timer
|
6
|
+
def initialize options = {}, &block
|
7
|
+
@delay = options[:in] or 1.0
|
8
|
+
@callback = block if block_given?
|
9
|
+
end
|
10
|
+
|
11
|
+
def start
|
12
|
+
@thread ||= Thread.new do
|
13
|
+
loop { @callback.call; sleep @delay }
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 1
|
7
7
|
- 3
|
8
|
-
-
|
9
|
-
version: 1.3.
|
8
|
+
- 3
|
9
|
+
version: 1.3.3
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Mikkel Kroman
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: executables
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-12-
|
17
|
+
date: 2010-12-29 00:00:00 +01:00
|
18
18
|
default_executable:
|
19
19
|
dependencies: []
|
20
20
|
|
@@ -27,18 +27,19 @@ extensions: []
|
|
27
27
|
extra_rdoc_files: []
|
28
28
|
|
29
29
|
files:
|
30
|
+
- library/pulse/channel.rb
|
30
31
|
- library/pulse/client.rb
|
31
|
-
- library/pulse/
|
32
|
+
- library/pulse/command.rb
|
32
33
|
- library/pulse/connection.rb
|
33
|
-
- library/pulse/
|
34
|
+
- library/pulse/conversation.rb
|
35
|
+
- library/pulse/enhancements.rb
|
36
|
+
- library/pulse/handling.rb
|
34
37
|
- library/pulse/queue.rb
|
35
|
-
- library/pulse/command.rb
|
36
|
-
- library/pulse/settings.rb
|
37
38
|
- library/pulse/script/cache.rb
|
39
|
+
- library/pulse/script/timer.rb
|
40
|
+
- library/pulse/script.rb
|
41
|
+
- library/pulse/settings.rb
|
38
42
|
- library/pulse/user.rb
|
39
|
-
- library/pulse/conversation.rb
|
40
|
-
- library/pulse/channel.rb
|
41
|
-
- library/pulse/enhancements.rb
|
42
43
|
- library/pulse.rb
|
43
44
|
has_rdoc: true
|
44
45
|
homepage:
|