sidekick 0.6.1 → 0.6.2

Sign up to get free protection for your applications and to get access to all the features.
data/.sidekick CHANGED
@@ -1,12 +1,8 @@
1
- # This is an example sidekick file that i use for testing
2
- # by doing. Proper tests are welcome.
3
1
 
4
2
 
3
+ # every(5) { notify sh 'fortune' }
5
4
 
6
-
7
- # watch '**/*.rb' {|paths| log 'made edits' }
8
-
9
- every(5) { notify sh 'fortune' }
5
+ watch('lib/**.rb') { rake 'docs' }
10
6
 
11
7
  auto_compile 'test/fixtures/*.haml', 'test/output/:name.html'
12
8
 
@@ -3,7 +3,7 @@ h1. Sidekick
3
3
  "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:
4
4
 
5
5
  <pre><code>
6
- watch('**/*.rb') { restart_passenger }
6
+ watch('**/*.rb') { restart_passenger; rake docs }
7
7
 
8
8
  auto_compile 'assets/*.sass', 'public/:name.css'
9
9
 
@@ -14,7 +14,7 @@ h3. Sample use cases
14
14
 
15
15
  * Restart server when code is changed
16
16
  * Auto-compile Sass or CoffeeScript templates (and many other languages)
17
- * Periodically run commands
17
+ * Periodically run tasks
18
18
  * Continuous testing, notifications, hooks, you name it
19
19
 
20
20
  h3. Features
@@ -23,40 +23,20 @@ h3. Features
23
23
  * Easy to extend
24
24
  * Compiles many formats, thanks to "Tilt":http://github.com/rtomayko/tilt.
25
25
  * Powered by "EventMachine":http://github.com/eventmachine/eventmachine
26
- * The core is about 60 lines of code
26
+ * Short and sweet codebase - core < 100 loc
27
27
 
28
- You should "read the annotated source code":http://jbe.github.com/sidekick/.
28
+ You can "read the annotated source code":http://jbe.github.com/sidekick/sidekick.html.
29
29
 
30
30
  h2. Basic usage
31
31
 
32
- Install with @gem install sidekick@ and invoke the @sidekick@ command in your project folder. If you do not have a @.sidekick@ file, you will be offered a template.
32
+ Install with @gem install sidekick@ and invoke the @sidekick@ command in your project folder. If you do not have a @.sidekick@ file, you will be offered a "template":http://github.com/jbe/sidekick/blob/master/lib/template with plenty of examples.
33
33
 
34
- For now, look to the source code to see all available
34
+ View source:
35
35
 
36
36
  * "triggers":http://jbe.github.com/sidekick/triggers.html
37
+ * "helpers":http://github.com/jbe/sidekick/tree/master/lib/sidekick/helpers/
37
38
 
38
- * "helpers":http://jbe.github.com/sidekick/helpers.html
39
-
40
- h2. Writing extensions
41
-
42
- h3. Writing new helpers
43
-
44
- To add more helpers, simply add methods to @Sidekick::Helpers@, like this:
45
-
46
- <pre>
47
- <code lang='ruby'>
48
- module Sidekick::Helpers
49
- def make_pickle
50
- PickeFactory.manufacture!
51
- end
52
- end
53
- </code>
54
- </pre>
55
-
56
- They will be available to other helpers and to @.sidekick@ files. When adding a group of methods it may be cleaner to write a module under @Sidekick::Helpers@, and then including it.
57
-
58
-
59
- h3. Writing new triggers
39
+ h2. Defining new triggers
60
40
 
61
41
  Have a look at the "existing triggers":http://jbe.github.com/sidekick/triggers.html, and you will get the idea. Basically, you define new triggers by calling @Sidekick::Triggers.register(:trigger_name) { .. }@, and hooking into EventMachine the same way as in @EM.run { .. }@ from there.
62
42
 
data/Rakefile CHANGED
@@ -37,15 +37,11 @@ require 'rocco/tasks'
37
37
  Rocco::make 'website/'
38
38
 
39
39
  desc 'Build docco'
40
- task :docs => [:rocco, 'website/index.html']
40
+ task :docs => [:clear_docs, :rocco]
41
41
  directory 'website/'
42
42
 
43
- # Make index.html a copy of rocco.html
44
- file 'website/index.html' => 'website/sidekick.html' do |f|
45
- cp 'website/sidekick.html', 'website/index.html', :preserve => true
43
+ task :clear_docs do
44
+ sh 'rm website/*.html'
46
45
  end
47
46
 
48
- CLEAN.include 'website/index.html'
49
- task :doc => :docs
50
-
51
47
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.6.1
1
+ 0.6.2
@@ -6,13 +6,10 @@ module Sidekick::Helpers::Compile
6
6
 
7
7
  def compile(source, target)
8
8
  needs 'tilt', 'to compile templates'
9
-
10
- begin
9
+ handling Exception, source do
11
10
  File.open(target, 'w') do |f|
12
11
  f.write(Tilt.new(source).render)
13
12
  end
14
- rescue Exception => e
15
- notify "Error compiling #{file}:\n#{e}"
16
13
  end
17
14
  end
18
15
 
@@ -0,0 +1,12 @@
1
+
2
+ module Sidekick::Helpers::Compile
3
+
4
+ def rake(task_name)
5
+ needs 'rake', 'to invoke rake tasks'
6
+ handling Exception, "rake #{task_name}" do
7
+ load 'Rakefile'
8
+ Rake::application[task_name].invoke
9
+ end
10
+ end
11
+
12
+ end
@@ -2,9 +2,7 @@
2
2
  module Sidekick::Helpers::Shell
3
3
 
4
4
  def sh(cmd)
5
- log cmd
6
- puts result = `#{cmd}`
7
- result
5
+ log cmd; `#{cmd}`
8
6
  end
9
7
 
10
8
  end
@@ -32,5 +32,17 @@ module Sidekick::Helpers::System
32
32
  log "Please install the #{gem_name} gem #{reason}."
33
33
  end
34
34
  end
35
+
36
+ def handling(err_kls=Exception, context=nil)
37
+ begin
38
+ yield
39
+ rescue err_kls => e
40
+ if context
41
+ notify "#{context}:\n#{e}", e.class.name
42
+ else
43
+ notify "#{e}\n#{e.backtrace[0..2]}", e.class.name
44
+ end
45
+ end
46
+ end
35
47
  end
36
48
 
@@ -1,8 +1,8 @@
1
1
 
2
- module Sidekick::Helpers::Shell
2
+ module Sidekick::Helpers::UserInteraction
3
3
  def notify(message, title='Sidekick')
4
4
 
5
- log "### #{title}: #{message}"
5
+ log "NOTIFY #{title}: #{message}"
6
6
  case platform
7
7
  when :linux
8
8
  needs 'libnotify', 'to display status messages on linux'
@@ -1,21 +1,32 @@
1
1
 
2
-
3
2
  stop "A new .sidekick file was generated -- now you just have to edit it."
4
3
 
4
+ # Now delete the line above, and set up some actions.
5
+ # Here are some samples:
5
6
 
6
- # now delete the above, and set up some actions.
7
- # here are some samples:
8
7
 
9
- # watch('**.rb') { restart_passenger }
10
- #
11
8
  # auto_compile 'assets/css/*.sass', 'public/css/:name.css'
12
- #
9
+
13
10
  # auto_compile 'assets/js/*.coffee', 'public/js/:name.js'
14
- #
15
- # every(60) { notify 'You are now one minute older.' }
16
- #
11
+
12
+ # every(60*60) { notify 'You are now one hour older.' }
13
+
17
14
  # every(60*15) { notify sh 'fortune' }
18
15
 
16
+ # watch('**.rb') do |paths|
17
+ # log 'code change'
18
+ # restart_passenger
19
+ # rake 'doc'
20
+ # end
21
+
22
+
23
+ # more sample actions:
24
+
25
+ # needs 'httparty', 'to look up your location'
26
+ # loc = HTTParty.get('http://ipinfodb.com/ip_query.php')
27
+ # notify "You are in #{loc['Response']['City']}"
28
+
29
+
19
30
 
20
31
 
21
32
 
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 6
8
- - 1
9
- version: 0.6.1
8
+ - 2
9
+ version: 0.6.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-31 00:00:00 +02:00
17
+ date: 2010-11-02 00:00:00 +01:00
18
18
  default_executable: sidekick
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -78,8 +78,9 @@ files:
78
78
  - lib/sidekick.rb
79
79
  - lib/sidekick/helpers/compile.rb
80
80
  - lib/sidekick/helpers/passenger.rb
81
+ - lib/sidekick/helpers/rake.rb
81
82
  - lib/sidekick/helpers/shell.rb
82
- - lib/sidekick/helpers/sidekick.rb
83
+ - lib/sidekick/helpers/sidekick_itself.rb
83
84
  - lib/sidekick/helpers/system.rb
84
85
  - lib/sidekick/helpers/user_interaction.rb
85
86
  - lib/sidekick/triggers.rb