Pulse 1.3.0 → 1.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. data/library/pulse/script.rb +24 -12
  2. metadata +3 -3
@@ -2,31 +2,29 @@
2
2
 
3
3
  module Pulse
4
4
  class Script < Module
5
+
5
6
  attr_accessor :name, :author, :version, :path
6
7
 
7
8
  def initialize path, client
8
- @path, @client, @loaded = path, client, false
9
+ @path, @client = path, client
10
+ @loaded = false
9
11
 
12
+ evaluate_script
10
13
  cache.load if has_cache?
11
- emit :loaded if evaluate_script
14
+ __send__ :loaded if respond_to? :loaded
12
15
  end
13
16
 
14
- def Script name, version = [1,0,0], author = nil, &block
17
+ def Script name, version = [1, 0, 0], author = nil, &block
15
18
  @name, @version, @author = name, version, author
16
-
17
19
  instance_eval &block
18
20
  end
19
21
 
20
- def cache_for name; script = @client.scripts.find { |script| script.name == name } ? script.cache : nil end
21
-
22
- def emit method, *args; __send__ method, *args if respond_to? method end
23
- def script name; @client.scripts.find { |script| script.name == name } end
24
- def cache; @cache ||= Cache.new self end
25
-
26
- def has_cache?; File.exists? "#{File.expand_path File.dirname $0}/cache/#@name.yml" end
27
22
  def loaded?; @loaded == true end
28
23
 
29
- def unload!; cache.save if @cache; emit :unloaded end
24
+ def unload!
25
+ cache.save if @cache
26
+ __send__ :unloaded if respond_to? :unloaded
27
+ end
30
28
 
31
29
  def to_yaml opts = {}; @name.to_yaml opts end
32
30
 
@@ -34,6 +32,19 @@ module Pulse
34
32
  %{#<#{self.class.name} @name=#{@name.inspect} @version=#{@version.inspect} @author=#{@author.inspect}}
35
33
  end
36
34
 
35
+ def cache_for name
36
+ script = @client.scripts.find { |script| script.name == name }
37
+ script ? script.cache : nil
38
+ end
39
+
40
+ def script name; @client.scripts.find { |script| script.name == name } end
41
+
42
+ def has_cache?
43
+ File.exists? "#{File.expand_path File.dirname $0}/cache/#@name.yml"
44
+ end
45
+
46
+ def cache; @cache ||= Cache.new self end
47
+
37
48
  private
38
49
 
39
50
  def evaluate_script
@@ -41,5 +52,6 @@ module Pulse
41
52
  rescue
42
53
  puts "Parse error: #{$!.message}"
43
54
  end
55
+
44
56
  end
45
57
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 1
7
7
  - 3
8
- - 0
9
- version: 1.3.0
8
+ - 1
9
+ version: 1.3.1
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-13 00:00:00 +01:00
17
+ date: 2010-12-14 00:00:00 +01:00
18
18
  default_executable:
19
19
  dependencies: []
20
20