juicer 0.2.1 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,9 +1,13 @@
1
- == 0.2.0 / 2009-xx-xx
1
+ == 0.2.3 / 2009-03-03
2
2
 
3
- * Refactored the minifyers execute method from compress to save
4
- * Refactored Juicer::Merger::FileMerger -> Juicer::Merger::Base
5
- * Refactored the mergers and minifyers to be chainable commands.
6
- * Added Chainable module
3
+ * Cache busters in CSS files should only be appended once to each URL
4
+ * Output to merge target should accept directories as well as files (in case of
5
+ directories, file name is generated)
6
+ * Tests should not ship with 3rd party libraries
7
+
8
+ == 0.2.0 / 2009-02-25
9
+
10
+ * First usable release; merge, verify, install targets
7
11
 
8
12
  == 0.1.0 / 2008-12-17
9
13
 
data/Rakefile CHANGED
@@ -4,10 +4,13 @@
4
4
 
5
5
  begin
6
6
  require 'bones'
7
- load 'tasks/test/setup.rake'
8
7
  Bones.setup
9
8
  rescue LoadError
10
- load 'tasks/setup.rb'
9
+ begin
10
+ load 'tasks/setup.rb'
11
+ rescue LoadError
12
+ raise RuntimeError, '### please install the "bones" gem ###'
13
+ end
11
14
  end
12
15
 
13
16
  ensure_in_path 'lib'
@@ -106,6 +106,7 @@ installed and the java executable available on your path.
106
106
 
107
107
  $ gem install juicer
108
108
  $ juicer install yui_compressor
109
+ $ juicer install jslint
109
110
 
110
111
  You need Java installed and available on your PATH. During gem installation,
111
112
  Juicer will download and install YUI Compressor, JsLint and Rhino for you.
@@ -3,7 +3,7 @@ require "logger"
3
3
  module Juicer
4
4
 
5
5
  # :stopdoc:
6
- VERSION = '0.2.1'
6
+ VERSION = '0.2.3'
7
7
  LIBPATH = ::File.expand_path(::File.dirname(__FILE__)) + ::File::SEPARATOR
8
8
  PATH = ::File.dirname(LIBPATH) + ::File::SEPARATOR
9
9
  LOGGER = Logger.new(STDOUT)
@@ -16,19 +16,19 @@ module Juicer
16
16
  super('merge', false, true)
17
17
  @types = { :js => Juicer::Merger::JavaScriptMerger,
18
18
  :css => Juicer::Merger::StylesheetMerger }
19
- @output = nil # File to write to
20
- @force = false # Overwrite existing file if true
21
- @type = nil # "css" or "js" - for minifyer
22
- @minifyer = "yui_compressor" # Which minifyer to use
23
- @opts = {} # Path to minifyer binary
24
- @arguments = nil # Minifyer arguments
25
- @ignore = false # Ignore syntax problems if true
26
- @cache_buster = :soft # What kind of cache buster to use, :soft or :hard
27
- @hosts = nil # Hosts to use when replacing URLs in stylesheets
28
- @web_root = nil # Used to understand absolute paths
29
- @relative_urls = false # Make the merger use relative URLs
30
- @absolute_urls = false # Make the merger use absolute URLs
31
- @local_hosts = [] # Host names that are served from :web_root
19
+ @output = nil # File to write to
20
+ @force = false # Overwrite existing file if true
21
+ @type = nil # "css" or "js" - for minifyer
22
+ @minifyer = "yui_compressor" # Which minifyer to use
23
+ @opts = {} # Path to minifyer binary
24
+ @arguments = nil # Minifyer arguments
25
+ @ignore = false # Ignore syntax problems if true
26
+ @cache_buster = :soft # What kind of cache buster to use, :soft or :hard
27
+ @hosts = nil # Hosts to use when replacing URLs in stylesheets
28
+ @web_root = nil # Used to understand absolute paths
29
+ @relative_urls = false # Make the merger use relative URLs
30
+ @absolute_urls = false # Make the merger use absolute URLs
31
+ @local_hosts = [] # Host names that are served from :web_root
32
32
 
33
33
  @log = log || Logger.new(STDOUT)
34
34
 
@@ -178,7 +178,9 @@ the YUI Compressor the path should be the path to where the jar file is found.
178
178
  # name on. It will prepend the original suffix with ".min"
179
179
  #
180
180
  def output(file = "#{Time.now.to_i}.tmp")
181
- @output || file.sub(/\.([^\.]+)$/, '.min.\1')
181
+ @output = File.dirname(file) if @output.nil?
182
+ @output = File.join(@output, File.basename(file).sub(/\.([^\.]+)$/, '.min.\1')) if File.directory?(@output)
183
+ @output = File.expand_path(@output)
182
184
  end
183
185
  end
184
186
  end
@@ -36,11 +36,14 @@ module Juicer
36
36
  #
37
37
  def save(file, output = nil)
38
38
  @contents = File.read(file)
39
+ used = []
39
40
 
40
41
  urls(file).each do |url|
41
42
  path = resolve(url, file)
43
+ next if used.include?(path)
42
44
 
43
45
  if path != url
46
+ used << path
44
47
  basename = File.basename(Juicer::CacheBuster.path(path))
45
48
  @contents.sub!(url, File.join(File.dirname(url), basename))
46
49
  end
@@ -55,7 +55,7 @@ class TestMergeCommand < Test::Unit::TestCase
55
55
 
56
56
  def test_output_name_from_file_should_have_suffix_prepended_with_min
57
57
  Juicer::Command::Merge.publicize_methods do
58
- assert_equal "test.min.js", @merge.output("test.js")
58
+ assert_equal File.expand_path("test.min.js"), @merge.output("test.js")
59
59
  end
60
60
  end
61
61
 
@@ -68,8 +68,15 @@ class TestMergeCommand < Test::Unit::TestCase
68
68
  def test_output_name_instance_value
69
69
  Juicer::Command::Merge.publicize_methods do
70
70
  @merge.instance_eval { @output = "output.css" }
71
- assert_equal "output.css", @merge.output
72
- assert_equal "output.css", @merge.output("bleh.css")
71
+ assert_equal File.expand_path("output.css"), @merge.output
72
+ assert_equal File.expand_path("output.css"), @merge.output("bleh.css")
73
+ end
74
+ end
75
+
76
+ def test_output_name_should_be_generated_when_output_is_directory
77
+ Juicer::Command::Merge.publicize_methods do
78
+ @merge.instance_eval { @output = path("css") }
79
+ assert_equal File.join(path("css"), "file.min.css"), @merge.output("file.css")
73
80
  end
74
81
  end
75
82
 
@@ -115,10 +122,10 @@ class TestMergeCommand < Test::Unit::TestCase
115
122
  end
116
123
 
117
124
  def test_update_output_when_force
118
- assert_nothing_raised do
119
- @merge.instance_eval { @force = true }
120
- @merge.execute(path("a.css"))
121
- end
125
+ assert_nothing_raised do
126
+ @merge.instance_eval { @force = true }
127
+ @merge.execute(path("a.css"))
128
+ end
122
129
  end
123
130
 
124
131
  def test_merge_successful
@@ -150,6 +157,4 @@ class TestMergeCommand < Test::Unit::TestCase
150
157
  assert_match(/Ignoring detected problems/, @io.string)
151
158
  end
152
159
  end
153
-
154
-
155
160
  end
@@ -69,4 +69,14 @@ class TestCssCacheBuster < Test::Unit::TestCase
69
69
  assert_match(/[^\?]*\?jcb=\d+/, path.first)
70
70
  end
71
71
  end
72
+
73
+ def test_urls_should_only_have_mtime_appended_once
74
+ File.open(path("a2.css"), "w") { |f| f.puts "" }
75
+ file = path("path_test2.css")
76
+ output = path("path_test3.css")
77
+ buster = Juicer::CssCacheBuster.new :web_root => path("")
78
+ buster.save file, output
79
+
80
+ buster.urls(output).each { |url| assert url !~ /(jcb=\d+).*(jcb=\d+)/, url }
81
+ end
72
82
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: juicer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christian Johansen
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-02-23 00:00:00 +01:00
12
+ date: 2009-03-01 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency