asset 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +4 -0
- data/CHANGELOG.md +3 -0
- data/Gemfile +9 -0
- data/LICENSE +21 -0
- data/README.md +134 -0
- data/app.rb +52 -0
- data/asset.gemspec +32 -0
- data/config.ru +21 -0
- data/lib/asset.rb +5 -4
- data/lib/assets/helpers.rb +40 -0
- data/lib/assets/item.rb +67 -0
- data/lib/assets/router.rb +76 -0
- data/lib/assets/util.rb +55 -0
- metadata +184 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4cd9e5084290d4157c2f2c45785bbc5813256273
|
4
|
+
data.tar.gz: 46b793da9b9774e454134f193036381d03e459f5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bd153573b90fbc422dadf116410462db9f06b8cbab3b0a3b6d5985d54d88b93e375819593c552d73456f41393180a9344fcab1eb215eadb5d6629bbbf62c2cb9
|
7
|
+
data.tar.gz: b73c59885ceacc7fcc72aa4b628c76a816ff31e62112bf65227a41d9f03eec3da89c67f80dbfb55b9d474ec51bc29383ebb27390a51589f3e8bf504255ac3e76
|
data/.gitignore
ADDED
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2016 Fugroup
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,134 @@
|
|
1
|
+
# Asset compresses and serves your CSS and JS files
|
2
|
+
|
3
|
+
Compress and cache your Javascript and CSS files automatically.
|
4
|
+
|
5
|
+
Set up your manifest file, install the helpers and the middleware, and you're up and running with compressed assets served lightning fast on pure in-memory Ruby Rack.
|
6
|
+
|
7
|
+
### Installation
|
8
|
+
```
|
9
|
+
gem install asset
|
10
|
+
```
|
11
|
+
or add to Gemfile. In your Rack app include the line
|
12
|
+
```ruby
|
13
|
+
# Rack apps
|
14
|
+
include Asset::Helpers
|
15
|
+
|
16
|
+
# Sinatra
|
17
|
+
helpers Asset::Helpers
|
18
|
+
```
|
19
|
+
|
20
|
+
### Settings
|
21
|
+
```ruby
|
22
|
+
Asset.mode = ENV['RACK_ENV'] || MODE rescue 'development'
|
23
|
+
Asset.path = APP_ASSETS rescue File.join(Dir.pwd, 'app', 'assets')
|
24
|
+
Asset.cache = File.join(Dir.pwd, 'tmp')
|
25
|
+
Asset.debug = false
|
26
|
+
```
|
27
|
+
|
28
|
+
### Usage
|
29
|
+
```yaml
|
30
|
+
# Install your manifest file in APP_ROOT/app/assets/manifest.yml
|
31
|
+
|
32
|
+
# Asset manifest. Only the files mentioned here will be available.
|
33
|
+
# Options are compress: true/false, bundle: true/false
|
34
|
+
css:
|
35
|
+
- app.css
|
36
|
+
- themes/themes.css
|
37
|
+
|
38
|
+
js:
|
39
|
+
- app.js
|
40
|
+
- lib/cookie.js
|
41
|
+
|
42
|
+
# Example with options:
|
43
|
+
css:
|
44
|
+
- app.css:
|
45
|
+
- compress: true
|
46
|
+
- bundle: false
|
47
|
+
- themes/themes.css
|
48
|
+
|
49
|
+
js:
|
50
|
+
- app.js:
|
51
|
+
- bundle: false
|
52
|
+
- lib/cookie.js
|
53
|
+
```
|
54
|
+
|
55
|
+
```ruby
|
56
|
+
# After setting up the manifest file, use the helpers in your views
|
57
|
+
<%= script_tag 'app.js' %>
|
58
|
+
<%= style_tag 'app.css' %>
|
59
|
+
|
60
|
+
# Multiple
|
61
|
+
<%= script_tag 'app.js', 'lib/cookies.js' %>
|
62
|
+
|
63
|
+
# Bundle all files with 'application.js'
|
64
|
+
<%= script_tag 'application.js' %>
|
65
|
+
|
66
|
+
# Bundle all files with 'application.css'
|
67
|
+
<%= script_tag 'application.css' %>
|
68
|
+
```
|
69
|
+
|
70
|
+
In development mode, all files will be printed. In production mode, you'll get only one file.
|
71
|
+
|
72
|
+
The file will also be cached and compressed. The cache auto-expires.
|
73
|
+
|
74
|
+
### Middleware
|
75
|
+
|
76
|
+
The Asset gem also comes with Rack middleware to handle requests for your assets.
|
77
|
+
|
78
|
+
```ruby
|
79
|
+
# Insert the asset middleware early in the stack
|
80
|
+
use Asset::Router
|
81
|
+
|
82
|
+
# Full example from the config.ru file
|
83
|
+
|
84
|
+
# Set up middleware stack
|
85
|
+
app = Rack::Builder.new do
|
86
|
+
use Asset::Router # Include the Asset middleware router
|
87
|
+
|
88
|
+
# Use this setup to have files served from /assets/images and /assets/fonts
|
89
|
+
use Rack::Static, :urls => ['/images', '/fonts'], :root => APP_ASSETS,
|
90
|
+
:header_rules => [
|
91
|
+
[:all, {'Cache-Control' => 'public, max-age=31536000'}],
|
92
|
+
[:fonts, {'Access-Control-Allow-Origin' => '*'}]
|
93
|
+
]
|
94
|
+
run App # Your app goes here
|
95
|
+
end
|
96
|
+
|
97
|
+
run app
|
98
|
+
|
99
|
+
# Files will be available here on your server (HTTP):
|
100
|
+
/assets/js/app.js
|
101
|
+
/assets/js/lib/app.js
|
102
|
+
/assets/css/app.css
|
103
|
+
/assets/css/themes/dark.css
|
104
|
+
|
105
|
+
# You can also drop the /assets in front
|
106
|
+
/js/app.js
|
107
|
+
/css/app.css
|
108
|
+
```
|
109
|
+
|
110
|
+
The helpers will generate these URLs, so you don't have to worry about it.
|
111
|
+
|
112
|
+
### Images and fonts
|
113
|
+
|
114
|
+
To include support for other static file types likes images and fonts, use [Rack::Static](https://github.com/rack/rack/blob/master/lib/rack/static.rb)
|
115
|
+
|
116
|
+
```ruby
|
117
|
+
use Rack::Static, :urls => ['/images', '/fonts'], :root => APP_ASSETS,
|
118
|
+
:header_rules => [
|
119
|
+
[:all, {'Cache-Control' => 'public, max-age=31536000'}],
|
120
|
+
[:fonts, {'Access-Control-Allow-Origin' => '*'}]
|
121
|
+
]
|
122
|
+
```
|
123
|
+
|
124
|
+
We've included an image tag helper too for this use:
|
125
|
+
```erb
|
126
|
+
# Use this in your application, will default to APP_ROOT/assets/images
|
127
|
+
<%= image_tag 'logo.png' %>
|
128
|
+
```
|
129
|
+
|
130
|
+
### Contribute
|
131
|
+
|
132
|
+
Created and maintained by [Fugroup Ltd.](https://www.fugroup.net) We are the creators of [CrowdfundHQ.](https://crowdfundhq.com)
|
133
|
+
|
134
|
+
`@authors: Vidar`
|
data/app.rb
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
class App < Sinatra::Base
|
2
|
+
|
3
|
+
# helpers Asset::Helpers
|
4
|
+
|
5
|
+
configure do
|
6
|
+
# Settings
|
7
|
+
set :app_file, __FILE__
|
8
|
+
set :root, APP_ROOT
|
9
|
+
set :views, APP_VIEWS
|
10
|
+
|
11
|
+
# Turn this on in dev to see handler
|
12
|
+
set :show_exceptions, MODE != 'production'
|
13
|
+
set :raise_errors, false
|
14
|
+
|
15
|
+
# Haml setup
|
16
|
+
set :haml, {:format => :html5}
|
17
|
+
set :haml, :layout => :'layout/layout'
|
18
|
+
set :sass, {:cache_location => './tmp/sass-cache'}
|
19
|
+
|
20
|
+
# Liquid setup
|
21
|
+
Liquid::Template.file_system = Liquid::LocalFileSystem.new(APP_VIEWS)
|
22
|
+
|
23
|
+
# Set up loggers and tmp files
|
24
|
+
Dir.mkdir('./tmp') unless File.exists?('./tmp')
|
25
|
+
Dir.mkdir('./log') unless File.exists?('./log')
|
26
|
+
|
27
|
+
# Global loggers
|
28
|
+
$log = Logger.new("./log/app.log")
|
29
|
+
$errors = Logger.new("./log/errors.log")
|
30
|
+
end
|
31
|
+
|
32
|
+
# Disable caching of classes when not in production
|
33
|
+
configure :development, :test do |c|
|
34
|
+
Liquid.cache_classes = false
|
35
|
+
Liquid::Template.error_mode = :strict
|
36
|
+
end
|
37
|
+
|
38
|
+
get('/') do
|
39
|
+
erb(:index)
|
40
|
+
end
|
41
|
+
|
42
|
+
# Default not found page
|
43
|
+
not_found do
|
44
|
+
"404, Not found".tap{|m| puts m}
|
45
|
+
end
|
46
|
+
|
47
|
+
# Default error pages
|
48
|
+
error(500..510) do
|
49
|
+
"50X, Application error".tap{|m| puts m}
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
data/asset.gemspec
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = 'asset'
|
3
|
+
s.version = '0.0.3'
|
4
|
+
s.date = '2017-01-05'
|
5
|
+
s.summary = "Compress and serve your CSS and JS automatically"
|
6
|
+
s.description = "The only thing you need for your assets."
|
7
|
+
s.authors = ["Fugroup Limited"]
|
8
|
+
s.email = 'vidar@fugroup.net'
|
9
|
+
s.license = 'MIT'
|
10
|
+
|
11
|
+
s.add_runtime_dependency 'rack', '>= 0'
|
12
|
+
s.add_runtime_dependency 'sass', '>= 0'
|
13
|
+
s.add_runtime_dependency 'uglifier', '>= 0'
|
14
|
+
|
15
|
+
s.add_development_dependency 'sinatra', '>= 0'
|
16
|
+
s.add_development_dependency 'puma', '>= 0'
|
17
|
+
s.add_development_dependency 'tilt', '>= 0'
|
18
|
+
s.add_development_dependency 'liquid', '>= 0'
|
19
|
+
s.add_development_dependency 'erubis', '>= 0'
|
20
|
+
s.add_development_dependency 'rest-client', '>= 0'
|
21
|
+
s.add_development_dependency 'request_store', '>= 0'
|
22
|
+
s.add_development_dependency 'fuprint', '>= 0'
|
23
|
+
s.add_development_dependency 'futest', '>= 0'
|
24
|
+
|
25
|
+
s.homepage = 'https://github.com/fugroup/asset'
|
26
|
+
s.license = 'MIT'
|
27
|
+
|
28
|
+
s.require_paths = ['lib']
|
29
|
+
s.files = `git ls-files -z`.split("\x0").reject do |f|
|
30
|
+
f.match(%r{^(test|spec|features|app|config|log|tmp)/})
|
31
|
+
end
|
32
|
+
end
|
data/config.ru
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
Encoding.default_external = Encoding::UTF_8
|
2
|
+
Encoding.default_internal = Encoding::UTF_8
|
3
|
+
|
4
|
+
# Init the app
|
5
|
+
require './config/boot.rb'
|
6
|
+
require './app.rb'
|
7
|
+
|
8
|
+
# Set up middleware stack
|
9
|
+
app = Rack::Builder.new do
|
10
|
+
use Fuprint::Request
|
11
|
+
use Asset::Router
|
12
|
+
use Rack::Static, :urls => ['/images', '/fonts'], :root => APP_ASSETS,
|
13
|
+
:header_rules => [
|
14
|
+
[:all, {'Cache-Control' => 'public, max-age=31536000'}],
|
15
|
+
[:fonts, {'Access-Control-Allow-Origin' => '*'}]
|
16
|
+
]
|
17
|
+
run App
|
18
|
+
end
|
19
|
+
|
20
|
+
run app
|
21
|
+
|
data/lib/asset.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'rack'
|
2
|
+
|
1
3
|
module Asset
|
2
4
|
|
3
5
|
# # # # # #
|
@@ -10,10 +12,10 @@ module Asset
|
|
10
12
|
class << self; attr_accessor :mode, :path, :cache, :manifest, :debug; end
|
11
13
|
|
12
14
|
# Default is production
|
13
|
-
@mode = ENV['RACK_ENV'] ||
|
14
|
-
@path =
|
15
|
+
@mode = ENV['RACK_ENV'] || 'development'
|
16
|
+
@path = File.join(Dir.pwd, 'app', 'assets')
|
15
17
|
@cache = File.join(Dir.pwd, 'tmp')
|
16
|
-
@debug =
|
18
|
+
@debug = false
|
17
19
|
|
18
20
|
end
|
19
21
|
|
@@ -23,6 +25,5 @@ require_relative 'assets/item'
|
|
23
25
|
# Load the manifest
|
24
26
|
::Asset.manifest = ::Asset::Util.load_manifest
|
25
27
|
|
26
|
-
|
27
28
|
require_relative 'assets/helpers'
|
28
29
|
require_relative 'assets/router'
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module Asset
|
2
|
+
module Helpers
|
3
|
+
|
4
|
+
# Script tags
|
5
|
+
def script_tag(*paths)
|
6
|
+
tag('js', *paths) do |src|
|
7
|
+
%{<script src="#{src}"></script>}
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
# Style tags
|
12
|
+
def style_tag(*paths)
|
13
|
+
tag('css', *paths) do |src|
|
14
|
+
%{<link href="#{src}" media="all" rel="stylesheet" type="text/css">}
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
# Image tags
|
19
|
+
def image_tag(path)
|
20
|
+
b = ::Asset::Util.mtime("images/#{path}")
|
21
|
+
%{<img src="/assets/images/#{CGI.escapeHTML(path)}#{b ? "?#{b.to_i}" : ''}">} rescue path
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
# Build the tags
|
27
|
+
def tag(type, *paths, &block)
|
28
|
+
paths.map do |path|
|
29
|
+
|
30
|
+
# Yield the source back to the tag builder
|
31
|
+
item = ::Asset.manifest.find{|i| i.path == path}
|
32
|
+
|
33
|
+
# Src is same as path if item not found
|
34
|
+
item ? item.files.map{|src| yield(%{/assets/#{type}/#{src}})} : yield(path)
|
35
|
+
|
36
|
+
end.flatten.join("\n")
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
data/lib/assets/item.rb
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
module Asset
|
2
|
+
class Item
|
3
|
+
|
4
|
+
attr_accessor :path, :type, :key, :modified, :compress, :bundle, :name
|
5
|
+
|
6
|
+
# Init
|
7
|
+
def initialize(*args)
|
8
|
+
@path, @type, @key, @modified, @compress, @bundle = args
|
9
|
+
@name = @path.rpartition('.')[0]
|
10
|
+
end
|
11
|
+
|
12
|
+
# File? Or bundle?
|
13
|
+
def file?
|
14
|
+
@path !~ /^application\.(js|css)$/
|
15
|
+
end
|
16
|
+
|
17
|
+
# Get the files. Pass keyed = false to get the path instead of the file
|
18
|
+
def files(keyed = true)
|
19
|
+
if file? or (keyed and ::Asset.mode == 'production')
|
20
|
+
[keyed ? file : path]
|
21
|
+
else
|
22
|
+
::Asset.manifest.select{|i| i.type == @type and i.file?}.map{|i| keyed ? i.file : i.path}
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
# Get the file, meaning the full path with key
|
27
|
+
def file
|
28
|
+
::Asset.mode == 'development' ? @path : %{#{file? ? @name : 'application'}-#{@key}.#{@type}}
|
29
|
+
end
|
30
|
+
|
31
|
+
# Get the content. Pass cache = false to fetch from disk instead of the cache.
|
32
|
+
def content(cache = (::Asset.mode = 'production'))
|
33
|
+
return joined unless cache
|
34
|
+
|
35
|
+
File.read(File.join(::Asset.cache, %{#{@key}.#{@type}})).tap{|f| return f if f} rescue nil
|
36
|
+
|
37
|
+
# Compress the files
|
38
|
+
compressed.tap{|r| write_cache(r)}
|
39
|
+
end
|
40
|
+
|
41
|
+
# Store in cache
|
42
|
+
def write_cache(r)
|
43
|
+
File.open(File.join(::Asset.cache, %{#{@key}.#{@type}}), 'w'){|f| f.write(r)}
|
44
|
+
end
|
45
|
+
|
46
|
+
# Compressed joined files
|
47
|
+
def compressed
|
48
|
+
case @type
|
49
|
+
when 'css'
|
50
|
+
Tilt.new('scss', :style => :compressed){ joined }.render rescue joined
|
51
|
+
when 'js'
|
52
|
+
Uglifier.compile(joined, {}) rescue joined
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
# All files joined
|
57
|
+
def joined
|
58
|
+
@joined ||= files(false).map{|f| File.read(File.join(::Asset.path, @type, f))}.join
|
59
|
+
end
|
60
|
+
|
61
|
+
# Print data
|
62
|
+
def print
|
63
|
+
[:path, :type, :key, :name, :modified, :files, :content].each{|r| puts "#{r.upcase}: #{send(r).inspect}"}
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
module Asset
|
2
|
+
class Router
|
3
|
+
|
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
|
+
}
|
10
|
+
|
11
|
+
# Init
|
12
|
+
def initialize(app)
|
13
|
+
@app = app
|
14
|
+
end
|
15
|
+
|
16
|
+
# Call
|
17
|
+
def call(env)
|
18
|
+
# Setting up request
|
19
|
+
@request = Rack::Request.new(env)
|
20
|
+
|
21
|
+
# The routes
|
22
|
+
case @request.path_info
|
23
|
+
|
24
|
+
# Match /assets?/:type/path
|
25
|
+
when /^(\/assets)?\/(js|css)\/(.+)/
|
26
|
+
type, path = $2, $3
|
27
|
+
|
28
|
+
path =~ /(-[a-f0-9]{1,32})/
|
29
|
+
path = path.gsub($1, '') if $1
|
30
|
+
|
31
|
+
item = ::Asset.manifest.find{|i| i.path == path and i.type == type}
|
32
|
+
|
33
|
+
# Not found if no item, wrong key or no content
|
34
|
+
return not_found if !item or ($1 and $1 != item.key) or !item.content(!!$1)
|
35
|
+
|
36
|
+
found(item)
|
37
|
+
|
38
|
+
# Bounce favicon requests
|
39
|
+
when /^\/favicon\.ico$/
|
40
|
+
not_found
|
41
|
+
|
42
|
+
# Return a standard robots.txt
|
43
|
+
when /^\/robots\.txt$/
|
44
|
+
robots
|
45
|
+
|
46
|
+
else
|
47
|
+
# No routes found, pass down the middleware stack
|
48
|
+
@app.call(env)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
private
|
53
|
+
|
54
|
+
# Found
|
55
|
+
def found(item)
|
56
|
+
[ 200, {'Content-Type' => MIME[item.type],
|
57
|
+
'Content-Length' => item.content.size,
|
58
|
+
'Cache-Control' => 'max-age=86400, public',
|
59
|
+
'Expires' => (Time.now + 86400*30).utc.rfc2822,
|
60
|
+
'Last-Modified' => item.modified.utc.rfc2822
|
61
|
+
}, [item.content]]
|
62
|
+
end
|
63
|
+
|
64
|
+
# Not found
|
65
|
+
def not_found(path = '@')
|
66
|
+
[404, {'Content-Type' => MIME['txt'], 'Content-Length' => 0}, []]
|
67
|
+
end
|
68
|
+
|
69
|
+
# Robots
|
70
|
+
def robots
|
71
|
+
s = %{Sitemap: #{@request.scheme}://#{@request.host}/sitemap.xml}
|
72
|
+
[200, {'Content-Type' => MIME['txt'],'Content-Length' => s.size}, [s]]
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
76
|
+
end
|
data/lib/assets/util.rb
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
module Asset
|
2
|
+
class Util
|
3
|
+
|
4
|
+
# Get timestamp
|
5
|
+
def self.mtime(path)
|
6
|
+
File.mtime(asset_path(path))
|
7
|
+
end
|
8
|
+
|
9
|
+
# Asset path
|
10
|
+
def self.asset_path(path)
|
11
|
+
File.join(::Asset.path, File.split(path))
|
12
|
+
end
|
13
|
+
|
14
|
+
# Digest
|
15
|
+
def self.digest(path, time)
|
16
|
+
Digest::MD5.hexdigest(%{#{path}#{time.to_i}})
|
17
|
+
end
|
18
|
+
|
19
|
+
# Load manifest
|
20
|
+
def self.load_manifest
|
21
|
+
list = YAML.load_file(File.join(::Asset.path, 'manifest.yml'))
|
22
|
+
manifest = []
|
23
|
+
|
24
|
+
list.each do |type, files|
|
25
|
+
max = Time.new(0).utc
|
26
|
+
files.each do |name|
|
27
|
+
|
28
|
+
# Depending on the options, the name can be a string or a Hash
|
29
|
+
h = name.is_a?(Hash)
|
30
|
+
|
31
|
+
# Path looks like app.js or similar
|
32
|
+
path = h ? name.keys[0] : name
|
33
|
+
|
34
|
+
# Get the modified time of the asset
|
35
|
+
modified = mtime("#{type}/#{path}").utc
|
36
|
+
|
37
|
+
# Record max to know the latest change
|
38
|
+
max = modified if modified > max
|
39
|
+
|
40
|
+
# Loading manifest with items
|
41
|
+
manifest << ::Asset::Item.new(
|
42
|
+
path, type, digest(path, modified), modified,
|
43
|
+
(h ? name['compress'] : true), (h ? name['bundle'] : true))
|
44
|
+
end
|
45
|
+
|
46
|
+
# Insert the application bundle
|
47
|
+
manifest.insert(0, ::Asset::Item.new(
|
48
|
+
"application.#{type}", type,
|
49
|
+
digest("application.#{type}", max), max))
|
50
|
+
end
|
51
|
+
manifest
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
end
|
metadata
CHANGED
@@ -1,22 +1,202 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: asset
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
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-
|
12
|
-
dependencies:
|
11
|
+
date: 2017-01-05 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rack
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: sass
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: uglifier
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: sinatra
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: puma
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: tilt
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: liquid
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: erubis
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: rest-client
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: request_store
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: fuprint
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - ">="
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0'
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - ">="
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: futest
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - ">="
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
174
|
+
type: :development
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - ">="
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '0'
|
13
181
|
description: The only thing you need for your assets.
|
14
182
|
email: vidar@fugroup.net
|
15
183
|
executables: []
|
16
184
|
extensions: []
|
17
185
|
extra_rdoc_files: []
|
18
186
|
files:
|
187
|
+
- ".gitignore"
|
188
|
+
- CHANGELOG.md
|
189
|
+
- Gemfile
|
190
|
+
- LICENSE
|
191
|
+
- README.md
|
192
|
+
- app.rb
|
193
|
+
- asset.gemspec
|
194
|
+
- config.ru
|
19
195
|
- lib/asset.rb
|
196
|
+
- lib/assets/helpers.rb
|
197
|
+
- lib/assets/item.rb
|
198
|
+
- lib/assets/router.rb
|
199
|
+
- lib/assets/util.rb
|
20
200
|
homepage: https://github.com/fugroup/asset
|
21
201
|
licenses:
|
22
202
|
- MIT
|
@@ -37,7 +217,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
37
217
|
version: '0'
|
38
218
|
requirements: []
|
39
219
|
rubyforge_project:
|
40
|
-
rubygems_version: 2.
|
220
|
+
rubygems_version: 2.6.8
|
41
221
|
signing_key:
|
42
222
|
specification_version: 4
|
43
223
|
summary: Compress and serve your CSS and JS automatically
|