smart_asset 0.5.10 → 0.5.11
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/.travis.yml +12 -0
- data/README.md +17 -6
- data/Rakefile +11 -1
- data/lib/smart_asset/adapters/stasis.rb +2 -2
- data/lib/smart_asset.rb +22 -28
- data/package.json +8 -0
- data/smart_asset.gemspec +7 -1
- data/spec/fixtures/all_frameworks/test.html.erb +0 -1
- data/spec/fixtures/development_output.txt +0 -1
- data/spec/fixtures/frameworks.yml +8 -0
- data/spec/fixtures/production_output.txt +2 -3
- data/spec/fixtures/rails3/development.rb +37 -0
- data/spec/fixtures/stasis/controller.rb +1 -0
- data/spec/run +21 -21
- data/spec/smart_asset/adapters/rails2_spec.rb +6 -24
- data/spec/smart_asset/adapters/rails3_spec.rb +7 -25
- data/spec/smart_asset/adapters/sinatra_spec.rb +6 -25
- data/spec/smart_asset/adapters/stasis_spec.rb +21 -0
- data/spec/smart_asset_spec.rb +6 -6
- data/spec/spec_helper.rb +17 -2
- metadata +148 -74
- data/bin/yuicompressor-2.4.6.jar +0 -0
data/.gitignore
CHANGED
data/.travis.yml
ADDED
data/README.md
CHANGED
@@ -1,28 +1,39 @@
|
|
1
1
|
SmartAsset
|
2
2
|
===========
|
3
3
|
|
4
|
-
Smart asset packaging for Rails and
|
4
|
+
Smart asset packaging for Rails, Sinatra, and Stasis.
|
5
|
+
|
6
|
+
[](http://travis-ci.org/winton/smart_asset)
|
5
7
|
|
6
8
|
Features
|
7
9
|
--------
|
8
10
|
|
9
11
|
Similar to <code>AssetPackager</code>, but with the following changes:
|
10
12
|
|
11
|
-
*
|
12
|
-
* [
|
13
|
-
*
|
13
|
+
* Uses file size and super fast hashing ([Murmur3](https://github.com/PeterScott/murmur3)) to determine if a new compressed package should be created
|
14
|
+
* [uglify-js](https://github.com/mishoo/UglifyJS) for javascript compression
|
15
|
+
* [clean-css](https://github.com/GoalSmashers/clean-css) for css compression
|
16
|
+
* Framework agnostic (adapters provided for Rails 2, Rails 3, Sinatra, and Stasis)
|
14
17
|
|
15
18
|
<a name="installation"></a>
|
16
19
|
|
17
20
|
Installation
|
18
21
|
------------
|
19
22
|
|
20
|
-
### Install
|
23
|
+
### Install gem
|
21
24
|
|
22
25
|
<pre>
|
23
26
|
gem install smart_asset
|
24
27
|
</pre>
|
25
28
|
|
29
|
+
### Install npm packages
|
30
|
+
|
31
|
+
<pre>
|
32
|
+
npm install uglify-js clean-css -g
|
33
|
+
</pre>
|
34
|
+
|
35
|
+
### Install
|
36
|
+
|
26
37
|
### Rails 2
|
27
38
|
|
28
39
|
#### config/environment.rb
|
@@ -146,7 +157,7 @@ You may use environment variables with the <code>smart\_asset</code> command to
|
|
146
157
|
|
147
158
|
<code>MODIFIED='12/1/2010 12:00'</code><br/>Use a default modified time other than Time.now for non-version controlled files
|
148
159
|
|
149
|
-
<code>WARN=1</code><br/>Get compression warnings from UglifyJS
|
160
|
+
<code>WARN=1</code><br/>Get compression warnings from UglifyJS
|
150
161
|
|
151
162
|
#### Example:
|
152
163
|
|
data/Rakefile
CHANGED
@@ -1 +1,11 @@
|
|
1
|
-
require 'bundler/gem_tasks'
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
require 'spec/rake/spectask'
|
3
|
+
|
4
|
+
Spec::Rake::SpecTask.new(:spec) do |t|
|
5
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
6
|
+
end
|
7
|
+
|
8
|
+
task :default do
|
9
|
+
system("npm install")
|
10
|
+
Rake::Task['spec'].execute
|
11
|
+
end
|
@@ -8,12 +8,12 @@ class SmartAsset
|
|
8
8
|
|
9
9
|
def initialize(stasis)
|
10
10
|
@stasis = stasis
|
11
|
-
|
12
|
-
SmartAsset.env = stasis.options[:development] ? 'development' : 'production'
|
13
11
|
SmartAsset.load_config(@stasis.root)
|
14
12
|
end
|
15
13
|
|
16
14
|
def before_all
|
15
|
+
SmartAsset.env = @stasis.options[:development] ?
|
16
|
+
'development' : 'production'
|
17
17
|
SmartAsset.cache = nil
|
18
18
|
|
19
19
|
@asset_rendered = false
|
data/lib/smart_asset.rb
CHANGED
@@ -3,6 +3,8 @@ require 'fileutils'
|
|
3
3
|
require 'time'
|
4
4
|
require 'yaml'
|
5
5
|
|
6
|
+
require "change"
|
7
|
+
|
6
8
|
$:.unshift File.dirname(__FILE__)
|
7
9
|
|
8
10
|
require 'smart_asset/helper'
|
@@ -12,9 +14,6 @@ class SmartAsset
|
|
12
14
|
|
13
15
|
attr_accessor :append_random, :asset_host, :asset_counter, :cache, :config, :dest, :env, :envs, :pub, :root, :sources
|
14
16
|
|
15
|
-
BIN = File.expand_path(File.dirname(__FILE__) + '/../bin')
|
16
|
-
YUI_COMPRESSOR = BIN + '/yuicompressor-2.4.6.jar'
|
17
|
-
|
18
17
|
def binary(root, relative_config=nil)
|
19
18
|
load_config root, relative_config
|
20
19
|
compress 'javascripts'
|
@@ -27,39 +26,28 @@ class SmartAsset
|
|
27
26
|
ext = ext_from_type(type)
|
28
27
|
packages = []
|
29
28
|
time_cache = {}
|
29
|
+
|
30
|
+
change = Change.new(dir)
|
31
|
+
change.d
|
32
|
+
states = change.send(:states)
|
30
33
|
|
31
34
|
FileUtils.mkdir_p dest
|
32
35
|
|
33
36
|
(@config[type] || {}).each do |package, files|
|
34
37
|
next if ENV['PACKAGE'] && ENV['PACKAGE'] != package
|
35
38
|
if files
|
36
|
-
#
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
if time_cache[file]
|
42
|
-
time = time_cache[file]
|
43
|
-
else
|
44
|
-
time = `cd #{@root} && git log --pretty=format:%cd -n 1 --date=iso #{@config['public']}/#{@sources[type]}/#{file}.#{ext}`
|
45
|
-
if time.strip.empty? || time.include?('command not found')
|
46
|
-
time = ENV['MODIFIED'] ? Time.parse(ENV['MODIFIED']) : Time.now
|
47
|
-
else
|
48
|
-
time = Time.parse(time)
|
49
|
-
end
|
50
|
-
time = time.utc.strftime("%Y%m%d%H%M%S")
|
51
|
-
time += file.to_s
|
52
|
-
time_cache[file] = time
|
53
|
-
end
|
54
|
-
timestamps << time
|
55
|
-
else
|
56
|
-
$stderr.puts "WARNING: '#{file_path}' was not found."
|
39
|
+
# Generate file hashes
|
40
|
+
hashes = files.inject([]) do |array, file|
|
41
|
+
path = "#{file}.#{ext}"
|
42
|
+
if states[path]
|
43
|
+
array << "#{states[path][:size]}#{states[path][:hash]}"
|
57
44
|
end
|
45
|
+
array
|
58
46
|
end
|
59
|
-
next if
|
47
|
+
next if hashes.empty?
|
60
48
|
|
61
49
|
# Modified hash
|
62
|
-
hash = Digest::SHA1.hexdigest(
|
50
|
+
hash = Digest::SHA1.hexdigest(hashes.join)[0..7]
|
63
51
|
|
64
52
|
# Package path
|
65
53
|
package = "#{dest}/#{hash}_#{package}.#{ext}"
|
@@ -86,10 +74,16 @@ class SmartAsset
|
|
86
74
|
File.open(tmp, 'w') { |f| f.write(data) }
|
87
75
|
puts "\nCreating #{package}..."
|
88
76
|
warning = ENV['WARN'] ? " -v" : nil
|
77
|
+
|
78
|
+
unless @bin
|
79
|
+
@bin = Dir.chdir(@root) { `npm bin`.strip }
|
80
|
+
@bin = File.directory?(@bin) ? "#{@bin}/" : nil
|
81
|
+
end
|
82
|
+
|
89
83
|
if ext == 'js'
|
90
|
-
cmd = "uglifyjs --output #{package}#{warning} -nc #{tmp}"
|
84
|
+
cmd = "#{@bin}uglifyjs --output #{package}#{warning} -nc #{tmp}"
|
91
85
|
elsif ext == 'css'
|
92
|
-
cmd = "
|
86
|
+
cmd = "#{@bin}cleancss #{tmp} -o #{package}"
|
93
87
|
end
|
94
88
|
puts cmd if ENV['DEBUG']
|
95
89
|
`#{cmd}`
|
data/package.json
ADDED
data/smart_asset.gemspec
CHANGED
@@ -6,7 +6,7 @@ $:.unshift lib unless $:.include?(lib)
|
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "smart_asset"
|
9
|
-
s.version = '0.5.
|
9
|
+
s.version = '0.5.11'
|
10
10
|
s.platform = Gem::Platform::RUBY
|
11
11
|
s.authors = ["Winton Welsh"]
|
12
12
|
s.email = ["mail@wintoni.us"]
|
@@ -21,5 +21,11 @@ Gem::Specification.new do |s|
|
|
21
21
|
|
22
22
|
s.add_development_dependency "framework_fixture"
|
23
23
|
s.add_development_dependency "rack-test"
|
24
|
+
s.add_development_dependency "rake"
|
25
|
+
s.add_development_dependency "rails", "~> 3.0"
|
24
26
|
s.add_development_dependency "rspec", "~> 1.0"
|
27
|
+
s.add_development_dependency "sinatra", "~> 1.0"
|
28
|
+
s.add_development_dependency "stasis", "0.2.0.pre"
|
29
|
+
|
30
|
+
s.add_dependency "change"
|
25
31
|
end
|
@@ -12,6 +12,7 @@ rails:
|
|
12
12
|
rails3:
|
13
13
|
- app/controllers/application_controller.rb
|
14
14
|
- config/application.rb
|
15
|
+
- config/environments/development.rb
|
15
16
|
- config/routes.rb
|
16
17
|
- Gemfile
|
17
18
|
all_frameworks:
|
@@ -27,6 +28,13 @@ sinatra:
|
|
27
28
|
<2:
|
28
29
|
sinatra:
|
29
30
|
- application.rb
|
31
|
+
all_frameworks:
|
32
|
+
- test.html.erb
|
33
|
+
- config/assets.yml
|
34
|
+
stasis:
|
35
|
+
<1:
|
36
|
+
stasis:
|
37
|
+
- controller.rb
|
30
38
|
all_frameworks:
|
31
39
|
- test.html.erb
|
32
40
|
- config/assets.yml
|
@@ -1,3 +1,2 @@
|
|
1
|
-
<script src="/packaged/
|
2
|
-
|
3
|
-
<link href="/packaged/4c0f7deb_package.css" media="screen" rel="stylesheet" />
|
1
|
+
<script src="/packaged/541a83e3_package.js"></script>
|
2
|
+
<link href="/packaged/63bae034_package.css" media="screen" rel="stylesheet" />
|
@@ -0,0 +1,37 @@
|
|
1
|
+
Rails3::Application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb
|
3
|
+
|
4
|
+
# In the development environment your application's code is reloaded on
|
5
|
+
# every request. This slows down response time but is perfect for development
|
6
|
+
# since you don't have to restart the web server when you make code changes.
|
7
|
+
config.cache_classes = false
|
8
|
+
|
9
|
+
# Log error messages when you accidentally call methods on nil.
|
10
|
+
config.whiny_nils = true
|
11
|
+
|
12
|
+
# Show full error reports and disable caching
|
13
|
+
config.consider_all_requests_local = true
|
14
|
+
config.action_controller.perform_caching = false
|
15
|
+
|
16
|
+
# Don't care if the mailer can't send
|
17
|
+
config.action_mailer.raise_delivery_errors = false
|
18
|
+
|
19
|
+
# Print deprecation notices to the Rails logger
|
20
|
+
config.active_support.deprecation = :log
|
21
|
+
|
22
|
+
# Only use best-standards-support built into browsers
|
23
|
+
config.action_dispatch.best_standards_support = :builtin
|
24
|
+
|
25
|
+
# Raise exception on mass assignment protection for Active Record models
|
26
|
+
# config.active_record.mass_assignment_sanitizer = :strict
|
27
|
+
|
28
|
+
# Log the query plan for queries taking more than this (works
|
29
|
+
# with SQLite, MySQL, and PostgreSQL)
|
30
|
+
# config.active_record.auto_explain_threshold_in_seconds = 0.5
|
31
|
+
|
32
|
+
# Do not compress assets
|
33
|
+
config.assets.compress = false
|
34
|
+
|
35
|
+
# Expands the lines which load the assets
|
36
|
+
config.assets.debug = true
|
37
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require "smart_asset"
|
data/spec/run
CHANGED
@@ -1,39 +1,39 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
system "spec -f n -c spec"
|
3
|
+
# system "spec -f n -c spec"
|
4
4
|
|
5
|
-
puts "\n"
|
5
|
+
# puts "\n"
|
6
6
|
|
7
|
-
ENV['RAILS'] = '2'
|
8
|
-
ENV['RAILS_ENV'] = 'development'
|
9
|
-
system "spec -f n -c spec"
|
7
|
+
# ENV['RAILS'] = '2'
|
8
|
+
# ENV['RAILS_ENV'] = 'development'
|
9
|
+
# system "spec -f n -c spec"
|
10
10
|
|
11
|
-
puts "\n"
|
11
|
+
# puts "\n"
|
12
12
|
|
13
|
-
ENV['RAILS_ENV'] = 'production'
|
14
|
-
system "spec -f n -c spec"
|
13
|
+
# ENV['RAILS_ENV'] = 'production'
|
14
|
+
# system "spec -f n -c spec"
|
15
15
|
|
16
|
-
puts "\n"
|
16
|
+
# puts "\n"
|
17
17
|
|
18
18
|
ENV['RAILS'] = '3'
|
19
19
|
ENV['RAILS_ENV'] = 'development'
|
20
20
|
system "spec -f n -c spec"
|
21
21
|
|
22
|
-
puts "\n"
|
22
|
+
# puts "\n"
|
23
23
|
|
24
|
-
ENV['RAILS_ENV'] = 'production'
|
25
|
-
system "spec -f n -c spec"
|
24
|
+
# ENV['RAILS_ENV'] = 'production'
|
25
|
+
# system "spec -f n -c spec"
|
26
26
|
|
27
|
-
ENV.delete 'RAILS'
|
28
|
-
ENV.delete 'RAILS_ENV'
|
27
|
+
# ENV.delete 'RAILS'
|
28
|
+
# ENV.delete 'RAILS_ENV'
|
29
29
|
|
30
|
-
puts "\n"
|
30
|
+
# puts "\n"
|
31
31
|
|
32
|
-
ENV['SINATRA'] = '1'
|
33
|
-
ENV['RACK_ENV'] = 'development'
|
34
|
-
system "spec -f n -c spec"
|
32
|
+
# ENV['SINATRA'] = '1'
|
33
|
+
# ENV['RACK_ENV'] = 'development'
|
34
|
+
# system "spec -f n -c spec"
|
35
35
|
|
36
|
-
puts "\n"
|
36
|
+
# puts "\n"
|
37
37
|
|
38
|
-
ENV['RACK_ENV'] = 'production'
|
39
|
-
system "spec -f n -c spec"
|
38
|
+
# ENV['RACK_ENV'] = 'production'
|
39
|
+
# system "spec -f n -c spec"
|
@@ -10,14 +10,9 @@ if FrameworkFixture.rails == '<3'
|
|
10
10
|
end
|
11
11
|
|
12
12
|
before(:all) do
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
FileUtils.cp_r "#{assets}/compressed", "#{pub}/packaged"
|
17
|
-
FileUtils.rm_rf "#{pub}/javascripts"
|
18
|
-
FileUtils.cp_r "#{assets}/javascripts", "#{pub}/javascripts"
|
19
|
-
FileUtils.rm_rf "#{pub}/stylesheets"
|
20
|
-
FileUtils.cp_r "#{assets}/stylesheets", "#{pub}/stylesheets"
|
13
|
+
build = "#{$root}/spec/fixtures/builds/rails2"
|
14
|
+
setup_adapter_build("#{build}/public")
|
15
|
+
SmartAsset.binary(build) if Rails.env == 'production'
|
21
16
|
end
|
22
17
|
|
23
18
|
it "should have a pulse" do
|
@@ -25,22 +20,9 @@ if FrameworkFixture.rails == '<3'
|
|
25
20
|
last_response.body.should == '1'
|
26
21
|
end
|
27
22
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
get "/test"
|
32
|
-
last_response.body.should == File.read("#{$root}/spec/fixtures/development_output.txt")
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
if Rails.env == 'production'
|
38
|
-
describe :production do
|
39
|
-
it "should execute helpers correctly" do
|
40
|
-
get "/test"
|
41
|
-
last_response.body.should == File.read("#{$root}/spec/fixtures/production_output.txt")
|
42
|
-
end
|
43
|
-
end
|
23
|
+
it "should execute helpers correctly" do
|
24
|
+
get "/test"
|
25
|
+
equals_output(Rails.env, last_response.body)
|
44
26
|
end
|
45
27
|
end
|
46
28
|
end
|
@@ -10,37 +10,19 @@ if FrameworkFixture.rails == '<4'
|
|
10
10
|
end
|
11
11
|
|
12
12
|
before(:all) do
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
FileUtils.cp_r "#{assets}/compressed", "#{pub}/packaged"
|
17
|
-
FileUtils.rm_rf "#{pub}/javascripts"
|
18
|
-
FileUtils.cp_r "#{assets}/javascripts", "#{pub}/javascripts"
|
19
|
-
FileUtils.rm_rf "#{pub}/stylesheets"
|
20
|
-
FileUtils.cp_r "#{assets}/stylesheets", "#{pub}/stylesheets"
|
13
|
+
build = "#{$root}/spec/fixtures/builds/rails3"
|
14
|
+
setup_adapter_build("#{build}/public")
|
15
|
+
SmartAsset.binary(build) if Rails.env == 'production'
|
21
16
|
end
|
22
17
|
|
23
18
|
it "should have a pulse" do
|
24
19
|
get "/pulse"
|
25
20
|
last_response.body.should == '1'
|
26
21
|
end
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
get "/test"
|
32
|
-
last_response.body.should == File.read("#{$root}/spec/fixtures/development_output.txt")
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
if Rails.env == 'production'
|
38
|
-
describe :production do
|
39
|
-
it "should execute helpers correctly" do
|
40
|
-
get "/test"
|
41
|
-
last_response.body.should == File.read("#{$root}/spec/fixtures/production_output.txt")
|
42
|
-
end
|
43
|
-
end
|
22
|
+
|
23
|
+
it "should execute helpers correctly" do
|
24
|
+
get "/test"
|
25
|
+
equals_output(Rails.env, last_response.body)
|
44
26
|
end
|
45
27
|
end
|
46
28
|
end
|
@@ -10,15 +10,9 @@ if FrameworkFixture.sinatra
|
|
10
10
|
end
|
11
11
|
|
12
12
|
before(:all) do
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
FileUtils.rm_rf "#{pub}/packaged"
|
17
|
-
FileUtils.cp_r "#{assets}/compressed", "#{pub}/packaged"
|
18
|
-
FileUtils.rm_rf "#{pub}/javascripts"
|
19
|
-
FileUtils.cp_r "#{assets}/javascripts", "#{pub}/javascripts"
|
20
|
-
FileUtils.rm_rf "#{pub}/stylesheets"
|
21
|
-
FileUtils.cp_r "#{assets}/stylesheets", "#{pub}/stylesheets"
|
13
|
+
build = "#{$root}/spec/fixtures/builds/sinatra#{FrameworkFixture.exact_version[0..0]}"
|
14
|
+
setup_adapter_build("#{build}/public")
|
15
|
+
SmartAsset.binary(build) if SmartAsset.env == :production
|
22
16
|
end
|
23
17
|
|
24
18
|
it "should have a pulse" do
|
@@ -26,22 +20,9 @@ if FrameworkFixture.sinatra
|
|
26
20
|
last_response.body.should == '1'
|
27
21
|
end
|
28
22
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
get "/test"
|
33
|
-
last_response.body.should == File.read("#{$root}/spec/fixtures/development_output.txt")
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
if Sinatra::Base.environment == :production
|
39
|
-
describe :production do
|
40
|
-
it "should execute helpers correctly" do
|
41
|
-
get "/test"
|
42
|
-
last_response.body.should == File.read("#{$root}/spec/fixtures/production_output.txt")
|
43
|
-
end
|
44
|
-
end
|
23
|
+
it "should execute helpers correctly" do
|
24
|
+
get "/test"
|
25
|
+
equals_output(Sinatra::Base.environment, last_response.body)
|
45
26
|
end
|
46
27
|
end
|
47
28
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require File.expand_path("#{File.dirname(__FILE__)}/../../spec_helper")
|
2
|
+
|
3
|
+
if FrameworkFixture.stasis
|
4
|
+
describe 'Stasis' do
|
5
|
+
|
6
|
+
before(:all) do
|
7
|
+
@stasis = FrameworkFixture.app.call
|
8
|
+
@build = "#{$root}/spec/fixtures/builds/stasis#{FrameworkFixture.exact_version[0..0]}"
|
9
|
+
setup_adapter_build("#{@build}/public", "#{@build}_output")
|
10
|
+
SmartAsset.binary @build
|
11
|
+
end
|
12
|
+
|
13
|
+
%w(production development).each do |env|
|
14
|
+
it "should execute helpers correctly in #{env}" do
|
15
|
+
@stasis.options[:development] = env == 'development'
|
16
|
+
@stasis.render
|
17
|
+
equals_output(env, File.read("#{@build}_output/test.html"))
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/spec/smart_asset_spec.rb
CHANGED
@@ -13,8 +13,8 @@ unless FrameworkFixture.framework
|
|
13
13
|
package.js
|
14
14
|
)
|
15
15
|
@versions = %w(
|
16
|
-
|
17
|
-
|
16
|
+
63bae034
|
17
|
+
541a83e3
|
18
18
|
)
|
19
19
|
end
|
20
20
|
|
@@ -203,7 +203,7 @@ unless FrameworkFixture.framework
|
|
203
203
|
end
|
204
204
|
|
205
205
|
it "should rewrite javascript package with underscore code first" do
|
206
|
-
File.size(path = "#{@dest}/
|
206
|
+
File.size(path = "#{@dest}/dbd79469_#{@files[1]}").should > 0
|
207
207
|
js = File.read(path)
|
208
208
|
js.index('jQuery').should > js.index('VERSION')
|
209
209
|
js.include?('jQuery').should == true
|
@@ -231,7 +231,7 @@ unless FrameworkFixture.framework
|
|
231
231
|
end
|
232
232
|
|
233
233
|
it "should rewrite javascript package with only jquery" do
|
234
|
-
File.size(path = "#{@dest}/
|
234
|
+
File.size(path = "#{@dest}/18f448b8_#{@files[1]}").should > 0
|
235
235
|
js = File.read(path)
|
236
236
|
js.include?('jQuery').should == true
|
237
237
|
js.include?('VERSION').should == false
|
@@ -265,9 +265,9 @@ unless FrameworkFixture.framework
|
|
265
265
|
describe 'untracked file' do
|
266
266
|
|
267
267
|
before(:all) do
|
268
|
-
@modified = Time.parse('12-01-2010')
|
268
|
+
@modified = Time.parse('12-01-2010 08:00:00 UTC')
|
269
269
|
ENV['MODIFIED'] = @modified.to_s
|
270
|
-
@package = "#{@dest}/
|
270
|
+
@package = "#{@dest}/c3939102_#{@files[1]}"
|
271
271
|
@untracked = "#{$root}/spec/fixtures/assets/javascripts/untracked.js"
|
272
272
|
|
273
273
|
File.open(@untracked, 'w') { |f| f.write("var untracked = true;") }
|
data/spec/spec_helper.rb
CHANGED
@@ -2,12 +2,11 @@ require "pp"
|
|
2
2
|
require "stringio"
|
3
3
|
|
4
4
|
require "bundler/setup"
|
5
|
+
require "stasis"
|
5
6
|
|
6
7
|
$root = File.expand_path('../../', __FILE__)
|
7
8
|
|
8
|
-
gem('framework_fixture', '0.1.3')
|
9
9
|
require 'framework_fixture'
|
10
|
-
|
11
10
|
FrameworkFixture.generate File.dirname(__FILE__) + '/fixtures'
|
12
11
|
|
13
12
|
require 'rack/test'
|
@@ -24,4 +23,20 @@ def capture_stdout
|
|
24
23
|
return out
|
25
24
|
ensure
|
26
25
|
$stdout = old
|
26
|
+
end
|
27
|
+
|
28
|
+
def equals_output(type, output)
|
29
|
+
output = output.gsub("\n", '')
|
30
|
+
output.should == File.read("#{$root}/spec/fixtures/#{type}_output.txt").gsub("\n", '')
|
31
|
+
end
|
32
|
+
|
33
|
+
def setup_adapter_build(source, destination=source)
|
34
|
+
assets = "#{$root}/spec/fixtures/assets"
|
35
|
+
FileUtils.mkdir_p source
|
36
|
+
FileUtils.mkdir_p destination
|
37
|
+
FileUtils.rm_rf "#{destination}/packaged"
|
38
|
+
FileUtils.rm_rf "#{source}/javascripts"
|
39
|
+
FileUtils.cp_r "#{assets}/javascripts", "#{source}/javascripts"
|
40
|
+
FileUtils.rm_rf "#{source}/stylesheets"
|
41
|
+
FileUtils.cp_r "#{assets}/stylesheets", "#{source}/stylesheets"
|
27
42
|
end
|
metadata
CHANGED
@@ -1,83 +1,159 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: smart_asset
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.5.11
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 5
|
9
|
-
- 10
|
10
|
-
version: 0.5.10
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Winton Welsh
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2012-07-10 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
21
15
|
name: framework_fixture
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
hash: 3
|
29
|
-
segments:
|
30
|
-
- 0
|
31
|
-
version: "0"
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
32
22
|
type: :development
|
33
|
-
|
34
|
-
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
35
31
|
name: rack-test
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rake
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
36
55
|
prerelease: false
|
37
|
-
|
38
|
-
none: false
|
39
|
-
requirements:
|
40
|
-
- -
|
41
|
-
- !ruby/object:Gem::Version
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: rails
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ~>
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '3.0'
|
46
70
|
type: :development
|
47
|
-
|
48
|
-
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '3.0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
49
79
|
name: rspec
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ~>
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '1.0'
|
86
|
+
type: :development
|
50
87
|
prerelease: false
|
51
|
-
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ~>
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '1.0'
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: sinatra
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
52
97
|
none: false
|
53
|
-
requirements:
|
98
|
+
requirements:
|
54
99
|
- - ~>
|
55
|
-
- !ruby/object:Gem::Version
|
56
|
-
|
57
|
-
segments:
|
58
|
-
- 1
|
59
|
-
- 0
|
60
|
-
version: "1.0"
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '1.0'
|
61
102
|
type: :development
|
62
|
-
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ~>
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '1.0'
|
110
|
+
- !ruby/object:Gem::Dependency
|
111
|
+
name: stasis
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
114
|
+
requirements:
|
115
|
+
- - '='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: 0.2.0.pre
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - '='
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: 0.2.0.pre
|
126
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
name: change
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
129
|
+
none: false
|
130
|
+
requirements:
|
131
|
+
- - ! '>='
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
134
|
+
type: :runtime
|
135
|
+
prerelease: false
|
136
|
+
version_requirements: !ruby/object:Gem::Requirement
|
137
|
+
none: false
|
138
|
+
requirements:
|
139
|
+
- - ! '>='
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0'
|
63
142
|
description: Smart asset packaging for Rails, Sinatra, and Stasis.
|
64
|
-
email:
|
143
|
+
email:
|
65
144
|
- mail@wintoni.us
|
66
|
-
executables:
|
145
|
+
executables:
|
67
146
|
- smart_asset
|
68
|
-
- yuicompressor-2.4.6.jar
|
69
147
|
extensions: []
|
70
|
-
|
71
148
|
extra_rdoc_files: []
|
72
|
-
|
73
|
-
files:
|
149
|
+
files:
|
74
150
|
- .gitignore
|
151
|
+
- .travis.yml
|
75
152
|
- Gemfile
|
76
153
|
- LICENSE
|
77
154
|
- README.md
|
78
155
|
- Rakefile
|
79
156
|
- bin/smart_asset
|
80
|
-
- bin/yuicompressor-2.4.6.jar
|
81
157
|
- lib/smart_asset.rb
|
82
158
|
- lib/smart_asset/adapters/rails2.rb
|
83
159
|
- lib/smart_asset/adapters/rails3.rb
|
@@ -85,6 +161,7 @@ files:
|
|
85
161
|
- lib/smart_asset/adapters/stasis.rb
|
86
162
|
- lib/smart_asset/helper.rb
|
87
163
|
- lib/smart_asset/recipes.rb
|
164
|
+
- package.json
|
88
165
|
- recipes/smart_asset.rb
|
89
166
|
- smart_asset.gemspec
|
90
167
|
- spec/fixtures/all_frameworks/assets.yml
|
@@ -104,48 +181,42 @@ files:
|
|
104
181
|
- spec/fixtures/rails3/Gemfile
|
105
182
|
- spec/fixtures/rails3/application.rb
|
106
183
|
- spec/fixtures/rails3/application_controller.rb
|
184
|
+
- spec/fixtures/rails3/development.rb
|
107
185
|
- spec/fixtures/rails3/routes.rb
|
108
186
|
- spec/fixtures/sinatra/application.rb
|
187
|
+
- spec/fixtures/stasis/controller.rb
|
109
188
|
- spec/run
|
110
189
|
- spec/smart_asset/adapters/rails2_spec.rb
|
111
190
|
- spec/smart_asset/adapters/rails3_spec.rb
|
112
191
|
- spec/smart_asset/adapters/sinatra_spec.rb
|
192
|
+
- spec/smart_asset/adapters/stasis_spec.rb
|
113
193
|
- spec/smart_asset_spec.rb
|
114
194
|
- spec/spec_helper.rb
|
115
195
|
homepage: http://github.com/winton/smart_asset
|
116
196
|
licenses: []
|
117
|
-
|
118
197
|
post_install_message:
|
119
198
|
rdoc_options: []
|
120
|
-
|
121
|
-
require_paths:
|
199
|
+
require_paths:
|
122
200
|
- lib
|
123
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
201
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
124
202
|
none: false
|
125
|
-
requirements:
|
126
|
-
- -
|
127
|
-
- !ruby/object:Gem::Version
|
128
|
-
|
129
|
-
|
130
|
-
- 0
|
131
|
-
version: "0"
|
132
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
203
|
+
requirements:
|
204
|
+
- - ! '>='
|
205
|
+
- !ruby/object:Gem::Version
|
206
|
+
version: '0'
|
207
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
133
208
|
none: false
|
134
|
-
requirements:
|
135
|
-
- -
|
136
|
-
- !ruby/object:Gem::Version
|
137
|
-
|
138
|
-
segments:
|
139
|
-
- 0
|
140
|
-
version: "0"
|
209
|
+
requirements:
|
210
|
+
- - ! '>='
|
211
|
+
- !ruby/object:Gem::Version
|
212
|
+
version: '0'
|
141
213
|
requirements: []
|
142
|
-
|
143
214
|
rubyforge_project:
|
144
|
-
rubygems_version: 1.8.
|
215
|
+
rubygems_version: 1.8.24
|
145
216
|
signing_key:
|
146
217
|
specification_version: 3
|
147
218
|
summary: Smart asset packaging for Rails, Sinatra, and Stasis
|
148
|
-
test_files:
|
219
|
+
test_files:
|
149
220
|
- spec/fixtures/all_frameworks/assets.yml
|
150
221
|
- spec/fixtures/all_frameworks/test.html.erb
|
151
222
|
- spec/fixtures/assets.yml
|
@@ -163,11 +234,14 @@ test_files:
|
|
163
234
|
- spec/fixtures/rails3/Gemfile
|
164
235
|
- spec/fixtures/rails3/application.rb
|
165
236
|
- spec/fixtures/rails3/application_controller.rb
|
237
|
+
- spec/fixtures/rails3/development.rb
|
166
238
|
- spec/fixtures/rails3/routes.rb
|
167
239
|
- spec/fixtures/sinatra/application.rb
|
240
|
+
- spec/fixtures/stasis/controller.rb
|
168
241
|
- spec/run
|
169
242
|
- spec/smart_asset/adapters/rails2_spec.rb
|
170
243
|
- spec/smart_asset/adapters/rails3_spec.rb
|
171
244
|
- spec/smart_asset/adapters/sinatra_spec.rb
|
245
|
+
- spec/smart_asset/adapters/stasis_spec.rb
|
172
246
|
- spec/smart_asset_spec.rb
|
173
247
|
- spec/spec_helper.rb
|
data/bin/yuicompressor-2.4.6.jar
DELETED
Binary file
|