diff --git a/README.md b/README.md index d63579d..c11bc1b 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ rails generate critical_path_css:install The generator adds the following files: -* `config/critical_path_css.yml` +* `config/critical_path_css.yml` **Note:** This file supports ERB. * `lib/tasks/critical_path_css.rake` diff --git a/lib/critical-path-css-rails.rb b/lib/critical-path-css-rails.rb index 1e9d12b..be64a3c 100644 --- a/lib/critical-path-css-rails.rb +++ b/lib/critical-path-css-rails.rb @@ -4,8 +4,12 @@ module CriticalPathCss CACHE_NAMESPACE = 'critical-path-css' def self.generate(route) - Rails.cache.write(route, CssFetcher.new.fetch_route(route), - namespace: CACHE_NAMESPACE, expires_in: nil) + Rails.cache.write( + route, + CssFetcher.new.fetch_route(route), + namespace: CACHE_NAMESPACE, + expires_in: nil + ) end def self.generate_all @@ -19,7 +23,7 @@ def self.clear(route) end def self.clear_matched(routes) - Rails.cache.delete_matched(routes,namespace: CACHE_NAMESPACE) + Rails.cache.delete_matched(routes, namespace: CACHE_NAMESPACE) end def self.fetch(route) diff --git a/lib/critical_path_css/css_fetcher.rb b/lib/critical_path_css/css_fetcher.rb index 9892ec7..90fbb2f 100644 --- a/lib/critical_path_css/css_fetcher.rb +++ b/lib/critical_path_css/css_fetcher.rb @@ -17,10 +17,18 @@ def fetch_route(route) css_for_route route end - protected + protected def css_for_route(route) - Phantomjs.run(PENTHOUSE_PATH, @config.base_url + route, @config.css_path) + url = @config.base_url + route + + Phantomjs.run( + '--ignore-ssl-errors=true', + '--ssl-protocol=tlsv1', + PENTHOUSE_PATH, + url, + @config.css_path + ) end end end diff --git a/lib/critical_path_css/rails/version.rb b/lib/critical_path_css/rails/version.rb index f48757d..0bffe92 100644 --- a/lib/critical_path_css/rails/version.rb +++ b/lib/critical_path_css/rails/version.rb @@ -1,6 +1,6 @@ module CriticalPathCSS module Rails - VERSION = '0.3.0' + VERSION = '0.3.1' PENTHOUSE_VERSION = '0.3.4' end end diff --git a/lib/tasks/critical_path_css.rake b/lib/tasks/critical_path_css.rake index 4e32f54..7038ceb 100644 --- a/lib/tasks/critical_path_css.rake +++ b/lib/tasks/critical_path_css.rake @@ -5,12 +5,13 @@ namespace :critical_path_css do task generate: :environment do CriticalPathCss.generate_all end + desc 'Clear all critical CSS from the cache' task clear_all: :environment do - # Use the following for Redis cache implmentations - CriticalPathCss.clear_matched('*') - # Some other cache implementations may require the following syntax instead - # CriticalPathCss.clear_matched(/.*/) + # Use the following for Redis cache implmentations + CriticalPathCss.clear_matched('*') + # Some other cache implementations may require the following syntax instead + # CriticalPathCss.clear_matched(/.*/) end end