cjohansen-juicer 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +2 -0
- data/History.txt +10 -0
- data/Manifest.txt +40 -0
- data/Rakefile +27 -0
- data/Readme.rdoc +108 -0
- data/bin/juicer +7 -0
- data/juicer.gemspec +38 -0
- data/lib/juicer/chainable.rb +105 -0
- data/lib/juicer/cli.rb +51 -0
- data/lib/juicer/command/merge.rb +90 -0
- data/lib/juicer/merger/base.rb +72 -0
- data/lib/juicer/merger/css_dependency_resolver.rb +25 -0
- data/lib/juicer/merger/dependency_resolver.rb +64 -0
- data/lib/juicer/merger/javascript_dependency_resolver.rb +21 -0
- data/lib/juicer/merger/javascript_merger.rb +30 -0
- data/lib/juicer/merger/stylesheet_merger.rb +42 -0
- data/lib/juicer/minifyer/compressor.rb +125 -0
- data/lib/juicer/minifyer/yui_compressor.rb +152 -0
- data/lib/juicer.rb +45 -0
- data/test/juicer/merger/test_base.rb +123 -0
- data/test/juicer/merger/test_css_dependency_resolver.rb +32 -0
- data/test/juicer/merger/test_javascript_dependency_resolver.rb +40 -0
- data/test/juicer/merger/test_javascript_merger.rb +75 -0
- data/test/juicer/merger/test_stylesheet_merger.rb +62 -0
- data/test/juicer/minifyer/test_compressor.rb +36 -0
- data/test/juicer/minifyer/test_yui_compressor.rb +79 -0
- data/test/juicer/test_chainable.rb +87 -0
- data/test/test_helper.rb +277 -0
- data/test/test_juicer.rb +4 -0
- metadata +125 -0
@@ -0,0 +1,62 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), %w[.. .. test_helper])) unless defined?(Juicer)
|
2
|
+
|
3
|
+
class TestStylesheetMerger < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
@file_merger = Juicer::Merger::StylesheetMerger.new
|
7
|
+
@file_setup = Juicer::Test::FileSetup.new($DATA_DIR)
|
8
|
+
@file_setup.create!
|
9
|
+
end
|
10
|
+
|
11
|
+
def teardown
|
12
|
+
file = path('test_out.css')
|
13
|
+
File.delete(file) if File.exists?(file)
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_init
|
17
|
+
Juicer::Merger::StylesheetMerger.publicize_methods do
|
18
|
+
assert_equal Juicer::Merger::CssDependencyResolver, @file_merger.dependency_resolver.class
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_merge
|
23
|
+
Juicer::Merger::StylesheetMerger.publicize_methods do
|
24
|
+
a_content = "\n\n/* Dette er a.css */\n"
|
25
|
+
content = @file_merger.merge(path('a.css'))
|
26
|
+
assert_equal a_content + "\n", content
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_constructor
|
31
|
+
file_merger = Juicer::Merger::StylesheetMerger.new(path('a.css'))
|
32
|
+
assert_equal 2, file_merger.files.length
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_append
|
36
|
+
@file_merger << path('a.css')
|
37
|
+
assert_equal 2, @file_merger.files.length
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_save
|
41
|
+
a_css = path('a.css')
|
42
|
+
b_css = path('b.css')
|
43
|
+
merged = <<EOF
|
44
|
+
/* Dette er b.css */
|
45
|
+
|
46
|
+
|
47
|
+
|
48
|
+
/* Dette er a.css */
|
49
|
+
|
50
|
+
EOF
|
51
|
+
|
52
|
+
@file_merger << a_css
|
53
|
+
ios = StringIO.new
|
54
|
+
@file_merger.save(ios)
|
55
|
+
assert_equal merged, ios.string
|
56
|
+
|
57
|
+
output_file = path('test_out.css')
|
58
|
+
@file_merger.save(output_file)
|
59
|
+
|
60
|
+
assert_equal merged, IO.read(output_file)
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), %w[.. .. test_helper])) unless defined?(Juicer)
|
2
|
+
|
3
|
+
class TestCompressor < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
@compressor = Juicer::Minifyer::Compressor.new({ :test_opt => '', :foo => '' })
|
7
|
+
@file_setup = Juicer::Test::FileSetup.new($DATA_DIR)
|
8
|
+
@file_setup.create!
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_get_opt
|
12
|
+
assert_equal '', @compressor.get_opt(:test_opt)
|
13
|
+
@compressor.set_opt(:test_opt, 'some_str')
|
14
|
+
assert_equal 'some_str', @compressor.get_opt(:test_opt)
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_set_opt
|
18
|
+
assert @compressor.set_opt(:test_opt, 'some_str')
|
19
|
+
assert_equal 'some_str', @compressor.get_opt(:test_opt)
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_default_options
|
23
|
+
Juicer::Minifyer::Compressor.publicize_methods do
|
24
|
+
obj = {}
|
25
|
+
assert_equal obj, @compressor.default_options
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_method_missing
|
30
|
+
assert_not_equal 'bar', @compressor.get_opt(:foo)
|
31
|
+
assert_not_equal 'bar', @compressor.foo
|
32
|
+
assert @compressor.foo = 'bar'
|
33
|
+
assert_equal 'bar', @compressor.get_opt(:foo)
|
34
|
+
assert_equal 'bar', @compressor.foo
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), %w[.. .. test_helper])) unless defined?(Juicer)
|
2
|
+
|
3
|
+
class TestYuiCompressor < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
@path = ENV.key?('YUI_HOME') ? ENV['YUI_HOME'] : File.expand_path('~/sources/yuicompressor-2.3.5/build')
|
7
|
+
# @path = File.expand_path(File.join(File.dirname(__FILE__), %w[.. .. ..]))
|
8
|
+
@yui_compressor = Juicer::Minifyer::YuiCompressor.new({ :bin_path => @path })
|
9
|
+
@file_setup = Juicer::Test::FileSetup.new($DATA_DIR)
|
10
|
+
@file_setup.create!
|
11
|
+
@file = path('out.min.css')
|
12
|
+
end
|
13
|
+
|
14
|
+
def teardown
|
15
|
+
File.delete(@file) if File.exists?(@file)
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_save
|
19
|
+
FileUtils.cp(path('a.css'), path('a-1.css'))
|
20
|
+
@yui_compressor.save(path('a-1.css'))
|
21
|
+
assert_equal "@import 'b.css';", IO.read(path('a-1.css'))
|
22
|
+
|
23
|
+
filename = path('a-minified.css')
|
24
|
+
@yui_compressor.save(path('a.css'), filename)
|
25
|
+
assert_equal "@import 'b.css';", IO.read(filename)
|
26
|
+
|
27
|
+
File.delete(filename)
|
28
|
+
File.delete(path('a-1.css'))
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_command
|
32
|
+
Juicer::Minifyer::YuiCompressor.publicize_methods do
|
33
|
+
cmd = /java -jar #{@path.sub('2.3.5', '\d\.\d\.\d')}\/yuicompressor-\d\.\d\.\d\.jar --type css/
|
34
|
+
assert_match cmd, @yui_compressor.command('css')
|
35
|
+
|
36
|
+
@yui_compressor.no_munge = true
|
37
|
+
cmd = /#{cmd} --no-munge/
|
38
|
+
assert_match cmd, @yui_compressor.command('css')
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_locate_jar
|
43
|
+
Juicer::Minifyer::YuiCompressor.publicize_methods do
|
44
|
+
# No env, no option, and no file in cwd
|
45
|
+
yuic_home = ENV['YUIC_HOME']
|
46
|
+
ENV.delete('YUIC_HOME')
|
47
|
+
@yui_compressor = Juicer::Minifyer::YuiCompressor.new
|
48
|
+
assert_nil @yui_compressor.locate_jar
|
49
|
+
|
50
|
+
# One file in cwd
|
51
|
+
File.open('yuicompressor-2.3.4.jar', 'w') { |f| f.puts '' }
|
52
|
+
assert_equal File.expand_path('yuicompressor-2.3.4.jar'), @yui_compressor.locate_jar
|
53
|
+
|
54
|
+
# Two files in cwd
|
55
|
+
File.open('yuicompressor-2.3.5.jar', 'w') { |f| f.puts '' }
|
56
|
+
assert_equal File.expand_path('yuicompressor-2.3.5.jar'), @yui_compressor.locate_jar
|
57
|
+
|
58
|
+
# Three files in cwd
|
59
|
+
File.open('yuicompressor.jar', 'w') { |f| f.puts '' }
|
60
|
+
assert_equal File.expand_path('yuicompressor.jar'), @yui_compressor.locate_jar
|
61
|
+
|
62
|
+
# Specify another directory
|
63
|
+
Dir.mkdir('another')
|
64
|
+
Dir.chdir('another')
|
65
|
+
File.open('yuicompressor-2.3.4.jar', 'w')
|
66
|
+
Dir.chdir('..')
|
67
|
+
assert_equal File.expand_path('yuicompressor.jar'), @yui_compressor.locate_jar
|
68
|
+
@yui_compressor = Juicer::Minifyer::YuiCompressor.new({ :bin_path => 'another' })
|
69
|
+
assert_equal File.expand_path('another/yuicompressor-2.3.4.jar'), @yui_compressor.locate_jar
|
70
|
+
|
71
|
+
# Cleanup
|
72
|
+
FileUtils.rm('yuicompressor-2.3.4.jar')
|
73
|
+
FileUtils.rm('yuicompressor-2.3.5.jar')
|
74
|
+
FileUtils.rm('yuicompressor.jar')
|
75
|
+
FileUtils.rm_rf('another')
|
76
|
+
ENV['YUIC_HOME'] = yuic_home
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), %w[.. test_helper])) unless defined?(Juicer)
|
2
|
+
|
3
|
+
class Host
|
4
|
+
include Juicer::Chainable
|
5
|
+
|
6
|
+
def initialize(msg = nil)
|
7
|
+
@msg = msg || ""
|
8
|
+
end
|
9
|
+
|
10
|
+
def dummy(ios)
|
11
|
+
ios.print @msg
|
12
|
+
end
|
13
|
+
|
14
|
+
chain_method :dummy
|
15
|
+
|
16
|
+
def unchained(ios)
|
17
|
+
ios.print @msg
|
18
|
+
end
|
19
|
+
|
20
|
+
def abortable(ios, abort = false)
|
21
|
+
ios.print @msg
|
22
|
+
abort_chain if abort
|
23
|
+
end
|
24
|
+
|
25
|
+
chain_method :abortable
|
26
|
+
end
|
27
|
+
|
28
|
+
class Dummy
|
29
|
+
end
|
30
|
+
|
31
|
+
class TestChainable < Test::Unit::TestCase
|
32
|
+
def test_next_initial_state
|
33
|
+
host = Host.new
|
34
|
+
assert host.respond_to?(:next_in_chain), "Host should respond to next_in_chain()"
|
35
|
+
assert_nil host.next_in_chain, "Next command should be nil for newly created object"
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_set_next
|
39
|
+
host = Host.new
|
40
|
+
host2 = Host.new
|
41
|
+
host.next_in_chain = host2
|
42
|
+
assert_equal host2, host.next_in_chain
|
43
|
+
|
44
|
+
host3 = host.next_in_chain = Host.new
|
45
|
+
assert_not_equal host3, host
|
46
|
+
assert_not_equal host3, host2
|
47
|
+
assert_equal host3, host.next_in_chain
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_set_next_return_value
|
51
|
+
host = Host.new
|
52
|
+
host2 = host.set_next(Host.new)
|
53
|
+
|
54
|
+
assert_not_equal host2, host
|
55
|
+
assert_equal host2, host.next_in_chain
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_simple_chain
|
59
|
+
host = Host.new("a")
|
60
|
+
host2 = host.next_in_chain = Host.new("b")
|
61
|
+
ios = StringIO.new
|
62
|
+
host.dummy(ios)
|
63
|
+
|
64
|
+
assert_equal "ab", ios.string
|
65
|
+
end
|
66
|
+
|
67
|
+
def test_unchained_method
|
68
|
+
host = Host.new("a")
|
69
|
+
host2 = host.next_in_chain = Host.new("b")
|
70
|
+
ios = StringIO.new
|
71
|
+
host.unchained(ios)
|
72
|
+
|
73
|
+
assert_equal "a", ios.string
|
74
|
+
end
|
75
|
+
|
76
|
+
def test_abort_chain
|
77
|
+
host = Host.new("a")
|
78
|
+
host2 = host.next_in_chain = Host.new("b")
|
79
|
+
ios = StringIO.new
|
80
|
+
|
81
|
+
host.abortable(ios)
|
82
|
+
assert_equal "ab", ios.string
|
83
|
+
|
84
|
+
host.abortable(ios, true)
|
85
|
+
assert_equal "aba", ios.string
|
86
|
+
end
|
87
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,277 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'test/unit'
|
3
|
+
require File.expand_path(File.join(File.dirname(__FILE__), %w[.. lib juicer])) unless defined?(Juicer)
|
4
|
+
|
5
|
+
# Test directory
|
6
|
+
$TEST_DIR = File.expand_path(File.dirname(__FILE__))
|
7
|
+
|
8
|
+
# Directory containing test data
|
9
|
+
$DATA_DIR = File.join($TEST_DIR, 'data')
|
10
|
+
|
11
|
+
# Prefixes paths with the data dir
|
12
|
+
def path(path)
|
13
|
+
File.join($DATA_DIR, path)
|
14
|
+
end
|
15
|
+
|
16
|
+
# Allow for testing of private methods inside a block:
|
17
|
+
#
|
18
|
+
# MyClass.publicize_methods do
|
19
|
+
# assert MyClass.some_private_method
|
20
|
+
# end
|
21
|
+
class Class
|
22
|
+
def publicize_methods
|
23
|
+
saved_private_instance_methods = self.private_instance_methods
|
24
|
+
self.class_eval { public(*saved_private_instance_methods) }
|
25
|
+
yield
|
26
|
+
self.class_eval { private(*saved_private_instance_methods) }
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
module Juicer
|
31
|
+
module Test
|
32
|
+
|
33
|
+
# Alot of Juicer functionality are filesystem operations. This class sets up files
|
34
|
+
# to work on
|
35
|
+
class FileSetup
|
36
|
+
attr_reader :file_count
|
37
|
+
|
38
|
+
def initialize(dir = $DATA_DIR)
|
39
|
+
@dir = dir
|
40
|
+
@file_count = 0
|
41
|
+
end
|
42
|
+
|
43
|
+
# Recursively deletes the data directory
|
44
|
+
def delete!
|
45
|
+
res = FileUtils.remove_dir(@dir) if File.exist?(@dir)
|
46
|
+
end
|
47
|
+
|
48
|
+
# Set up files for unit tests
|
49
|
+
def create!(force = false)
|
50
|
+
return if File.exist?(@dir) && !force
|
51
|
+
|
52
|
+
delete! if File.exist?(@dir)
|
53
|
+
mkdir @dir
|
54
|
+
|
55
|
+
# mappe/
|
56
|
+
mappe = mkdir(File.join(@dir, 'mappe'))
|
57
|
+
#mkfile(mappe, 'a.css', "@import 'b.css';\n\n/* Dette er a.css */")
|
58
|
+
mkfile(mappe, 'a.css', "/**\n * Test with comment\n */\n@import 'b.css';\n\n/* Dette er a.css */\n")
|
59
|
+
|
60
|
+
mkfile(mappe, 'c.css', "/* Dette er b.css */")
|
61
|
+
|
62
|
+
# mappe/enda_en_mappe/
|
63
|
+
enda_en_mappe = mkdir(File.join(@dir, 'mappe', 'enda_en_mappe'))
|
64
|
+
mkfile(enda_en_mappe, 'a.css', "@import 'b.css';\n\n/* Dette er a.css */\n")
|
65
|
+
mksvndir(enda_en_mappe)
|
66
|
+
|
67
|
+
# Filer
|
68
|
+
mkfile(@dir, 'a.css', "@import 'b.css';\n\n/* Dette er a.css */")
|
69
|
+
mkfile(@dir, 'a.js', "/**\n * @depend b.js\n */\n\n/* Dette er a.js */")
|
70
|
+
mkfile(@dir, 'b.css', "/* Dette er b.css */")
|
71
|
+
mkfile(@dir, 'b.js', "/**\n * @depends a.js\n */\n\n/* Dette er b.css */")
|
72
|
+
mkfile(@dir, 'Changelog.txt', "2008.02.09 | stb-base 1.29\n\nFEATURE: Core | Bla bla bla bla bla\nFEATURE: UI: | Bla bla bla bla bla\n\n\n2008.02.09 | stb-base 1.29\n\nFEATURE: Core | Bla bla bla bla bla\nFEATURE: UI: | Bla bla bla bla bla\n")
|
73
|
+
|
74
|
+
mkfile(@dir, 'version2.txt', "branch: 1.0\nversion: 5\nbuild: 879\nrevision: 79867\ndate: 2008-01-17 16:05:33\n")
|
75
|
+
mkfile(@dir, 'version.txt', "")
|
76
|
+
mkfile(@dir, 'version-test.txt', "branch: 1.5\nversion: 2\nbuild: 65\nrevision: 64\ndate: 2008-01-02 22:03:10\n")
|
77
|
+
|
78
|
+
mksvndir(mappe)
|
79
|
+
mksvndir(@dir)
|
80
|
+
end
|
81
|
+
|
82
|
+
def create_design!(force = false, root = 'design')
|
83
|
+
return if File.exist?(@dir) && !force
|
84
|
+
|
85
|
+
delete! if File.exist?(@dir)
|
86
|
+
mkdir @dir
|
87
|
+
|
88
|
+
mkdesign(root)
|
89
|
+
end
|
90
|
+
|
91
|
+
def mkdesign(root, force = false)
|
92
|
+
design = mkdir(File.join(@dir, root))
|
93
|
+
|
94
|
+
# JavaScripts
|
95
|
+
js = mkdir(File.join(design, 'js'))
|
96
|
+
|
97
|
+
lib_content = <<-EOF
|
98
|
+
/**
|
99
|
+
* Javascript library
|
100
|
+
*/
|
101
|
+
var ns = {
|
102
|
+
fn: function() {
|
103
|
+
alert(''Hey there!);
|
104
|
+
}
|
105
|
+
};
|
106
|
+
|
107
|
+
/**
|
108
|
+
* A really smart function
|
109
|
+
*/
|
110
|
+
function rlySmrt() {
|
111
|
+
return 'I am so smart, S-M-R-T';
|
112
|
+
}
|
113
|
+
EOF
|
114
|
+
lib = mkfile(js, 'lib.js', lib_content)
|
115
|
+
|
116
|
+
dom_content = <<-EOF
|
117
|
+
function tis() {
|
118
|
+
var just = 'another';
|
119
|
+
return just + 'function';
|
120
|
+
}
|
121
|
+
EOF
|
122
|
+
dom = mkfile(js, 'dom.js', dom_content)
|
123
|
+
|
124
|
+
yet_content = <<-EOF
|
125
|
+
/**
|
126
|
+
* @depends 'lib.js'
|
127
|
+
*/
|
128
|
+
var another = 'file';
|
129
|
+
|
130
|
+
function good(stuff, is) {
|
131
|
+
var happening = 'now';
|
132
|
+
}
|
133
|
+
EOF
|
134
|
+
yet = mkfile(js, 'yet.js', yet_content)
|
135
|
+
|
136
|
+
another_content = <<-EOF
|
137
|
+
/**
|
138
|
+
* This file definately is really nice
|
139
|
+
*/
|
140
|
+
var someClass = Base.extend({
|
141
|
+
couple: 'of',
|
142
|
+
them: false,
|
143
|
+
ole: 'properties',
|
144
|
+
|
145
|
+
andThen: function(a, freakin) {
|
146
|
+
this.methodMan(a + 3, freakin - 6);
|
147
|
+
}
|
148
|
+
|
149
|
+
mehtodMan: function(some, params) {
|
150
|
+
return 'ALOHA!';
|
151
|
+
}
|
152
|
+
});
|
153
|
+
EOF
|
154
|
+
another = mkfile(js, 'another.js', another_content)
|
155
|
+
|
156
|
+
dom_min_content = <<-EOF
|
157
|
+
/**
|
158
|
+
* Simply includes other files to make a monolithic minified file. Du-da, du-da
|
159
|
+
* @depends dom.js
|
160
|
+
* @depends yet.js
|
161
|
+
*/
|
162
|
+
EOF
|
163
|
+
dom_min = mkfile(js, 'dom.min.js', dom_min_content)
|
164
|
+
|
165
|
+
# CSS files
|
166
|
+
css = mkdir(File.join(design, 'css'))
|
167
|
+
|
168
|
+
defaults_content = <<-EOF
|
169
|
+
/**
|
170
|
+
* This is a set of defaults for all browsers
|
171
|
+
*/
|
172
|
+
* {
|
173
|
+
margin: 0;
|
174
|
+
padding: 0;
|
175
|
+
border: none;
|
176
|
+
}
|
177
|
+
|
178
|
+
h1, h2, h3, h4, h5, h6, p, ol, ul, dl {
|
179
|
+
margin: 0 0 1em;
|
180
|
+
test-decoration: none;
|
181
|
+
}
|
182
|
+
EOF
|
183
|
+
defaults = mkfile(css, 'defaults.css', defaults_content)
|
184
|
+
|
185
|
+
layout_content = <<-EOF
|
186
|
+
#main_content {
|
187
|
+
margin: 0 12px 16px;
|
188
|
+
width: 900px;
|
189
|
+
border: 3px solid #344;
|
190
|
+
}
|
191
|
+
|
192
|
+
#nav {
|
193
|
+
float: left;
|
194
|
+
width: 400px;
|
195
|
+
}
|
196
|
+
EOF
|
197
|
+
layout = mkfile(css, 'layout.css', layout_content)
|
198
|
+
|
199
|
+
fonts_content = <<-EOF
|
200
|
+
body {
|
201
|
+
font-family: arial, sans-serif;
|
202
|
+
font-size: 76%;
|
203
|
+
}
|
204
|
+
|
205
|
+
table {
|
206
|
+
font-style: normal;
|
207
|
+
}
|
208
|
+
EOF
|
209
|
+
fonts = mkfile(css, 'fonts.css', fonts_content)
|
210
|
+
|
211
|
+
fancy_font_content = <<-EOF
|
212
|
+
/**
|
213
|
+
* Fancy fonts
|
214
|
+
*/
|
215
|
+
@import 'fonts.css';
|
216
|
+
|
217
|
+
body {
|
218
|
+
font-family: tahoma, verdana;
|
219
|
+
}
|
220
|
+
EOF
|
221
|
+
fancy_font = mkfile(css, 'fancy_font.css', fancy_font_content)
|
222
|
+
|
223
|
+
layout_min_content = <<-EOF
|
224
|
+
@import 'defaults.css';
|
225
|
+
@import 'layout.css';
|
226
|
+
EOF
|
227
|
+
layout_min = mkfile(css, 'layout.min.css', layout_min_content)
|
228
|
+
|
229
|
+
images = mkdir(File.join(design, 'images'))
|
230
|
+
icons = mkdir(File.join(images, 'icons'))
|
231
|
+
10.times { |i| mkfile(icons, "icon#{i}.png", "#{i}") }
|
232
|
+
15.times { |i| mkfile(images, "img#{i}.gif", "#{i}") }
|
233
|
+
end
|
234
|
+
|
235
|
+
private
|
236
|
+
# Create a file
|
237
|
+
def mkfile(parent, name, content)
|
238
|
+
file = File.open(File.join(parent, name), 'w+') { |f| f.puts content }
|
239
|
+
@file_count += 1
|
240
|
+
end
|
241
|
+
|
242
|
+
def mkdir(dir)
|
243
|
+
FileUtils.mkdir(dir)
|
244
|
+
@file_count += 1
|
245
|
+
dir
|
246
|
+
end
|
247
|
+
|
248
|
+
def mksvndir(dir)
|
249
|
+
svn_dir = mkdir(File.join(dir, '.svn'))
|
250
|
+
mkdir(File.join(svn_dir, 'prop-base'))
|
251
|
+
mkdir(File.join(svn_dir, 'props'))
|
252
|
+
text_base = mkdir(File.join(svn_dir, 'text-base'))
|
253
|
+
tmp = mkdir(File.join(svn_dir, 'tmp'))
|
254
|
+
mkdir(File.join(tmp, 'prop-base'))
|
255
|
+
mkdir(File.join(tmp, 'props'))
|
256
|
+
mkdir(File.join(tmp, 'text-base'))
|
257
|
+
mkfile(svn_dir, 'all-wcprops', '')
|
258
|
+
mkfile(svn_dir, 'entries', '')
|
259
|
+
mkfile(svn_dir, 'format', '')
|
260
|
+
|
261
|
+
Dir.new(dir).each do |f|
|
262
|
+
if File.file?(File.join(dir, f)) && !(f =~ /^\.\.?/)
|
263
|
+
mkfile(text_base, File.basename(f) + '.svn-base', '')
|
264
|
+
end
|
265
|
+
end
|
266
|
+
end
|
267
|
+
end
|
268
|
+
end
|
269
|
+
end
|
270
|
+
|
271
|
+
def noout
|
272
|
+
std = $stdout
|
273
|
+
$stdout = StringIO.new
|
274
|
+
res = yield
|
275
|
+
$stdout = std
|
276
|
+
return res
|
277
|
+
end
|
data/test/test_juicer.rb
ADDED
metadata
ADDED
@@ -0,0 +1,125 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cjohansen-juicer
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Christian Johansen
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-01-04 00:00:00 -08:00
|
13
|
+
default_executable: juicer
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: cmdparse
|
17
|
+
version_requirement:
|
18
|
+
version_requirements: !ruby/object:Gem::Requirement
|
19
|
+
requirements:
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 2.0.2
|
23
|
+
version:
|
24
|
+
- !ruby/object:Gem::Dependency
|
25
|
+
name: bones
|
26
|
+
version_requirement:
|
27
|
+
version_requirements: !ruby/object:Gem::Requirement
|
28
|
+
requirements:
|
29
|
+
- - ">="
|
30
|
+
- !ruby/object:Gem::Version
|
31
|
+
version: 2.2.0
|
32
|
+
version:
|
33
|
+
description: Juicer is a command line tool aimed at easing JavaScript and CSS development. Currently it only provides a wrapper to YUI Compressor along with a module that can dynamically link together files, but there are plans for more functionality.
|
34
|
+
email: christian@cjohansen.no
|
35
|
+
executables:
|
36
|
+
- juicer
|
37
|
+
extensions: []
|
38
|
+
|
39
|
+
extra_rdoc_files:
|
40
|
+
- History.txt
|
41
|
+
- Readme.rdoc
|
42
|
+
- bin/juicer
|
43
|
+
- test/data/Changelog.txt
|
44
|
+
- test/data/version-test.txt
|
45
|
+
- test/data/version.txt
|
46
|
+
- test/data/version2.txt
|
47
|
+
files:
|
48
|
+
- .gitignore
|
49
|
+
- History.txt
|
50
|
+
- Manifest.txt
|
51
|
+
- Rakefile
|
52
|
+
- Readme.rdoc
|
53
|
+
- bin/juicer
|
54
|
+
- juicer.gemspec
|
55
|
+
- lib/juicer.rb
|
56
|
+
- lib/juicer/chainable.rb
|
57
|
+
- lib/juicer/cli.rb
|
58
|
+
- lib/juicer/command/merge.rb
|
59
|
+
- lib/juicer/merger/base.rb
|
60
|
+
- lib/juicer/merger/css_dependency_resolver.rb
|
61
|
+
- lib/juicer/merger/dependency_resolver.rb
|
62
|
+
- lib/juicer/merger/javascript_dependency_resolver.rb
|
63
|
+
- lib/juicer/merger/javascript_merger.rb
|
64
|
+
- lib/juicer/merger/stylesheet_merger.rb
|
65
|
+
- lib/juicer/minifyer/compressor.rb
|
66
|
+
- lib/juicer/minifyer/yui_compressor.rb
|
67
|
+
- test/data/Changelog.txt
|
68
|
+
- test/data/a.css
|
69
|
+
- test/data/a.js
|
70
|
+
- test/data/b.css
|
71
|
+
- test/data/b.js
|
72
|
+
- test/data/mappe/a.css
|
73
|
+
- test/data/mappe/c.css
|
74
|
+
- test/data/mappe/enda_en_mappe/a.css
|
75
|
+
- test/data/version-test.txt
|
76
|
+
- test/data/version.txt
|
77
|
+
- test/data/version2.txt
|
78
|
+
- test/juicer/merger/test_base.rb
|
79
|
+
- test/juicer/merger/test_css_dependency_resolver.rb
|
80
|
+
- test/juicer/merger/test_javascript_dependency_resolver.rb
|
81
|
+
- test/juicer/merger/test_javascript_merger.rb
|
82
|
+
- test/juicer/merger/test_stylesheet_merger.rb
|
83
|
+
- test/juicer/minifyer/test_compressor.rb
|
84
|
+
- test/juicer/minifyer/test_yui_compressor.rb
|
85
|
+
- test/juicer/test_chainable.rb
|
86
|
+
- test/test_helper.rb
|
87
|
+
- test/test_juicer.rb
|
88
|
+
has_rdoc: true
|
89
|
+
homepage: http://www.cjohansen.no/en/projects/juicer
|
90
|
+
post_install_message:
|
91
|
+
rdoc_options:
|
92
|
+
- --main
|
93
|
+
- Readme.rdoc
|
94
|
+
require_paths:
|
95
|
+
- lib
|
96
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: "0"
|
101
|
+
version:
|
102
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
103
|
+
requirements:
|
104
|
+
- - ">="
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: "0"
|
107
|
+
version:
|
108
|
+
requirements: []
|
109
|
+
|
110
|
+
rubyforge_project: juicer
|
111
|
+
rubygems_version: 1.2.0
|
112
|
+
signing_key:
|
113
|
+
specification_version: 2
|
114
|
+
summary: Juicer is a command line tool aimed at easing JavaScript and CSS development
|
115
|
+
test_files:
|
116
|
+
- test/test_helper.rb
|
117
|
+
- test/juicer/test_chainable.rb
|
118
|
+
- test/juicer/merger/test_javascript_dependency_resolver.rb
|
119
|
+
- test/juicer/merger/test_css_dependency_resolver.rb
|
120
|
+
- test/juicer/merger/test_base.rb
|
121
|
+
- test/juicer/merger/test_javascript_merger.rb
|
122
|
+
- test/juicer/merger/test_stylesheet_merger.rb
|
123
|
+
- test/juicer/minifyer/test_compressor.rb
|
124
|
+
- test/juicer/minifyer/test_yui_compressor.rb
|
125
|
+
- test/test_juicer.rb
|