front-end-blender 0.8.2 → 0.8.3
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/bin/blend +1 -1
- metadata +4 -6
- data/lib/front_end_architect/blender.rb +0 -159
- data/lib/yui/LICENSE +0 -30
- data/lib/yui/yuicompressor.jar +0 -0
data/bin/blend
CHANGED
metadata
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: front-end-blender
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Blake Elshire & Chris Griego
|
8
|
-
autorequire:
|
8
|
+
autorequire: front_end_architect/blend
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
@@ -32,10 +32,8 @@ extra_rdoc_files: []
|
|
32
32
|
files:
|
33
33
|
- README
|
34
34
|
- MIT-LICENSE
|
35
|
-
- bin
|
36
|
-
- lib
|
37
|
-
- lib/yui/yuicompressor.jar
|
38
|
-
- lib/yui/LICENSE
|
35
|
+
- bin/*
|
36
|
+
- lib/**/*
|
39
37
|
has_rdoc: false
|
40
38
|
homepage: http://github.com/front-end/front-end-blender/tree/master
|
41
39
|
post_install_message:
|
@@ -1,159 +0,0 @@
|
|
1
|
-
# Copyright (c) 2008 Chris Griego
|
2
|
-
# (c) 2008 Blake Elshire
|
3
|
-
#
|
4
|
-
# Blender is freely distributable under the terms of an MIT-style license.
|
5
|
-
# For details, see http://www.opensource.org/licenses/mit-license.php
|
6
|
-
|
7
|
-
require 'rubygems'
|
8
|
-
require 'yaml'
|
9
|
-
require 'base64'
|
10
|
-
require 'benchmark'
|
11
|
-
require 'mime/types'
|
12
|
-
require 'find'
|
13
|
-
|
14
|
-
class Blender
|
15
|
-
VERSION = '0.8.2'
|
16
|
-
|
17
|
-
DEFAULT_OPTIONS = {
|
18
|
-
:blendfile => 'blender.yaml',
|
19
|
-
:data => false,
|
20
|
-
:force => false,
|
21
|
-
}
|
22
|
-
|
23
|
-
attr_reader :options
|
24
|
-
|
25
|
-
def initialize(opts)
|
26
|
-
@options = DEFAULT_OPTIONS.merge(opts)
|
27
|
-
end
|
28
|
-
|
29
|
-
def blend
|
30
|
-
if @options[:generate]
|
31
|
-
create_blendfile
|
32
|
-
end
|
33
|
-
|
34
|
-
elapsed = Benchmark.realtime do
|
35
|
-
unless File.exists? @options[:blendfile]
|
36
|
-
puts "Couldn't find '#{@options[:blendfile]}'"
|
37
|
-
exit 1
|
38
|
-
end
|
39
|
-
|
40
|
-
blender = YAML::load_file @options[:blendfile]
|
41
|
-
|
42
|
-
Dir.chdir(File.dirname(@options[:blendfile]))
|
43
|
-
|
44
|
-
blender.each do |output_name, sources|
|
45
|
-
output_new = false
|
46
|
-
|
47
|
-
# Checks the type flag and if the current file meets the type requirements continues
|
48
|
-
if output_name.match "." + @options[:file_type].to_s
|
49
|
-
file_type = output_name.match(/\.css/) ? "css" : "js"
|
50
|
-
|
51
|
-
# Checks if output file exists and checks the mtimes of the source files to the output file if new creates a new file
|
52
|
-
if File.exists? output_name
|
53
|
-
sources.each do |i|
|
54
|
-
if File.mtime(i) > File.mtime(output_name)
|
55
|
-
output_new = true
|
56
|
-
break
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
if output_new || @options[:force]
|
61
|
-
create_output(output_name, sources, file_type)
|
62
|
-
else
|
63
|
-
puts "Skipping: #{output_name}"
|
64
|
-
end
|
65
|
-
else
|
66
|
-
create_output(output_name, sources, file_type)
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
puts sprintf("%.5f", elapsed) + " seconds"
|
73
|
-
end
|
74
|
-
|
75
|
-
protected
|
76
|
-
|
77
|
-
def create_blendfile
|
78
|
-
if File.exists?(@options[:blendfile]) && !@options[:force]
|
79
|
-
puts "'#{@options[:blendfile]}' already exists"
|
80
|
-
exit 1
|
81
|
-
end
|
82
|
-
|
83
|
-
blend_files = Hash.new
|
84
|
-
|
85
|
-
Find.find(Dir.getwd) do |f|
|
86
|
-
f.gsub!(Dir.getwd.to_s+"/", "")
|
87
|
-
if File.extname(f) == ".css"
|
88
|
-
file = f.split(".css")
|
89
|
-
min_file = file[0] + "-min.css"
|
90
|
-
blend_files[f] = [min_file]
|
91
|
-
end
|
92
|
-
|
93
|
-
if File.extname(f) == ".js"
|
94
|
-
file = f.split(".js")
|
95
|
-
min_file = file[0] + "-min.js"
|
96
|
-
blend_files[f] = [min_file]
|
97
|
-
end
|
98
|
-
|
99
|
-
Find.prune if File.basename(f).index('.') == 0
|
100
|
-
end
|
101
|
-
|
102
|
-
File.open(@options[:blendfile], 'w') { |f| YAML.dump(blend_files, f) }
|
103
|
-
|
104
|
-
exit 0
|
105
|
-
end
|
106
|
-
|
107
|
-
# TODO Change to work with directory hashes (css/: [ colors.css, layout.css ])
|
108
|
-
def create_output(output_name, sources, type)
|
109
|
-
File.open(output_name, 'w') do |output_file|
|
110
|
-
output = ''
|
111
|
-
|
112
|
-
sources.each do |i|
|
113
|
-
output << IO.read(i)
|
114
|
-
end
|
115
|
-
|
116
|
-
# Compress
|
117
|
-
libdir = File.join(File.dirname(File.symlink?(__FILE__) ? File.readlink(__FILE__) : __FILE__), *%w[.. .. lib])
|
118
|
-
|
119
|
-
IO.popen("java -jar #{libdir}/yui/yuicompressor.jar #{@options[:yuiopts]} --type #{type}", mode="r+") do |io|
|
120
|
-
io.write output
|
121
|
-
io.close_write
|
122
|
-
|
123
|
-
output = io.read
|
124
|
-
|
125
|
-
if File.extname(output_name) == ".css"
|
126
|
-
output.gsub! ' and(', ' and (' # Workaround for YUI Compressor Bug #1938329
|
127
|
-
output.gsub! '/**/;}', '/**/}' # Workaround for YUI Compressor Bug #1961175
|
128
|
-
|
129
|
-
if @options[:data]
|
130
|
-
output = output.gsub(/url\(['"]?([^?']+)['"]+\)/im) do
|
131
|
-
uri = $1
|
132
|
-
mime_type = ''
|
133
|
-
|
134
|
-
# Make the URI absolute instead of relative. TODO Seems kinda hacky is there a better way?
|
135
|
-
uri.gsub! "../", ""
|
136
|
-
|
137
|
-
# Figure out the mime type.
|
138
|
-
mime_type = MIME::Types.type_for(uri)
|
139
|
-
|
140
|
-
url_contents = make_data_uri(IO.read(uri), mime_type[0])
|
141
|
-
|
142
|
-
%Q!url("#{url_contents}")!
|
143
|
-
end
|
144
|
-
end
|
145
|
-
end
|
146
|
-
|
147
|
-
output_file << output
|
148
|
-
end
|
149
|
-
end
|
150
|
-
|
151
|
-
puts output_name
|
152
|
-
end
|
153
|
-
|
154
|
-
def make_data_uri(content, content_type)
|
155
|
-
content = Base64.encode64(content)
|
156
|
-
uri = "data:#{content_type};base64,#{content}"
|
157
|
-
uri.gsub("\n", '')
|
158
|
-
end
|
159
|
-
end
|
data/lib/yui/LICENSE
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
Software License Agreement (BSD License)
|
2
|
-
|
3
|
-
Copyright (c) 2008, Yahoo! Inc.
|
4
|
-
All rights reserved.
|
5
|
-
|
6
|
-
Redistribution and use of this software in source and binary forms, with or without modification, are
|
7
|
-
permitted provided that the following conditions are met:
|
8
|
-
|
9
|
-
* Redistributions of source code must retain the above
|
10
|
-
copyright notice, this list of conditions and the
|
11
|
-
following disclaimer.
|
12
|
-
|
13
|
-
* Redistributions in binary form must reproduce the above
|
14
|
-
copyright notice, this list of conditions and the
|
15
|
-
following disclaimer in the documentation and/or other
|
16
|
-
materials provided with the distribution.
|
17
|
-
|
18
|
-
* Neither the name of Yahoo! Inc. nor the names of its
|
19
|
-
contributors may be used to endorse or promote products
|
20
|
-
derived from this software without specific prior
|
21
|
-
written permission of Yahoo! Inc.
|
22
|
-
|
23
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
|
24
|
-
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
25
|
-
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
26
|
-
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
27
|
-
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
28
|
-
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
29
|
-
TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
30
|
-
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
data/lib/yui/yuicompressor.jar
DELETED
Binary file
|