asset 0.2.0 → 0.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 06536e51676a5659bbf7bdc27bd0813377ad92bd
4
- data.tar.gz: d81786f8d07370fc9da801f684d65002ef0bfb9a
3
+ metadata.gz: 97797bb9b02ffca18a74539c99311a5e340428cb
4
+ data.tar.gz: fbca1ddac3acb66ee358d6eca68aa48f3928fbf1
5
5
  SHA512:
6
- metadata.gz: 89dcb3239bc7c159af662f557648792ea372ab399e24b449547c53343fae4bbbe3f139256d4f3adb1a678da577ade6f6c1b4cbe11d0bfbfbd41c9050db2015c2
7
- data.tar.gz: 51592460d1f4cdc4f3a13c26efbb957894d7dcc51cca1270d9ed97c53163da38ee7c0c4fec04abc208a2eeb8a74f179868e16f00f404e58d5f64c51fb4844ee1
6
+ metadata.gz: 54f28fa505aea145ffddec9353083f98c6a68eb16330e67ebed7747faafa684a846dc60d4df6240af3becaf77cc61dc3f631f7b3d3b09a2c2dbc866b259ff621
7
+ data.tar.gz: f105cdbb7c3d3db7643768ac4fe6059ae86667837fd532e9491d81ea0bdb7823c0adc52bbdc44dbad1471a9bc5a07ecee6b4ccbe41ed6a18698fd8ae4ec4b8c4
data/README.md CHANGED
@@ -2,7 +2,9 @@
2
2
 
3
3
  Compress and cache your Javascript and CSS files automatically.
4
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.
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 Rack.
6
+
7
+ All assets are loaded only once, and then stored in the browser disk cache, making your pages load in milliseconds. This is a must-have for any web site.
6
8
 
7
9
  ### Installation
8
10
  ```
@@ -69,10 +71,9 @@ js:
69
71
 
70
72
  In development mode, all files will be printed. In production mode, you'll get only one file.
71
73
 
72
- 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.
74
+ The file will also be cached and compressed. The cache auto-expires.
73
75
 
74
76
  ### Middleware
75
-
76
77
  The Asset gem also comes with Rack middleware to handle requests for your assets.
77
78
 
78
79
  ```ruby
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'asset'
3
- s.version = '0.2.0'
4
- s.date = '2017-02-01'
3
+ s.version = '0.2.1'
4
+ s.date = '2017-06-12'
5
5
  s.summary = "Compress and serve your CSS and JS assets automatically"
6
6
  s.description = "The only thing you need for your assets."
7
7
  s.authors = ["Fugroup Limited"]
@@ -11,9 +11,9 @@ module Asset
11
11
  autoload :Uglifier, 'uglifier'
12
12
  autoload :Sass, 'sass'
13
13
 
14
- class << self; attr_accessor :mode, :path, :cache, :favicon, :robots, :manifest, :bundle, :images, :listener, :debug; end
14
+ class << self; attr_accessor :mode, :path, :cache, :favicon, :robots, :manifest, :bundle, :images, :listener, :symlinks, :debug; end
15
15
 
16
- # Default is development
16
+ # Default is production
17
17
  @mode = ENV['RACK_ENV'] || 'production'
18
18
 
19
19
  # Where your assets live
@@ -31,6 +31,9 @@ module Asset
31
31
  # Reset the assets on change in development mode
32
32
  @listener = true
33
33
 
34
+ # Follow symlinks in assets
35
+ @symlinks = false
36
+
34
37
  # Debug option
35
38
  @debug = false
36
39
  end
@@ -1,3 +1,6 @@
1
+ # Naming convenience for use with Liquid templates
2
+ # Usage: Liquid::Template.register_filter(::Asset::Filters)
3
+
1
4
  module Asset
2
5
  module Filters
3
6
 
@@ -61,7 +61,7 @@ module Asset
61
61
  end
62
62
 
63
63
  # Not found
64
- def not_found(path = '@')
64
+ def not_found
65
65
  [404, {'Content-Type' => MIME['txt'], 'Content-Length' => 0}, []]
66
66
  end
67
67
 
@@ -33,7 +33,7 @@ module Asset
33
33
 
34
34
  # Load manifest
35
35
  def self.load_manifest
36
- Dir["#{Asset.path}/{css,js}/**/*.*"].map do |f|
36
+ Dir["#{Asset.path}/{css,js}/#{pattern}"].uniq.map do |f|
37
37
  # Extract type and name
38
38
  f =~ /(js|css)\/(.+)$/; type, name = $1, $2
39
39
 
@@ -57,12 +57,17 @@ module Asset
57
57
  # Load images into memory
58
58
  def self.load_images
59
59
  # Store the path and the timestamp
60
- img = Dir["#{::Asset.path}/images/**/*.*"].map do |i|
60
+ img = Dir["#{::Asset.path}/images/#{pattern}"].uniq.map do |i|
61
61
  i =~ /\/images\/(.+)/; [$1, mtime("images/#{$1}").to_i]
62
62
  end
63
63
  Hash[*img.flatten]
64
64
  end
65
65
 
66
+ # File match pattern
67
+ def self.pattern
68
+ ::Asset.symlinks ? '**{,/*/**}/*.*' : '**/*.*'
69
+ end
70
+
66
71
  # Production mode?
67
72
  def self.p?
68
73
  %w[staging production].include?(::Asset.mode)
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.2.0
4
+ version: 0.2.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-02-01 00:00:00.000000000 Z
11
+ date: 2017-06-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
@@ -246,7 +246,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
246
246
  version: '0'
247
247
  requirements: []
248
248
  rubyforge_project:
249
- rubygems_version: 2.6.8
249
+ rubygems_version: 2.6.10
250
250
  signing_key:
251
251
  specification_version: 4
252
252
  summary: Compress and serve your CSS and JS assets automatically