sidekick 0.5.1 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/.gitmodules +3 -0
- data/README.textile +23 -17
- data/Rakefile +22 -23
- data/VERSION +1 -1
- data/annotated/helpers.html +143 -0
- data/annotated/index.html +155 -0
- data/annotated/lib/sidekick.html +144 -0
- data/annotated/sidekick.html +155 -0
- data/annotated/triggers.html +76 -0
- data/annotated/util.html +74 -0
- data/lib/sidekick.rb +44 -20
- data/lib/sidekick/helpers/compile.rb +34 -0
- data/lib/sidekick/helpers/passenger.rb +14 -0
- data/lib/sidekick/helpers/shell.rb +10 -0
- data/lib/sidekick/helpers/sidekick.rb +12 -0
- data/lib/sidekick/helpers/system.rb +36 -0
- data/lib/sidekick/helpers/user_interaction.rb +15 -0
- data/lib/sidekick/triggers.rb +3 -4
- data/lib/template +1 -3
- metadata +17 -7
- data/lib/sidekick/helpers.rb +0 -71
- data/lib/sidekick/helpers/util.rb +0 -26
- data/sidekick.gemspec +0 -71
@@ -0,0 +1,36 @@
|
|
1
|
+
|
2
|
+
require 'rbconfig'
|
3
|
+
|
4
|
+
|
5
|
+
|
6
|
+
module Sidekick::Helpers::System
|
7
|
+
def platform
|
8
|
+
{
|
9
|
+
:linux => /linux/,
|
10
|
+
:darwin => /darwin/,
|
11
|
+
:windows => /mswin|mingw|cygwin/
|
12
|
+
}.each do |platform, regex|
|
13
|
+
return platform if Config::CONFIG['host_os'] =~ regex
|
14
|
+
end; :other
|
15
|
+
end
|
16
|
+
|
17
|
+
def gem_load?(gemname)
|
18
|
+
begin
|
19
|
+
require gemname
|
20
|
+
true
|
21
|
+
rescue LoadError; false; end
|
22
|
+
end
|
23
|
+
|
24
|
+
def needs(gem_name, reason)
|
25
|
+
unless gem_load?(gem_name)
|
26
|
+
::Sidekick.stop "You must install the #{gem_name} gem #{reason}."
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def prefers(gem_name, reason)
|
31
|
+
unless gem_load?(gem_name)
|
32
|
+
log "Please install the #{gem_name} gem #{reason}."
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
@@ -0,0 +1,15 @@
|
|
1
|
+
|
2
|
+
module Sidekick::Helpers::Shell
|
3
|
+
def notify(message, title='Sidekick')
|
4
|
+
|
5
|
+
log "### #{title}: #{message}"
|
6
|
+
case platform
|
7
|
+
when :linux
|
8
|
+
needs 'libnotify', 'to display status messages on linux'
|
9
|
+
Libnotify.show :body => message, :summary => title
|
10
|
+
when :darwin
|
11
|
+
needs 'growl', 'to display status messages on a Mac.'
|
12
|
+
Growl.notify message, :title => title, :name => 'Sidekick'
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/lib/sidekick/triggers.rb
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
|
2
2
|
|
3
|
-
require 'em-dir-watcher'
|
4
|
-
|
5
|
-
|
6
3
|
module Sidekick::Triggers
|
7
4
|
|
8
|
-
|
5
|
+
extend ::Sidekick::Helpers
|
9
6
|
|
10
7
|
register :watch do |callback, glob|
|
8
|
+
needs 'em-dir-watcher', 'to watch file changes'
|
9
|
+
|
11
10
|
EMDirWatcher.watch(
|
12
11
|
File.expand_path('.'),
|
13
12
|
:include_only => [glob],
|
data/lib/template
CHANGED
@@ -1,14 +1,12 @@
|
|
1
1
|
|
2
2
|
|
3
|
-
|
4
|
-
|
5
3
|
stop "A new .sidekick file was generated -- now you just have to edit it."
|
6
4
|
|
7
5
|
|
8
6
|
# now delete the above, and set up some actions.
|
9
7
|
# here are some samples:
|
10
8
|
|
11
|
-
# watch('
|
9
|
+
# watch('**.rb') { restart_passenger }
|
12
10
|
#
|
13
11
|
# auto_compile 'assets/css/*.sass', 'public/css/:name.css'
|
14
12
|
#
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
8
|
-
-
|
9
|
-
version: 0.
|
7
|
+
- 6
|
8
|
+
- 0
|
9
|
+
version: 0.6.0
|
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-
|
17
|
+
date: 2010-10-31 00:00:00 +02:00
|
18
18
|
default_executable: sidekick
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -68,18 +68,28 @@ extra_rdoc_files:
|
|
68
68
|
files:
|
69
69
|
- .document
|
70
70
|
- .gitignore
|
71
|
+
- .gitmodules
|
71
72
|
- .sidekick
|
72
73
|
- LICENSE
|
73
74
|
- README.textile
|
74
75
|
- Rakefile
|
75
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
|
76
83
|
- bin/sidekick
|
77
84
|
- lib/sidekick.rb
|
78
|
-
- lib/sidekick/helpers.rb
|
79
|
-
- lib/sidekick/helpers/
|
85
|
+
- lib/sidekick/helpers/compile.rb
|
86
|
+
- lib/sidekick/helpers/passenger.rb
|
87
|
+
- lib/sidekick/helpers/shell.rb
|
88
|
+
- lib/sidekick/helpers/sidekick.rb
|
89
|
+
- lib/sidekick/helpers/system.rb
|
90
|
+
- lib/sidekick/helpers/user_interaction.rb
|
80
91
|
- lib/sidekick/triggers.rb
|
81
92
|
- lib/template
|
82
|
-
- sidekick.gemspec
|
83
93
|
- test/fixtures/page.haml
|
84
94
|
- test/fixtures/site.coffee
|
85
95
|
- test/fixtures/styles.sass
|
data/lib/sidekick/helpers.rb
DELETED
@@ -1,71 +0,0 @@
|
|
1
|
-
require 'fileutils'
|
2
|
-
require 'rbconfig'
|
3
|
-
require 'tilt'
|
4
|
-
|
5
|
-
|
6
|
-
# default helpers
|
7
|
-
|
8
|
-
module Sidekick::Helpers
|
9
|
-
|
10
|
-
# system
|
11
|
-
|
12
|
-
require 'sidekick/helpers/util'
|
13
|
-
include Util
|
14
|
-
|
15
|
-
def log(str)
|
16
|
-
puts ' -> ' + str
|
17
|
-
end
|
18
|
-
|
19
|
-
def stop(*prms)
|
20
|
-
Sidekick.stop(*prms)
|
21
|
-
end
|
22
|
-
|
23
|
-
# notifications
|
24
|
-
|
25
|
-
def notify(message, title='Sidekick')
|
26
|
-
|
27
|
-
gems = {:linux => 'libnotify', :darwin => 'growl'}
|
28
|
-
|
29
|
-
stop('Notifications not supported.') unless platform_load?(
|
30
|
-
gems, 'notifications')
|
31
|
-
case platform
|
32
|
-
when :linux
|
33
|
-
Libnotify.show :body => message, :summary => title
|
34
|
-
when :darwin
|
35
|
-
Growl.notify message, :title => title, :name => 'Sidekick'
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
def sh(cmd)
|
40
|
-
log cmd
|
41
|
-
puts result = `#{cmd}`
|
42
|
-
result
|
43
|
-
end
|
44
|
-
|
45
|
-
def restart_passenger
|
46
|
-
FileUtils.touch './tmp/restart.txt'
|
47
|
-
log 'restarted passenger'
|
48
|
-
end
|
49
|
-
|
50
|
-
# watches for changes matching the source glob,
|
51
|
-
# compiles using the tilt gem, and saves to
|
52
|
-
# target. Target is interpolated for :name
|
53
|
-
def auto_compile(source, target)
|
54
|
-
watch(source) do |files|
|
55
|
-
files.each do |file|
|
56
|
-
if File.exists?(file)
|
57
|
-
begin
|
58
|
-
t = target.gsub(':name', File.basename(file, '.*'))
|
59
|
-
File.open(t, 'w') do |f|
|
60
|
-
f.write(Tilt.new(file).render)
|
61
|
-
end
|
62
|
-
log "render #{file} => #{t}"
|
63
|
-
rescue Exception => e
|
64
|
-
notify "Error in #{file}:\n#{e}"
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
module Util
|
6
|
-
# :linux, :darwin, :other
|
7
|
-
def platform
|
8
|
-
[:linux, :darwin].each do |plf|
|
9
|
-
return plf if Config::CONFIG['target_os'] =~ /#{plf}/i
|
10
|
-
end; :other
|
11
|
-
end
|
12
|
-
|
13
|
-
def gem_load?(gemname, function='full')
|
14
|
-
@installed ||= begin
|
15
|
-
require gemname
|
16
|
-
true
|
17
|
-
rescue LoadError
|
18
|
-
"Please gem install #{gemname} for #{function} support."
|
19
|
-
::Sidekick.stop
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
def platform_load?(gems, function='full')
|
24
|
-
gem_load?(gems[platform], function)
|
25
|
-
end
|
26
|
-
end
|
data/sidekick.gemspec
DELETED
@@ -1,71 +0,0 @@
|
|
1
|
-
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
-
# -*- encoding: utf-8 -*-
|
5
|
-
|
6
|
-
Gem::Specification.new do |s|
|
7
|
-
s.name = %q{sidekick}
|
8
|
-
s.version = "0.5.1"
|
9
|
-
|
10
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
-
s.authors = ["Jostein Berre Eliassen,"]
|
12
|
-
s.date = %q{2010-10-27}
|
13
|
-
s.default_executable = %q{sidekick}
|
14
|
-
s.description = %q{Automatically run common development tasks on events, as defined by a local .sidekick file. Easy, powerful DSL. Powered by EventMachine. Easy to extend.}
|
15
|
-
s.email = %q{post@jostein.be}
|
16
|
-
s.executables = ["sidekick"]
|
17
|
-
s.extra_rdoc_files = [
|
18
|
-
"LICENSE",
|
19
|
-
"README.textile"
|
20
|
-
]
|
21
|
-
s.files = [
|
22
|
-
".document",
|
23
|
-
".gitignore",
|
24
|
-
".sidekick",
|
25
|
-
"LICENSE",
|
26
|
-
"README.textile",
|
27
|
-
"Rakefile",
|
28
|
-
"VERSION",
|
29
|
-
"bin/sidekick",
|
30
|
-
"lib/sidekick.rb",
|
31
|
-
"lib/sidekick/helpers.rb",
|
32
|
-
"lib/sidekick/helpers/util.rb",
|
33
|
-
"lib/sidekick/triggers.rb",
|
34
|
-
"lib/template",
|
35
|
-
"sidekick.gemspec",
|
36
|
-
"test/fixtures/page.haml",
|
37
|
-
"test/fixtures/site.coffee",
|
38
|
-
"test/fixtures/styles.sass",
|
39
|
-
"test/helper.rb",
|
40
|
-
"test/test_sidekick.rb"
|
41
|
-
]
|
42
|
-
s.homepage = %q{http://github.com/jbe/sidekick}
|
43
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
44
|
-
s.require_paths = ["lib"]
|
45
|
-
s.rubygems_version = %q{1.3.7}
|
46
|
-
s.summary = %q{Automatically run common development tasks on events, as defined by a local .sidekick file.}
|
47
|
-
s.test_files = [
|
48
|
-
"test/helper.rb",
|
49
|
-
"test/test_sidekick.rb"
|
50
|
-
]
|
51
|
-
|
52
|
-
if s.respond_to? :specification_version then
|
53
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
54
|
-
s.specification_version = 3
|
55
|
-
|
56
|
-
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
57
|
-
s.add_runtime_dependency(%q<tilt>, [">= 1"])
|
58
|
-
s.add_runtime_dependency(%q<eventmachine>, [">= 0"])
|
59
|
-
s.add_runtime_dependency(%q<em-dir-watcher>, [">= 0"])
|
60
|
-
else
|
61
|
-
s.add_dependency(%q<tilt>, [">= 1"])
|
62
|
-
s.add_dependency(%q<eventmachine>, [">= 0"])
|
63
|
-
s.add_dependency(%q<em-dir-watcher>, [">= 0"])
|
64
|
-
end
|
65
|
-
else
|
66
|
-
s.add_dependency(%q<tilt>, [">= 1"])
|
67
|
-
s.add_dependency(%q<eventmachine>, [">= 0"])
|
68
|
-
s.add_dependency(%q<em-dir-watcher>, [">= 0"])
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|