sidekick 0.4.1 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.textile CHANGED
@@ -1,48 +1,45 @@
1
1
  h1. Sidekick
2
2
 
3
3
 
4
- Sidekick is a command line tool to automatically trigger running tasks on certain events, such as when you make updates. This is defined per project, in a local @.sidekick@ file in your project folder.
4
+ "Sidekick":http://ibuildlegobricks.tumblr.com/post/1398895151/automate-common-tasks-with-sidekick is a command line tool to automatically trigger actions on certain events, as defined per project, in a local @.sidekick@ file in your project folder.
5
5
 
6
- h3. Features
7
-
8
- * Simple, powerful dsl. "Examples here.":http://github.com/jbe/sidekick/blob/master/lib/template
9
- * Pre-defined triggers.
10
- * Pre-defined helpers for common tasks.
11
- * Easy to write new triggers and helpers.
12
- * Esily compiles most languages thanks to "Tilt":http://github.com/rtomayko/tilt.
13
-
14
6
  h3. Use cases
15
7
 
16
- * Triggering server restart when code is changed
17
- * Automatically compiling sass, CoffeeScript, etc.
18
- * Continuous testing with notifications or hooks
8
+ * Restart server when code is changed
9
+ * Compile Sass and CoffeeScript templates when they are updated
10
+ * Continuous testing, with notifications and flexible hooks
19
11
  * Periodically running commands
20
12
 
13
+ You typically run Sidekick in the background while coding, to automate all this.
21
14
 
22
- You would typically run it in the background while coding, to automatize things like restarting development servers on file changes, recompiling assets, continously running tests or periodically running commands.
15
+ h3. Features
23
16
 
17
+ * Simple and powerful DSL. "Examples here.":http://github.com/jbe/sidekick/blob/master/lib/template
18
+ * Use triggers to watch files etc.
19
+ * Use helpers to compile templates etc.
20
+ * Easy to write new triggers and helpers.
21
+ * Already compiles many languages, thanks to "Tilt":http://github.com/rtomayko/tilt.
24
22
 
25
- h2. Basic usage
26
23
 
27
- Install with @gem install sidekick@ and invoke it using the @sidekick@ shell command in your project folder. If you do not have a @.sidekick@ file, you will be offered a template.
28
24
 
29
- I recommend "reading the template":http://github.com/jbe/sidekick/blob/master/lib/template.
25
+ h2. Basic usage
30
26
 
31
- The @watch@ and @every@ commands you see in it are triggers, while @notify@, @sh@, and @restart_passenger@ are helper methods. Some helpers, like @auto_compile@ set up both triggers and actions for you.
27
+ Install with @gem install sidekick@ and invoke using the @sidekick@ command in your project folder. If you do not have a @.sidekick@ file, you will be offered a template.
32
28
 
33
29
  h3. Currently available triggers:
34
30
 
35
- |@watch(glob)@|run on file changes matching @glob@. Globs like @Dir[]@. |
36
- |@every(duration)@|run every @duration@ seconds|
31
+ |@watch(glob) { ... }@|run on file changes matching @glob@. Globs like "Dir[]":http://ruby-doc.org/core/classes/Dir.html#M002323. |
32
+ |@every(duration) { ... }@|run every @duration@ seconds|
37
33
 
38
34
  h3. Currently available helpers:
39
35
 
40
- |@sh(cmd)@|run shell command, showing output, like in rake|
41
- |@log(str)@|log events to screen. cleaner than puts.|
42
- |@notify@|notify user via growl, libnotify etc|
43
- |@auto_compile(source_glob, target_path)@|compile using tilt on file changes (language automatically detected -- see template examples and tilt documentation)|
36
+ |@sh(cmd)@|run shell command, printing and returning output|
37
+ |@log(str)@|log events to @STDOUT@.|
38
+ |@notify(message, title='sidekick')@|notify user via growl, libnotify etc.|
39
+ |@auto_compile(source_glob, target_path)@|compile on file changes using tilt (language automatically detected -- see example usage in template, and tilt documentation)|
44
40
  |@restart_passenger@|restart passenger based environments by touching tmp/restart.txt|
45
- |@load_gem?(name)@|tries to load gem, true if success. otherwise false. informs user that more functions are available if they install it|
41
+
42
+ Note how some helpers, like @auto_compile@ set up both triggers and actions for you.
46
43
 
47
44
  h2. Writing extensions
48
45
 
@@ -60,17 +57,25 @@ To add more helpers, simply add methods to @Sidekick::Helpers@, like this:
60
57
  </code>
61
58
  </pre>
62
59
 
63
- When adding a group of methods it may be cleaner to use a separate module under @Sidekick::Helpers@, and then including it.
60
+ They will be available to other helpers and to @.sidekick@ files. Also, if adding a group of methods it may be cleaner to use a separate module under @Sidekick::Helpers@, and then including it.
64
61
 
65
62
 
66
63
  h3. Writing new triggers
67
64
 
68
- To add new triggers, you have two options: blocks, and classes. Blocks are best for simple stuff, while classes are good for more complex code. This is how you set up a new trigger using a block:
65
+ To add new triggers, you have two options: blocks, and classes. Blocks are best for simple stuff, while classes are good for more complex code. Here are some examples of how you set up a new trigger using a block:
69
66
 
70
67
  <pre>
71
68
  <code lang='ruby'>
72
69
 
73
- register :every do |callback, duration|
70
+ Sidekick::Triggers.register(:never) {|callback| }
71
+ # available in .sidekick like:
72
+ # never { puts 'nobody listens to me' }
73
+
74
+ Sidekick::Triggers.register(:on_startup) {|callback| callback.call }
75
+ # available like:
76
+ # on_startup { puts 'better to do this in the main scope than here' }
77
+
78
+ Sidekick::Triggers.register(:every) do |callback, duration|
74
79
  timeshare(duration) do
75
80
  callback.call
76
81
  end
@@ -79,9 +84,9 @@ end
79
84
  </code>
80
85
  </pre>
81
86
 
82
- This is the internal implementation of the @every@ function seen earlier. The @timeshare@ method is provided by Sidekick to all extensions, and will call the supplied block every @duration@ seconds. This is also useful for polling something without blocking or forking.
87
+ The last example is the internal implementation of the @every@ trigger seen earlier, which calls the block periodically. @callback@ is the block given to the trigger in the @.sidekick@ file. @timeshare@ is a special method provided by Sidekick to all extensions, to register the supplied block to be called every @duration@ seconds. This is useful for polling something without blocking or doing something out of this world.
83
88
 
84
- Next, here is an example of the above written as a class:
89
+ Now, here is the last example written as a class:
85
90
 
86
91
  <pre>
87
92
  <code lang='ruby'>
@@ -107,17 +112,17 @@ Sidekick::Triggers.register_class(:watch, Watch)
107
112
  </code>
108
113
  </pre>
109
114
 
110
- The @poll@ and @poll_freq@ methods are optional. @poll@ functions like the callback block in the previous example, while @poll_freq@ functions like the @duration@ argument, specifying how often to call @poll@ in seconds. Only integers are accepted. Finally, notice the last statement, which registers the class.
115
+ The @poll@ and @poll_freq@ methods are optional. @poll@ functions like the callback block in the previous example, while @poll_freq@ functions like the @duration@ argument, specifying how often to call @poll@. Only integers (whole seconds) are accepted. Finally, notice the last statement, which registers the class.
111
116
 
112
- h2. Final lines...
117
+ h2. Fun facts
113
118
 
114
- The main code chunk of Sidekick is just under 100 lines, including documentation, excluding the default triggers and helpers. Why not read it..?
119
+ The main code chunk of Sidekick is just under 100 lines, including documentation, excluding the default triggers and helpers.
115
120
 
116
- You can keep your extensions in the @.sidekick@ file itself, or package them in gems, or ask me to merge them into the main repository.
121
+ You can keep your extensions in the @.sidekick@ file itself, or package them in gems, or (better) ask me to merge them into the main repository.
117
122
 
118
123
  Similar projects:
119
124
 
120
- * "Guard":http://github.com/guard/guard (too enterprisey for me)
125
+ * "Guard":http://github.com/guard/guard (too enterprisey imho)
121
126
 
122
127
 
123
128
  h3. Copyright
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.1
1
+ 0.4.2
@@ -79,8 +79,8 @@ module Sidekick::Helpers
79
79
  watch(source) do |files|
80
80
  files.each do |file|
81
81
  begin
82
- target.gsub! ':name', File.basename(file, '.*')
83
- File.open(target, 'w') do |f|
82
+ t = target.gsub ':name', File.basename(file, '.*')
83
+ File.open(t, 'w') do |f|
84
84
  f.write(Tilt.new(file).render)
85
85
  end
86
86
  log "rendered #{file} => #{target}"
data/lib/template CHANGED
@@ -5,7 +5,7 @@
5
5
  abort "A new .sidekick file was generated -- now you just have to edit it."
6
6
 
7
7
 
8
- # now delete the above, and tell me what to do.
8
+ # now delete the above, and set up some actions.
9
9
  # here are some samples:
10
10
 
11
11
  # watch('**/*.rb') { restart_passenger }
data/sidekick.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{sidekick}
8
- s.version = "0.4.1"
8
+ s.version = "0.4.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Jostein Berre Eliassen,"]
12
- s.date = %q{2010-10-25}
12
+ s.date = %q{2010-10-26}
13
13
  s.default_executable = %q{sidekick}
14
14
  s.description = %q{Automatically run common development tasks on events, as defined by a local .sidekick file. Easy, powerful dsl. Several pre-defined triggers. Helper methods for common tasks. Easy to extend with new triggers and helpers.}
15
15
  s.email = %q{post@jostein.be}
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 4
8
- - 1
9
- version: 0.4.1
8
+ - 2
9
+ version: 0.4.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Jostein Berre Eliassen,
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-10-25 00:00:00 +02:00
17
+ date: 2010-10-26 00:00:00 +02:00
18
18
  default_executable: sidekick
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency