sprockets 2.2.0.beta → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of sprockets might be problematic. Click here for more details.

@@ -64,12 +64,17 @@ OptionParser.new do |opts|
64
64
  end
65
65
  end
66
66
 
67
- environment.append_path(".")
67
+ if environment.paths.empty?
68
+ warn "No load paths given"
69
+ warn "Usage: sprockets -Ijavascripts/ filename"
70
+ exit 1
71
+ end
68
72
 
69
73
  if manifest
70
74
  manifest.compile(filenames)
75
+ elsif filenames.length == 1
76
+ puts environment.find_asset(filenames.first).to_s
71
77
  else
72
- filenames.each do |filename|
73
- puts environment.find_asset(filename).to_s
74
- end
78
+ warn "Only one file can be compiled to stdout at a time"
79
+ exit 1
75
80
  end
@@ -49,6 +49,9 @@ module Rake
49
49
  #
50
50
  attr_accessor :assets
51
51
 
52
+ # Number of old assets to keep.
53
+ attr_accessor :keep
54
+
52
55
  # Logger to use during rake tasks. Defaults to using stderr.
53
56
  #
54
57
  # t.logger = Logger.new($stdout)
@@ -77,7 +80,8 @@ module Rake
77
80
  @name = name
78
81
  @environment = lambda { Sprockets::Environment.new(Dir.pwd) }
79
82
  @logger = Logger.new($stderr)
80
- @logger.level = Logger::WARN
83
+ @logger.level = Logger::INFO
84
+ @keep = 2
81
85
 
82
86
  yield self if block_given?
83
87
 
@@ -105,7 +109,7 @@ module Rake
105
109
  desc name == :assets ? "Clean old assets" : "Clean old #{name} assets"
106
110
  task "clean_#{name}" do
107
111
  with_logger do
108
- manifest.clean
112
+ manifest.clean(keep)
109
113
  end
110
114
  end
111
115
 
@@ -179,7 +179,9 @@ module Sprockets
179
179
  result = options[:data]
180
180
  else
181
181
  if environment.respond_to?(:default_external_encoding)
182
- result = Sprockets::Utils.read_unicode(pathname, environment.default_external_encoding)
182
+ mime_type = environment.mime_types(pathname.extname)
183
+ encoding = environment.encoding_for_mime_type(mime_type)
184
+ result = Sprockets::Utils.read_unicode(pathname, encoding)
183
185
  else
184
186
  result = Sprockets::Utils.read_unicode(pathname)
185
187
  end
@@ -260,7 +260,7 @@ module Sprockets
260
260
  root = pathname.dirname.join(path).expand_path
261
261
 
262
262
  unless (stats = stat(root)) && stats.directory?
263
- raise ArgumentError, "require_tree argument must be a directory"
263
+ raise ArgumentError, "require_directory argument must be a directory"
264
264
  end
265
265
 
266
266
  context.depend_on(root)
@@ -30,6 +30,16 @@ module Sprockets
30
30
  ext = Sprockets::Utils.normalize_extension(ext)
31
31
  @mime_types[ext] = mime_type
32
32
  end
33
+
34
+ if defined? Encoding
35
+ # Returns the correct encoding for a given mime type, while falling
36
+ # back on the default external encoding, if it exists.
37
+ def encoding_for_mime_type(type)
38
+ encoding = Encoding::BINARY if type =~ %r{^(image|audio|video)/}
39
+ encoding ||= default_external_encoding if respond_to?(:default_external_encoding)
40
+ encoding
41
+ end
42
+ end
33
43
  end
34
44
 
35
45
  # Extend Sprockets module to provide global registry
@@ -1,3 +1,3 @@
1
1
  module Sprockets
2
- VERSION = "2.2.0.beta"
2
+ VERSION = "2.2.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sprockets
3
3
  version: !ruby/object:Gem::Version
4
- hash: 31098225
5
- prerelease: 6
4
+ hash: 7
5
+ prerelease:
6
6
  segments:
7
7
  - 2
8
8
  - 2
9
9
  - 0
10
- - beta
11
- version: 2.2.0.beta
10
+ version: 2.2.0
12
11
  platform: ruby
13
12
  authors:
14
13
  - Sam Stephenson
@@ -17,7 +16,7 @@ autorequire:
17
16
  bindir: bin
18
17
  cert_chain: []
19
18
 
20
- date: 2011-12-16 00:00:00 -06:00
19
+ date: 2012-01-10 00:00:00 -06:00
21
20
  default_executable:
22
21
  dependencies:
23
22
  - !ruby/object:Gem::Dependency
@@ -104,22 +103,23 @@ dependencies:
104
103
  type: :development
105
104
  version_requirements: *id005
106
105
  - !ruby/object:Gem::Dependency
107
- name: eco
106
+ name: coffee-script-source
108
107
  prerelease: false
109
108
  requirement: &id006 !ruby/object:Gem::Requirement
110
109
  none: false
111
110
  requirements:
112
111
  - - ~>
113
112
  - !ruby/object:Gem::Version
114
- hash: 15
113
+ hash: 31
115
114
  segments:
116
115
  - 1
116
+ - 2
117
117
  - 0
118
- version: "1.0"
118
+ version: 1.2.0
119
119
  type: :development
120
120
  version_requirements: *id006
121
121
  - !ruby/object:Gem::Dependency
122
- name: ejs
122
+ name: eco
123
123
  prerelease: false
124
124
  requirement: &id007 !ruby/object:Gem::Requirement
125
125
  none: false
@@ -134,7 +134,7 @@ dependencies:
134
134
  type: :development
135
135
  version_requirements: *id007
136
136
  - !ruby/object:Gem::Dependency
137
- name: execjs
137
+ name: ejs
138
138
  prerelease: false
139
139
  requirement: &id008 !ruby/object:Gem::Requirement
140
140
  none: false
@@ -149,21 +149,22 @@ dependencies:
149
149
  type: :development
150
150
  version_requirements: *id008
151
151
  - !ruby/object:Gem::Dependency
152
- name: json
152
+ name: execjs
153
153
  prerelease: false
154
154
  requirement: &id009 !ruby/object:Gem::Requirement
155
155
  none: false
156
156
  requirements:
157
- - - ">="
157
+ - - ~>
158
158
  - !ruby/object:Gem::Version
159
- hash: 3
159
+ hash: 15
160
160
  segments:
161
+ - 1
161
162
  - 0
162
- version: "0"
163
+ version: "1.0"
163
164
  type: :development
164
165
  version_requirements: *id009
165
166
  - !ruby/object:Gem::Dependency
166
- name: rack-test
167
+ name: json
167
168
  prerelease: false
168
169
  requirement: &id010 !ruby/object:Gem::Requirement
169
170
  none: false
@@ -177,7 +178,7 @@ dependencies:
177
178
  type: :development
178
179
  version_requirements: *id010
179
180
  - !ruby/object:Gem::Dependency
180
- name: rake
181
+ name: rack-test
181
182
  prerelease: false
182
183
  requirement: &id011 !ruby/object:Gem::Requirement
183
184
  none: false
@@ -190,6 +191,20 @@ dependencies:
190
191
  version: "0"
191
192
  type: :development
192
193
  version_requirements: *id011
194
+ - !ruby/object:Gem::Dependency
195
+ name: rake
196
+ prerelease: false
197
+ requirement: &id012 !ruby/object:Gem::Requirement
198
+ none: false
199
+ requirements:
200
+ - - ">="
201
+ - !ruby/object:Gem::Version
202
+ hash: 3
203
+ segments:
204
+ - 0
205
+ version: "0"
206
+ type: :development
207
+ version_requirements: *id012
193
208
  description: Sprockets is a Rack-based asset packaging system that concatenates and serves JavaScript, CoffeeScript, CSS, LESS, Sass, and SCSS.
194
209
  email:
195
210
  - sstephenson@gmail.com
@@ -254,14 +269,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
254
269
  required_rubygems_version: !ruby/object:Gem::Requirement
255
270
  none: false
256
271
  requirements:
257
- - - ">"
272
+ - - ">="
258
273
  - !ruby/object:Gem::Version
259
- hash: 25
274
+ hash: 3
260
275
  segments:
261
- - 1
262
- - 3
263
- - 1
264
- version: 1.3.1
276
+ - 0
277
+ version: "0"
265
278
  requirements: []
266
279
 
267
280
  rubyforge_project: sprockets