File tree Expand file tree Collapse file tree 2 files changed +16
-7
lines changed
Expand file tree Collapse file tree 2 files changed +16
-7
lines changed Original file line number Diff line number Diff line change @@ -6,9 +6,12 @@ Gem::Specification.new do |s|
66 s . description = 'Critical Path CSS'
77 s . authors = [ 'Michael Misshore' ]
88 s . email = 'mmisshore@gmail.com'
9- s . files = [ 'lib/critical-path-css.rb' ]
109 s . homepage = 'http://rubygems.org/gems/critical-path-css'
1110 s . license = 'MIT'
1211
1312 s . add_runtime_dependency 'phantomjs' , [ '~> 1.9.8.0' ]
13+
14+ s . files = `git ls-files` . split ( "\n " )
15+ s . executables = `git ls-files -- bin/*` . split ( "\n " ) . map { |f | File . basename ( f ) }
16+ s . require_path = 'lib'
1417end
Original file line number Diff line number Diff line change 11class CriticalPathCss
22 require 'phantomjs'
33
4- def self . generate_css
5- Phantomjs . run ( "#{ penthouse_path } http://google.com google.css > critical-css-google.css" )
6- end
4+ CACHE_NAMESPACE = 'critical-path-css'
5+ PENTHOUSE_PATH = "#{ File . dirname ( __FILE__ ) } /penthouse/penthouse.js"
6+
7+ def self . generate ( main_css_path , base_url , routes )
8+ full_main_css_path = "#{ Rails . root . to_s } /public#{ main_css_path } "
79
8- private
10+ routes . each do |route |
11+ css = Phantomjs . run ( PENTHOUSE_PATH , base_url + route , full_main_css_path )
12+ Rails . cache . write ( route , css , namespace : CACHE_NAMESPACE )
13+ end
14+ end
915
10- def penthouse_path
11- 'penthouse/penthouse.js '
16+ def self . fetch ( route )
17+ Rails . cache . read ( route , namespace : CACHE_NAMESPACE ) || ' '
1218 end
1319end
You can’t perform that action at this time.
0 commit comments