Module: Critical
- Defined in:
- lib/critical.rb,
lib/critical/version.rb
Overview
Calls the npm package “critical”. See: github.com/addyosmani/critical
Constant Summary collapse
- GEM_ROOT =
File.('..', File.dirname(__FILE__)).freeze
- VERSION =
'0.1.2'- CRITICAL_VERSION =
'0.8.4'
Class Method Summary collapse
-
.generate(options) ⇒ Object
For more information and available options, see: github.com/addyosmani/critical.
Class Method Details
.generate(options) ⇒ Object
For more information and available options, see: github.com/addyosmani/critical
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/critical.rb', line 14 def self.generate() out, err, st = Dir.chdir(GEM_ROOT) do Open3.capture3('node', 'lib/critical-wrapper.js', JSON.dump()) end if !st.exitstatus.zero? || out.empty? && !err.empty? STDOUT.puts out STDERR.puts err fail "Failed to get critical CSS for:\n" + JSON.pretty_generate() end out end |