guard-shell 0.2.0 → 0.3.0
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.
- data/{README.md → Readme.md} +13 -14
- data/lib/guard/shell.rb +9 -9
- metadata +6 -6
data/{README.md → Readme.md}
RENAMED
@@ -1,11 +1,11 @@
|
|
1
|
-
# Guard
|
1
|
+
# Guard::Shell
|
2
2
|
|
3
|
-
This little addition
|
4
|
-
|
3
|
+
This little addition to guard allows you to run shell commands when files are
|
4
|
+
altered.
|
5
5
|
|
6
6
|
|
7
7
|
## Install
|
8
|
-
|
8
|
+
|
9
9
|
Make sure you have [guard](http://github.com/guard/guard) installed.
|
10
10
|
|
11
11
|
Install the gem with:
|
@@ -23,11 +23,11 @@ And then add a basic setup to your Guardfile:
|
|
23
23
|
|
24
24
|
## Usage
|
25
25
|
|
26
|
-
If you can do something in your shell, it is probably very easy to setup with
|
26
|
+
If you can do something in your shell, it is probably very easy to setup with
|
27
27
|
guard-shell. It can take an option, `:all_on_start` which will, if set to true,
|
28
28
|
run all tasks on start.
|
29
29
|
|
30
|
-
There is also a shortcut method, `#n(msg, title='')`, which can be used to
|
30
|
+
There is also a shortcut method, `#n(msg, title='')`, which can be used to
|
31
31
|
display a notification within your watch blocks. See the examples for usage.
|
32
32
|
|
33
33
|
### Examples
|
@@ -35,30 +35,29 @@ display a notification within your watch blocks. See the examples for usage.
|
|
35
35
|
#### Printing the Name of the File You Changed
|
36
36
|
|
37
37
|
guard :shell do
|
38
|
-
# if the block returns something, it will be
|
38
|
+
# if the block returns something, it will be printed with `puts`
|
39
39
|
watch(/(.*)/) {|m| m[0] + " was just changed" }
|
40
40
|
end
|
41
41
|
|
42
42
|
#### Saying the Name of the File You Changed and Displaying a Notification
|
43
43
|
|
44
44
|
guard :shell do
|
45
|
-
watch /(.*)/ do |m|
|
45
|
+
watch /(.*)/ do |m|
|
46
46
|
n m[0], 'Changed'
|
47
47
|
`say -v cello #{m[0]}`
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
51
|
-
#### Rebuilding LaTeX
|
51
|
+
#### Rebuilding LaTeX
|
52
52
|
|
53
53
|
guard :shell do
|
54
54
|
watch /^([^\/]*)\.tex/ do |m|
|
55
55
|
`pdflatex -shell-escape #{m[0]}`
|
56
56
|
`rm #{m[1]}.log`
|
57
|
-
|
58
|
-
count = `texcount -inc -nc -1
|
59
|
-
msg = "
|
57
|
+
|
58
|
+
count = `texcount -inc -nc -1 #{m[0]}`.split('+').first
|
59
|
+
msg = "Built #{m[1]}.pdf (#{count} words)"
|
60
60
|
n msg, 'LaTeX'
|
61
|
-
"->
|
61
|
+
"-> #{msg}"
|
62
62
|
end
|
63
63
|
end
|
64
|
-
|
data/lib/guard/shell.rb
CHANGED
@@ -4,30 +4,30 @@ require 'guard/watcher'
|
|
4
4
|
|
5
5
|
module Guard
|
6
6
|
class Shell < Guard
|
7
|
-
|
8
|
-
VERSION = '0.
|
9
|
-
|
7
|
+
|
8
|
+
VERSION = '0.3.0'
|
9
|
+
|
10
10
|
# Calls #run_all if the :all_on_start option is present.
|
11
11
|
def start
|
12
12
|
run_all if options[:all_on_start]
|
13
13
|
end
|
14
|
-
|
14
|
+
|
15
15
|
# Call #run_on_change for all files which match this guard.
|
16
16
|
def run_all
|
17
17
|
run_on_change(Watcher.match_files(self, Dir.glob('{,**/}*{,.*}').uniq))
|
18
18
|
end
|
19
19
|
|
20
|
-
# Print the result of the command, if there
|
20
|
+
# Print the result of the command(s), if there are results to be printed.
|
21
21
|
def run_on_change(res)
|
22
|
-
puts res
|
22
|
+
puts res if res
|
23
23
|
end
|
24
|
-
|
24
|
+
|
25
25
|
end
|
26
|
-
|
26
|
+
|
27
27
|
class Dsl
|
28
28
|
# Easy method to display a notification
|
29
29
|
def n(msg, title='')
|
30
30
|
::Guard::Notifier.notify(msg, :title => title)
|
31
31
|
end
|
32
32
|
end
|
33
|
-
end
|
33
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: guard-shell
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2012-01-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: guard
|
16
|
-
requirement: &
|
16
|
+
requirement: &2152958780 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,15 +21,15 @@ dependencies:
|
|
21
21
|
version: 0.2.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2152958780
|
25
25
|
description: ! " Guard::Shell automatically runs shell commands when watched files
|
26
|
-
are
|
26
|
+
are\n modified.\n"
|
27
27
|
email: m@hawx.me
|
28
28
|
executables: []
|
29
29
|
extensions: []
|
30
30
|
extra_rdoc_files: []
|
31
31
|
files:
|
32
|
-
-
|
32
|
+
- Readme.md
|
33
33
|
- LICENSE
|
34
34
|
- lib/guard/shell/templates/Guardfile
|
35
35
|
- lib/guard/shell.rb
|