geoffreywiseman-prune 1.2.0.rc4 → 1.2.0.rc5

Sign up to get free protection for your applications and to get access to all the features.
@@ -7,6 +7,10 @@ require 'tmpdir'
7
7
  include Archive::Tar
8
8
 
9
9
  module Prune
10
+
11
+ # Responsible for making or updating archives based on a list of files.
12
+ #
13
+ # This is essentially a wrapper around tar/zlib.
10
14
  class Archiver
11
15
  attr_reader :destination
12
16
 
@@ -1,34 +1,40 @@
1
- class Category
2
- attr_accessor :action, :description
3
-
4
- def initialize( description, action, quiet = false, predicate = Proc.new { |x| true } )
5
- @description = description
6
- @action = action
7
- @predicate = predicate
8
- @quiet = quiet
9
- end
10
-
11
- def requires_prompt?
12
- case @action
13
- when :remove
14
- true
15
- when :archive
16
- true
17
- else
18
- false
1
+ module Prune
2
+
3
+ # A category indicates how a file has been classified. These are defined in the retention policy,
4
+ # whether that be a project-specific one or the core retention policy. This is the primary abstraction
5
+ # used to decide what to do with a file.
6
+ class Category
7
+ attr_accessor :action, :description
8
+
9
+ def initialize( description, action, quiet = false, predicate = Proc.new { |x| true } )
10
+ @description = description
11
+ @action = action
12
+ @predicate = predicate
13
+ @quiet = quiet
19
14
  end
15
+
16
+ def requires_prompt?
17
+ case @action
18
+ when :remove
19
+ true
20
+ when :archive
21
+ true
22
+ else
23
+ false
24
+ end
25
+ end
26
+
27
+ def includes?( filename )
28
+ @predicate.call filename
29
+ end
30
+
31
+ def quiet?
32
+ @quiet
33
+ end
34
+
35
+ def to_s
36
+ @description
37
+ end
38
+
20
39
  end
21
-
22
- def includes?( filename )
23
- @predicate.call filename
24
- end
25
-
26
- def quiet?
27
- @quiet
28
- end
29
-
30
- def to_s
31
- @description
32
- end
33
-
34
- end
40
+ end
data/lib/prune/cli.rb CHANGED
@@ -4,8 +4,10 @@ require 'optparse'
4
4
  require 'date'
5
5
 
6
6
  module Prune
7
- VERSION = Gem::Version.new '1.2.0.rc4'
8
7
 
8
+ # The command-line interface for prune is the primary way to interact with it, although it can be invoked programatically as well.
9
+ #
10
+ # This class defines the arguments and options taken by Prune and how it reacts to various forms of command-line input.
9
11
  class CommandLineInterface
10
12
 
11
13
  DEFAULT_OPTIONS = { :verbose => false, :did_work => false, :dry_run => false, :prompt => true, :archive => true, :configure => false }
@@ -1,6 +1,11 @@
1
1
  require 'fileutils'
2
2
 
3
3
  module Prune
4
+
5
+ # The configurer is used for configure a custom retention policy for a specified folder by either
6
+ # editing the retention policy already in place,
7
+ # or by copying the default retention policy from the gem into place in the specified directory,
8
+ # and then editing it.
4
9
  class Configurer
5
10
 
6
11
  def initialize( folder, options = {} )
data/lib/prune/grouper.rb CHANGED
@@ -1,4 +1,7 @@
1
1
  module Prune
2
+
3
+ # Assembles files into groups by month name, for archival. This is not
4
+ # currently a configurable behaviour (grouping by some other means, for instance.)
2
5
  class Grouper
3
6
 
4
7
  def initialize( archiver )
data/lib/prune/meta.rb ADDED
@@ -0,0 +1,9 @@
1
+ # The prune module contains all the classes defined for Prune to do its job -- it's the namespace for the project, essentially.
2
+ #
3
+ # In addition, the prune module contains a single piece of metadata -- the version of the GEM.
4
+ #
5
+ # @author Geoffrey Wiseman
6
+ module Prune
7
+ # The version of the prune gem and all the associated code.
8
+ VERSION = Gem::Version.new '1.2.0.rc5'
9
+ end
data/lib/prune/pruner.rb CHANGED
@@ -4,6 +4,8 @@ require 'date'
4
4
 
5
5
  module Prune
6
6
 
7
+ # The co-ordinating class of Prune, Pruner works with the retention policy, archiver, grouper to get everything done.
8
+ # This is the central hub through which almost all other activity passes.
7
9
  class Pruner
8
10
  FILTERS = [ '.', '..', '.prune' ]
9
11
 
@@ -5,6 +5,9 @@ require 'pathname'
5
5
 
6
6
  module Prune
7
7
 
8
+ # Represents a retention policy, whether loaded from the core retention policy or from a project-specific configured retention
9
+ # policy. It defines all the categories, the actions associated with them and some other elements. It is the primary form of
10
+ # prune Configuration.
8
11
  class RetentionPolicy
9
12
  DEFAULT_OPTIONS={ :load_dsl => true }
10
13
 
@@ -54,7 +57,8 @@ module Prune
54
57
  end
55
58
 
56
59
  end
57
-
60
+
61
+ # A builder for building categories -- this is essentially the DSL used in the retention policy.
58
62
  class CategoryBuilder
59
63
 
60
64
  def initialize( description )
@@ -97,6 +101,8 @@ module Prune
97
101
 
98
102
  end
99
103
 
104
+ # A thin wrapper around files for holding attributes that might be precalculated and then
105
+ # used by a number of categories.
100
106
  class FileContext
101
107
  attr_accessor :name
102
108
 
data/lib/prune.rb CHANGED
@@ -7,4 +7,4 @@ require 'prune/retention'
7
7
  require 'prune/grouper'
8
8
  require 'prune/category'
9
9
  require 'prune/configurer'
10
-
10
+ require 'prune/meta'
data/spec/pruner_spec.rb CHANGED
@@ -8,7 +8,7 @@ describe Prune::Pruner do
8
8
  subject { Prune::Pruner.new Hash.new }
9
9
 
10
10
  before( :each ) do
11
- @categories = [ Category.new( "Unmatched Files", :retain, true ) ]
11
+ @categories = [ Prune::Category.new( "Unmatched Files", :retain, true ) ]
12
12
  @retention_policy = double( "RetentionPolicy" )
13
13
  @retention_policy.stub( :categories ) { @categories }
14
14
  Prune::RetentionPolicy.stub( :new ) { @retention_policy }
@@ -198,17 +198,17 @@ describe Prune::Pruner do
198
198
  end
199
199
 
200
200
  it "should display empty categories" do
201
- subject.display_categories( { Category.new( "Empty Category", :retain ) => [] } )
201
+ subject.display_categories( { Prune::Category.new( "Empty Category", :retain ) => [] } )
202
202
  @messages.should include_match( /Empty Category/ )
203
203
  end
204
204
 
205
205
  it "should display quiet categories" do
206
- subject.display_categories( { Category.new( "Quiet Category", :retain, true ) => [ 'quiet.txt' ] } )
206
+ subject.display_categories( { Prune::Category.new( "Quiet Category", :retain, true ) => [ 'quiet.txt' ] } )
207
207
  @messages.should include_match( /Quiet Category/ )
208
208
  end
209
209
 
210
210
  it "should display categories with files" do
211
- subject.display_categories( { Category.new( "Normal Category", :retain ) => [ 'normal.txt' ] } )
211
+ subject.display_categories( { Prune::Category.new( "Normal Category", :retain ) => [ 'normal.txt' ] } )
212
212
  @messages.should include_match( /Normal Category/ )
213
213
  end
214
214
  end
@@ -220,17 +220,17 @@ describe Prune::Pruner do
220
220
  end
221
221
 
222
222
  it "should not display empty categories" do
223
- subject.display_categories( { Category.new( "Empty Category", :retain, true ) => [] } )
223
+ subject.display_categories( { Prune::Category.new( "Empty Category", :retain, true ) => [] } )
224
224
  @messages.should_not include_match( /Empty Category/ )
225
225
  end
226
226
 
227
227
  it "should not display quiet categories" do
228
- subject.display_categories( { Category.new( "Quiet Category", :retain, true ) => [ 'shhh.txt' ] } )
228
+ subject.display_categories( { Prune::Category.new( "Quiet Category", :retain, true ) => [ 'shhh.txt' ] } )
229
229
  @messages.should_not include_match( /Quiet Category/ )
230
230
  end
231
231
 
232
232
  it "should display categories with files" do
233
- subject.display_categories( { Category.new( "Normal Category", :retain ) => [ 'normal.txt' ] } )
233
+ subject.display_categories( { Prune::Category.new( "Normal Category", :retain ) => [ 'normal.txt' ] } )
234
234
  @messages.should include_match( /Normal Category/ )
235
235
  end
236
236
 
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.rc4
4
+ version: 1.2.0.rc5
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: &70347705700040 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,12 @@ dependencies:
21
21
  version: 0.5.3
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70347705700040
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 0.5.3
25
30
  description: Prune is meant to analyze a folder full of files, run them against a
26
31
  retention policy and decide which to keep, which to remove and which to archive.
27
32
  It is extensible and embeddable.
@@ -37,6 +42,7 @@ files:
37
42
  - lib/prune/configurer.rb
38
43
  - lib/prune/default_retention.rb
39
44
  - lib/prune/grouper.rb
45
+ - lib/prune/meta.rb
40
46
  - lib/prune/pruner.rb
41
47
  - lib/prune/retention.rb
42
48
  - lib/prune.rb
@@ -62,6 +68,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
62
68
  - - ! '>='
63
69
  - !ruby/object:Gem::Version
64
70
  version: '0'
71
+ segments:
72
+ - 0
73
+ hash: 2783546995479807081
65
74
  required_rubygems_version: !ruby/object:Gem::Requirement
66
75
  none: false
67
76
  requirements:
@@ -70,7 +79,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
70
79
  version: 1.3.1
71
80
  requirements: []
72
81
  rubyforge_project:
73
- rubygems_version: 1.8.17
82
+ rubygems_version: 1.8.24
74
83
  signing_key:
75
84
  specification_version: 3
76
85
  summary: Prunes files from a folder based on a retention policy, often time-based.