asset 0.1.0 → 0.1.1
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +2 -2
- data/asset.gemspec +2 -2
- data/lib/asset.rb +4 -1
- data/lib/assets/helpers.rb +2 -2
- data/lib/assets/router.rb +1 -5
- data/lib/assets/util.rb +9 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 479c8dc6efb7f01a5694c691ed57cc7b8c76670a
|
4
|
+
data.tar.gz: bc9b8e3a07bc3fb783c4cfb241ed10fb6bb73632
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 497dc2eca7a3fb680577b0092fd12d76105189dda0b386552a9d77a9b504205923972b9170459477b715c470d684b1b6031246868d387e8c5e6c409078817c46
|
7
|
+
data.tar.gz: 2883a55245975e3f0f54f5ee06c18bd9d8c07e29af8e3faec9c0be101d741b7f4b4725f56725f5bcff2410c76b46fc3860c267dd3bce6c874893fec49363925a
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,10 @@
|
|
1
|
+
**Version 0.1.1** - *2017-01-16*
|
2
|
+
|
3
|
+
- Moved image timestamps to startup
|
4
|
+
|
1
5
|
**Version 0.1.0** - *2017-01-07*
|
2
6
|
|
7
|
+
- Renamed application.js/css to bundle.js/css
|
3
8
|
- Options added for robots.txt and favicon.ico
|
4
9
|
- Compress and bundle options are working
|
5
10
|
- Fixed caching issue
|
data/README.md
CHANGED
@@ -68,7 +68,7 @@ js:
|
|
68
68
|
- lib/cookie.js
|
69
69
|
```
|
70
70
|
|
71
|
-
```
|
71
|
+
```erb
|
72
72
|
# After setting up the manifest file, use the helpers in your views
|
73
73
|
<%= script_tag 'app.js' %>
|
74
74
|
<%= style_tag 'app.css' %>
|
@@ -85,7 +85,7 @@ js:
|
|
85
85
|
|
86
86
|
In development mode, all files will be printed. In production mode, you'll get only one file.
|
87
87
|
|
88
|
-
The file will also be cached and compressed. The cache auto-expires.
|
88
|
+
The file will also be cached and compressed. The cache auto-expires, but if you're storing the cache on disk you can clean it with a cron job.
|
89
89
|
|
90
90
|
### Middleware
|
91
91
|
|
data/asset.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'asset'
|
3
|
-
s.version = '0.1.
|
4
|
-
s.date = '2017-01-
|
3
|
+
s.version = '0.1.1'
|
4
|
+
s.date = '2017-01-16'
|
5
5
|
s.summary = "Compress and serve your CSS and JS automatically"
|
6
6
|
s.description = "The only thing you need for your assets."
|
7
7
|
s.authors = ["Fugroup Limited"]
|
data/lib/asset.rb
CHANGED
@@ -8,7 +8,7 @@ autoload :Tilt, 'tilt'
|
|
8
8
|
# @author: Vidar <vidar@fugroup.net>, Fugroup Ltd.
|
9
9
|
# @license: MIT, contributions are welcome.
|
10
10
|
module Asset
|
11
|
-
class << self; attr_accessor :mode, :path, :cache, :favicon, :robots, :manifest, :debug; end
|
11
|
+
class << self; attr_accessor :mode, :path, :cache, :favicon, :robots, :manifest, :images, :debug; end
|
12
12
|
|
13
13
|
# Default is development
|
14
14
|
@mode = ENV['RACK_ENV'] || 'development'
|
@@ -35,5 +35,8 @@ require_relative 'assets/item'
|
|
35
35
|
# Load the manifest
|
36
36
|
::Asset.manifest = ::Asset::Util.load_manifest
|
37
37
|
|
38
|
+
# Load the images
|
39
|
+
::Asset.images = ::Asset::Util.load_images
|
40
|
+
|
38
41
|
require_relative 'assets/helpers'
|
39
42
|
require_relative 'assets/router'
|
data/lib/assets/helpers.rb
CHANGED
@@ -17,8 +17,8 @@ module Asset
|
|
17
17
|
|
18
18
|
# Image tags
|
19
19
|
def image_tag(path)
|
20
|
-
b = ::Asset
|
21
|
-
%{<img src="/assets/images/#{CGI.escapeHTML(path)}#{b ? "?#{b
|
20
|
+
b = ::Asset.images[path] rescue nil
|
21
|
+
%{<img src="/assets/images/#{CGI.escapeHTML(path)}#{b ? "?#{b}" : ''}">} rescue path
|
22
22
|
end
|
23
23
|
|
24
24
|
private
|
data/lib/assets/router.rb
CHANGED
@@ -2,11 +2,7 @@ module Asset
|
|
2
2
|
class Router
|
3
3
|
|
4
4
|
# Mime types
|
5
|
-
MIME = {
|
6
|
-
'js' => 'application/javascript; charset=UTF-8',
|
7
|
-
'css' => 'text/css; charset=UTF-8',
|
8
|
-
'txt' => 'text/plain; charset=UTF-8'
|
9
|
-
}
|
5
|
+
MIME = {'js' => 'application/javascript; charset=UTF-8', 'css' => 'text/css; charset=UTF-8', 'txt' => 'text/plain; charset=UTF-8'}
|
10
6
|
|
11
7
|
# Init
|
12
8
|
def initialize(app)
|
data/lib/assets/util.rb
CHANGED
@@ -51,5 +51,14 @@ module Asset
|
|
51
51
|
manifest
|
52
52
|
end
|
53
53
|
|
54
|
+
# Load images into memory
|
55
|
+
def self.load_images
|
56
|
+
# Store the path and the timestamp
|
57
|
+
images = Dir["#{::Asset.path}/images/**/*"].select{|f| File.file?(f)}.map do |i|
|
58
|
+
i =~ /\/images\/(.+)/; [$1, mtime("images/#{$1}").to_i]
|
59
|
+
end
|
60
|
+
Hash[*images.flatten]
|
61
|
+
end
|
62
|
+
|
54
63
|
end
|
55
64
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: asset
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fugroup Limited
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-01-
|
11
|
+
date: 2017-01-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|