cdn_fu 0.6 → 0.6.1
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/Gemfile +4 -0
- data/Gemfile.lock +26 -0
- data/Rakefile +9 -0
- data/cdn_fu.gemspec +26 -0
- data/lib/cdn_fu/minifiers/yui_minifier.rb +1 -1
- data/lib/cdn_fu/uploaders/cloudfront_uploader.rb +9 -3
- data/lib/cdn_fu/version.rb +3 -0
- data/lib/cdn_fu.rb +2 -1
- data/test/asset_root/css/style.css +0 -0
- data/test/asset_root/images/1.png +0 -0
- data/test/asset_root/images/2.png +0 -0
- data/test/asset_root/images/fun/fun.png +0 -0
- data/test/asset_root/images/image.png +0 -0
- data/test/asset_root/js/another.js +4 -0
- data/test/asset_root/js/unminified.js +4 -0
- data/test/asset_root/single/single.png +0 -0
- data/test/basic_test.rb +40 -0
- data/test/configs/basic_cdn_fu_config.rb +4 -0
- data/test/configs/diff_remote_paths.rb +9 -0
- data/test/configs/file_lister.rb +19 -0
- data/test/configs/local_upload_config.rb +15 -0
- data/test/local_uploader_test.rb +19 -0
- data/test/test_helper.rb +8 -0
- metadata +76 -23
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
cdn_fu (0.6.1)
|
5
|
+
aws-s3 (>= 0.6.2)
|
6
|
+
rake (>= 0.8)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: http://rubygems.org/
|
10
|
+
specs:
|
11
|
+
aws-s3 (0.6.2)
|
12
|
+
builder
|
13
|
+
mime-types
|
14
|
+
xml-simple
|
15
|
+
builder (3.0.0)
|
16
|
+
mime-types (1.16)
|
17
|
+
rake (0.9.0)
|
18
|
+
xml-simple (1.0.15)
|
19
|
+
|
20
|
+
PLATFORMS
|
21
|
+
ruby
|
22
|
+
|
23
|
+
DEPENDENCIES
|
24
|
+
aws-s3 (>= 0.6.2)
|
25
|
+
cdn_fu!
|
26
|
+
rake (>= 0.8)
|
data/Rakefile
ADDED
data/cdn_fu.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
$:.push File.expand_path("../lib", __FILE__)
|
2
|
+
require "cdn_fu/version"
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{cdn_fu}
|
5
|
+
s.version = CdnFu::VERSION
|
6
|
+
s.authors = ["Curtis Spencer"]
|
7
|
+
s.email = ["curtis@sevenforge.com"]
|
8
|
+
s.summary = %q{CDN Fu is a framework for making minification and deployment of static assets easy}
|
9
|
+
s.description = <<-EOF
|
10
|
+
CDN Fu is a framework for making listing, minification and deployment of static
|
11
|
+
assets easy. It allows you to use it standalone on the command line for non
|
12
|
+
Rails project and it can be used as a Rails plugin to add useful rake tasks and
|
13
|
+
sensible defaults.
|
14
|
+
EOF
|
15
|
+
|
16
|
+
s.rubyforge_project = %q{cdn_fu}
|
17
|
+
|
18
|
+
s.add_dependency('rake', '>=0.8')
|
19
|
+
s.add_dependency('aws-s3', '>=0.6.2')
|
20
|
+
|
21
|
+
s.files = `git ls-files`.split("\n")
|
22
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
23
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
24
|
+
s.require_paths = ["lib"]
|
25
|
+
end
|
26
|
+
|
@@ -12,7 +12,7 @@ class YuiMinifier < CdnFu::Minifier
|
|
12
12
|
def validate
|
13
13
|
if @yui_jar_path
|
14
14
|
if File.exists?(@yui_jar_path)
|
15
|
-
output = `java -jar #{@yui_jar_path}`
|
15
|
+
output = `java -jar #{@yui_jar_path} 2>&1`
|
16
16
|
if output !~ /java -jar yuicompressor-x\.y\.z\.jar/
|
17
17
|
raise CdnFu::ConfigError,"Invalid YUI Compressor jar specified in cdn_fu.rb"
|
18
18
|
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# This uploader using aws:s3 gem to upload everything to the specified bucket
|
2
2
|
require 'zlib'
|
3
3
|
require 'aws/s3'
|
4
|
+
require 'time'
|
4
5
|
class CloudfrontUploader < CdnFu::Uploader
|
5
6
|
include AWS::S3
|
6
7
|
required_attribute :s3_bucket
|
@@ -58,7 +59,7 @@ class CloudfrontUploader < CdnFu::Uploader
|
|
58
59
|
end
|
59
60
|
|
60
61
|
def upload_single_file(cf_file)
|
61
|
-
versioned_filename = CdnFu::Config.config.asset_id + cf_file.remote_path
|
62
|
+
versioned_filename = CdnFu::Config.config.asset_id.to_s + cf_file.remote_path
|
62
63
|
options = {}
|
63
64
|
options[:access] = :public_read
|
64
65
|
path_to_upload = cf_file.minified_path
|
@@ -69,6 +70,8 @@ class CloudfrontUploader < CdnFu::Uploader
|
|
69
70
|
if remote_sha1 != sha1sum
|
70
71
|
puts "Your assets are different from the ones in s3 with this asset_id. Please increment your asset_id in cdn_fu.rb"
|
71
72
|
exit
|
73
|
+
else
|
74
|
+
puts "Skipping #{versioned_filename}" if CdnFu::Config.config.verbose
|
72
75
|
end
|
73
76
|
else
|
74
77
|
options[:access] = :public_read
|
@@ -77,6 +80,7 @@ class CloudfrontUploader < CdnFu::Uploader
|
|
77
80
|
options["x-amz-meta-size"] = fstat.size
|
78
81
|
file_content =open(path_to_upload).read
|
79
82
|
if cf_file.gzip?
|
83
|
+
puts "Gzipping"
|
80
84
|
options["Content-Encoding"] = 'gzip'
|
81
85
|
strio = StringIO.open('', 'w')
|
82
86
|
gz = Zlib::GzipWriter.new(strio)
|
@@ -85,8 +89,10 @@ class CloudfrontUploader < CdnFu::Uploader
|
|
85
89
|
file_content = strio.string
|
86
90
|
end
|
87
91
|
|
88
|
-
|
89
|
-
|
92
|
+
eight_years = 8 * 60 * 60 * 24 * 365
|
93
|
+
eight_years_from_now = Time.now + eight_years
|
94
|
+
options[:cache_control] = "max-age=#{eight_years}"
|
95
|
+
options[:expires] = eight_years_from_now.httpdate
|
90
96
|
S3Object.store(versioned_filename,file_content,s3_bucket, options)
|
91
97
|
puts "[upload] #{s3_bucket} #{versioned_filename}" if CdnFu::Config.config.verbose
|
92
98
|
end
|
data/lib/cdn_fu.rb
CHANGED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/test/basic_test.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
dir = File.dirname(__FILE__)
|
2
|
+
$LOAD_PATH.unshift dir unless $LOAD_PATH.include?(dir)
|
3
|
+
|
4
|
+
require 'test_helper'
|
5
|
+
|
6
|
+
class BasicTest < Test::Unit::TestCase
|
7
|
+
def setup
|
8
|
+
CdnFu::Config.clear
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_basic
|
12
|
+
config = eval(File.open(File.join(TEST_ROOT,'configs/basic_cdn_fu_config.rb')).read)
|
13
|
+
assert_equal('1',config.asset_id)
|
14
|
+
assert_equal('/tmp',config.tmp_dir)
|
15
|
+
assert_nil(config.uploader)
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_file_lister
|
19
|
+
config = eval(File.open(File.join(TEST_ROOT,'configs/file_lister.rb')).read)
|
20
|
+
assert_equal('1',config.asset_id)
|
21
|
+
assert_equal(File.join(TEST_ROOT,'asset_root'),config.asset_root_dir)
|
22
|
+
assert_equal(YuiMinifier,config.minifier.class)
|
23
|
+
|
24
|
+
config.prepare_and_upload
|
25
|
+
file_list = config.files
|
26
|
+
assert_equal(8,file_list.size)
|
27
|
+
assert_equal('/js/another.js',file_list[0].remote_path)
|
28
|
+
assert(file_list[0].gzip?)
|
29
|
+
assert(file_list[0].minify?)
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_different_remote_paths
|
33
|
+
config = eval(File.open(File.join(TEST_ROOT,'configs/diff_remote_paths.rb')).read)
|
34
|
+
config.prepare_and_upload
|
35
|
+
file_list = config.files
|
36
|
+
assert_equal(6,file_list.size)
|
37
|
+
assert_equal('/javascripts/another.js',file_list[0].remote_path)
|
38
|
+
assert_equal('/img/fun/fun.png',file_list[4].remote_path)
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
CdnFu::Config.configure do |cfg|
|
2
|
+
asset_id '1'
|
3
|
+
asset_root_dir File.join(TEST_ROOT,'asset_root')
|
4
|
+
verbose false
|
5
|
+
|
6
|
+
files do
|
7
|
+
glob "js/*.js", :minify => true, :gzip => true
|
8
|
+
glob "css/*.css", :minify => true, :gzip => true
|
9
|
+
glob "images/**/*.png"
|
10
|
+
file 'single/single.png', :path => '/s/s.png'
|
11
|
+
end
|
12
|
+
|
13
|
+
minifier YuiMinifier do
|
14
|
+
yui_jar_path "/usr/bin/yuicompressor-2.4.2.jar"
|
15
|
+
end
|
16
|
+
|
17
|
+
upload do |file_list|
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
CdnFu::Config.configure do
|
2
|
+
tmp_dir File.join(TEST_ROOT,'/tmp/minified')
|
3
|
+
asset_root_dir File.join(TEST_ROOT,'asset_root')
|
4
|
+
|
5
|
+
files do
|
6
|
+
glob "js/*.js", :minify => true, :gzip => true
|
7
|
+
glob "css/*.css", :minify => true, :gzip => true
|
8
|
+
glob "images/**/*.png"
|
9
|
+
file 'single/single.png', :path => '/s/s.png'
|
10
|
+
end
|
11
|
+
|
12
|
+
uploader LocalUploader do
|
13
|
+
path File.join(TEST_ROOT, '/tmp/local_path')
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
dir = File.dirname(__FILE__)
|
2
|
+
$LOAD_PATH.unshift dir unless $LOAD_PATH.include?(dir)
|
3
|
+
|
4
|
+
require 'test_helper'
|
5
|
+
|
6
|
+
class LocalUploaderTest < Test::Unit::TestCase
|
7
|
+
def setup
|
8
|
+
CdnFu::Config.clear
|
9
|
+
end
|
10
|
+
|
11
|
+
def teardown
|
12
|
+
TEST_ROOT
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_local
|
16
|
+
config = eval(File.open(File.join(TEST_ROOT,'configs/local_upload_config.rb')).read)
|
17
|
+
config.prepare_and_upload
|
18
|
+
end
|
19
|
+
end
|
data/test/test_helper.rb
ADDED
metadata
CHANGED
@@ -1,7 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cdn_fu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 6
|
8
|
+
- 1
|
9
|
+
version: 0.6.1
|
5
10
|
platform: ruby
|
6
11
|
authors:
|
7
12
|
- Curtis Spencer
|
@@ -9,36 +14,46 @@ autorequire:
|
|
9
14
|
bindir: bin
|
10
15
|
cert_chain: []
|
11
16
|
|
12
|
-
date:
|
17
|
+
date: 2011-05-23 00:00:00 -07:00
|
13
18
|
default_executable:
|
14
19
|
dependencies:
|
15
20
|
- !ruby/object:Gem::Dependency
|
16
21
|
name: rake
|
17
|
-
|
18
|
-
|
19
|
-
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
20
25
|
requirements:
|
21
26
|
- - ">="
|
22
27
|
- !ruby/object:Gem::Version
|
28
|
+
segments:
|
29
|
+
- 0
|
30
|
+
- 8
|
23
31
|
version: "0.8"
|
24
|
-
|
32
|
+
type: :runtime
|
33
|
+
version_requirements: *id001
|
25
34
|
- !ruby/object:Gem::Dependency
|
26
35
|
name: aws-s3
|
27
|
-
|
28
|
-
|
29
|
-
|
36
|
+
prerelease: false
|
37
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
38
|
+
none: false
|
30
39
|
requirements:
|
31
40
|
- - ">="
|
32
41
|
- !ruby/object:Gem::Version
|
42
|
+
segments:
|
43
|
+
- 0
|
44
|
+
- 6
|
45
|
+
- 2
|
33
46
|
version: 0.6.2
|
34
|
-
|
47
|
+
type: :runtime
|
48
|
+
version_requirements: *id002
|
35
49
|
description: |
|
36
50
|
CDN Fu is a framework for making listing, minification and deployment of static
|
37
51
|
assets easy. It allows you to use it standalone on the command line for non
|
38
52
|
Rails project and it can be used as a Rails plugin to add useful rake tasks and
|
39
53
|
sensible defaults.
|
40
54
|
|
41
|
-
email:
|
55
|
+
email:
|
56
|
+
- curtis@sevenforge.com
|
42
57
|
executables:
|
43
58
|
- cdnfu
|
44
59
|
extensions: []
|
@@ -46,9 +61,15 @@ extensions: []
|
|
46
61
|
extra_rdoc_files: []
|
47
62
|
|
48
63
|
files:
|
49
|
-
-
|
64
|
+
- .gitignore
|
65
|
+
- Gemfile
|
66
|
+
- Gemfile.lock
|
50
67
|
- MIT-LICENSE
|
68
|
+
- README.md
|
69
|
+
- Rakefile
|
51
70
|
- bin/cdnfu
|
71
|
+
- cdn_fu.gemspec
|
72
|
+
- lib/cdn_fu.rb
|
52
73
|
- lib/cdn_fu/config.rb
|
53
74
|
- lib/cdn_fu/config_error.rb
|
54
75
|
- lib/cdn_fu/executor.rb
|
@@ -56,41 +77,73 @@ files:
|
|
56
77
|
- lib/cdn_fu/lister.rb
|
57
78
|
- lib/cdn_fu/minifier.rb
|
58
79
|
- lib/cdn_fu/minifiers/yui_minifier.rb
|
59
|
-
- lib/cdn_fu/tasks/cdn_fu.rake
|
60
80
|
- lib/cdn_fu/tasks.rb
|
81
|
+
- lib/cdn_fu/tasks/cdn_fu.rake
|
61
82
|
- lib/cdn_fu/uploader.rb
|
62
83
|
- lib/cdn_fu/uploaders/cloudfront_uploader.rb
|
63
84
|
- lib/cdn_fu/uploaders/local_uploader.rb
|
64
|
-
- lib/cdn_fu.rb
|
85
|
+
- lib/cdn_fu/version.rb
|
65
86
|
- rails/init.rb
|
87
|
+
- test/asset_root/css/style.css
|
88
|
+
- test/asset_root/images/1.png
|
89
|
+
- test/asset_root/images/2.png
|
90
|
+
- test/asset_root/images/fun/fun.png
|
91
|
+
- test/asset_root/images/image.png
|
92
|
+
- test/asset_root/js/another.js
|
93
|
+
- test/asset_root/js/unminified.js
|
94
|
+
- test/asset_root/single/single.png
|
95
|
+
- test/basic_test.rb
|
96
|
+
- test/configs/basic_cdn_fu_config.rb
|
97
|
+
- test/configs/diff_remote_paths.rb
|
98
|
+
- test/configs/file_lister.rb
|
99
|
+
- test/configs/local_upload_config.rb
|
100
|
+
- test/local_uploader_test.rb
|
101
|
+
- test/test_helper.rb
|
66
102
|
has_rdoc: true
|
67
|
-
homepage:
|
103
|
+
homepage:
|
68
104
|
licenses: []
|
69
105
|
|
70
106
|
post_install_message:
|
71
|
-
rdoc_options:
|
72
|
-
|
73
|
-
- --charset=UTF-8
|
107
|
+
rdoc_options: []
|
108
|
+
|
74
109
|
require_paths:
|
75
110
|
- lib
|
76
111
|
required_ruby_version: !ruby/object:Gem::Requirement
|
112
|
+
none: false
|
77
113
|
requirements:
|
78
114
|
- - ">="
|
79
115
|
- !ruby/object:Gem::Version
|
116
|
+
segments:
|
117
|
+
- 0
|
80
118
|
version: "0"
|
81
|
-
version:
|
82
119
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
120
|
+
none: false
|
83
121
|
requirements:
|
84
122
|
- - ">="
|
85
123
|
- !ruby/object:Gem::Version
|
124
|
+
segments:
|
125
|
+
- 0
|
86
126
|
version: "0"
|
87
|
-
version:
|
88
127
|
requirements: []
|
89
128
|
|
90
129
|
rubyforge_project: cdn_fu
|
91
|
-
rubygems_version: 1.3.
|
130
|
+
rubygems_version: 1.3.7
|
92
131
|
signing_key:
|
93
132
|
specification_version: 3
|
94
133
|
summary: CDN Fu is a framework for making minification and deployment of static assets easy
|
95
|
-
test_files:
|
96
|
-
|
134
|
+
test_files:
|
135
|
+
- test/asset_root/css/style.css
|
136
|
+
- test/asset_root/images/1.png
|
137
|
+
- test/asset_root/images/2.png
|
138
|
+
- test/asset_root/images/fun/fun.png
|
139
|
+
- test/asset_root/images/image.png
|
140
|
+
- test/asset_root/js/another.js
|
141
|
+
- test/asset_root/js/unminified.js
|
142
|
+
- test/asset_root/single/single.png
|
143
|
+
- test/basic_test.rb
|
144
|
+
- test/configs/basic_cdn_fu_config.rb
|
145
|
+
- test/configs/diff_remote_paths.rb
|
146
|
+
- test/configs/file_lister.rb
|
147
|
+
- test/configs/local_upload_config.rb
|
148
|
+
- test/local_uploader_test.rb
|
149
|
+
- test/test_helper.rb
|