sitefuel 0.0.0b → 0.1.0a

Sign up to get free protection for your applications and to get access to all the features.
Files changed (109) hide show
  1. data/README.rdoc +81 -0
  2. data/{RELEASE_NOTES → RELEASE_NOTES.rdoc} +0 -0
  3. data/bin/sitefuel +64 -111
  4. data/lib/sitefuel/CommandLine.rb +142 -0
  5. data/lib/sitefuel/Configuration.rb +49 -13
  6. data/lib/sitefuel/License.rb +292 -0
  7. data/lib/sitefuel/SiteFuelLogger.rb +34 -5
  8. data/lib/sitefuel/SiteFuelRuntime.rb +217 -44
  9. data/lib/sitefuel/extensions/ArrayComparisons.rb +2 -2
  10. data/lib/sitefuel/extensions/ColumnPrinter.rb +276 -0
  11. data/lib/sitefuel/extensions/DynamicClassMethods.rb +2 -2
  12. data/lib/sitefuel/extensions/FileComparison.rb +2 -2
  13. data/lib/sitefuel/extensions/FileTree.rb +94 -0
  14. data/lib/sitefuel/extensions/Silently.rb +2 -2
  15. data/lib/sitefuel/extensions/StringFormatting.rb +52 -8
  16. data/lib/sitefuel/extensions/SymbolComparison.rb +4 -2
  17. data/lib/sitefuel/extensions/TerminalInfo.rb +53 -0
  18. data/lib/sitefuel/external/AbstractExternalProgram.rb +65 -11
  19. data/lib/sitefuel/external/ExternalProgramTestCase.rb +2 -2
  20. data/lib/sitefuel/external/GIT.rb +50 -3
  21. data/lib/sitefuel/external/JPEGTran.rb +2 -2
  22. data/lib/sitefuel/external/PNGCrush.rb +2 -2
  23. data/lib/sitefuel/external/SVN.rb +57 -0
  24. data/lib/sitefuel/processors/AbstractExternalProgramProcessor.rb +17 -4
  25. data/lib/sitefuel/processors/AbstractProcessor.rb +64 -47
  26. data/lib/sitefuel/processors/AbstractStringBasedProcessor.rb +20 -3
  27. data/lib/sitefuel/processors/CSSProcessor.rb +2 -2
  28. data/lib/sitefuel/processors/Configurable.rb +94 -0
  29. data/lib/sitefuel/processors/HAMLProcessor.rb +4 -4
  30. data/lib/sitefuel/processors/HTMLProcessor.rb +2 -2
  31. data/lib/sitefuel/processors/JavaScriptProcessor.rb +2 -2
  32. data/lib/sitefuel/processors/PHPProcessor.rb +2 -2
  33. data/lib/sitefuel/processors/PNGProcessor.rb +2 -2
  34. data/lib/sitefuel/processors/RHTMLProcessor.rb +2 -2
  35. data/lib/sitefuel/processors/SASSProcessor.rb +4 -4
  36. data/test/{test_images → images}/sample_jpg01.jpg +0 -0
  37. data/test/{test_images → images}/sample_png01.png +0 -0
  38. data/test/processor_listing.rb +2 -2
  39. data/test/{test_programs → programs}/versioning.rb +2 -2
  40. data/test/repositories/git/few_files/deployment.yml +0 -0
  41. data/test/repositories/git/few_files/index.html +10 -0
  42. data/test/repositories/git/few_files/style.css +2 -0
  43. data/test/repositories/svn/testrepo1/README.txt +5 -0
  44. data/test/repositories/svn/testrepo1/conf/authz +32 -0
  45. data/test/repositories/svn/testrepo1/conf/passwd +8 -0
  46. data/test/repositories/svn/testrepo1/conf/svnserve.conf +47 -0
  47. data/test/repositories/svn/testrepo1/db/current +1 -0
  48. data/test/repositories/svn/testrepo1/db/format +2 -0
  49. data/test/repositories/svn/testrepo1/db/fs-type +1 -0
  50. data/test/repositories/svn/testrepo1/db/fsfs.conf +37 -0
  51. data/test/repositories/svn/testrepo1/db/min-unpacked-rev +1 -0
  52. data/test/repositories/svn/testrepo1/db/rep-cache.db +0 -0
  53. data/test/repositories/svn/testrepo1/db/revprops/0/0 +5 -0
  54. data/test/repositories/svn/testrepo1/db/revprops/0/1 +13 -0
  55. data/test/repositories/svn/testrepo1/db/revs/0/0 +11 -0
  56. data/test/repositories/svn/testrepo1/db/revs/0/1 +0 -0
  57. data/test/repositories/svn/testrepo1/db/txn-current +1 -0
  58. data/test/repositories/svn/testrepo1/db/txn-current-lock +0 -0
  59. data/test/repositories/svn/testrepo1/db/uuid +1 -0
  60. data/test/repositories/svn/testrepo1/db/write-lock +0 -0
  61. data/test/repositories/svn/testrepo1/format +1 -0
  62. data/test/repositories/svn/testrepo1/hooks/post-commit.tmpl +50 -0
  63. data/test/repositories/svn/testrepo1/hooks/post-lock.tmpl +45 -0
  64. data/test/repositories/svn/testrepo1/hooks/post-revprop-change.tmpl +57 -0
  65. data/test/repositories/svn/testrepo1/hooks/post-unlock.tmpl +43 -0
  66. data/test/repositories/svn/testrepo1/hooks/pre-commit.tmpl +85 -0
  67. data/test/repositories/svn/testrepo1/hooks/pre-lock.tmpl +71 -0
  68. data/test/repositories/svn/testrepo1/hooks/pre-revprop-change.tmpl +66 -0
  69. data/test/repositories/svn/testrepo1/hooks/pre-unlock.tmpl +63 -0
  70. data/test/repositories/svn/testrepo1/hooks/start-commit.tmpl +68 -0
  71. data/test/repositories/svn/testrepo1/locks/db-logs.lock +3 -0
  72. data/test/repositories/svn/testrepo1/locks/db.lock +3 -0
  73. data/test/sites/simplehtml/deployment.yml +19 -0
  74. data/test/{test_sites → sites}/simplehtml/index.html +0 -0
  75. data/test/{test_sites → sites}/simplehtml/style.css +0 -0
  76. data/test/sites/sitefuelteaser/deployment.yml +13 -0
  77. data/test/sites/sitefuelteaser/img/hd.png +0 -0
  78. data/test/sites/sitefuelteaser/img/logo.png +0 -0
  79. data/test/sites/sitefuelteaser/img/uses-sitefuel.png +0 -0
  80. data/test/sites/sitefuelteaser/index.html +1 -1
  81. data/test/sites/sitefuelteaser/master.css +18 -0
  82. data/test/test_AbstractExternalProgram.rb +5 -5
  83. data/test/test_AbstractProcessor.rb +4 -4
  84. data/test/test_AbstractStringBasedProcessor.rb +2 -2
  85. data/test/test_AllProcessors.rb +4 -4
  86. data/test/test_ArrayComparisons.rb +4 -4
  87. data/test/test_CSSProcessor.rb +4 -4
  88. data/test/test_ColumnPrinter.rb +40 -0
  89. data/test/test_Configurable.rb +106 -0
  90. data/test/test_FileComparisons.rb +4 -4
  91. data/test/test_GIT.rb +41 -0
  92. data/test/{test_HAMLProcessor.rb.rb → test_HAMLProcessor.rb} +4 -4
  93. data/test/test_HTMLProcessor.rb +4 -4
  94. data/test/test_JPEGTran.rb +4 -4
  95. data/test/test_JavaScriptProcessor.rb +3 -2
  96. data/test/test_PHPProcessor.rb +4 -4
  97. data/test/test_PNGCrush.rb +8 -8
  98. data/test/test_PNGProcessor.rb +5 -5
  99. data/test/test_RHTMLProcessor.rb +4 -4
  100. data/test/test_SASSProcessor.rb +4 -4
  101. data/test/test_SVN.rb +44 -0
  102. data/test/test_SiteFuelLogging.rb +4 -4
  103. data/test/test_SiteFuelRuntime.rb +42 -4
  104. data/test/test_StringFormatting.rb +27 -4
  105. data/test/test_SymbolComparison.rb +4 -4
  106. data/test/ts_all.rb +2 -2
  107. metadata +94 -20
  108. data/README +0 -86
  109. data/test/test_sites/simplehtml/deployment.yml +0 -22
@@ -1,9 +1,11 @@
1
1
  #
2
2
  # File:: SymbolComparison.rb
3
3
  # Author:: wkm
4
- # Copyright:: 2009
4
+ # Copyright:: 2009, Zanoccio LLC.
5
+ # License:: GPL version 2.0 (see LICENSE.rb)
5
6
  #
6
- # Defines a spaceship for symbols based off of to_s
7
+ # Defines a spaceship for symbols based off of to_s, this let's us sort lists
8
+ # of symbols.
7
9
  #
8
10
 
9
11
  class Symbol
@@ -0,0 +1,53 @@
1
+ #
2
+ # File:: TerminalInfo.rb
3
+ # Author:: wkm
4
+ # Copyright:: 2009, Zanoccio LLC.
5
+ # License:: GPL version 2.0 (see LICENSE.rb)
6
+ #
7
+ # Little Ruby library for querying for various properties of
8
+ # a terminal window.
9
+ #
10
+
11
+ module TerminalInfo
12
+
13
+ # gives an array containing the current dimensions of the terminal
14
+ # window
15
+ #
16
+ # Note that unlike =stty= (and #size) the first parameter is the width of
17
+ # the window (x) and the second parameter is the height of the window (y)
18
+ #
19
+ # TerminalInfo.dimensions # => [105, 34]
20
+ def self.dimensions
21
+ grab_output('stty size').split(' ').reverse.map do |val|
22
+ val.to_i
23
+ end
24
+ end
25
+
26
+ # gives an array with the current size of the terminal window
27
+ #
28
+ # Note that the first parameter is the height of the window, just like with
29
+ # =stty=
30
+ #
31
+ # TerminalInfo.size # => [34, 105]
32
+ def self.size
33
+ dimensions.reverse
34
+ end
35
+
36
+ # gives the current width of the terminal window
37
+ def self.width
38
+ dimensions.first
39
+ end
40
+
41
+ # gives the current height of the terminal window
42
+ def self.height
43
+ dimensions.last
44
+ end
45
+
46
+ private
47
+
48
+ # the back tick notation is annoying to read...
49
+ def self.grab_output(command)
50
+ `#{command}`
51
+ end
52
+
53
+ end
@@ -1,8 +1,8 @@
1
1
  #
2
2
  # File:: AbstractExternalProgram.rb
3
3
  # Author:: wkm
4
- # Copyright:: 2009
5
- # License:: GPL
4
+ # Copyright:: 2009, Zanoccio LLC.
5
+ # License:: GPL version 2.0 (see LICENSE.rb)
6
6
  #
7
7
  # An abstraction around calling an external program.
8
8
  #
@@ -16,6 +16,9 @@ module SiteFuel
16
16
  require 'sitefuel/extensions/DynamicClassMethods'
17
17
  require 'sitefuel/SiteFuelLogger'
18
18
 
19
+ require 'tmpdir'
20
+ require 'sha1'
21
+
19
22
  # raised when an external program can't be found
20
23
  class ProgramNotFound < StandardError
21
24
  attr_reader :program_name
@@ -131,6 +134,24 @@ module SiteFuel
131
134
 
132
135
 
133
136
 
137
+ # raised when a program exits with a return code other than
138
+ # 0, generally indicating some sort of failure.
139
+ class ProgramExitedWithFailure < StandardError
140
+ attr_reader :program, :command_line, :return_code
141
+ def initialize(program, command_line, return_code)
142
+ @program = program
143
+ @command_line = command_line
144
+ @return_code = return_code
145
+ end
146
+
147
+ def to_s
148
+ "Program %s exited with %d when evaluating:\n%s" %
149
+ [program, return_code, command_line]
150
+ end
151
+ end
152
+
153
+
154
+
134
155
 
135
156
 
136
157
 
@@ -427,6 +448,7 @@ module SiteFuel
427
448
  define_class_method(method_name.to_sym) { struct }
428
449
  end
429
450
 
451
+
430
452
  # organizes a list of options into a ragged array of arrays
431
453
  #
432
454
  # organize_options(:setflag, :paramsetting, 'val1', 'val2')
@@ -444,7 +466,7 @@ module SiteFuel
444
466
  j = i+1
445
467
  while j < options.length
446
468
  case options[j]
447
- when String
469
+ when String, Fixnum, Float
448
470
  # adds this value
449
471
  option_row << options[j]
450
472
  j += 1
@@ -490,6 +512,21 @@ module SiteFuel
490
512
  end
491
513
 
492
514
 
515
+ # creates a random string by hashing the current time into hexadecimal
516
+ def self.random_string(length=12)
517
+ Digest::SHA1.hexdigest(Time.now.to_f.to_s)[0, length]
518
+ end
519
+
520
+
521
+ # creates a temporary directory for sitefuel
522
+ def self.create_tmp_directory(keyword)
523
+ dir_name = File.join(Dir.tmpdir, "sitefuel-#{keyword}-#{random_string}")
524
+ Dir.mkdir(dir_name)
525
+
526
+ dir_name
527
+ end
528
+
529
+
493
530
 
494
531
 
495
532
 
@@ -555,7 +592,7 @@ module SiteFuel
555
592
 
556
593
  # applies a given value into an option template
557
594
  def apply_value(option_template, value)
558
- option_template.gsub('${value}', value)
595
+ option_template.gsub('${value}', value.to_s)
559
596
  end
560
597
 
561
598
 
@@ -576,10 +613,10 @@ module SiteFuel
576
613
  def requires_value?(name)
577
614
  takes_value?(name) and not has_default?(name)
578
615
  end
579
-
580
616
 
581
- # executes the given AbstractExternalProgram instance
582
- def execute
617
+
618
+ # builds the command line for a given program instance
619
+ def build_command_line
583
620
  self.class.verify_compatible_version
584
621
 
585
622
  exec_string = self.class.program_binary.clone
@@ -600,14 +637,31 @@ module SiteFuel
600
637
  exec_string << ' ' << option_string
601
638
  end
602
639
 
603
- info 'Executing: '+exec_string
640
+ exec_string
641
+ end
642
+
643
+
644
+ # executes the given AbstractExternalProgram instance
645
+ def execute
646
+ exec_string = build_command_line
604
647
 
605
- case self.class.output_handling
648
+ info ' Executing: '+exec_string
649
+ output_handler = self.class.output_handling
650
+ case output_handler
606
651
  when :capture
607
- self.class.capture_output(exec_string)
652
+ output_string = self.class.capture_output(exec_string)
608
653
 
609
654
  when :forward
610
- exec(exec_string)
655
+ output_string = exec(exec_string)
656
+
657
+ else
658
+ raise "Unknown output handler: #{output_handler}"
659
+ end
660
+
661
+ if $?.success?
662
+ return output_string
663
+ else
664
+ raise ProgramExitedWithFailure.new(self.class, exec_string, $?.to_i)
611
665
  end
612
666
  end
613
667
 
@@ -1,8 +1,8 @@
1
1
  #
2
2
  # File:: ExternalProgramTestCase.rb
3
3
  # Author:: wkm
4
- # Copyright:: 2009
5
- # License:: GPl
4
+ # Copyright:: 2009, Zanoccio LLC.
5
+ # License:: GPL version 2.0 (see LICENSE.rb)
6
6
  #
7
7
  # Lightweight utility that will effectively scrap
8
8
  # the entire test case if the program being tested doesn't exist.
@@ -1,9 +1,56 @@
1
1
  #
2
2
  # File:: GIT.rb
3
3
  # Author:: wkm
4
- # Copyright:: 2009
5
- # License:: GPL
4
+ # Copyright:: 2009, Zanoccio LLC.
5
+ # License:: GPL version 2.0 (see LICENSE.rb)
6
6
  #
7
7
  # Wrapper around the git version control system.
8
8
  #
9
- #
9
+
10
+ module SiteFuel
11
+ module External
12
+
13
+ require 'sitefuel/external/AbstractExternalProgram'
14
+
15
+ # defines a wrapper around the Git version control system
16
+ # this wrapper is designed to only handle
17
+ class GIT < AbstractExternalProgram
18
+
19
+ def self.program_name
20
+ 'git'
21
+ end
22
+
23
+ # this would probably work with
24
+ def self.compatible_versions
25
+ '> 1.4'
26
+ end
27
+
28
+ # creates a new repository from an existing git repository
29
+ option :clone, 'clone'
30
+
31
+ # sets the source from which to read repository data
32
+ option :source, '${value}'
33
+
34
+ # specify a depth for a shallow clone
35
+ option :depth, '--depth ${value}', 1
36
+
37
+ # specifies an output directory for git
38
+ option :output, '${value}'
39
+
40
+ # creates a shallow clone of an existing repository
41
+ def self.shallow_clone(source, directory = nil, depth=1)
42
+ if directory == nil
43
+ directory = create_tmp_directory('git')
44
+ end
45
+
46
+ execute :clone,
47
+ :depth, depth,
48
+ :source, source,
49
+ :output, directory
50
+
51
+ directory
52
+ end
53
+
54
+ end
55
+ end
56
+ end
@@ -1,8 +1,8 @@
1
1
  #
2
2
  # File:: JPEGTran.rb
3
3
  # Author:: wkm
4
- # Copyright:: 2009
5
- # License:: GPL
4
+ # Copyright:: 2009, Zanoccio LLC.
5
+ # License:: GPL version 2.0 (see LICENSE.rb)
6
6
  #
7
7
  # Wrapper around the jpegtran program.
8
8
  #
@@ -1,8 +1,8 @@
1
1
  #
2
2
  # File:: PNGCrush.rb
3
3
  # Author:: wkm
4
- # Copyright:: 2009
5
- # License:: GPL
4
+ # Copyright:: 2009, Zanoccio LLC.
5
+ # License:: GPL version 2.0 (see LICENSE.rb)
6
6
  #
7
7
  # Wrapper around the pngcrush program.
8
8
  #
@@ -0,0 +1,57 @@
1
+ #
2
+ # File:: SVN.rb
3
+ # Author:: wkm
4
+ # Copyright:: 2009, Zanoccio LLC.
5
+ # License:: GPL version 2.0 (see LICENSE.rb)
6
+ #
7
+ # Wrapper around the SVN version control system.
8
+ #
9
+
10
+ module SiteFuel
11
+ module External
12
+
13
+ require 'sitefuel/external/AbstractExternalProgram'
14
+
15
+ class SVN < AbstractExternalProgram
16
+
17
+ def self.program_name
18
+ 'svn'
19
+ end
20
+
21
+ # again, earlier versions would probably work
22
+ def self.compatible_versions
23
+ '> 1.2'
24
+ end
25
+
26
+
27
+ option :source, '${value}'
28
+ option :export, 'export'
29
+ option :revision, '-r ${value}'
30
+ option :output, '${value}'
31
+ option :force, '--force'
32
+
33
+ def self.export(source, output=nil, revision='HEAD')
34
+ use_force = false
35
+
36
+ if output == nil
37
+ output = create_tmp_directory('svn')
38
+ use_force = true
39
+ end
40
+
41
+ args = [:export,
42
+ :revision, revision,
43
+ :source, source,
44
+ :output, output]
45
+
46
+ if use_force
47
+ args << :force
48
+ end
49
+
50
+ execute(*args)
51
+
52
+ output
53
+ end
54
+
55
+ end
56
+ end
57
+ end
@@ -1,8 +1,8 @@
1
1
  #
2
2
  # File:: AbstractExternalProgramProcessor.rb
3
3
  # Author:: wkm
4
- # Copyright:: 2009
5
- # License:: GPL
4
+ # Copyright:: 2009, Zanoccio LLC.
5
+ # License:: GPL version 2.0 (see LICENSE.rb)
6
6
  #
7
7
  # TODO: this abstraction assumes only one filter will ever be run on a file,
8
8
  # which is rather naive. Need to add support to process a file multiple times.
@@ -33,8 +33,14 @@ module SiteFuel
33
33
  'External'
34
34
  end
35
35
 
36
+ def processor_symbol
37
+ 'E'
38
+ end
39
+
36
40
  # processes a file using a given configuration
37
41
  def self.process_file(filename, config = {})
42
+ info "#{self.class} opening for #{filename}"
43
+
38
44
  proc = self.new()
39
45
  proc.configure(config)
40
46
  proc.set_file(filename)
@@ -64,9 +70,16 @@ module SiteFuel
64
70
  self.execute
65
71
  self.processed_size = File.size(output_filename)
66
72
  return self
73
+ rescue SiteFuel::External::ProgramExitedWithFailure => exception
74
+ error "When processing #{resource_name}:"
75
+ error exception.to_s
67
76
  end
68
-
69
- end
70
77
 
78
+ def save(base_file_tree)
79
+ final_filename = base_file_tree.get_file(resource_name)
80
+ File.rename(output_filename, final_filename)
81
+ info "Moved #{output_filename} to #{final_filename}"
82
+ end
83
+ end
71
84
  end
72
85
  end
@@ -1,7 +1,8 @@
1
1
  #
2
2
  # File:: AbstractProcessor.rb
3
3
  # Author:: wkm
4
- # Copyright:: 2009
4
+ # Copyright:: 2009, Zanoccio LLC.
5
+ # License:: GPL version 2.0 (see LICENSE.rb)
5
6
  #
6
7
  # Defines an AbstractProcessor class that gives the interface implemented by
7
8
  # specific processors.
@@ -11,10 +12,13 @@ module SiteFuel
11
12
  module Processor
12
13
 
13
14
  require 'sitefuel/SiteFuelLogger'
15
+ require 'sitefuel/processors/Configurable'
14
16
 
15
17
  # raised when a method isn't implemented by a child class.
16
18
  class NotImplemented < StandardError; end
17
19
 
20
+
21
+
18
22
  # raised when attempting to run a filter that doesn't exist
19
23
  class UnknownFilter < StandardError
20
24
  attr_reader :processor, :name
@@ -30,6 +34,8 @@ module SiteFuel
30
34
  end
31
35
  end
32
36
 
37
+
38
+
33
39
  class UnknownFilterset < StandardError
34
40
  attr_reader :processor, :name
35
41
 
@@ -44,6 +50,8 @@ module SiteFuel
44
50
  end
45
51
  end
46
52
 
53
+
54
+
47
55
  # raised when multiple processors trigger off of a single file
48
56
  class MultipleApplicableProcessors < StandardError
49
57
  attr_reader :filename, :processors, :chosen_processor
@@ -60,14 +68,19 @@ module SiteFuel
60
68
  end
61
69
  end
62
70
 
71
+
72
+
63
73
  # defines the base functions every processor must implement to
64
74
  # interface with the sitefuel architecture
65
75
  class AbstractProcessor
66
76
 
67
77
  include SiteFuel::Logging
78
+ extend SiteFuel::ClassLogging
79
+
80
+ include Configurable
68
81
 
69
82
  # setup an AbstractProcessor
70
- def initialize
83
+ def initialize
71
84
  self.logger = SiteFuelLogger.instance
72
85
  @execution_list = []
73
86
  @filters = []
@@ -114,6 +127,12 @@ module SiteFuel
114
127
  self.to_s.sub(/.*\b(.*)Processor/, '\1')
115
128
  end
116
129
 
130
+ # gives the symbol of the processor; used when showing deployment
131
+ # progress
132
+ def processor_symbol
133
+ 'A'
134
+ end
135
+
117
136
 
118
137
  # gives the file patterns that trigger the processor by default; this
119
138
  # behavior can be over-ridden by configuration files.
@@ -283,18 +302,22 @@ module SiteFuel
283
302
  end
284
303
  end
285
304
 
305
+
286
306
  # called in #execute _before_ running the execution list of filters; note
287
307
  # that #setup_filters is only called _once_ before all of the filters are
288
308
  # batch executed. It is not called before every filter executes.
289
309
  def setup_filters; end
290
310
 
311
+
291
312
  # called in #execute _after_ running the execution list of filters
292
313
  def finish_filters; end
293
314
 
315
+
294
316
  # runs all filters in the execution list
295
317
  def execute
296
318
  setup_filters
297
319
  @execution_list.uniq.each do |filter|
320
+ info " Running filter: #{filter}"
298
321
  run_filter(filter)
299
322
  end
300
323
  finish_filters
@@ -303,71 +326,65 @@ module SiteFuel
303
326
  end
304
327
 
305
328
 
329
+ # creates a file with the given name
330
+ def create_file(base_file_tree)
331
+ base_file_tree.get_file(resource_name)
332
+ end
306
333
 
307
334
 
308
- def save(basepath)
309
- File.open(File.join(basepath, resource_name), 'w') do |fhndl|
310
- fhndl.write(document.to_s)
311
- end
335
+ # default save method. This will only create a file, the
336
+ # more specific abstractions need to implement the actual method
337
+ def save(base_file_tree)
338
+ create_file(base_file_tree)
312
339
  end
313
340
 
314
-
341
+ protected
315
342
  #
316
- # CONFIGURATION SUPPORT
343
+ # Configuration Support
317
344
  #
318
- def configure(config)
345
+
346
+ def pre_configuration
319
347
  @filters_cleared = false
320
- unless config == nil or config == {}
321
- config.each_pair do |k, v|
322
- set_configuration(k, v)
323
- end
324
- end
348
+ end
325
349
 
326
- if !@filters_cleared && execution_list.empty?
350
+ def post_configuration
351
+ if !@filters_cleared and execution_list.empty?
327
352
  add_filterset(self.class.default_filterset)
328
353
  end
329
- @filters_cleared = false
354
+ @filters_cleared = true
330
355
  end
331
356
 
332
- private
333
- def set_configuration(key, value)
334
- case key
335
- when :resource_name
336
- @resource_name = value
357
+
358
+ # ensures the filters have been cleared during this
359
+ # configuration phase. Preforms the #clear_filters if they haven't
360
+ def ensure_cleared_filters
361
+ if not @filters_cleared
362
+ clear_filters
363
+ @filters_cleared = true
364
+ end
365
+ end
337
366
 
338
367
 
339
- when :filters
340
- if not @filters_cleared
341
- clear_filters
342
- @filters_cleared = true
343
- end
368
+ # sets the name for the resource that is being processed
369
+ def configure_resource_name(value)
370
+ @resource_name = value
371
+ end
344
372
 
345
- case value
346
- when Array
347
- value.each { |v| add_filter(v) }
348
- when Symbol, String
349
- add_filter(value)
350
- end
351
373
 
352
- when :filtersets
353
- if not @filters_cleared
354
- clear_filters
355
- @filters_cleared = true
356
- end
374
+ # adds filters to this processor
375
+ def configure_filters(*values)
376
+ ensure_cleared_filters
377
+ values.each { |v| add_filter(v) }
378
+ end
357
379
 
358
- case value
359
- when Array
360
- value.each { |v| add_filterset(v) }
361
- when Symbol, String
362
- add_filterset(value)
363
- end
364
380
 
365
- else
366
- raise UnknownConfigurationOption(self.class, key, value)
367
- end
381
+ # adds filtersets to this processor
382
+ def configure_filtersets(*values)
383
+ ensure_cleared_filters
384
+ values.each { |v| add_filterset(v) }
368
385
  end
369
386
 
370
- protected
387
+
371
388
  # gives write-access to children classes
372
389
  attr_writer :original_size
373
390
  attr_writer :processed_size