critical-path-css-rails 0.3.0 → 0.3.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/README.md +1 -1
- data/lib/critical-path-css-rails.rb +7 -3
- data/lib/critical_path_css/css_fetcher.rb +10 -2
- data/lib/critical_path_css/rails/version.rb +1 -1
- data/lib/tasks/critical_path_css.rake +5 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: efbeb0837b2752563a6e71bb6bd960e1faa22df1
|
4
|
+
data.tar.gz: 024c57f77b449192a39ae2c46f236f8f5faff5bd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1d40eca9468a179785263c60826766fc237ef9f0c908f5613641e9458dba18982395bc2404e0a0f4f0cfbe5a05528c77e5cfa60686a87b3c29bd507d9ffcae58
|
7
|
+
data.tar.gz: 98cd11ed349e88d1c5fe89daee6bb98e87d2141f9f86d4e4e9d43e583615c544774486f8f34759e205f730ae48c79b720dfb3268f0d27517e94252fe17e66064
|
data/README.md
CHANGED
@@ -4,8 +4,12 @@ module CriticalPathCss
|
|
4
4
|
CACHE_NAMESPACE = 'critical-path-css'
|
5
5
|
|
6
6
|
def self.generate(route)
|
7
|
-
|
8
|
-
|
7
|
+
Rails.cache.write(
|
8
|
+
route,
|
9
|
+
CssFetcher.new.fetch_route(route),
|
10
|
+
namespace: CACHE_NAMESPACE,
|
11
|
+
expires_in: nil
|
12
|
+
)
|
9
13
|
end
|
10
14
|
|
11
15
|
def self.generate_all
|
@@ -19,7 +23,7 @@ module CriticalPathCss
|
|
19
23
|
end
|
20
24
|
|
21
25
|
def self.clear_matched(routes)
|
22
|
-
Rails.cache.delete_matched(routes,namespace: CACHE_NAMESPACE)
|
26
|
+
Rails.cache.delete_matched(routes, namespace: CACHE_NAMESPACE)
|
23
27
|
end
|
24
28
|
|
25
29
|
def self.fetch(route)
|
@@ -17,10 +17,18 @@ module CriticalPathCss
|
|
17
17
|
css_for_route route
|
18
18
|
end
|
19
19
|
|
20
|
-
|
20
|
+
protected
|
21
21
|
|
22
22
|
def css_for_route(route)
|
23
|
-
|
23
|
+
url = @config.base_url + route
|
24
|
+
|
25
|
+
Phantomjs.run(
|
26
|
+
'--ignore-ssl-errors=true',
|
27
|
+
'--ssl-protocol=tlsv1',
|
28
|
+
PENTHOUSE_PATH,
|
29
|
+
url,
|
30
|
+
@config.css_path
|
31
|
+
)
|
24
32
|
end
|
25
33
|
end
|
26
34
|
end
|
@@ -5,12 +5,13 @@ namespace :critical_path_css do
|
|
5
5
|
task generate: :environment do
|
6
6
|
CriticalPathCss.generate_all
|
7
7
|
end
|
8
|
+
|
8
9
|
desc 'Clear all critical CSS from the cache'
|
9
10
|
task clear_all: :environment do
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
11
|
+
# Use the following for Redis cache implmentations
|
12
|
+
CriticalPathCss.clear_matched('*')
|
13
|
+
# Some other cache implementations may require the following syntax instead
|
14
|
+
# CriticalPathCss.clear_matched(/.*/)
|
14
15
|
end
|
15
16
|
end
|
16
17
|
|