File tree Expand file tree Collapse file tree 3 files changed +28
-11
lines changed Expand file tree Collapse file tree 3 files changed +28
-11
lines changed Original file line number Diff line number Diff line change 11# This configuration was generated by
22# `rubocop --auto-gen-config`
3- # on 2015-10-01 20:43:37 -0500 using RuboCop version 0.34.1.
3+ # on 2015-10-03 13:02:27 -0500 using RuboCop version 0.34.1.
44# The point is for the user to remove these configuration records
55# one by one as the offenses are removed from the code base.
66# Note that changes in the inspected code, or installation of new
77# versions of RuboCop, may require this file to be generated again.
88
9- # Offense count: 2
9+ # Offense count: 1
1010# Configuration parameters: AllowURI, URISchemes.
1111Metrics/LineLength :
1212 Max : 90
Original file line number Diff line number Diff line change 1+ module CriticalPathCss
2+ class CssFetcher
3+ require 'phantomjs'
4+ require 'critical_path_css/configuration'
5+
6+ PENTHOUSE_PATH = "#{ File . dirname ( __FILE__ ) } /../penthouse/penthouse.js"
7+
8+ def initialize ( main_css_relative_path )
9+ @main_css_path = "#{ Rails . root } /public#{ main_css_relative_path } "
10+ @config = Configuration . new
11+ end
12+
13+ def fetch
14+ @config . routes . map { |route | [ route , css_for_route ( route ) ] } . to_h
15+ end
16+
17+ private
18+
19+ def css_for_route ( route )
20+ Phantomjs . run ( PENTHOUSE_PATH , @config . base_url + route , @main_css_path )
21+ end
22+ end
23+ end
Original file line number Diff line number Diff line change 11module CriticalPathCss
2- require 'phantomjs '
2+ require 'critical_path_css/css_fetcher '
33
44 CACHE_NAMESPACE = 'critical-path-css'
5- PENTHOUSE_PATH = "#{ File . dirname ( __FILE__ ) } /penthouse/penthouse.js"
6-
7- def self . generate ( main_css_path )
8- full_main_css_path = "#{ Rails . root } /public#{ main_css_path } "
9- config = CriticalPathCss ::Configuration . new ( Rails . root , Rails . env )
10-
11- config . routes . each do |route |
12- css = Phantomjs . run ( PENTHOUSE_PATH , config . base_url + route , full_main_css_path )
135
6+ def self . generate ( main_css_relative_path )
7+ CssFetcher . new ( main_css_relative_path ) . fetch . each do |route , css |
148 Rails . cache . write ( route , css , namespace : CACHE_NAMESPACE )
159 end
1610 end
You can’t perform that action at this time.
0 commit comments