front-end-blender 0.6.0 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/README +1 -1
  2. data/bin/blend +21 -17
  3. metadata +3 -3
data/README CHANGED
@@ -50,7 +50,7 @@ For help use: blend -h
50
50
  -f <file>, --file <file> Use given Blendfile
51
51
  -t <css|js>, --type <css|js> Compress CSS or JavaScript only
52
52
  -d, --data Convert CSS url(image.ext) to url(data:) EXPERIMENTAL
53
- -F, --force Force file minification when there are no new updates
53
+ --force Force file minification when there are no new updates
54
54
 
55
55
  == Installation
56
56
 
data/bin/blend CHANGED
@@ -17,7 +17,7 @@ require 'find'
17
17
 
18
18
  # TODO Move class to lib so other tools could potentially reuse it
19
19
  class Blender
20
- VERSION = '0.5.3'
20
+ VERSION = '0.6.1'
21
21
 
22
22
  attr_reader :options
23
23
 
@@ -94,7 +94,7 @@ class Blender
94
94
  end
95
95
 
96
96
  opts.on("-d", "--data", String, "Change url(image.ext) to url(data:) in css files") { @options.data = true }
97
- opts.on("-F", "--force", String, "Force minification when source files aren't newer than min files") { @options.force = true }
97
+ opts.on("--force", String, "Force minification when source files aren't newer than output files") { @options.force = true }
98
98
  opts.on("--generate", String, "Generate a blendfile") { create_blendfile() }
99
99
  opts.parse!(@arguments) rescue return false
100
100
 
@@ -102,7 +102,13 @@ class Blender
102
102
  end
103
103
 
104
104
  def create_blendfile()
105
+ if File.exists?(@options.blendfile) && !@options.force
106
+ puts "'#{@options.blendfile}' already exists"
107
+ exit 1
108
+ end
109
+
105
110
  blend_files = Hash.new
111
+
106
112
  Find.find(Dir.getwd) do |f|
107
113
  if f.match /\.css$/
108
114
  key = File.dirname(f) + "-min.css"
@@ -112,7 +118,7 @@ class Blender
112
118
  blend_files[key] = [f]
113
119
  end
114
120
  end
115
-
121
+
116
122
  if f.match /\.js$/
117
123
  key = File.dirname(f) + "-min.js"
118
124
  if blend_files.has_key? key
@@ -121,14 +127,12 @@ class Blender
121
127
  blend_files[key] = [f]
122
128
  end
123
129
  end
124
-
125
- Find.prune if f=~ /.svn/
126
- end
127
130
 
128
- if !File.exists? 'blender.yaml' || @options.force
129
- File.open('blender.yaml', 'w') {|f| YAML.dump(blend_files, f)}
131
+ Find.prune if File.basename(f).index('.') == 0 # TODO Ignore all files in any dot folder
130
132
  end
131
133
 
134
+ File.open(@options.blendfile, 'w') { |f| YAML.dump(blend_files, f) }
135
+
132
136
  exit 0
133
137
  end
134
138
 
@@ -139,39 +143,39 @@ class Blender
139
143
  inputs.each do |i|
140
144
  output += IO.read(i)
141
145
  end
142
-
146
+
143
147
  # Compress
144
148
  real_file = File.symlink?(__FILE__) ? File.readlink(__FILE__) : __FILE__
145
-
149
+
146
150
  IO.popen("java -jar #{File.dirname(real_file)}/../lib/yuicompressor.jar #{@passthrough} --type #{type}", mode="r+") do |io|
147
151
  io.write output
148
152
  io.close_write
149
-
153
+
150
154
  output = io.read
151
155
  # TODO Move this to before the file gets written
152
156
  # Workaround for YUI Compressor Bug #1938329 & Bug #1961175
153
157
  if output_name.match /\.css$/
154
-
158
+
155
159
  output.gsub! ' and(', ' and ('
156
160
  output.gsub! '/**/;}', '/**/}'
157
-
161
+
158
162
  if @options.data
159
163
  output = output.gsub(/url\(['"]?([^?']+)['"]+\)/im) do
160
164
  uri = $1
161
165
  mime_type = ''
162
-
166
+
163
167
  # Make the URI absolute instead of relative. TODO Seems kinda hacky is there a better way?
164
168
  uri.gsub! "../", ""
165
-
169
+
166
170
  # Figure out the mime type.
167
171
  mime_type = MIME::Types.type_for(uri)
168
172
 
169
173
  url_contents = make_data_uri(IO.read(uri), mime_type[0])
170
-
174
+
171
175
  %Q!url("#{url_contents}")!
172
176
  end
173
177
  end
174
-
178
+
175
179
  output_file << output
176
180
  end
177
181
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: front-end-blender
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Blake Elshire & Chris Griego
@@ -9,8 +9,8 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-05-21 00:00:00 -07:00
13
- default_executable:
12
+ date: 2008-05-22 00:00:00 -07:00
13
+ default_executable: blend
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: mime-types