sidekick 0.6.0 → 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +2 -4
- data/VERSION +1 -1
- data/lib/sidekick/helpers/system.rb +1 -1
- metadata +2 -8
- data/annotated/helpers.html +0 -143
- data/annotated/index.html +0 -155
- data/annotated/lib/sidekick.html +0 -144
- data/annotated/sidekick.html +0 -155
- data/annotated/triggers.html +0 -76
- data/annotated/util.html +0 -74
data/Rakefile
CHANGED
@@ -34,11 +34,11 @@ end
|
|
34
34
|
=end
|
35
35
|
|
36
36
|
require 'rocco/tasks'
|
37
|
-
Rocco::make '
|
37
|
+
Rocco::make 'website/'
|
38
38
|
|
39
39
|
desc 'Build docco'
|
40
40
|
task :docs => [:rocco, 'website/index.html']
|
41
|
-
directory '
|
41
|
+
directory 'website/'
|
42
42
|
|
43
43
|
# Make index.html a copy of rocco.html
|
44
44
|
file 'website/index.html' => 'website/sidekick.html' do |f|
|
@@ -48,6 +48,4 @@ end
|
|
48
48
|
CLEAN.include 'website/index.html'
|
49
49
|
task :doc => :docs
|
50
50
|
|
51
|
-
# GITHUB PAGES ===============================================================
|
52
|
-
|
53
51
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.6.
|
1
|
+
0.6.1
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 6
|
8
|
-
-
|
9
|
-
version: 0.6.
|
8
|
+
- 1
|
9
|
+
version: 0.6.1
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Jostein Berre Eliassen,
|
@@ -74,12 +74,6 @@ files:
|
|
74
74
|
- README.textile
|
75
75
|
- Rakefile
|
76
76
|
- VERSION
|
77
|
-
- annotated/helpers.html
|
78
|
-
- annotated/index.html
|
79
|
-
- annotated/lib/sidekick.html
|
80
|
-
- annotated/sidekick.html
|
81
|
-
- annotated/triggers.html
|
82
|
-
- annotated/util.html
|
83
77
|
- bin/sidekick
|
84
78
|
- lib/sidekick.rb
|
85
79
|
- lib/sidekick/helpers/compile.rb
|
data/annotated/helpers.html
DELETED
@@ -1,143 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<meta http-equiv="content-type" content="text/html;charset=utf-8">
|
5
|
-
<title>helpers.rb</title>
|
6
|
-
<link rel="stylesheet" href="http://jashkenas.github.com/docco/resources/docco.css">
|
7
|
-
</head>
|
8
|
-
<body>
|
9
|
-
<div id='container'>
|
10
|
-
<div id="background"></div>
|
11
|
-
<div id="jump_to">
|
12
|
-
Jump To …
|
13
|
-
<div id="jump_wrapper">
|
14
|
-
<div id="jump_page">
|
15
|
-
<a class="source" href="sidekick.html">sidekick.rb</a>
|
16
|
-
<a class="source" href="helpers.html">helpers.rb</a>
|
17
|
-
<a class="source" href="util.html">util.rb</a>
|
18
|
-
<a class="source" href="triggers.html">triggers.rb</a>
|
19
|
-
</div>
|
20
|
-
</div>
|
21
|
-
</div>
|
22
|
-
<table cellspacing=0 cellpadding=0>
|
23
|
-
<thead>
|
24
|
-
<tr>
|
25
|
-
<th class=docs><h1>helpers.rb</h1></th>
|
26
|
-
<th class=code></th>
|
27
|
-
</tr>
|
28
|
-
</thead>
|
29
|
-
<tbody>
|
30
|
-
<tr id='section-1'>
|
31
|
-
<td class=docs>
|
32
|
-
<div class="octowrap">
|
33
|
-
<a class="octothorpe" href="#section-1">#</a>
|
34
|
-
</div>
|
35
|
-
|
36
|
-
</td>
|
37
|
-
<td class=code>
|
38
|
-
<div class='highlight'><pre><span class="nb">require</span> <span class="s1">'fileutils'</span>
|
39
|
-
<span class="nb">require</span> <span class="s1">'rbconfig'</span>
|
40
|
-
<span class="nb">require</span> <span class="s1">'tilt'</span></pre></div>
|
41
|
-
</td>
|
42
|
-
</tr>
|
43
|
-
<tr id='section-2'>
|
44
|
-
<td class=docs>
|
45
|
-
<div class="octowrap">
|
46
|
-
<a class="octothorpe" href="#section-2">#</a>
|
47
|
-
</div>
|
48
|
-
<p> default helpers</p>
|
49
|
-
</td>
|
50
|
-
<td class=code>
|
51
|
-
<div class='highlight'><pre><span class="k">module</span> <span class="nn">Sidekick::Helpers</span></pre></div>
|
52
|
-
</td>
|
53
|
-
</tr>
|
54
|
-
<tr id='section-3'>
|
55
|
-
<td class=docs>
|
56
|
-
<div class="octowrap">
|
57
|
-
<a class="octothorpe" href="#section-3">#</a>
|
58
|
-
</div>
|
59
|
-
<p> system</p>
|
60
|
-
</td>
|
61
|
-
<td class=code>
|
62
|
-
<div class='highlight'><pre> <span class="nb">require</span> <span class="s1">'sidekick/helpers/util'</span>
|
63
|
-
<span class="kp">include</span> <span class="no">Util</span>
|
64
|
-
|
65
|
-
<span class="k">def</span> <span class="nf">log</span><span class="p">(</span><span class="n">str</span><span class="p">)</span>
|
66
|
-
<span class="nb">puts</span> <span class="s1">' -> '</span> <span class="o">+</span> <span class="n">str</span>
|
67
|
-
<span class="k">end</span>
|
68
|
-
|
69
|
-
<span class="k">def</span> <span class="nf">stop</span><span class="p">(</span><span class="o">*</span><span class="n">prms</span><span class="p">)</span>
|
70
|
-
<span class="no">Sidekick</span><span class="o">.</span><span class="n">stop</span><span class="p">(</span><span class="o">*</span><span class="n">prms</span><span class="p">)</span>
|
71
|
-
<span class="k">end</span></pre></div>
|
72
|
-
</td>
|
73
|
-
</tr>
|
74
|
-
<tr id='section-4'>
|
75
|
-
<td class=docs>
|
76
|
-
<div class="octowrap">
|
77
|
-
<a class="octothorpe" href="#section-4">#</a>
|
78
|
-
</div>
|
79
|
-
<p> notifications</p>
|
80
|
-
</td>
|
81
|
-
<td class=code>
|
82
|
-
<div class='highlight'><pre> <span class="k">def</span> <span class="nf">notify</span><span class="p">(</span><span class="n">message</span><span class="p">,</span> <span class="n">title</span><span class="o">=</span><span class="s1">'Sidekick'</span><span class="p">)</span>
|
83
|
-
|
84
|
-
<span class="n">gems</span> <span class="o">=</span> <span class="p">{</span><span class="ss">:linux</span> <span class="o">=></span> <span class="s1">'libnotify'</span><span class="p">,</span> <span class="ss">:darwin</span> <span class="o">=></span> <span class="s1">'growl'</span><span class="p">}</span>
|
85
|
-
|
86
|
-
<span class="n">stop</span><span class="p">(</span><span class="s1">'Notifications not supported.'</span><span class="p">)</span> <span class="k">unless</span> <span class="n">platform_load?</span><span class="p">(</span>
|
87
|
-
<span class="n">gems</span><span class="p">,</span> <span class="s1">'notifications'</span><span class="p">)</span>
|
88
|
-
<span class="k">case</span> <span class="n">platform</span>
|
89
|
-
<span class="k">when</span> <span class="ss">:linux</span>
|
90
|
-
<span class="no">Libnotify</span><span class="o">.</span><span class="n">show</span> <span class="ss">:body</span> <span class="o">=></span> <span class="n">message</span><span class="p">,</span> <span class="ss">:summary</span> <span class="o">=></span> <span class="n">title</span>
|
91
|
-
<span class="k">when</span> <span class="ss">:darwin</span>
|
92
|
-
<span class="no">Growl</span><span class="o">.</span><span class="n">notify</span> <span class="n">message</span><span class="p">,</span> <span class="ss">:title</span> <span class="o">=></span> <span class="n">title</span><span class="p">,</span> <span class="ss">:name</span> <span class="o">=></span> <span class="s1">'Sidekick'</span>
|
93
|
-
<span class="k">end</span>
|
94
|
-
<span class="k">end</span>
|
95
|
-
|
96
|
-
<span class="k">def</span> <span class="nf">sh</span><span class="p">(</span><span class="n">cmd</span><span class="p">)</span>
|
97
|
-
<span class="n">log</span> <span class="n">cmd</span>
|
98
|
-
<span class="nb">puts</span> <span class="n">result</span> <span class="o">=</span> <span class="sb">`</span><span class="si">#{</span><span class="n">cmd</span><span class="si">}</span><span class="sb">`</span>
|
99
|
-
<span class="n">result</span>
|
100
|
-
<span class="k">end</span>
|
101
|
-
|
102
|
-
<span class="k">def</span> <span class="nf">restart_passenger</span>
|
103
|
-
<span class="no">FileUtils</span><span class="o">.</span><span class="n">touch</span> <span class="s1">'./tmp/restart.txt'</span>
|
104
|
-
<span class="n">log</span> <span class="s1">'restarted passenger'</span>
|
105
|
-
<span class="k">end</span></pre></div>
|
106
|
-
</td>
|
107
|
-
</tr>
|
108
|
-
<tr id='section-5'>
|
109
|
-
<td class=docs>
|
110
|
-
<div class="octowrap">
|
111
|
-
<a class="octothorpe" href="#section-5">#</a>
|
112
|
-
</div>
|
113
|
-
<p> watches for changes matching the source glob,
|
114
|
-
compiles using the tilt gem, and saves to
|
115
|
-
target. Target is interpolated for :name</p>
|
116
|
-
|
117
|
-
</td>
|
118
|
-
<td class=code>
|
119
|
-
<div class='highlight'><pre> <span class="k">def</span> <span class="nf">auto_compile</span><span class="p">(</span><span class="n">source</span><span class="p">,</span> <span class="n">target</span><span class="p">)</span>
|
120
|
-
<span class="n">watch</span><span class="p">(</span><span class="n">source</span><span class="p">)</span> <span class="k">do</span> <span class="o">|</span><span class="n">files</span><span class="o">|</span>
|
121
|
-
<span class="n">files</span><span class="o">.</span><span class="n">each</span> <span class="k">do</span> <span class="o">|</span><span class="n">file</span><span class="o">|</span>
|
122
|
-
<span class="k">if</span> <span class="no">File</span><span class="o">.</span><span class="n">exists?</span><span class="p">(</span><span class="n">file</span><span class="p">)</span>
|
123
|
-
<span class="k">begin</span>
|
124
|
-
<span class="n">t</span> <span class="o">=</span> <span class="n">target</span><span class="o">.</span><span class="n">gsub</span><span class="p">(</span><span class="s1">':name'</span><span class="p">,</span> <span class="no">File</span><span class="o">.</span><span class="n">basename</span><span class="p">(</span><span class="n">file</span><span class="p">,</span> <span class="s1">'.*'</span><span class="p">))</span>
|
125
|
-
<span class="no">File</span><span class="o">.</span><span class="n">open</span><span class="p">(</span><span class="n">t</span><span class="p">,</span> <span class="s1">'w'</span><span class="p">)</span> <span class="k">do</span> <span class="o">|</span><span class="n">f</span><span class="o">|</span>
|
126
|
-
<span class="n">f</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="no">Tilt</span><span class="o">.</span><span class="n">new</span><span class="p">(</span><span class="n">file</span><span class="p">)</span><span class="o">.</span><span class="n">render</span><span class="p">)</span>
|
127
|
-
<span class="k">end</span>
|
128
|
-
<span class="n">log</span> <span class="s2">"render </span><span class="si">#{</span><span class="n">file</span><span class="si">}</span><span class="s2"> => </span><span class="si">#{</span><span class="n">t</span><span class="si">}</span><span class="s2">"</span>
|
129
|
-
<span class="k">rescue</span> <span class="no">Exception</span> <span class="o">=></span> <span class="n">e</span>
|
130
|
-
<span class="n">notify</span> <span class="s2">"Error in </span><span class="si">#{</span><span class="n">file</span><span class="si">}</span><span class="s2">:</span><span class="se">\n</span><span class="si">#{</span><span class="n">e</span><span class="si">}</span><span class="s2">"</span>
|
131
|
-
<span class="n">log</span> <span class="s2">"Error in </span><span class="si">#{</span><span class="n">file</span><span class="si">}</span><span class="s2">:</span><span class="se">\n</span><span class="si">#{</span><span class="n">e</span><span class="si">}</span><span class="s2">"</span>
|
132
|
-
<span class="k">end</span>
|
133
|
-
<span class="k">end</span>
|
134
|
-
<span class="k">end</span>
|
135
|
-
<span class="k">end</span>
|
136
|
-
<span class="k">end</span>
|
137
|
-
|
138
|
-
<span class="k">end</span></pre></div>
|
139
|
-
</td>
|
140
|
-
</tr>
|
141
|
-
</table>
|
142
|
-
</div>
|
143
|
-
</body>
|
data/annotated/index.html
DELETED
@@ -1,155 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<meta http-equiv="content-type" content="text/html;charset=utf-8">
|
5
|
-
<title>sidekick.rb</title>
|
6
|
-
<link rel="stylesheet" href="http://jashkenas.github.com/docco/resources/docco.css">
|
7
|
-
</head>
|
8
|
-
<body>
|
9
|
-
<div id='container'>
|
10
|
-
<div id="background"></div>
|
11
|
-
<div id="jump_to">
|
12
|
-
Jump To …
|
13
|
-
<div id="jump_wrapper">
|
14
|
-
<div id="jump_page">
|
15
|
-
<a class="source" href="sidekick.html">sidekick.rb</a>
|
16
|
-
<a class="source" href="helpers.html">helpers.rb</a>
|
17
|
-
<a class="source" href="util.html">util.rb</a>
|
18
|
-
<a class="source" href="triggers.html">triggers.rb</a>
|
19
|
-
</div>
|
20
|
-
</div>
|
21
|
-
</div>
|
22
|
-
<table cellspacing=0 cellpadding=0>
|
23
|
-
<thead>
|
24
|
-
<tr>
|
25
|
-
<th class=docs><h1>sidekick.rb</h1></th>
|
26
|
-
<th class=code></th>
|
27
|
-
</tr>
|
28
|
-
</thead>
|
29
|
-
<tbody>
|
30
|
-
<tr id='section-1'>
|
31
|
-
<td class=docs>
|
32
|
-
<div class="octowrap">
|
33
|
-
<a class="octothorpe" href="#section-1">#</a>
|
34
|
-
</div>
|
35
|
-
<p> <em>Sidekick</em> is a simple event driven background assistant. Among other things, you can use it to automatically compile assets, test code, restart servers and so on – as prescribed per project, in a <code>.sidekick</code> file. It is powered by EventMachine and Tilt.</p>
|
36
|
-
|
37
|
-
<p> This is the annotated source code. See the <a href="http://github.com/jbe/sidekick#readme">README</a> too.</p>
|
38
|
-
|
39
|
-
<hr />
|
40
|
-
|
41
|
-
<p> Sidekick basically helps you do two things:</p>
|
42
|
-
|
43
|
-
<p> — <em>Define</em> named triggers, such as saying that <code>watch(glob)</code> means doing something when a file matching <code>glob</code> changes, or that <code>every(duration)</code> means doing something every <code>duration</code> seconds.</p>
|
44
|
-
|
45
|
-
<p> — <em>Use</em> the defined triggers with callbacks, such as <code>watch(**.rb) { notify 'Code change' }</code></p>
|
46
|
-
</td>
|
47
|
-
<td class=code>
|
48
|
-
<div class='highlight'><pre><span class="nb">require</span> <span class="s1">'fileutils'</span>
|
49
|
-
<span class="nb">require</span> <span class="s1">'eventmachine'</span>
|
50
|
-
|
51
|
-
<span class="k">module</span> <span class="nn">Sidekick</span></pre></div>
|
52
|
-
</td>
|
53
|
-
</tr>
|
54
|
-
<tr id='section-2'>
|
55
|
-
<td class=docs>
|
56
|
-
<div class="octowrap">
|
57
|
-
<a class="octothorpe" href="#section-2">#</a>
|
58
|
-
</div>
|
59
|
-
<p> This core functionality is provided by <code>Sidekick::Triggers</code>.</p>
|
60
|
-
|
61
|
-
<p> New triggers can be defined by calling <code>Sidekick::Triggers.register(:trigger_name) { ... }</code>.</p>
|
62
|
-
|
63
|
-
<p>Basically, the job of a trigger definition is to take the parameters and the block from a call in <code>.sidekick</code> and use it to hook into EventMachine in some way. — Just have a look at the <a href="http://github.com/jbe/sidekick/blob/master/lib/sidekick/triggers.rb">default trigger library</a>.</p>
|
64
|
-
|
65
|
-
<p> By using Ruby’s <code>method_missing</code>, we can forward method calls to the registered trigger definitions. Any module can thereby extend the <code>Triggers</code> module in order to expose the defined triggers as if they were methods.</p>
|
66
|
-
</td>
|
67
|
-
<td class=code>
|
68
|
-
<div class='highlight'><pre> <span class="k">module</span> <span class="nn">Triggers</span>
|
69
|
-
<span class="vc">@@triggers</span> <span class="o">=</span> <span class="p">{}</span>
|
70
|
-
|
71
|
-
<span class="k">def</span> <span class="nc">self</span><span class="o">.</span><span class="nf">register</span><span class="p">(</span><span class="nb">name</span><span class="p">,</span> <span class="o">&</span><span class="n">block</span><span class="p">)</span>
|
72
|
-
<span class="vc">@@triggers</span><span class="o">[</span><span class="nb">name</span><span class="o">]</span> <span class="o">=</span> <span class="n">block</span>
|
73
|
-
<span class="k">end</span>
|
74
|
-
|
75
|
-
<span class="k">def</span> <span class="nc">self</span><span class="o">.</span><span class="nf">log</span><span class="p">(</span><span class="n">str</span><span class="p">)</span> <span class="c1"># used by triggers</span>
|
76
|
-
<span class="nb">puts</span> <span class="n">str</span>
|
77
|
-
<span class="k">end</span>
|
78
|
-
|
79
|
-
<span class="k">def</span> <span class="nf">method_missing</span><span class="p">(</span><span class="nb">name</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">&</span><span class="n">blk</span><span class="p">)</span>
|
80
|
-
<span class="vc">@@triggers</span><span class="o">[</span><span class="nb">name</span><span class="o">]</span> <span class="p">?</span>
|
81
|
-
<span class="vc">@@triggers</span><span class="o">[</span><span class="nb">name</span><span class="o">].</span><span class="n">call</span><span class="p">(</span><span class="n">blk</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">)</span> <span class="p">:</span> <span class="k">super</span>
|
82
|
-
<span class="k">end</span>
|
83
|
-
|
84
|
-
<span class="k">def</span> <span class="nf">respond_to?</span><span class="p">(</span><span class="nb">method</span><span class="p">)</span>
|
85
|
-
<span class="k">super</span> <span class="o">||</span> <span class="o">!!</span><span class="vc">@@triggers</span><span class="o">[</span><span class="nb">method</span><span class="o">]</span>
|
86
|
-
<span class="k">end</span>
|
87
|
-
|
88
|
-
<span class="k">end</span></pre></div>
|
89
|
-
</td>
|
90
|
-
</tr>
|
91
|
-
<tr id='section-3'>
|
92
|
-
<td class=docs>
|
93
|
-
<div class="octowrap">
|
94
|
-
<a class="octothorpe" href="#section-3">#</a>
|
95
|
-
</div>
|
96
|
-
<p> A default library of triggers and helpers is included..</p>
|
97
|
-
</td>
|
98
|
-
<td class=code>
|
99
|
-
<div class='highlight'><pre> <span class="nb">require</span> <span class="s1">'sidekick/triggers'</span>
|
100
|
-
<span class="nb">require</span> <span class="s1">'sidekick/helpers'</span></pre></div>
|
101
|
-
</td>
|
102
|
-
</tr>
|
103
|
-
<tr id='section-4'>
|
104
|
-
<td class=docs>
|
105
|
-
<div class="octowrap">
|
106
|
-
<a class="octothorpe" href="#section-4">#</a>
|
107
|
-
</div>
|
108
|
-
<p> The <code>.sidekick</code> file is evaluated in a <code>Sidekick::Context</code> module, which exposes DSL style methods by extending <code>Sidekick::Triggers</code> and <code>Sidekick::Helpers</code>.</p>
|
109
|
-
</td>
|
110
|
-
<td class=code>
|
111
|
-
<div class='highlight'><pre> <span class="no">Context</span> <span class="o">=</span> <span class="no">Module</span><span class="o">.</span><span class="n">new</span>
|
112
|
-
<span class="no">Context</span><span class="o">.</span><span class="n">extend</span> <span class="no">Triggers</span>
|
113
|
-
<span class="no">Context</span><span class="o">.</span><span class="n">extend</span> <span class="no">Helpers</span></pre></div>
|
114
|
-
</td>
|
115
|
-
</tr>
|
116
|
-
<tr id='section-5'>
|
117
|
-
<td class=docs>
|
118
|
-
<div class="octowrap">
|
119
|
-
<a class="octothorpe" href="#section-5">#</a>
|
120
|
-
</div>
|
121
|
-
<p> The <code>Sidekick.run!</code> method reads and applies the <code>.sidekick</code> file, wrapping the setup phase inside <code>EM.run { .. }</code>, and thus begins the event loop.</p>
|
122
|
-
|
123
|
-
</td>
|
124
|
-
<td class=code>
|
125
|
-
<div class='highlight'><pre> <span class="k">def</span> <span class="nc">self</span><span class="o">.</span><span class="nf">run!</span><span class="p">(</span><span class="n">path</span><span class="o">=</span><span class="s1">'.sidekick'</span><span class="p">)</span>
|
126
|
-
<span class="n">ensure_config_exists</span><span class="p">(</span><span class="n">path</span><span class="p">)</span>
|
127
|
-
|
128
|
-
<span class="no">Signal</span><span class="o">.</span><span class="n">trap</span><span class="p">(</span><span class="ss">:INT</span><span class="p">)</span> <span class="p">{</span> <span class="n">stop</span> <span class="p">}</span>
|
129
|
-
|
130
|
-
<span class="no">EventMachine</span><span class="o">.</span><span class="n">run</span> <span class="k">do</span>
|
131
|
-
<span class="no">Context</span><span class="o">.</span><span class="n">module_eval</span><span class="p">(</span>
|
132
|
-
<span class="nb">open</span><span class="p">(</span><span class="n">path</span><span class="p">)</span> <span class="p">{</span><span class="o">|</span><span class="n">f</span><span class="o">|</span> <span class="n">f</span><span class="o">.</span><span class="n">read</span> <span class="p">},</span> <span class="n">path</span> <span class="p">)</span>
|
133
|
-
<span class="k">end</span>
|
134
|
-
<span class="k">end</span>
|
135
|
-
|
136
|
-
<span class="k">def</span> <span class="nc">self</span><span class="o">.</span><span class="nf">ensure_config_exists</span><span class="p">(</span><span class="n">path</span><span class="p">)</span>
|
137
|
-
<span class="k">unless</span> <span class="no">File</span><span class="o">.</span><span class="n">exists?</span><span class="p">(</span><span class="n">path</span><span class="p">)</span>
|
138
|
-
<span class="nb">puts</span> <span class="s1">'Generate new sidekick file? (Y/n)'</span>
|
139
|
-
<span class="nb">gets</span> <span class="o">=~</span> <span class="sr">/^N|n/</span> <span class="p">?</span> <span class="nb">exit</span> <span class="p">:</span>
|
140
|
-
<span class="no">FileUtils</span><span class="o">.</span><span class="n">cp</span><span class="p">(</span><span class="no">File</span><span class="o">.</span><span class="n">expand_path</span><span class="p">(</span><span class="s1">'../template'</span><span class="p">,</span>
|
141
|
-
<span class="bp">__FILE__</span><span class="p">),</span> <span class="n">path</span><span class="p">)</span>
|
142
|
-
<span class="k">end</span>
|
143
|
-
<span class="k">end</span>
|
144
|
-
|
145
|
-
<span class="k">def</span> <span class="nc">self</span><span class="o">.</span><span class="nf">stop</span><span class="p">(</span><span class="n">msg</span><span class="o">=</span><span class="kp">false</span><span class="p">)</span>
|
146
|
-
<span class="no">EventMachine</span><span class="o">.</span><span class="n">stop</span>
|
147
|
-
<span class="nb">puts</span> <span class="s2">"</span><span class="se">\n</span><span class="si">#{</span><span class="n">msg</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">msg</span>
|
148
|
-
<span class="k">end</span>
|
149
|
-
|
150
|
-
<span class="k">end</span></pre></div>
|
151
|
-
</td>
|
152
|
-
</tr>
|
153
|
-
</table>
|
154
|
-
</div>
|
155
|
-
</body>
|
data/annotated/lib/sidekick.html
DELETED
@@ -1,144 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<meta http-equiv="content-type" content="text/html;charset=utf-8">
|
5
|
-
<title>sidekick.rb</title>
|
6
|
-
<link rel="stylesheet" href="http://jashkenas.github.com/docco/resources/docco.css">
|
7
|
-
</head>
|
8
|
-
<body>
|
9
|
-
<div id='container'>
|
10
|
-
<div id="background"></div>
|
11
|
-
<table cellspacing=0 cellpadding=0>
|
12
|
-
<thead>
|
13
|
-
<tr>
|
14
|
-
<th class=docs><h1>sidekick.rb</h1></th>
|
15
|
-
<th class=code></th>
|
16
|
-
</tr>
|
17
|
-
</thead>
|
18
|
-
<tbody>
|
19
|
-
<tr id='section-1'>
|
20
|
-
<td class=docs>
|
21
|
-
<div class="octowrap">
|
22
|
-
<a class="octothorpe" href="#section-1">#</a>
|
23
|
-
</div>
|
24
|
-
<p> <em>Sidekick</em> is a simple event driven background assistant. Among other things, you can use it to automatically compile assets, test code, restart servers and so on – as prescribed per project, in a <code>.sidekick</code> file. It is powered by EventMachine and Tilt.</p>
|
25
|
-
|
26
|
-
<p> This is the annotated source code. See the <a href="http://github.com/jbe/sidekick#readme">README</a> too.</p>
|
27
|
-
|
28
|
-
<hr />
|
29
|
-
|
30
|
-
<p> Sidekick basically helps you do two things:</p>
|
31
|
-
|
32
|
-
<p> — <em>Define</em> named triggers, such as saying that <code>watch(glob)</code> means doing something when a file matching <code>glob</code> changes, or that <code>every(duration)</code> means doing something every <code>duration</code> seconds.</p>
|
33
|
-
|
34
|
-
<p> — <em>Use</em> the defined triggers with callbacks, such as <code>watch(**.rb) { notify 'Code change' }</code></p>
|
35
|
-
</td>
|
36
|
-
<td class=code>
|
37
|
-
<div class='highlight'><pre><span class="nb">require</span> <span class="s1">'fileutils'</span>
|
38
|
-
<span class="nb">require</span> <span class="s1">'eventmachine'</span>
|
39
|
-
|
40
|
-
<span class="k">module</span> <span class="nn">Sidekick</span></pre></div>
|
41
|
-
</td>
|
42
|
-
</tr>
|
43
|
-
<tr id='section-2'>
|
44
|
-
<td class=docs>
|
45
|
-
<div class="octowrap">
|
46
|
-
<a class="octothorpe" href="#section-2">#</a>
|
47
|
-
</div>
|
48
|
-
<p> This core functionality is provided by <code>Sidekick::Triggers</code>.</p>
|
49
|
-
|
50
|
-
<p> New triggers can be defined by calling <code>Sidekick::Triggers.register(:trigger_name) { ... }</code>.</p>
|
51
|
-
|
52
|
-
<p>Basically, the job of a trigger definition is to take the parameters and the block from a call in <code>.sidekick</code> and use it to hook into EventMachine in some way. — Just have a look at the <a href="http://github.com/jbe/sidekick/blob/master/lib/sidekick/triggers.rb">default trigger library</a>.</p>
|
53
|
-
|
54
|
-
<p> By using Ruby’s <code>method_missing</code>, we can forward method calls to the registered trigger definitions. Any module can thereby extend the <code>Triggers</code> module in order to expose the defined triggers as if they were methods.</p>
|
55
|
-
</td>
|
56
|
-
<td class=code>
|
57
|
-
<div class='highlight'><pre> <span class="k">module</span> <span class="nn">Triggers</span>
|
58
|
-
<span class="vc">@@triggers</span> <span class="o">=</span> <span class="p">{}</span>
|
59
|
-
|
60
|
-
<span class="k">def</span> <span class="nc">self</span><span class="o">.</span><span class="nf">register</span><span class="p">(</span><span class="nb">name</span><span class="p">,</span> <span class="o">&</span><span class="n">block</span><span class="p">)</span>
|
61
|
-
<span class="vc">@@triggers</span><span class="o">[</span><span class="nb">name</span><span class="o">]</span> <span class="o">=</span> <span class="n">block</span>
|
62
|
-
<span class="k">end</span>
|
63
|
-
|
64
|
-
<span class="k">def</span> <span class="nc">self</span><span class="o">.</span><span class="nf">log</span><span class="p">(</span><span class="n">str</span><span class="p">)</span> <span class="c1"># used by triggers</span>
|
65
|
-
<span class="nb">puts</span> <span class="n">str</span>
|
66
|
-
<span class="k">end</span>
|
67
|
-
|
68
|
-
<span class="k">def</span> <span class="nf">method_missing</span><span class="p">(</span><span class="nb">name</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">&</span><span class="n">blk</span><span class="p">)</span>
|
69
|
-
<span class="vc">@@triggers</span><span class="o">[</span><span class="nb">name</span><span class="o">]</span> <span class="p">?</span>
|
70
|
-
<span class="vc">@@triggers</span><span class="o">[</span><span class="nb">name</span><span class="o">].</span><span class="n">call</span><span class="p">(</span><span class="n">blk</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">)</span> <span class="p">:</span> <span class="k">super</span>
|
71
|
-
<span class="k">end</span>
|
72
|
-
|
73
|
-
<span class="k">def</span> <span class="nf">respond_to?</span><span class="p">(</span><span class="nb">method</span><span class="p">)</span>
|
74
|
-
<span class="k">super</span> <span class="o">||</span> <span class="o">!!</span><span class="vc">@@triggers</span><span class="o">[</span><span class="nb">method</span><span class="o">]</span>
|
75
|
-
<span class="k">end</span>
|
76
|
-
|
77
|
-
<span class="k">end</span></pre></div>
|
78
|
-
</td>
|
79
|
-
</tr>
|
80
|
-
<tr id='section-3'>
|
81
|
-
<td class=docs>
|
82
|
-
<div class="octowrap">
|
83
|
-
<a class="octothorpe" href="#section-3">#</a>
|
84
|
-
</div>
|
85
|
-
<p> A default library of triggers and helpers is included..</p>
|
86
|
-
</td>
|
87
|
-
<td class=code>
|
88
|
-
<div class='highlight'><pre> <span class="nb">require</span> <span class="s1">'sidekick/triggers'</span>
|
89
|
-
<span class="nb">require</span> <span class="s1">'sidekick/helpers'</span></pre></div>
|
90
|
-
</td>
|
91
|
-
</tr>
|
92
|
-
<tr id='section-4'>
|
93
|
-
<td class=docs>
|
94
|
-
<div class="octowrap">
|
95
|
-
<a class="octothorpe" href="#section-4">#</a>
|
96
|
-
</div>
|
97
|
-
<p> The <code>.sidekick</code> file is evaluated in a <code>Sidekick::Context</code> module, which exposes DSL style methods by extending <code>Sidekick::Triggers</code> and <code>Sidekick::Helpers</code>.</p>
|
98
|
-
</td>
|
99
|
-
<td class=code>
|
100
|
-
<div class='highlight'><pre> <span class="no">Context</span> <span class="o">=</span> <span class="no">Module</span><span class="o">.</span><span class="n">new</span>
|
101
|
-
<span class="no">Context</span><span class="o">.</span><span class="n">extend</span> <span class="no">Triggers</span>
|
102
|
-
<span class="no">Context</span><span class="o">.</span><span class="n">extend</span> <span class="no">Helpers</span></pre></div>
|
103
|
-
</td>
|
104
|
-
</tr>
|
105
|
-
<tr id='section-5'>
|
106
|
-
<td class=docs>
|
107
|
-
<div class="octowrap">
|
108
|
-
<a class="octothorpe" href="#section-5">#</a>
|
109
|
-
</div>
|
110
|
-
<p> The <code>Sidekick.run!</code> method reads and applies the <code>.sidekick</code> file, wrapping the setup phase inside <code>EM.run { .. }</code>, and thus begins the event loop.</p>
|
111
|
-
|
112
|
-
</td>
|
113
|
-
<td class=code>
|
114
|
-
<div class='highlight'><pre> <span class="k">def</span> <span class="nc">self</span><span class="o">.</span><span class="nf">run!</span><span class="p">(</span><span class="n">path</span><span class="o">=</span><span class="s1">'.sidekick'</span><span class="p">)</span>
|
115
|
-
<span class="n">ensure_config_exists</span><span class="p">(</span><span class="n">path</span><span class="p">)</span>
|
116
|
-
|
117
|
-
<span class="no">Signal</span><span class="o">.</span><span class="n">trap</span><span class="p">(</span><span class="ss">:INT</span><span class="p">)</span> <span class="p">{</span> <span class="n">stop</span> <span class="p">}</span>
|
118
|
-
|
119
|
-
<span class="no">EventMachine</span><span class="o">.</span><span class="n">run</span> <span class="k">do</span>
|
120
|
-
<span class="no">Context</span><span class="o">.</span><span class="n">module_eval</span><span class="p">(</span>
|
121
|
-
<span class="nb">open</span><span class="p">(</span><span class="n">path</span><span class="p">)</span> <span class="p">{</span><span class="o">|</span><span class="n">f</span><span class="o">|</span> <span class="n">f</span><span class="o">.</span><span class="n">read</span> <span class="p">},</span> <span class="n">path</span> <span class="p">)</span>
|
122
|
-
<span class="k">end</span>
|
123
|
-
<span class="k">end</span>
|
124
|
-
|
125
|
-
<span class="k">def</span> <span class="nc">self</span><span class="o">.</span><span class="nf">ensure_config_exists</span><span class="p">(</span><span class="n">path</span><span class="p">)</span>
|
126
|
-
<span class="k">unless</span> <span class="no">File</span><span class="o">.</span><span class="n">exists?</span><span class="p">(</span><span class="n">path</span><span class="p">)</span>
|
127
|
-
<span class="nb">puts</span> <span class="s1">'Generate new sidekick file? (Y/n)'</span>
|
128
|
-
<span class="nb">gets</span> <span class="o">=~</span> <span class="sr">/^N|n/</span> <span class="p">?</span> <span class="nb">exit</span> <span class="p">:</span>
|
129
|
-
<span class="no">FileUtils</span><span class="o">.</span><span class="n">cp</span><span class="p">(</span><span class="no">File</span><span class="o">.</span><span class="n">expand_path</span><span class="p">(</span><span class="s1">'../template'</span><span class="p">,</span>
|
130
|
-
<span class="bp">__FILE__</span><span class="p">),</span> <span class="n">path</span><span class="p">)</span>
|
131
|
-
<span class="k">end</span>
|
132
|
-
<span class="k">end</span>
|
133
|
-
|
134
|
-
<span class="k">def</span> <span class="nc">self</span><span class="o">.</span><span class="nf">stop</span><span class="p">(</span><span class="n">msg</span><span class="o">=</span><span class="kp">false</span><span class="p">)</span>
|
135
|
-
<span class="no">EventMachine</span><span class="o">.</span><span class="n">stop</span>
|
136
|
-
<span class="nb">puts</span> <span class="s2">"</span><span class="se">\n</span><span class="si">#{</span><span class="n">msg</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">msg</span>
|
137
|
-
<span class="k">end</span>
|
138
|
-
|
139
|
-
<span class="k">end</span></pre></div>
|
140
|
-
</td>
|
141
|
-
</tr>
|
142
|
-
</table>
|
143
|
-
</div>
|
144
|
-
</body>
|
data/annotated/sidekick.html
DELETED
@@ -1,155 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<meta http-equiv="content-type" content="text/html;charset=utf-8">
|
5
|
-
<title>sidekick.rb</title>
|
6
|
-
<link rel="stylesheet" href="http://jashkenas.github.com/docco/resources/docco.css">
|
7
|
-
</head>
|
8
|
-
<body>
|
9
|
-
<div id='container'>
|
10
|
-
<div id="background"></div>
|
11
|
-
<div id="jump_to">
|
12
|
-
Jump To …
|
13
|
-
<div id="jump_wrapper">
|
14
|
-
<div id="jump_page">
|
15
|
-
<a class="source" href="sidekick.html">sidekick.rb</a>
|
16
|
-
<a class="source" href="helpers.html">helpers.rb</a>
|
17
|
-
<a class="source" href="util.html">util.rb</a>
|
18
|
-
<a class="source" href="triggers.html">triggers.rb</a>
|
19
|
-
</div>
|
20
|
-
</div>
|
21
|
-
</div>
|
22
|
-
<table cellspacing=0 cellpadding=0>
|
23
|
-
<thead>
|
24
|
-
<tr>
|
25
|
-
<th class=docs><h1>sidekick.rb</h1></th>
|
26
|
-
<th class=code></th>
|
27
|
-
</tr>
|
28
|
-
</thead>
|
29
|
-
<tbody>
|
30
|
-
<tr id='section-1'>
|
31
|
-
<td class=docs>
|
32
|
-
<div class="octowrap">
|
33
|
-
<a class="octothorpe" href="#section-1">#</a>
|
34
|
-
</div>
|
35
|
-
<p> <em>Sidekick</em> is a simple event driven background assistant. Among other things, you can use it to automatically compile assets, test code, restart servers and so on – as prescribed per project, in a <code>.sidekick</code> file. It is powered by EventMachine and Tilt.</p>
|
36
|
-
|
37
|
-
<p> This is the annotated source code. See the <a href="http://github.com/jbe/sidekick#readme">README</a> too.</p>
|
38
|
-
|
39
|
-
<hr />
|
40
|
-
|
41
|
-
<p> Sidekick basically helps you do two things:</p>
|
42
|
-
|
43
|
-
<p> — <em>Define</em> named triggers, such as saying that <code>watch(glob)</code> means doing something when a file matching <code>glob</code> changes, or that <code>every(duration)</code> means doing something every <code>duration</code> seconds.</p>
|
44
|
-
|
45
|
-
<p> — <em>Use</em> the defined triggers with callbacks, such as <code>watch(**.rb) { notify 'Code change' }</code></p>
|
46
|
-
</td>
|
47
|
-
<td class=code>
|
48
|
-
<div class='highlight'><pre><span class="nb">require</span> <span class="s1">'fileutils'</span>
|
49
|
-
<span class="nb">require</span> <span class="s1">'eventmachine'</span>
|
50
|
-
|
51
|
-
<span class="k">module</span> <span class="nn">Sidekick</span></pre></div>
|
52
|
-
</td>
|
53
|
-
</tr>
|
54
|
-
<tr id='section-2'>
|
55
|
-
<td class=docs>
|
56
|
-
<div class="octowrap">
|
57
|
-
<a class="octothorpe" href="#section-2">#</a>
|
58
|
-
</div>
|
59
|
-
<p> This core functionality is provided by <code>Sidekick::Triggers</code>.</p>
|
60
|
-
|
61
|
-
<p> New triggers can be defined by calling <code>Sidekick::Triggers.register(:trigger_name) { ... }</code>.</p>
|
62
|
-
|
63
|
-
<p>Basically, the job of a trigger definition is to take the parameters and the block from a call in <code>.sidekick</code> and use it to hook into EventMachine in some way. — Just have a look at the <a href="http://github.com/jbe/sidekick/blob/master/lib/sidekick/triggers.rb">default trigger library</a>.</p>
|
64
|
-
|
65
|
-
<p> By using Ruby’s <code>method_missing</code>, we can forward method calls to the registered trigger definitions. Any module can thereby extend the <code>Triggers</code> module in order to expose the defined triggers as if they were methods.</p>
|
66
|
-
</td>
|
67
|
-
<td class=code>
|
68
|
-
<div class='highlight'><pre> <span class="k">module</span> <span class="nn">Triggers</span>
|
69
|
-
<span class="vc">@@triggers</span> <span class="o">=</span> <span class="p">{}</span>
|
70
|
-
|
71
|
-
<span class="k">def</span> <span class="nc">self</span><span class="o">.</span><span class="nf">register</span><span class="p">(</span><span class="nb">name</span><span class="p">,</span> <span class="o">&</span><span class="n">block</span><span class="p">)</span>
|
72
|
-
<span class="vc">@@triggers</span><span class="o">[</span><span class="nb">name</span><span class="o">]</span> <span class="o">=</span> <span class="n">block</span>
|
73
|
-
<span class="k">end</span>
|
74
|
-
|
75
|
-
<span class="k">def</span> <span class="nc">self</span><span class="o">.</span><span class="nf">log</span><span class="p">(</span><span class="n">str</span><span class="p">)</span> <span class="c1"># used by triggers</span>
|
76
|
-
<span class="nb">puts</span> <span class="n">str</span>
|
77
|
-
<span class="k">end</span>
|
78
|
-
|
79
|
-
<span class="k">def</span> <span class="nf">method_missing</span><span class="p">(</span><span class="nb">name</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">&</span><span class="n">blk</span><span class="p">)</span>
|
80
|
-
<span class="vc">@@triggers</span><span class="o">[</span><span class="nb">name</span><span class="o">]</span> <span class="p">?</span>
|
81
|
-
<span class="vc">@@triggers</span><span class="o">[</span><span class="nb">name</span><span class="o">].</span><span class="n">call</span><span class="p">(</span><span class="n">blk</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">)</span> <span class="p">:</span> <span class="k">super</span>
|
82
|
-
<span class="k">end</span>
|
83
|
-
|
84
|
-
<span class="k">def</span> <span class="nf">respond_to?</span><span class="p">(</span><span class="nb">method</span><span class="p">)</span>
|
85
|
-
<span class="k">super</span> <span class="o">||</span> <span class="o">!!</span><span class="vc">@@triggers</span><span class="o">[</span><span class="nb">method</span><span class="o">]</span>
|
86
|
-
<span class="k">end</span>
|
87
|
-
|
88
|
-
<span class="k">end</span></pre></div>
|
89
|
-
</td>
|
90
|
-
</tr>
|
91
|
-
<tr id='section-3'>
|
92
|
-
<td class=docs>
|
93
|
-
<div class="octowrap">
|
94
|
-
<a class="octothorpe" href="#section-3">#</a>
|
95
|
-
</div>
|
96
|
-
<p> A default library of triggers and helpers is included..</p>
|
97
|
-
</td>
|
98
|
-
<td class=code>
|
99
|
-
<div class='highlight'><pre> <span class="nb">require</span> <span class="s1">'sidekick/triggers'</span>
|
100
|
-
<span class="nb">require</span> <span class="s1">'sidekick/helpers'</span></pre></div>
|
101
|
-
</td>
|
102
|
-
</tr>
|
103
|
-
<tr id='section-4'>
|
104
|
-
<td class=docs>
|
105
|
-
<div class="octowrap">
|
106
|
-
<a class="octothorpe" href="#section-4">#</a>
|
107
|
-
</div>
|
108
|
-
<p> The <code>.sidekick</code> file is evaluated in a <code>Sidekick::Context</code> module, which exposes DSL style methods by extending <code>Sidekick::Triggers</code> and <code>Sidekick::Helpers</code>.</p>
|
109
|
-
</td>
|
110
|
-
<td class=code>
|
111
|
-
<div class='highlight'><pre> <span class="no">Context</span> <span class="o">=</span> <span class="no">Module</span><span class="o">.</span><span class="n">new</span>
|
112
|
-
<span class="no">Context</span><span class="o">.</span><span class="n">extend</span> <span class="no">Triggers</span>
|
113
|
-
<span class="no">Context</span><span class="o">.</span><span class="n">extend</span> <span class="no">Helpers</span></pre></div>
|
114
|
-
</td>
|
115
|
-
</tr>
|
116
|
-
<tr id='section-5'>
|
117
|
-
<td class=docs>
|
118
|
-
<div class="octowrap">
|
119
|
-
<a class="octothorpe" href="#section-5">#</a>
|
120
|
-
</div>
|
121
|
-
<p> The <code>Sidekick.run!</code> method reads and applies the <code>.sidekick</code> file, wrapping the setup phase inside <code>EM.run { .. }</code>, and thus begins the event loop.</p>
|
122
|
-
|
123
|
-
</td>
|
124
|
-
<td class=code>
|
125
|
-
<div class='highlight'><pre> <span class="k">def</span> <span class="nc">self</span><span class="o">.</span><span class="nf">run!</span><span class="p">(</span><span class="n">path</span><span class="o">=</span><span class="s1">'.sidekick'</span><span class="p">)</span>
|
126
|
-
<span class="n">ensure_config_exists</span><span class="p">(</span><span class="n">path</span><span class="p">)</span>
|
127
|
-
|
128
|
-
<span class="no">Signal</span><span class="o">.</span><span class="n">trap</span><span class="p">(</span><span class="ss">:INT</span><span class="p">)</span> <span class="p">{</span> <span class="n">stop</span> <span class="p">}</span>
|
129
|
-
|
130
|
-
<span class="no">EventMachine</span><span class="o">.</span><span class="n">run</span> <span class="k">do</span>
|
131
|
-
<span class="no">Context</span><span class="o">.</span><span class="n">module_eval</span><span class="p">(</span>
|
132
|
-
<span class="nb">open</span><span class="p">(</span><span class="n">path</span><span class="p">)</span> <span class="p">{</span><span class="o">|</span><span class="n">f</span><span class="o">|</span> <span class="n">f</span><span class="o">.</span><span class="n">read</span> <span class="p">},</span> <span class="n">path</span> <span class="p">)</span>
|
133
|
-
<span class="k">end</span>
|
134
|
-
<span class="k">end</span>
|
135
|
-
|
136
|
-
<span class="k">def</span> <span class="nc">self</span><span class="o">.</span><span class="nf">ensure_config_exists</span><span class="p">(</span><span class="n">path</span><span class="p">)</span>
|
137
|
-
<span class="k">unless</span> <span class="no">File</span><span class="o">.</span><span class="n">exists?</span><span class="p">(</span><span class="n">path</span><span class="p">)</span>
|
138
|
-
<span class="nb">puts</span> <span class="s1">'Generate new sidekick file? (Y/n)'</span>
|
139
|
-
<span class="nb">gets</span> <span class="o">=~</span> <span class="sr">/^N|n/</span> <span class="p">?</span> <span class="nb">exit</span> <span class="p">:</span>
|
140
|
-
<span class="no">FileUtils</span><span class="o">.</span><span class="n">cp</span><span class="p">(</span><span class="no">File</span><span class="o">.</span><span class="n">expand_path</span><span class="p">(</span><span class="s1">'../template'</span><span class="p">,</span>
|
141
|
-
<span class="bp">__FILE__</span><span class="p">),</span> <span class="n">path</span><span class="p">)</span>
|
142
|
-
<span class="k">end</span>
|
143
|
-
<span class="k">end</span>
|
144
|
-
|
145
|
-
<span class="k">def</span> <span class="nc">self</span><span class="o">.</span><span class="nf">stop</span><span class="p">(</span><span class="n">msg</span><span class="o">=</span><span class="kp">false</span><span class="p">)</span>
|
146
|
-
<span class="no">EventMachine</span><span class="o">.</span><span class="n">stop</span>
|
147
|
-
<span class="nb">puts</span> <span class="s2">"</span><span class="se">\n</span><span class="si">#{</span><span class="n">msg</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">msg</span>
|
148
|
-
<span class="k">end</span>
|
149
|
-
|
150
|
-
<span class="k">end</span></pre></div>
|
151
|
-
</td>
|
152
|
-
</tr>
|
153
|
-
</table>
|
154
|
-
</div>
|
155
|
-
</body>
|
data/annotated/triggers.html
DELETED
@@ -1,76 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<meta http-equiv="content-type" content="text/html;charset=utf-8">
|
5
|
-
<title>triggers.rb</title>
|
6
|
-
<link rel="stylesheet" href="http://jashkenas.github.com/docco/resources/docco.css">
|
7
|
-
</head>
|
8
|
-
<body>
|
9
|
-
<div id='container'>
|
10
|
-
<div id="background"></div>
|
11
|
-
<div id="jump_to">
|
12
|
-
Jump To …
|
13
|
-
<div id="jump_wrapper">
|
14
|
-
<div id="jump_page">
|
15
|
-
<a class="source" href="sidekick.html">sidekick.rb</a>
|
16
|
-
<a class="source" href="helpers.html">helpers.rb</a>
|
17
|
-
<a class="source" href="util.html">util.rb</a>
|
18
|
-
<a class="source" href="triggers.html">triggers.rb</a>
|
19
|
-
</div>
|
20
|
-
</div>
|
21
|
-
</div>
|
22
|
-
<table cellspacing=0 cellpadding=0>
|
23
|
-
<thead>
|
24
|
-
<tr>
|
25
|
-
<th class=docs><h1>triggers.rb</h1></th>
|
26
|
-
<th class=code></th>
|
27
|
-
</tr>
|
28
|
-
</thead>
|
29
|
-
<tbody>
|
30
|
-
<tr id='section-1'>
|
31
|
-
<td class=docs>
|
32
|
-
<div class="octowrap">
|
33
|
-
<a class="octothorpe" href="#section-1">#</a>
|
34
|
-
</div>
|
35
|
-
|
36
|
-
</td>
|
37
|
-
<td class=code>
|
38
|
-
<div class='highlight'><pre><span class="nb">require</span> <span class="s1">'em-dir-watcher'</span>
|
39
|
-
|
40
|
-
|
41
|
-
<span class="k">module</span> <span class="nn">Sidekick::Triggers</span></pre></div>
|
42
|
-
</td>
|
43
|
-
</tr>
|
44
|
-
<tr id='section-2'>
|
45
|
-
<td class=docs>
|
46
|
-
<div class="octowrap">
|
47
|
-
<a class="octothorpe" href="#section-2">#</a>
|
48
|
-
</div>
|
49
|
-
<p> default triggers</p>
|
50
|
-
|
51
|
-
</td>
|
52
|
-
<td class=code>
|
53
|
-
<div class='highlight'><pre> <span class="n">register</span> <span class="ss">:watch</span> <span class="k">do</span> <span class="o">|</span><span class="n">callback</span><span class="p">,</span> <span class="n">glob</span><span class="o">|</span>
|
54
|
-
<span class="no">EMDirWatcher</span><span class="o">.</span><span class="n">watch</span><span class="p">(</span>
|
55
|
-
<span class="no">File</span><span class="o">.</span><span class="n">expand_path</span><span class="p">(</span><span class="s1">'.'</span><span class="p">),</span>
|
56
|
-
<span class="ss">:include_only</span> <span class="o">=></span> <span class="o">[</span><span class="n">glob</span><span class="o">]</span><span class="p">,</span>
|
57
|
-
<span class="ss">:grace_period</span> <span class="o">=></span> <span class="mi">0</span><span class="o">.</span><span class="mi">2</span>
|
58
|
-
<span class="p">)</span> <span class="k">do</span> <span class="o">|</span><span class="n">paths</span><span class="o">|</span>
|
59
|
-
<span class="n">log</span> <span class="s2">"watch </span><span class="si">#{</span><span class="n">paths</span><span class="o">.</span><span class="n">inspect</span><span class="si">}</span><span class="s2">"</span>
|
60
|
-
<span class="n">callback</span><span class="o">.</span><span class="n">call</span><span class="p">(</span><span class="n">paths</span><span class="p">)</span>
|
61
|
-
<span class="k">end</span>
|
62
|
-
<span class="k">end</span>
|
63
|
-
|
64
|
-
<span class="n">register</span> <span class="ss">:every</span> <span class="k">do</span> <span class="o">|</span><span class="n">callback</span><span class="p">,</span> <span class="n">duration</span><span class="o">|</span>
|
65
|
-
<span class="no">EventMachine</span><span class="o">::</span><span class="no">PeriodicTimer</span><span class="o">.</span><span class="n">new</span><span class="p">(</span><span class="n">duration</span><span class="p">)</span> <span class="k">do</span>
|
66
|
-
<span class="n">log</span> <span class="s2">"every </span><span class="si">#{</span><span class="n">duration</span><span class="si">}</span><span class="s2"> seconds"</span>
|
67
|
-
<span class="n">callback</span><span class="o">.</span><span class="n">call</span>
|
68
|
-
<span class="k">end</span>
|
69
|
-
<span class="k">end</span>
|
70
|
-
|
71
|
-
<span class="k">end</span></pre></div>
|
72
|
-
</td>
|
73
|
-
</tr>
|
74
|
-
</table>
|
75
|
-
</div>
|
76
|
-
</body>
|
data/annotated/util.html
DELETED
@@ -1,74 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<meta http-equiv="content-type" content="text/html;charset=utf-8">
|
5
|
-
<title>util.rb</title>
|
6
|
-
<link rel="stylesheet" href="http://jashkenas.github.com/docco/resources/docco.css">
|
7
|
-
</head>
|
8
|
-
<body>
|
9
|
-
<div id='container'>
|
10
|
-
<div id="background"></div>
|
11
|
-
<div id="jump_to">
|
12
|
-
Jump To …
|
13
|
-
<div id="jump_wrapper">
|
14
|
-
<div id="jump_page">
|
15
|
-
<a class="source" href="sidekick.html">sidekick.rb</a>
|
16
|
-
<a class="source" href="helpers.html">helpers.rb</a>
|
17
|
-
<a class="source" href="util.html">util.rb</a>
|
18
|
-
<a class="source" href="triggers.html">triggers.rb</a>
|
19
|
-
</div>
|
20
|
-
</div>
|
21
|
-
</div>
|
22
|
-
<table cellspacing=0 cellpadding=0>
|
23
|
-
<thead>
|
24
|
-
<tr>
|
25
|
-
<th class=docs><h1>util.rb</h1></th>
|
26
|
-
<th class=code></th>
|
27
|
-
</tr>
|
28
|
-
</thead>
|
29
|
-
<tbody>
|
30
|
-
<tr id='section-1'>
|
31
|
-
<td class=docs>
|
32
|
-
<div class="octowrap">
|
33
|
-
<a class="octothorpe" href="#section-1">#</a>
|
34
|
-
</div>
|
35
|
-
|
36
|
-
</td>
|
37
|
-
<td class=code>
|
38
|
-
<div class='highlight'><pre><span class="k">module</span> <span class="nn">Util</span></pre></div>
|
39
|
-
</td>
|
40
|
-
</tr>
|
41
|
-
<tr id='section-2'>
|
42
|
-
<td class=docs>
|
43
|
-
<div class="octowrap">
|
44
|
-
<a class="octothorpe" href="#section-2">#</a>
|
45
|
-
</div>
|
46
|
-
<p> :linux, :darwin, :other</p>
|
47
|
-
|
48
|
-
</td>
|
49
|
-
<td class=code>
|
50
|
-
<div class='highlight'><pre> <span class="k">def</span> <span class="nf">platform</span>
|
51
|
-
<span class="o">[</span><span class="ss">:linux</span><span class="p">,</span> <span class="ss">:darwin</span><span class="o">].</span><span class="n">each</span> <span class="k">do</span> <span class="o">|</span><span class="n">plf</span><span class="o">|</span>
|
52
|
-
<span class="k">return</span> <span class="n">plf</span> <span class="k">if</span> <span class="no">Config</span><span class="o">::</span><span class="no">CONFIG</span><span class="o">[</span><span class="s1">'target_os'</span><span class="o">]</span> <span class="o">=~</span> <span class="sr">/</span><span class="si">#{</span><span class="n">plf</span><span class="si">}</span><span class="sr">/i</span>
|
53
|
-
<span class="k">end</span><span class="p">;</span> <span class="ss">:other</span>
|
54
|
-
<span class="k">end</span>
|
55
|
-
|
56
|
-
<span class="k">def</span> <span class="nf">gem_load?</span><span class="p">(</span><span class="n">gemname</span><span class="p">,</span> <span class="n">function</span><span class="o">=</span><span class="s1">'full'</span><span class="p">)</span>
|
57
|
-
<span class="vi">@installed</span> <span class="o">||=</span> <span class="k">begin</span>
|
58
|
-
<span class="nb">require</span> <span class="n">gemname</span>
|
59
|
-
<span class="kp">true</span>
|
60
|
-
<span class="k">rescue</span> <span class="no">LoadError</span>
|
61
|
-
<span class="s2">"Please gem install </span><span class="si">#{</span><span class="n">gemname</span><span class="si">}</span><span class="s2"> for </span><span class="si">#{</span><span class="n">function</span><span class="si">}</span><span class="s2"> support."</span>
|
62
|
-
<span class="o">::</span><span class="no">Sidekick</span><span class="o">.</span><span class="n">stop</span>
|
63
|
-
<span class="k">end</span>
|
64
|
-
<span class="k">end</span>
|
65
|
-
|
66
|
-
<span class="k">def</span> <span class="nf">platform_load?</span><span class="p">(</span><span class="n">gems</span><span class="p">,</span> <span class="n">function</span><span class="o">=</span><span class="s1">'full'</span><span class="p">)</span>
|
67
|
-
<span class="n">gem_load?</span><span class="p">(</span><span class="n">gems</span><span class="o">[</span><span class="n">platform</span><span class="o">]</span><span class="p">,</span> <span class="n">function</span><span class="p">)</span>
|
68
|
-
<span class="k">end</span>
|
69
|
-
<span class="k">end</span></pre></div>
|
70
|
-
</td>
|
71
|
-
</tr>
|
72
|
-
</table>
|
73
|
-
</div>
|
74
|
-
</body>
|