geoffreywiseman-prune 1.2.0.rc3 → 1.2.0.rc4

Sign up to get free protection for your applications and to get access to all the features.
data/lib/prune/cli.rb CHANGED
@@ -4,7 +4,7 @@ require 'optparse'
4
4
  require 'date'
5
5
 
6
6
  module Prune
7
- VERSION = Gem::Version.new '1.2.0.rc3'
7
+ VERSION = Gem::Version.new '1.2.0.rc4'
8
8
 
9
9
  class CommandLineInterface
10
10
 
data/lib/prune/pruner.rb CHANGED
@@ -5,9 +5,11 @@ require 'date'
5
5
  module Prune
6
6
 
7
7
  class Pruner
8
+ FILTERS = [ '.', '..', '.prune' ]
9
+
8
10
  attr_reader :categories
9
11
  attr_reader :options
10
-
12
+
11
13
  def initialize( options )
12
14
  @options = options
13
15
  @categories = Hash.new { |h,k| h[k] = [] } # initialize new keys with an empty array
@@ -28,7 +30,7 @@ module Prune
28
30
  print "Analyzing '#{folder_name}':\n"
29
31
  files = Dir.entries( folder_name ).sort_by { |f| test(?M, File.join( folder_name, f ) ) }
30
32
  files.each do |file|
31
- analyze_file( policy, file )
33
+ analyze_file( policy, file ) unless filter?(file)
32
34
  end
33
35
  print "\n" if @options[:verbose]
34
36
 
@@ -136,6 +138,14 @@ module Prune
136
138
  @analyzed_count += 1
137
139
  end
138
140
 
141
+ def filter?( file )
142
+ return file =~ /\.prune/
143
+ end
144
+
145
+ def filter?( file )
146
+ return FILTERS.include? file
147
+ end
148
+
139
149
  end
140
150
 
141
151
  end
data/spec/pruner_spec.rb CHANGED
@@ -52,6 +52,33 @@ describe Prune::Pruner do
52
52
 
53
53
  end
54
54
 
55
+ context "with just a .prune file" do
56
+
57
+ before( :each ) do
58
+ stub_files [ ".prune", '.', '..' ]
59
+ stub_messages
60
+ subject.prune PRUNE_PATH
61
+ end
62
+
63
+ it "should not invoke the retention policy" do
64
+ @retention_policy.should_not_receive( :categorize )
65
+ end
66
+
67
+ it "should print 'Analyzing #{PRUNE_PATH}'" do
68
+ @messages.should include("Analyzing '#{PRUNE_PATH}':\n")
69
+ end
70
+
71
+ it "should say no action was required" do
72
+ @messages.should include("No actions necessary.\n")
73
+ end
74
+
75
+ it "should say no files were analyzed" do
76
+ @messages.should include_match( /0 file\(s\) analyzed/ )
77
+ end
78
+
79
+ end
80
+
81
+
55
82
  context "with three files" do
56
83
  ONE_DAY = 86400
57
84
 
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.2.0.rc3
4
+ version: 1.2.0.rc4
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2011-09-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: minitar
16
- requirement: &70115417584560 !ruby/object:Gem::Requirement
16
+ requirement: &70347705700040 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: 0.5.3
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70115417584560
24
+ version_requirements: *70347705700040
25
25
  description: Prune is meant to analyze a folder full of files, run them against a
26
26
  retention policy and decide which to keep, which to remove and which to archive.
27
27
  It is extensible and embeddable.
@@ -49,7 +49,6 @@ files:
49
49
  - spec/spec_helper.rb
50
50
  - bin/prune
51
51
  - Rakefile
52
- - README.mdown
53
52
  - UNLICENSE
54
53
  homepage: http://geoffreywiseman.github.com/prune
55
54
  licenses: []
data/README.mdown DELETED
@@ -1,28 +0,0 @@
1
- # Prune: Deleting and archiving files by date
2
-
3
- We have some nightly processes that archive information that we'd like to retain, either for reference or
4
- for possible restoration. In order to keep space usage somewhat reasonable, we'd like to prune some of
5
- those files as they get older. Prune satisfies that need.
6
-
7
- Prune is written as a Ruby library with an optional command-line interface and a wrapping shell script.
8
-
9
- ## Usage
10
-
11
- Prune has a command-line interface and a configurable retention policy. It is packaged as a gem, which
12
- can be installed easily:
13
-
14
- gem install geoffreywiseman-prune
15
-
16
- At which point you should be able to prune a directory using the default retention policy:
17
-
18
- prune <directory>
19
-
20
- And get more information on using it:
21
-
22
- prune --help
23
-
24
- The retention policy is [configurable](http://geoffreywiseman.github.com/prune/configure.html).
25
-
26
- ## Continuous Integration
27
-
28
- Prune is built by [Travis CI](http://travis-ci.org/#!/geoffreywiseman/prune).