guard-copy 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Guard::Copy [![Build Status](https://secure.travis-ci.org/marcisme/guard-copy.png?branch=master)](http://travis-ci.org/marcisme/guard-copy)
1
+ # Guard::Copy [![Build Status](https://secure.travis-ci.org/marcisme/guard-copy.png?branch=master)](http://travis-ci.org/marcisme/guard-copy) [![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/marcisme/guard-copy)
2
2
 
3
3
  Copy guard copies files to one or more locations whenever files are
4
4
  created or modified.
@@ -58,12 +58,13 @@ the directory specified by the `:from` option to that specified by the
58
58
 
59
59
  ``` ruby
60
60
  :from => 'source' # directory to copy files from
61
- :to => 'target' # directory or glob to copy files to; can be an array
61
+ :to => 'target' # directory or glob to copy files to; string or array
62
62
  :glob => :newest # how to handle globs; default: :all
63
63
  # :newest - copy to only the newest directory
64
64
  # :all - copy to all directories
65
- :delete => true # delete files from target directories
66
- :verbose => true # log all operations as info messages
65
+ :delete => true # delete files from target directories; default: false
66
+ :verbose => true # log all operations as info messages; default: false
67
+ :absolute => true # allow absolute paths for :to; default: false
67
68
  ```
68
69
 
69
70
  ## Watchers
data/lib/guard/copy.rb CHANGED
@@ -28,6 +28,7 @@ module Guard
28
28
  validate_presence_of(:from)
29
29
  validate_from_is_directory
30
30
  validate_presence_of(:to)
31
+ validate_to_patterns_are_not_absolute
31
32
  validate_to_does_not_include_from
32
33
  resolve_targets
33
34
  validate_no_targets_are_files
@@ -159,19 +160,23 @@ module Guard
159
160
  end
160
161
  end
161
162
 
163
+ def validate_to_patterns_are_not_absolute
164
+ targets.each do |target|
165
+ if target.absolute? && !options[:absolute]
166
+ UI.error('Guard::Copy - :to contains an absolute path:')
167
+ UI.error(" #{target.pattern}")
168
+ UI.error('Set the :absolute option to allow absolute target paths')
169
+ throw :task_has_failed
170
+ end
171
+ end
172
+ end
173
+
162
174
  def display_target_paths
163
175
  if target_paths.any?
164
- UI.info("Guard::Copy will copy files from:")
176
+ UI.info("Guard::Copy - files in:")
165
177
  UI.info(" #{options[:from]}")
166
- UI.info("to:")
178
+ UI.info("will be copied to#{ ' and removed from' if options[:delete] }:")
167
179
  target_paths.each { |target_path| UI.info(" #{target_path}") }
168
-
169
- if options[:delete]
170
- UI.info("Guard::Copy will delete files removed from:")
171
- UI.info(" #{options[:from]}")
172
- UI.info("from:")
173
- target_paths.each { |target_path| UI.info(" #{target_path}") }
174
- end
175
180
  end
176
181
  end
177
182
 
@@ -32,6 +32,11 @@ module Guard
32
32
  @paths.any?
33
33
  end
34
34
 
35
+ # @return [Boolean] true if the pattern is an absolute path
36
+ def absolute?
37
+ @pattern.start_with?('/')
38
+ end
39
+
35
40
  end
36
41
  end
37
42
  end
@@ -1,5 +1,5 @@
1
1
  module Guard
2
2
  module CopyVersion
3
- VERSION = "0.0.4"
3
+ VERSION = "0.0.5"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: guard-copy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-06-26 00:00:00.000000000 Z
12
+ date: 2012-07-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: guard
@@ -54,7 +54,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
54
54
  version: '0'
55
55
  segments:
56
56
  - 0
57
- hash: 7137334980115499
57
+ hash: 258885786691457194
58
58
  required_rubygems_version: !ruby/object:Gem::Requirement
59
59
  none: false
60
60
  requirements:
@@ -63,7 +63,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
63
63
  version: '0'
64
64
  segments:
65
65
  - 0
66
- hash: 7137334980115499
66
+ hash: 258885786691457194
67
67
  requirements: []
68
68
  rubyforge_project:
69
69
  rubygems_version: 1.8.24