juicer 0.2.5 → 0.2.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,7 @@
1
+ == 0.2.6 / 2009-07-20
2
+ * New installation paths for YUI Compressor
3
+ Patch by http://github.com/craveytrain
4
+
1
5
  == 0.2.5 / 2009-05-22
2
6
  * Fixed a bug with the stylesheet merger where url( <url> ); (ie URL surrounded
3
7
  by spaces) resolved wrong.
@@ -3,7 +3,7 @@ require "logger"
3
3
  module Juicer
4
4
 
5
5
  # :stopdoc:
6
- VERSION = '0.2.5'
6
+ VERSION = '0.2.6'
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)
@@ -49,7 +49,7 @@ module Juicer
49
49
  @contents.gsub!(url, File.join(File.dirname(url), basename))
50
50
  end
51
51
  rescue Errno::ENOENT
52
- puts "Unable to locate file #{path || url}, skipping"
52
+ puts "Unable to locate file #{path || url}, skipping cache buster"
53
53
  end
54
54
  end
55
55
 
@@ -12,7 +12,7 @@ module Juicer
12
12
  def initialize(install_dir = Juicer.home)
13
13
  super(install_dir)
14
14
  @latest = nil
15
- @website = "http://www.julienlecomte.net/yuicompressor/"
15
+ @website = "http://yuilibrary.com/downloads/"
16
16
  end
17
17
 
18
18
  #
@@ -27,7 +27,7 @@ module Juicer
27
27
  def install(version = nil)
28
28
  version = super(version)
29
29
  base = "yuicompressor-#{version}"
30
- filename = download(File.join(@website, "#{base}.zip"))
30
+ filename = download(File.join(@website, "yuicompressor", "#{base}.zip"))
31
31
  target = File.join(@install_dir, path)
32
32
 
33
33
  Zip::ZipFile.open(filename) do |file|
@@ -59,7 +59,7 @@ module Juicer
59
59
  def latest
60
60
  return @latest if @latest
61
61
  webpage = Hpricot(open(@website))
62
- @latest = (webpage / "#downloadbutton a")[0].get_attribute("href").match(/(\d\.\d\.\d)/)[1]
62
+ @latest = (webpage / "//h2[@id='yuicompressor']/../../../..//a")[0].get_attribute("href").match(/(\d\.\d\.\d)/)[1]
63
63
  end
64
64
  end
65
65
  end
@@ -19,10 +19,11 @@ namespace :doc do
19
19
  end
20
20
  rd.rdoc_files.push(*files)
21
21
 
22
- title = "#{PROJ.name}-#{PROJ.version} Documentation"
23
-
22
+ name = PROJ.name
24
23
  rf_name = PROJ.rubyforge.name
25
- title = "#{rf_name}'s " + title if rf_name.valid? and rf_name != title
24
+
25
+ title = "#{name}-#{PROJ.version} Documentation"
26
+ title = "#{rf_name}'s " + title if rf_name.valid? and rf_name != name
26
27
 
27
28
  rd.options << "-t #{title}"
28
29
  rd.options.concat(rdoc.opts)
@@ -6,7 +6,7 @@ require 'fileutils'
6
6
  require 'ostruct'
7
7
  require 'find'
8
8
 
9
- class OpenStruct; undef :gem; end
9
+ class OpenStruct; undef :gem if defined? :gem; end
10
10
 
11
11
  # TODO: make my own openstruct type object that includes descriptions
12
12
  # TODO: use the descriptions to output help on the available bones options
@@ -124,9 +124,7 @@ import(*rakefiles)
124
124
  %w(lib ext).each {|dir| PROJ.libs << dir if test ?d, dir}
125
125
 
126
126
  # Setup some constants
127
- WIN32 = %r/djgpp|(cyg|ms|bcc)win|mingw/ =~ RUBY_PLATFORM unless defined? WIN32
128
-
129
- DEV_NULL = WIN32 ? 'NUL:' : '/dev/null'
127
+ DEV_NULL = File.exist?('/dev/null') ? '/dev/null' : 'NUL:'
130
128
 
131
129
  def quiet( &block )
132
130
  io = [STDOUT.dup, STDERR.dup]
@@ -139,23 +137,17 @@ ensure
139
137
  $stdout, $stderr = STDOUT, STDERR
140
138
  end
141
139
 
142
- DIFF = if WIN32 then 'diff.exe'
143
- else
144
- if quiet {system "gdiff", __FILE__, __FILE__} then 'gdiff'
145
- else 'diff' end
146
- end unless defined? DIFF
140
+ DIFF = if system("gdiff '#{__FILE__}' '#{__FILE__}' > #{DEV_NULL} 2>&1") then 'gdiff'
141
+ else 'diff' end unless defined? DIFF
147
142
 
148
- SUDO = if WIN32 then ''
149
- else
150
- if quiet {system 'which sudo'} then 'sudo'
151
- else '' end
152
- end
143
+ SUDO = if system("which sudo > #{DEV_NULL} 2>&1") then 'sudo'
144
+ else '' end unless defined? SUDO
153
145
 
154
- RCOV = WIN32 ? 'rcov.bat' : 'rcov'
155
- RDOC = WIN32 ? 'rdoc.bat' : 'rdoc'
156
- GEM = WIN32 ? 'gem.bat' : 'gem'
146
+ RCOV = "#{RUBY} -S rcov"
147
+ RDOC = "#{RUBY} -S rdoc"
148
+ GEM = "#{RUBY} -S gem"
157
149
 
158
- %w(rcov spec/rake/spectask rubyforge bones facets/ansicode).each do |lib|
150
+ %w(rcov spec/rake/spectask rubyforge bones facets/ansicode zentest).each do |lib|
159
151
  begin
160
152
  require lib
161
153
  Object.instance_eval {const_set "HAVE_#{lib.tr('/','_').upcase}", true}
@@ -0,0 +1,36 @@
1
+ if HAVE_ZENTEST
2
+
3
+ # --------------------------------------------------------------------------
4
+ if test(?e, PROJ.test.file) or not PROJ.test.files.to_a.empty?
5
+ require 'autotest'
6
+
7
+ namespace :test do
8
+ task :autotest do
9
+ Autotest.run
10
+ end
11
+ end
12
+
13
+ desc "Run the autotest loop"
14
+ task :autotest => 'test:autotest'
15
+
16
+ end # if test
17
+
18
+ # --------------------------------------------------------------------------
19
+ if HAVE_SPEC_RAKE_SPECTASK and not PROJ.spec.files.to_a.empty?
20
+ require 'autotest/rspec'
21
+
22
+ namespace :spec do
23
+ task :autotest do
24
+ load '.autotest' if test(?f, '.autotest')
25
+ Autotest::Rspec.run
26
+ end
27
+ end
28
+
29
+ desc "Run the autotest loop"
30
+ task :autotest => 'spec:autotest'
31
+
32
+ end # if rspec
33
+
34
+ end # if HAVE_ZENTEST
35
+
36
+ # EOF
@@ -0,0 +1,133 @@
1
+ require "test_helper"
2
+
3
+ # TODO: Only keep tests that are actually needed to verify
4
+ # yui_compressor working with the java lib
5
+ class TestYuiCompressor < Test::Unit::TestCase
6
+ def setup
7
+ @path = File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "..", "bin"))
8
+ @yui_compressor = Juicer::Minifyer::YuiCompressor.new({ :bin_path => @path })
9
+ Juicer::Test::FileSetup.new.create
10
+ @file = path('out.min.css')
11
+ end
12
+
13
+ def teardown
14
+ File.delete(@file) if @file && File.exists?(@file)
15
+ File.delete(path("a-1.css")) if File.exists?(path("a-1.css"))
16
+ end
17
+
18
+ def test_save_overwrite
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
+ end
23
+
24
+ def test_save_with_symbol_type
25
+ @yui_compressor.save(path('a.css'), path('a-1.css'), :css)
26
+ assert_equal "@import 'b.css';", IO.read(path('a-1.css'))
27
+ File.delete(path('a-1.css'))
28
+ end
29
+
30
+ def test_save_with_string_type
31
+ @yui_compressor.save(path('a.css'), path('a-1.css'), "css")
32
+ assert_equal "@import 'b.css';", IO.read(path('a-1.css'))
33
+ File.delete(path('a-1.css'))
34
+ end
35
+
36
+ def test_save_other_file
37
+ @yui_compressor.save(path('a.css'), path('a-1.css'))
38
+ assert_equal "@import 'b.css';", IO.read(path('a-1.css'))
39
+ assert_not_equal IO.read(path('a-1.css')), IO.read(path('a.css'))
40
+ File.delete(path('a-1.css'))
41
+ end
42
+
43
+ def test_save_should_create_non_existant_path
44
+ @yui_compressor.save(path('a.css'), path('bleh/blah/a-1.css'))
45
+ assert File.exists? path('bleh/blah/a-1.css')
46
+ FileUtils.rm_rf(path('bleh'))
47
+ end
48
+
49
+ # def test_command
50
+ # Juicer::Minifyer::YuiCompressor.publicize_methods do
51
+ # cmd = /java -jar #{@path.sub('2.3.5', '\d\.\d\.\d')}\/yuicompressor-\d\.\d\.\d\.jar --type css/
52
+ # assert_match cmd, @yui_compressor.command('css')
53
+
54
+ # @yui_compressor.no_munge = true
55
+ # cmd = /#{cmd} --no-munge/
56
+ # assert_match cmd, @yui_compressor.command('css')
57
+ # end
58
+ # end
59
+
60
+ context "locating jar" do
61
+ setup do
62
+ # Avoid developer env settings
63
+ @yuic_home = ENV['YUIC_HOME']
64
+ ENV.delete('YUIC_HOME')
65
+ end
66
+
67
+ teardown do
68
+ ENV['YUIC_HOME'] = @yuic_home
69
+ File.delete('yuicompressor-2.3.4.jar') if File.exists?('yuicompressor-2.3.4.jar')
70
+ File.delete('yuicompressor-2.3.5.jar') if File.exists?('yuicompressor-2.3.5.jar')
71
+ File.delete('yuicompressor.jar') if File.exists?('yuicompressor.jar')
72
+ FileUtils.rm_rf("another") if File.exists?("another")
73
+ end
74
+
75
+ should "not find jar when no jars on path" do
76
+ Juicer::Minifyer::YuiCompressor.publicize_methods do
77
+ yui_compressor = Juicer::Minifyer::YuiCompressor.new
78
+
79
+ assert_nil yui_compressor.locate_jar
80
+ end
81
+ end
82
+
83
+ should "find only jar in path" do
84
+ Juicer::Minifyer::YuiCompressor.publicize_methods do
85
+ File.open('yuicompressor-2.3.4.jar', 'w') { |f| f.puts '' }
86
+ yui_compressor = Juicer::Minifyer::YuiCompressor.new
87
+ assert_equal File.expand_path('yuicompressor-2.3.4.jar'), yui_compressor.locate_jar
88
+ end
89
+ end
90
+
91
+ should "find most recent of two jars on path" do
92
+ Juicer::Minifyer::YuiCompressor.publicize_methods do
93
+ # Create files
94
+ File.open('yuicompressor-2.3.4.jar', 'w') { |f| f.puts '' }
95
+ File.open('yuicompressor-2.3.5.jar', 'w') { |f| f.puts '' }
96
+
97
+ yui_compressor = Juicer::Minifyer::YuiCompressor.new
98
+
99
+ # Test
100
+ assert_equal File.expand_path('yuicompressor-2.3.5.jar'), yui_compressor.locate_jar
101
+ end
102
+ end
103
+
104
+ should "find most recent of three jar files on path" do
105
+ Juicer::Minifyer::YuiCompressor.publicize_methods do
106
+ # Create files
107
+ File.open('yuicompressor-2.3.4.jar', 'w') { |f| f.puts '' }
108
+ File.open('yuicompressor-2.3.5.jar', 'w') { |f| f.puts '' }
109
+ File.open('yuicompressor.jar', 'w') { |f| f.puts '' }
110
+
111
+ yui_compressor = Juicer::Minifyer::YuiCompressor.new
112
+
113
+ # Test
114
+ assert_equal File.expand_path('yuicompressor.jar'), yui_compressor.locate_jar
115
+ end
116
+ end
117
+
118
+ should "find jar in custom directory" do
119
+ Juicer::Minifyer::YuiCompressor.publicize_methods do
120
+ # Prepare
121
+ Dir.mkdir('another')
122
+ File.open('another/yuicompressor-2.3.4.jar', 'w') { |f| f.puts "" }
123
+
124
+ yui_compressor = Juicer::Minifyer::YuiCompressor.new
125
+
126
+ # Test
127
+ assert_nil yui_compressor.locate_jar
128
+ yui_compressor = Juicer::Minifyer::YuiCompressor.new({ :bin_path => 'another' })
129
+ assert_equal File.expand_path('another/yuicompressor-2.3.4.jar'), yui_compressor.locate_jar
130
+ end
131
+ end
132
+ end
133
+ end
@@ -0,0 +1,66 @@
1
+ require "test_helper"
2
+
3
+
4
+ class TestStringExtensions < Test::Unit::TestCase
5
+ context "camel case method" do
6
+ should "convert underscored string" do
7
+ assert_equal "CamelCase", "camel_case".camel_case
8
+ end
9
+
10
+ should "convert spaced string" do
11
+ assert_equal "Camel case", "camel case".camel_case
12
+ end
13
+
14
+ should "convert upper-case underscored string" do
15
+ assert_equal "CamelCase", "CAMEL_CASE".camel_case
16
+ end
17
+
18
+ should "convert 'camel cased' underscored string" do
19
+ assert_equal "CamelCase", "Camel_Case".camel_case
20
+ end
21
+ end
22
+
23
+ context "to_class method" do
24
+ should "return String class" do
25
+ assert_equal String, "String".to_class
26
+ end
27
+
28
+ should "raise error when loading String class from array class" do
29
+ assert_raise RuntimeError do
30
+ "String".to_class(Array)
31
+ end
32
+ end
33
+
34
+ should "return String class from Object" do
35
+ assert_equal String, "String".to_class(Object)
36
+ end
37
+
38
+ should "return nested class" do
39
+ assert_equal Juicer::DependencyResolver, "Juicer::DependencyResolver".to_class
40
+ end
41
+
42
+ should "return class from module" do
43
+ assert_equal Juicer::DependencyResolver, "DependencyResolver".to_class(Juicer)
44
+ end
45
+
46
+ should "return class from nested module" do
47
+ assert_equal Juicer::Install::YuiCompressorInstaller, "YuiCompressorInstaller".to_class(Juicer::Install)
48
+ end
49
+ end
50
+
51
+ context "classify method" do
52
+ should "return class from underscored string" do
53
+ assert_equal Juicer::DependencyResolver, "dependency_resolver".classify(Juicer)
54
+ end
55
+
56
+ should "return top level class from underscored string" do
57
+ assert_equal FileUtils, "file_utils".classify
58
+ end
59
+ end
60
+
61
+ context "underscore method" do
62
+ should "return underscored string from camel cased string" do
63
+ assert_equal "stylesheet_merger", "StylesheetMerger".underscore
64
+ end
65
+ end
66
+ 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.5
4
+ version: 0.2.6
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-05-22 00:00:00 +02:00
12
+ date: 2009-10-27 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -50,9 +50,21 @@ dependencies:
50
50
  requirements:
51
51
  - - ">="
52
52
  - !ruby/object:Gem::Version
53
- version: 2.4.0
53
+ version: 2.5.1
54
54
  version:
55
- description: Juicer is a command line tool that helps you ship frontend code for production. High level overview; Juicer can * figure out which files depend on each other and merge them together, reducing the number of http requests per page view, thus improving performance * use YUI Compressor to compress code, thus improving performance * verify that your JavaScript is safe to minify/compress by running JsLint on it * cycle asset hosts in CSS files * add "cache busters" to URLs in CSS files * recalculate relative URLs in CSS files, as well as convert them to absolute (or convert absolute URLs to relative URLs)
55
+ description: |-
56
+ Juicer is a command line tool that helps you ship frontend code for production.
57
+
58
+ High level overview; Juicer can
59
+
60
+ * figure out which files depend on each other and merge them together, reducing
61
+ the number of http requests per page view, thus improving performance
62
+ * use YUI Compressor to compress code, thus improving performance
63
+ * verify that your JavaScript is safe to minify/compress by running JsLint on it
64
+ * cycle asset hosts in CSS files
65
+ * add "cache busters" to URLs in CSS files
66
+ * recalculate relative URLs in CSS files, as well as convert them to absolute
67
+ (or convert absolute URLs to relative URLs)
56
68
  email: christian@cjohansen.no
57
69
  executables:
58
70
  - juicer
@@ -106,6 +118,8 @@ files:
106
118
  - tasks/svn.rake
107
119
  - tasks/test.rake
108
120
  - tasks/test/setup.rake
121
+ - tasks/zentest.rake
122
+ - test/integration/juicer/minifyer/yui_compressor_test.rb
109
123
  - test/juicer/command/test_install.rb
110
124
  - test/juicer/command/test_list.rb
111
125
  - test/juicer/command/test_merge.rb
@@ -128,8 +142,11 @@ files:
128
142
  - test/juicer/test_jslint.rb
129
143
  - test/test_helper.rb
130
144
  - test/test_juicer.rb
145
+ - test/unit/juicer/ext/#string_test.rb#
131
146
  has_rdoc: true
132
147
  homepage: http://www.cjohansen.no/en/projects/juicer
148
+ licenses: []
149
+
133
150
  post_install_message: |
134
151
  Juicer does not ship with third party libraries. You probably want to install
135
152
  Yui Compressor and JsLint now:
@@ -159,30 +176,30 @@ required_rubygems_version: !ruby/object:Gem::Requirement
159
176
  requirements: []
160
177
 
161
178
  rubyforge_project: juicer
162
- rubygems_version: 1.3.1
179
+ rubygems_version: 1.3.5
163
180
  signing_key:
164
- specification_version: 2
181
+ specification_version: 3
165
182
  summary: Juicer is a command line tool that helps you ship frontend code for production
166
183
  test_files:
167
- - test/test_helper.rb
168
- - test/juicer/test_cache_buster.rb
169
- - test/juicer/test_chainable.rb
170
- - test/juicer/test_jslint.rb
184
+ - test/juicer/command/test_install.rb
185
+ - test/juicer/command/test_list.rb
186
+ - test/juicer/command/test_merge.rb
187
+ - test/juicer/command/test_util.rb
188
+ - test/juicer/command/test_verify.rb
171
189
  - test/juicer/install/test_installer_base.rb
172
190
  - test/juicer/install/test_jslint_installer.rb
173
- - test/juicer/install/test_yui_compressor_installer.rb
174
191
  - test/juicer/install/test_rhino_installer.rb
175
- - test/juicer/test_css_cache_buster.rb
176
- - test/juicer/merger/test_javascript_dependency_resolver.rb
177
- - test/juicer/merger/test_css_dependency_resolver.rb
192
+ - test/juicer/install/test_yui_compressor_installer.rb
178
193
  - test/juicer/merger/test_base.rb
194
+ - test/juicer/merger/test_css_dependency_resolver.rb
195
+ - test/juicer/merger/test_javascript_dependency_resolver.rb
179
196
  - test/juicer/merger/test_javascript_merger.rb
180
197
  - test/juicer/merger/test_stylesheet_merger.rb
181
- - test/juicer/command/test_verify.rb
182
- - test/juicer/command/test_util.rb
183
- - test/juicer/command/test_install.rb
184
- - test/juicer/command/test_merge.rb
185
- - test/juicer/command/test_list.rb
186
- - test/juicer/test_core.rb
187
198
  - test/juicer/minifyer/test_yui_compressor.rb
199
+ - test/juicer/test_cache_buster.rb
200
+ - test/juicer/test_chainable.rb
201
+ - test/juicer/test_core.rb
202
+ - test/juicer/test_css_cache_buster.rb
203
+ - test/juicer/test_jslint.rb
204
+ - test/test_helper.rb
188
205
  - test/test_juicer.rb