Skip to content

Commit d34a2d0

Browse files
committed
Move some deprecated asset methods to legacy
1 parent 645482e commit d34a2d0

File tree

2 files changed

+49
-46
lines changed

2 files changed

+49
-46
lines changed

lib/sprockets/asset.rb

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,6 @@ def to_hash
4949
# Public: Returns String path of asset.
5050
attr_reader :filename
5151

52-
# Deprecated: Use #filename instead.
53-
#
54-
# Returns Pathname.
55-
def pathname
56-
@pathname ||= Pathname.new(filename)
57-
end
58-
5952
# Internal: Unique asset object ID.
6053
#
6154
# Returns a String.
@@ -97,36 +90,6 @@ def included
9790
metadata[:included]
9891
end
9992

100-
# Deprecated: Expand asset into an `Array` of parts.
101-
#
102-
# Appending all of an assets body parts together should give you
103-
# the asset's contents as a whole.
104-
#
105-
# This allows you to link to individual files for debugging
106-
# purposes.
107-
#
108-
# Use Asset#included instead. Keeping a full copy of the bundle's processed
109-
# assets in memory (and in cache) is expensive and redundant. The common use
110-
# case is to relink to the assets anyway.
111-
#
112-
# Returns Array of Assets.
113-
def to_a
114-
if metadata[:included]
115-
metadata[:included].map { |uri| @environment.load(uri) }
116-
else
117-
[self]
118-
end
119-
end
120-
121-
# Deprecated: Get all required Assets.
122-
#
123-
# See Asset#to_a
124-
#
125-
# Returns Array of Assets.
126-
def dependencies
127-
to_a.reject { |a| a.filename.eql?(self.filename) }
128-
end
129-
13093
# Public: Return `String` of concatenated source.
13194
#
13295
# Returns String.
@@ -159,15 +122,6 @@ def length
159122
end
160123
alias_method :bytesize, :length
161124

162-
# Deprecated: Returns Time of the last time the source was modified.
163-
#
164-
# Time resolution is normalized to the nearest second.
165-
#
166-
# Returns Time.
167-
def mtime
168-
Time.at(@mtime)
169-
end
170-
171125
# Public: Returns String hexdigest of source.
172126
def hexdigest
173127
DigestUtils.pack_hexdigest(metadata[:digest])

lib/sprockets/legacy.rb

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
require 'sprockets/asset'
12
require 'sprockets/context'
23
require 'sprockets/manifest'
34
require 'sprockets/resolve'
@@ -155,6 +156,54 @@ def unescape(str)
155156
end
156157
end
157158

159+
class Asset
160+
# Deprecated: Use #filename instead.
161+
#
162+
# Returns Pathname.
163+
def pathname
164+
@pathname ||= Pathname.new(filename)
165+
end
166+
167+
# Deprecated: Expand asset into an `Array` of parts.
168+
#
169+
# Appending all of an assets body parts together should give you
170+
# the asset's contents as a whole.
171+
#
172+
# This allows you to link to individual files for debugging
173+
# purposes.
174+
#
175+
# Use Asset#included instead. Keeping a full copy of the bundle's processed
176+
# assets in memory (and in cache) is expensive and redundant. The common use
177+
# case is to relink to the assets anyway.
178+
#
179+
# Returns Array of Assets.
180+
def to_a
181+
if metadata[:included]
182+
metadata[:included].map { |uri| @environment.load(uri) }
183+
else
184+
[self]
185+
end
186+
end
187+
188+
# Deprecated: Get all required Assets.
189+
#
190+
# See Asset#to_a
191+
#
192+
# Returns Array of Assets.
193+
def dependencies
194+
to_a.reject { |a| a.filename.eql?(self.filename) }
195+
end
196+
197+
# Deprecated: Returns Time of the last time the source was modified.
198+
#
199+
# Time resolution is normalized to the nearest second.
200+
#
201+
# Returns Time.
202+
def mtime
203+
Time.at(@mtime)
204+
end
205+
end
206+
158207
class Context
159208
# Deprecated: Change default return type of resolve() to return 2.x
160209
# compatible plain filename String. 4.x will always return an Asset URI.

0 commit comments

Comments
 (0)