ro 1.4.2 → 1.4.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/ro.rb +1 -1
- data/lib/ro/node.rb +54 -31
- data/notes/ara.txt +2 -0
- data/ro.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MWE0ZWVlNDk0Nzc1YzRlMTcyNGNkYmViMWI1YmExMzYzYTE0YzU0NA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YWU4YjhhY2Y1ZWYyY2EwOTJjODQwOTlmNTZhZDkyZDcwZjhmZmQ0Nw==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NDk4YzE1Yzc1NDM0MTJjY2QyOWM5NTU4NmM4OThlZjJmOGE1NDc3NTZkMmUz
|
10
|
+
Yjk1YmQyZTNhMTE4YTRjNjE4ZjQ1OTBiZTllYjYwZTY5ZDVhNTNhMzZhOTI1
|
11
|
+
YzFiOTlmNDQ3ZDVmN2I5ODNlNzEwYjU2OGE2NDZmNTdmZDQyZWU=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
N2IxNjJlNjhhMWM3YjYyNTBhNDVhZWUyMTlkYTRmN2RmNzhmMmE2ODAwYmFm
|
14
|
+
NjRiMDQwYjg4YWFkNjIxM2YxMTM0MGVjMzI4YWNlYzFkYjUzMjM2NzY5ZmZm
|
15
|
+
NTZhMDFmZTdhZGZmNDdlYmRlMjk2ODQ0YjZlMzRmNzAxZDQ4NWQ=
|
data/lib/ro.rb
CHANGED
data/lib/ro/node.rb
CHANGED
@@ -101,7 +101,8 @@ module Ro
|
|
101
101
|
def assets
|
102
102
|
asset_paths.map do |path|
|
103
103
|
name = path.sub(asset_dir + "/", "")
|
104
|
-
|
104
|
+
path_info = path.gsub(/^#{ Regexp.escape(Ro.root) }/, '')
|
105
|
+
url = File.join(Ro.route, path_info)
|
105
106
|
Asset.new(name, :path => path, :url => url)
|
106
107
|
end
|
107
108
|
end
|
@@ -110,6 +111,45 @@ module Ro
|
|
110
111
|
assets.map(&:url)
|
111
112
|
end
|
112
113
|
|
114
|
+
def asset_for(*args, &block)
|
115
|
+
options = Map.options_for!(args)
|
116
|
+
|
117
|
+
path_info = Ro.relative_path_for(args)
|
118
|
+
|
119
|
+
path = File.join(@path.to_s, 'assets', path_info)
|
120
|
+
|
121
|
+
glob = path_info.gsub(/[_-]/, '[_-]')
|
122
|
+
|
123
|
+
globs =
|
124
|
+
[
|
125
|
+
File.join(@path.to_s, 'assets', "#{ glob }"),
|
126
|
+
File.join(@path.to_s, 'assets', "#{ glob }*"),
|
127
|
+
File.join(@path.to_s, 'assets', "**/#{ glob }")
|
128
|
+
]
|
129
|
+
|
130
|
+
candidates = globs.map{|glob| Dir.glob(glob, ::File::FNM_CASEFOLD)}.flatten.compact.uniq
|
131
|
+
|
132
|
+
case candidates.size
|
133
|
+
when 0
|
134
|
+
raise ArgumentError.new("no asset matching #{ globs.inspect }")
|
135
|
+
else
|
136
|
+
path = candidates.first
|
137
|
+
name = path.sub(asset_dir + "/", "")
|
138
|
+
path_info = path.gsub(/^#{ Regexp.escape(Ro.root) }/, '')
|
139
|
+
url = File.join(Ro.route, path_info)
|
140
|
+
end
|
141
|
+
|
142
|
+
Asset.new(name, :path => path, :url => url)
|
143
|
+
end
|
144
|
+
|
145
|
+
def asset_for?(*args, &block)
|
146
|
+
begin
|
147
|
+
asset_for(*args, &block)
|
148
|
+
rescue
|
149
|
+
nil
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
113
153
|
class Asset < ::String
|
114
154
|
fattr(:path)
|
115
155
|
fattr(:url)
|
@@ -141,44 +181,27 @@ module Ro
|
|
141
181
|
def url_for(*args, &block)
|
142
182
|
options = Map.options_for!(args)
|
143
183
|
|
144
|
-
|
184
|
+
opts = Map.new
|
145
185
|
|
146
|
-
|
186
|
+
opts[:timestamp] = options.delete(:timestamp)
|
147
187
|
|
148
|
-
|
188
|
+
args.push(options)
|
149
189
|
|
150
|
-
|
190
|
+
asset = asset_for(*args, &block)
|
151
191
|
|
152
|
-
|
153
|
-
|
154
|
-
File.
|
155
|
-
File.join(@path.to_s, 'assets', "#{ glob }*"),
|
156
|
-
File.join(@path.to_s, 'assets', "**/#{ glob }")
|
157
|
-
]
|
158
|
-
|
159
|
-
candidates = globs.map{|glob| Dir.glob(glob, ::File::FNM_CASEFOLD)}.flatten.compact.uniq
|
160
|
-
|
161
|
-
case candidates.size
|
162
|
-
when 0
|
163
|
-
raise ArgumentError.new("no asset matching #{ globs.inspect }")
|
192
|
+
if ts = opts.delete(:timestamp)
|
193
|
+
if ts == true
|
194
|
+
opts[:_] = File.stat(asset.path).mtime.utc.to_i
|
164
195
|
else
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
if timestamp
|
169
|
-
#options['_'] = Ro.md5(IO.binread(path))
|
170
|
-
timestamp = File.stat(path).mtime.utc.to_i
|
171
|
-
options['_'] = timestamp
|
172
|
-
end
|
196
|
+
opts[:_] = ts
|
197
|
+
end
|
173
198
|
end
|
174
199
|
|
175
|
-
|
176
|
-
|
177
|
-
if options.empty?
|
178
|
-
url
|
200
|
+
if opts.empty?
|
201
|
+
asset.url
|
179
202
|
else
|
180
|
-
query_string = Ro.query_string_for(
|
181
|
-
"#{ url }?#{ query_string }"
|
203
|
+
query_string = Ro.query_string_for(opts)
|
204
|
+
"#{ asset.url }?#{ query_string }"
|
182
205
|
end
|
183
206
|
end
|
184
207
|
|
data/notes/ara.txt
CHANGED
data/ro.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ro
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ara T. Howard
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-02-
|
11
|
+
date: 2014-02-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: map
|