geoffreywiseman-prune 1.3.0 → 1.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +1 -7
- data/lib/prune/meta.rb +1 -1
- data/lib/prune/pruner.rb +12 -3
- data/spec/pruner_spec.rb +10 -3
- data/spec/spec_helper.rb +3 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1cabe7b54d6be975a001aabb086928275d572c4f
|
4
|
+
data.tar.gz: 7e597d2bf76ccf5b0699783d8c8e3ff9cb9bc737
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 359b5317271207d42ad2b1353b46b158ad7bf75f946fb7e59e4b96bc48db0ee5ec49e278f3f2c869a23ccbbaf53f387cf6f4fc99618e84a65fd83ebd25ffe106
|
7
|
+
data.tar.gz: ee680bd731faff3f791b7d45826edd1699a04ec981ce27e03a2e73c909528729e371b18810d7344456b1a5250b6fded1426e35165f86d55b87e9b5406fa461d7
|
data/Rakefile
CHANGED
@@ -6,7 +6,7 @@ require 'rubygems'
|
|
6
6
|
require 'rubygems/package_task'
|
7
7
|
require 'prune'
|
8
8
|
|
9
|
-
CLEAN.include( '
|
9
|
+
CLEAN.include( 'pkg' )
|
10
10
|
|
11
11
|
desc '"spec" (run RSpec)'
|
12
12
|
task :default => :spec
|
@@ -14,12 +14,6 @@ task :default => :spec
|
|
14
14
|
desc "Run RSpec on spec/*"
|
15
15
|
RSpec::Core::RakeTask.new
|
16
16
|
|
17
|
-
desc "Generate code coverage"
|
18
|
-
RSpec::Core::RakeTask.new(:coverage) do |t|
|
19
|
-
t.rcov = true
|
20
|
-
t.rcov_opts = ['--exclude', 'spec,/gems/,/rubygems/', '--text-report']
|
21
|
-
end
|
22
|
-
|
23
17
|
spec = Gem::Specification.new do |spec|
|
24
18
|
spec.name = 'geoffreywiseman-prune'
|
25
19
|
spec.version = Prune::VERSION
|
data/lib/prune/meta.rb
CHANGED
data/lib/prune/pruner.rb
CHANGED
@@ -95,9 +95,18 @@ module Prune
|
|
95
95
|
paths = files.map { |file| File.join folder_name, file }
|
96
96
|
|
97
97
|
begin
|
98
|
-
|
99
|
-
|
100
|
-
|
98
|
+
failed_paths = []
|
99
|
+
paths.each do |path|
|
100
|
+
if FileUtils.remove_entry( path, true ) == 0
|
101
|
+
failed_paths << path
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
if failed_paths.empty?
|
106
|
+
"#{files.size} file(s) deleted"
|
107
|
+
else
|
108
|
+
"#{files.size-failed_paths.size} file(s) deleted, #{failed_paths.size} file(s) could not be deleted."
|
109
|
+
end
|
101
110
|
rescue
|
102
111
|
raise IOError, "Could not remove file(s): #{$!}"
|
103
112
|
end
|
data/spec/pruner_spec.rb
CHANGED
@@ -118,15 +118,22 @@ describe Prune::Pruner do
|
|
118
118
|
end
|
119
119
|
|
120
120
|
it "should delete file" do
|
121
|
-
FileUtils.should_receive( :remove_entry ).with( File.join( PRUNE_PATH, FILENAME ), true )
|
121
|
+
FileUtils.should_receive( :remove_entry ).with( File.join( PRUNE_PATH, FILENAME ), true ) { 1 }
|
122
122
|
subject.prune PRUNE_PATH
|
123
123
|
end
|
124
124
|
|
125
125
|
it "should display file deleted message" do
|
126
|
-
FileUtils.should_receive( :remove_entry ).with( File.join( PRUNE_PATH, FILENAME ), true )
|
126
|
+
FileUtils.should_receive( :remove_entry ).with( File.join( PRUNE_PATH, FILENAME ), true ) { 1 }
|
127
127
|
subject.prune PRUNE_PATH
|
128
|
-
@messages.should include_match( /file\(s\) deleted/ )
|
128
|
+
@messages.should include_match( /1 file\(s\) deleted/ )
|
129
129
|
end
|
130
|
+
|
131
|
+
it "should display failed deletion mesage" do
|
132
|
+
FileUtils.should_receive( :remove_entry ).with( File.join( PRUNE_PATH, FILENAME ), true ) { 0 }
|
133
|
+
subject.prune PRUNE_PATH
|
134
|
+
@messages.should include_match( /0 file\(s\) deleted, 1 file\(s\) could not be deleted/ )
|
135
|
+
end
|
136
|
+
|
130
137
|
end
|
131
138
|
|
132
139
|
context "with no files categorized as archive" do
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: geoffreywiseman-prune
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Geoffrey Wiseman
|
@@ -72,7 +72,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
72
72
|
version: '0'
|
73
73
|
requirements: []
|
74
74
|
rubyforge_project:
|
75
|
-
rubygems_version: 2.
|
75
|
+
rubygems_version: 2.4.5.2
|
76
76
|
signing_key:
|
77
77
|
specification_version: 4
|
78
78
|
summary: Prunes files from a folder based on a retention policy, often time-based.
|