sitefuel 0.0.0a

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. data/README +86 -0
  2. data/RELEASE_NOTES +7 -0
  3. data/bin/sitefuel +162 -0
  4. data/lib/sitefuel/Configuration.rb +35 -0
  5. data/lib/sitefuel/SiteFuelLogger.rb +128 -0
  6. data/lib/sitefuel/SiteFuelRuntime.rb +293 -0
  7. data/lib/sitefuel/extensions/ArrayComparisons.rb +34 -0
  8. data/lib/sitefuel/extensions/DynamicClassMethods.rb +19 -0
  9. data/lib/sitefuel/extensions/FileComparison.rb +24 -0
  10. data/lib/sitefuel/extensions/Silently.rb +27 -0
  11. data/lib/sitefuel/extensions/StringFormatting.rb +75 -0
  12. data/lib/sitefuel/extensions/SymbolComparison.rb +13 -0
  13. data/lib/sitefuel/external/AbstractExternalProgram.rb +616 -0
  14. data/lib/sitefuel/external/ExternalProgramTestCase.rb +67 -0
  15. data/lib/sitefuel/external/GIT.rb +9 -0
  16. data/lib/sitefuel/external/JPEGTran.rb +68 -0
  17. data/lib/sitefuel/external/PNGCrush.rb +66 -0
  18. data/lib/sitefuel/processors/AbstractExternalProgramProcessor.rb +72 -0
  19. data/lib/sitefuel/processors/AbstractProcessor.rb +378 -0
  20. data/lib/sitefuel/processors/AbstractStringBasedProcessor.rb +88 -0
  21. data/lib/sitefuel/processors/CSSProcessor.rb +84 -0
  22. data/lib/sitefuel/processors/HAMLProcessor.rb +52 -0
  23. data/lib/sitefuel/processors/HTMLProcessor.rb +211 -0
  24. data/lib/sitefuel/processors/JavaScriptProcessor.rb +57 -0
  25. data/lib/sitefuel/processors/PHPProcessor.rb +32 -0
  26. data/lib/sitefuel/processors/PNGProcessor.rb +80 -0
  27. data/lib/sitefuel/processors/RHTMLProcessor.rb +25 -0
  28. data/lib/sitefuel/processors/SASSProcessor.rb +50 -0
  29. data/test/processor_listing.rb +28 -0
  30. data/test/test_AbstractExternalProgram.rb +186 -0
  31. data/test/test_AbstractProcessor.rb +237 -0
  32. data/test/test_AbstractStringBasedProcessor.rb +48 -0
  33. data/test/test_AllProcessors.rb +65 -0
  34. data/test/test_ArrayComparisons.rb +32 -0
  35. data/test/test_CSSProcessor.rb +120 -0
  36. data/test/test_FileComparisons.rb +42 -0
  37. data/test/test_HAMLProcessor.rb.rb +60 -0
  38. data/test/test_HTMLProcessor.rb +186 -0
  39. data/test/test_JPEGTran.rb +40 -0
  40. data/test/test_JavaScriptProcessor.rb +63 -0
  41. data/test/test_PHPProcessor.rb +51 -0
  42. data/test/test_PNGCrush.rb +58 -0
  43. data/test/test_PNGProcessor.rb +32 -0
  44. data/test/test_RHTMLProcessor.rb +62 -0
  45. data/test/test_SASSProcessor.rb +68 -0
  46. data/test/test_SiteFuelLogging.rb +79 -0
  47. data/test/test_SiteFuelRuntime.rb +96 -0
  48. data/test/test_StringFormatting.rb +51 -0
  49. data/test/test_SymbolComparison.rb +27 -0
  50. data/test/test_images/sample_jpg01.jpg +0 -0
  51. data/test/test_images/sample_png01.png +0 -0
  52. data/test/test_programs/versioning.rb +26 -0
  53. data/test/test_sites/simplehtml/deployment.yml +22 -0
  54. data/test/test_sites/simplehtml/index.html +66 -0
  55. data/test/test_sites/simplehtml/style.css +40 -0
  56. data/test/ts_all.rb +39 -0
  57. metadata +165 -0
@@ -0,0 +1,34 @@
1
+ #
2
+ # File:: ArrayComparisons.rb
3
+ # Author:: wkm
4
+ # Copyright:: 2009
5
+ # License:: GPL
6
+ #
7
+ # Adds methods to Array for comparing with other arrays
8
+ #
9
+
10
+ class Array
11
+
12
+ # gives true if self ends with the given array
13
+ #
14
+ # [1, 2, 3].ends_with? [2, 3] # ==> true
15
+ # [1, 2, 3].ends_with? [] # ==> true
16
+ # [1, 2, 3].ends_with? [1, 2, 3] # ==> true
17
+ # [1, 2, 3].ends_with? [1, 2] # ==> false
18
+ def ends_with?(other)
19
+ # if the supposed 'ending' is longer, it can't be an ending
20
+ if length < other.length
21
+ return false
22
+ end
23
+
24
+ index = -1
25
+ while -index <= other.length and -index <= length
26
+ if other[index] != self[index]
27
+ return false
28
+ end
29
+ index -= 1
30
+ end
31
+
32
+ return true
33
+ end
34
+ end
@@ -0,0 +1,19 @@
1
+ #
2
+ # File:: DynamicClassMethods.rb
3
+ # Author:: wkm
4
+ # Copyright:: 2009
5
+ # License:: GPL
6
+ #
7
+ # Adds a #meta_def function to Object so we can programmatically define class
8
+ # methods.
9
+ #
10
+
11
+ class Object
12
+
13
+ # defines a class method
14
+ # based on: http://blog.jayfields.com/2007/10/ruby-defining-class-methods.html
15
+ # and: http://whytheluckystiff.net/articles/seeingMetaclassesClearly.html
16
+ def define_class_method name, &blk
17
+ (class << self; self; end).instance_eval { define_method name, &blk}
18
+ end
19
+ end
@@ -0,0 +1,24 @@
1
+ #
2
+ # File:: FileComparison.rb
3
+ # Author:: wkm
4
+ # Copyright:: 2009
5
+ # License:: GPL
6
+ #
7
+ # Adds File.equivalent? that tries to guess whether two files are equivalent
8
+ #
9
+
10
+ require 'sitefuel/extensions/ArrayComparisons'
11
+
12
+ class File
13
+ # gives true if one of the paths is the ending of another path
14
+ #
15
+ # File.equivalent?('b/a.rb', 'a.rb') # ==> true
16
+ # File.equivalent?('c/b/a.rb', 'c/a.rb') # ==> false
17
+ def self.equivalent?(a, b)
18
+ list = [
19
+ File.expand_path(a, '/').split(File::SEPARATOR)[1 .. -1],
20
+ File.expand_path(b, '/').split(File::SEPARATOR)[1 .. -1]
21
+ ].sort {|l,r| l.length <=> r.length }.reverse
22
+ list.first.ends_with? list.last
23
+ end
24
+ end
@@ -0,0 +1,27 @@
1
+ #
2
+ # File:: Silently.rb
3
+ # Author:: wkm
4
+ # Copyright:: 2009
5
+ # License:: GPL
6
+ #
7
+ # Implements a silently method for executing code without warnings; intended for
8
+ # wrapping around require statements
9
+ #
10
+
11
+
12
+
13
+ # this is sourced directly from
14
+ # http://vidyapsi.wordpress.com/category/ruby/#warnings
15
+
16
+ def silently(&block)
17
+ warn_level = $VERBOSE
18
+ $VERBOSE = nil
19
+
20
+ result = block.call
21
+
22
+ $VERBOSE = warn_level
23
+ result
24
+ end
25
+
26
+ # /end sourcing
27
+
@@ -0,0 +1,75 @@
1
+ #
2
+ # File:: StringFormatting.rb
3
+ # Author:: wkm
4
+ # Copyright:: 2009
5
+ # License:: GPL
6
+ #
7
+ # Adds String#cabbrev for abbreviating strings
8
+ #
9
+
10
+ class String
11
+
12
+ # gives an abbreviated form of a string, showing some of the beginning
13
+ # and some of the end.
14
+ #
15
+ # "the quick brown dog".cabbrev 12 # => "the q... dog"
16
+ def cabbrev(len)
17
+ if length <= len
18
+ self
19
+ else
20
+ self[0..(len/2-2).floor] + "..." + self[(length - len/2+2) .. (length)]
21
+ end
22
+ end
23
+
24
+ # gives an abbreviated form of the string, showing as much of the beginning
25
+ # as possible
26
+ #
27
+ # "the quick brown dog".labbrev 12 # => "the quick ..."
28
+ def labbrev(len)
29
+ if length <= len
30
+ self
31
+ else
32
+ self[0..(len-4)] + '...'
33
+ end
34
+ end
35
+
36
+ # gives an abbreviated form of the string, showing as much of the end as
37
+ # possible
38
+ #
39
+ # "the quick brown dog".rabbrev 12 # => "...brown dog"
40
+ def rabbrev(len)
41
+ if length <= len
42
+ self
43
+ else
44
+ '...' + self[(length - (len-3)) .. length]
45
+ end
46
+ end
47
+
48
+ # removes leading whitespace from a set of lines, preserving indentation
49
+ # relative to the first non-empty line
50
+ def align
51
+ return self if empty?
52
+
53
+ # split by lines
54
+ lines = split("\n")
55
+
56
+ # get rid of the first line if it is null
57
+ if lines.first == ''
58
+ lines = lines[1..-1]
59
+ end
60
+
61
+ # take the first line and extract the leading whitespace
62
+ leading = lines.first[/^[ \t]*/]
63
+
64
+ # iterate over each line dumping the leading whitespace
65
+ lines = lines.map do |l|
66
+ l.gsub!(Regexp.new('^'+leading), '')
67
+ end
68
+
69
+ lines.join("\n")
70
+ end
71
+
72
+
73
+ alias :format :%
74
+
75
+ end
@@ -0,0 +1,13 @@
1
+ #
2
+ # File:: SymbolComparison.rb
3
+ # Author:: wkm
4
+ # Copyright:: 2009
5
+ #
6
+ # Defines a spaceship for symbols based off of to_s
7
+ #
8
+
9
+ class Symbol
10
+ def <=>(other)
11
+ self.to_s <=> other.to_s
12
+ end
13
+ end