guard-addremove 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2012 Pascal Ehlert
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Readme.md ADDED
@@ -0,0 +1,38 @@
1
+ # Guard::Addremove
2
+
3
+ This guard allows you execute shell commands whenever files are added or removed.
4
+ It is very much like guard-shell, but ignores changes to existing files.
5
+
6
+
7
+ ## Install
8
+
9
+ Make sure you have [guard](http://github.com/guard/guard) installed.
10
+
11
+ Install the gem with:
12
+
13
+ gem install guard-addremove
14
+
15
+ Or add it to your Gemfile:
16
+
17
+ gem 'guard-addremove'
18
+
19
+ And then add a basic setup to your Guardfile:
20
+
21
+ guard init addremove
22
+
23
+
24
+ ## Usage
25
+
26
+ This guard was originally written to allow the removal of caches when the filesystem changes.
27
+ This can be helpful in combination with vim's plugins CtrlP or Command-T. Find a quick guide how
28
+ to use it in my [blog](http://www.hacksrus.net/blog/2012/10/using-vims-ctrlp/).
29
+
30
+ ``` ruby
31
+ guard :addremove do
32
+ watch /.*/ do |m|
33
+ `echo "#{m[0]} has been added or removed."`
34
+ end
35
+ end
36
+ ```
37
+
38
+ will simply print a message telling you a file has been added or removed.
@@ -0,0 +1,6 @@
1
+ # Add files and commands to this file, like the example:
2
+ # watch(%r{file/path}) { `command(s)` }
3
+ #
4
+ guard 'addremove' do
5
+ watch(/(.*)/) {|m| `echo "File as been added or removed: #{m[0]}"` }
6
+ end
@@ -0,0 +1,32 @@
1
+ require 'guard'
2
+ require 'guard/guard'
3
+ require 'guard/watcher'
4
+
5
+ module Guard
6
+ class Addremove < Guard
7
+
8
+ VERSION = '1.0.0'
9
+
10
+ # Calls #run_all if the :all_on_start option is present.
11
+ def start
12
+ run_all if options[:all_on_start]
13
+ end
14
+
15
+ # Call #run_on_additions for all files which match this guard.
16
+ def run_all
17
+ run_on_additions(Watcher.match_files(self, Dir.glob('{,**/}*{,.*}').uniq))
18
+ end
19
+
20
+ def run_on_additions(res)
21
+ puts res if res
22
+ end
23
+ alias_method :run_on_removals, :run_on_additions
24
+ end
25
+
26
+ class Dsl
27
+ # Taken from guard-shell. Easy method to display a notification
28
+ def n(msg, title='', image=nil)
29
+ Notifier.notify(msg, :title => title, :image => image)
30
+ end
31
+ end
32
+ end
metadata ADDED
@@ -0,0 +1,65 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: guard-addremove
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Pascal Ehlert
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-10-27 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: guard
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: 0.2.0
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 0.2.0
30
+ description: ! " Guard::Shell automatically runs shell commands when watched files
31
+ are added or\n removed from the file system.\n"
32
+ email: pascal@hacksrus.net
33
+ executables: []
34
+ extensions: []
35
+ extra_rdoc_files: []
36
+ files:
37
+ - Readme.md
38
+ - LICENSE
39
+ - lib/guard/addremove/templates/Guardfile
40
+ - lib/guard/addremove.rb
41
+ homepage: http://github.com/pehlert/guard-addremove
42
+ licenses: []
43
+ post_install_message:
44
+ rdoc_options: []
45
+ require_paths:
46
+ - lib
47
+ required_ruby_version: !ruby/object:Gem::Requirement
48
+ none: false
49
+ requirements:
50
+ - - ! '>='
51
+ - !ruby/object:Gem::Version
52
+ version: '0'
53
+ required_rubygems_version: !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ! '>='
57
+ - !ruby/object:Gem::Version
58
+ version: '0'
59
+ requirements: []
60
+ rubyforge_project:
61
+ rubygems_version: 1.8.24
62
+ signing_key:
63
+ specification_version: 3
64
+ summary: Guard gem for running shell commands when files are added or removed
65
+ test_files: []