plezi 0.12.16 → 0.12.17
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/lib/plezi/common/cache.rb +21 -4
- data/lib/plezi/common/renderer.rb +4 -3
- data/lib/plezi/common/settings.rb +12 -0
- data/lib/plezi/helpers/http_sender.rb +3 -1
- data/lib/plezi/version.rb +1 -1
- data/plezi.gemspec +1 -1
- data/resources/mini_app.rb +2 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 09beaf8c38e5eed4e1cc3580fe3ce78be7628f8c
|
4
|
+
data.tar.gz: dd718e677a9e7a00ca747c5cb06e936e1248453c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f20d81b4969cec3edd49f65aeef948d08e90ee8a650411bc3c043cc2a80658d1e99df322fecce7c0cc7fd62ed3d61aeddf8caf4fe85a2324321fb5d174170e2d
|
7
|
+
data.tar.gz: 8913e9cfbe636463d0493182de4e7306a0354ea34c210afadba38cf8879f57ca9cc7787af197c02a82bb5939571d49cebfe8359bafbfc39d45157eff83b119ec
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,14 @@
|
|
2
2
|
|
3
3
|
***
|
4
4
|
|
5
|
+
Change log v.0.12.17
|
6
|
+
|
7
|
+
**Fix**: error template format would (and should) fallback to 'html' if the originally requested format (i.e. 'json') was missing. An issue with nested template rendering (when the error template would call `render` to render a partial or other template) caused the fallback to revert to the original (missing) format when searching for the nested template. This issue is now fixed, by instructing ErrorCtrl to set the global format rather than the local one.
|
8
|
+
|
9
|
+
**Update**: when the `ENV["ENV"]` or `ENV["ENV"]` are set to `"production"`, the SASS asset render engine will be set to compress the css (minify), for smaller transfers.
|
10
|
+
|
11
|
+
***
|
12
|
+
|
5
13
|
Change log v.0.12.16
|
6
14
|
|
7
15
|
**Fix**: fixed an issue with the `#url_for` method, which couldn't be used as a class method.
|
data/lib/plezi/common/cache.rb
CHANGED
@@ -12,8 +12,6 @@ module Plezi
|
|
12
12
|
CACHE_LOCK = Mutex.new
|
13
13
|
CACHABLE = (%w{cache object slim haml css map js html scss sass coffee txt xml json yaml rb}).to_set
|
14
14
|
|
15
|
-
@cache_to_disk = true
|
16
|
-
|
17
15
|
# this class holds cached objects (data and modification times)
|
18
16
|
class CacheObject
|
19
17
|
# Cached attributes
|
@@ -92,11 +90,30 @@ module Plezi
|
|
92
90
|
( CACHE_STORE[filename] || File.exist?(filename) ) && true
|
93
91
|
end
|
94
92
|
|
95
|
-
# returns true if the file has been update since data was last cached.
|
93
|
+
# returns true if the {#allow_cache_update?} is true and the file has been update since data was last cached.
|
96
94
|
def cache_needs_update? filename
|
97
|
-
return true if CACHE_STORE[filename].nil? || CACHE_STORE[filename].mtime < File.mtime(filename)
|
95
|
+
return true if CACHE_STORE[filename].nil? || (CACHE_STORE[filename].mtime < File.mtime(filename))
|
98
96
|
false
|
99
97
|
end
|
98
|
+
|
99
|
+
# # # The following was discarded because benchmarks show the difference is negligible
|
100
|
+
# @refresh_cache ||= (ENV['ENV'] != 'production')
|
101
|
+
# # get the cache refresh directive for {#cache_needs_update}. Defaults to ENV['ENV'] != 'production'
|
102
|
+
# def allow_cache_update?
|
103
|
+
# @refresh_cache ||= (ENV['ENV'] != 'production')
|
104
|
+
# end
|
105
|
+
# # set the cache refresh directive for {#cache_needs_update}
|
106
|
+
# def allow_cache_update= val
|
107
|
+
# @refresh_cache = val
|
108
|
+
# end
|
109
|
+
# # returns true if the {#allow_cache_update?} is true and the file has been update since data was last cached.
|
110
|
+
# def cache_needs_update? filename
|
111
|
+
# return true if CACHE_STORE[filename].nil? || (allow_cache_update? && (CACHE_STORE[filename].mtime < File.mtime(filename)))
|
112
|
+
# false
|
113
|
+
# end
|
114
|
+
|
115
|
+
|
116
|
+
|
100
117
|
end
|
101
118
|
|
102
119
|
public
|
@@ -41,13 +41,14 @@ module Plezi
|
|
41
41
|
|
42
42
|
module SASSExt
|
43
43
|
module_function
|
44
|
+
SASS_OPTIONS = { style: (ENV['SASS_STYLE'] || ((ENV['ENV'] || ENV['RACK_ENV']) == 'production' ? :compressed : :nested )) }
|
44
45
|
|
45
46
|
def call filename, context, &block
|
46
47
|
return false unless defined? ::Sass
|
47
|
-
|
48
|
+
SASS_OPTIONS[:cache_store] ||= Sass::CacheStores::Memory.new
|
48
49
|
# review mtime and render sass if necessary
|
49
50
|
if refresh_sass?(filename)
|
50
|
-
eng = Sass::Engine.for_file(filename,
|
51
|
+
eng = Sass::Engine.for_file(filename, SASS_OPTIONS)
|
51
52
|
Plezi.cache_data filename, eng.dependencies
|
52
53
|
css, map = eng.render_with_sourcemap("#{File.basename(filename, '.*'.freeze)}.map".freeze)
|
53
54
|
Plezi.cache_data filename.sub(/\.s[ac]ss$/, '.map'.freeze), map.to_json( css_uri: File.basename(filename, '.*'.freeze) )
|
@@ -58,8 +59,8 @@ module Plezi
|
|
58
59
|
end
|
59
60
|
|
60
61
|
def refresh_sass? sass
|
61
|
-
return false unless File.exists?(sass)
|
62
62
|
return true if Plezi.cache_needs_update?(sass)
|
63
|
+
# return false unless Plezi.allow_cache_update? # no meaningful performance boost.
|
63
64
|
mt = Plezi.file_mtime(sass)
|
64
65
|
Plezi.get_cached(sass).each {|e| return true if File.exists?(e.options[:filename]) && (File.mtime(e.options[:filename]) > mt)} # fn = File.join( e.options[:load_paths][0].root, e.options[:filename])
|
65
66
|
false
|
@@ -36,5 +36,17 @@ module Plezi
|
|
36
36
|
def uuid
|
37
37
|
@uuid ||= SecureRandom.uuid
|
38
38
|
end
|
39
|
+
|
40
|
+
|
41
|
+
# # # The following was discarded because benchmarks show the difference is negligible
|
42
|
+
# # Get the cache refresh directive for the {#cache_needs_update?} implementation. Defaults to ENV['ENV'] != 'production'
|
43
|
+
# def allow_cache_update?
|
44
|
+
# Plezi.allow_cache_update?
|
45
|
+
# end
|
46
|
+
# # Set the cache refresh directive for the {#cache_needs_update?} implementation. Defaults to ENV['ENV'] != 'production'
|
47
|
+
# def allow_cache_update= val
|
48
|
+
# Plezi.allow_cache_update = val
|
49
|
+
# end
|
50
|
+
# # **Update**: up until now, Plezi would allow refresh any cached assets ot templated when they are edited. This file review is usually a waste of resources after deployment, since the files never get updated in production environments. Plezi now supports a two new settings options: `Plezi.allow_cache_update?` and `Plezi.allow_cache_update=` which will dictate if file review should be performed after caching. The default is now set to AVOID file reviews for production environments (`ENV['ENV'] || ENV['RACK_ENV'] != 'production'`).
|
39
51
|
end
|
40
52
|
end
|
@@ -13,7 +13,9 @@ module Plezi
|
|
13
13
|
include ::Plezi::ControllerMagic
|
14
14
|
|
15
15
|
def index
|
16
|
-
render(response.status.to_s) ||
|
16
|
+
render(response.status.to_s) ||
|
17
|
+
(params[:format] && (params[:format] != 'html'.freeze) && (params[:format] = 'html'.freeze) && (response['content-type'] = nil).nil? && render(response.status.to_s)) ||
|
18
|
+
((response['content-type'.freeze] = 'text/plain'.freeze) && response.class::STATUS_CODES[response.status])
|
17
19
|
end
|
18
20
|
def requested_method
|
19
21
|
:index
|
data/lib/plezi/version.rb
CHANGED
data/plezi.gemspec
CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.add_dependency "iodine", "~> 0.1.
|
21
|
+
spec.add_dependency "iodine", "~> 0.1.17"
|
22
22
|
spec.add_development_dependency "bundler", "~> 1.7"
|
23
23
|
spec.add_development_dependency "rake", "~> 10.0"
|
24
24
|
|
data/resources/mini_app.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
-
## Set working directory, load gems and create logs
|
3
|
+
## Set environment, working directory, load gems and create logs
|
4
|
+
ENV['ENV'] ||= ENV['RACK_ENV'] # production ENV will render SASS as compressed.
|
4
5
|
## Using pathname extentions for setting public folder
|
5
6
|
require 'pathname'
|
6
7
|
## Set up root object, it might be used by the environment and\or the plezi extension gems.
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: plezi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.12.
|
4
|
+
version: 0.12.17
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Boaz Segev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-11-
|
11
|
+
date: 2015-11-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: iodine
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.1.
|
19
|
+
version: 0.1.17
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.1.
|
26
|
+
version: 0.1.17
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|