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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 89c920f4af989a1bba3db2478a1237a3cc0603b2
4
- data.tar.gz: a6ad83bb456149beafbea78df830742be3129b78
3
+ metadata.gz: 1cabe7b54d6be975a001aabb086928275d572c4f
4
+ data.tar.gz: 7e597d2bf76ccf5b0699783d8c8e3ff9cb9bc737
5
5
  SHA512:
6
- metadata.gz: 00b0dfc00922b298475fc4e69e3c7c22c9a6ade2af0faffc8a24547888af4e3977003293ff4644034f7ef2b4b57a78c651c1db311907d0358e4f8fc7f08a5865
7
- data.tar.gz: 44ed5f208033ba8c1fd4e070a264a633c2c126905ff163076389e342b42e53d621c53678d6f15a04cb6d9541499a95e5b0e6067d53017a8e86fae058409546ec
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( 'coverage', 'pkg' )
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
@@ -5,7 +5,7 @@
5
5
  # @author Geoffrey Wiseman
6
6
  module Prune
7
7
  # The version of the prune gem and all the associated code.
8
- VERSION = Gem::Version.new '1.3.0'
8
+ VERSION = Gem::Version.new '1.3.1'
9
9
 
10
10
  # The release date associated with the version
11
11
  RELEASE_DATE = '2016-06-24'
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
- paths.each { |path| FileUtils.remove_entry( path, true ) }
99
-
100
- "#{files.size} file(s) deleted"
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
@@ -1,3 +1,6 @@
1
+ require 'simplecov'
2
+ SimpleCov.start
3
+
1
4
  def stub_messages
2
5
  @messages = []
3
6
  $stdout.stub( :write ) { |message| @messages << message }
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.0
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.2.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.