Skip to content

Commit eeb2bf3

Browse files
Merge pull request #16 from mudbugmedia/allow-ssl-phantomjs
Allow ssl phantomjs
2 parents 1879c02 + 404048b commit eeb2bf3

File tree

5 files changed

+24
-11
lines changed

5 files changed

+24
-11
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ rails generate critical_path_css:install
3434

3535
The generator adds the following files:
3636

37-
* `config/critical_path_css.yml`
37+
* `config/critical_path_css.yml` **Note:** This file supports ERB.
3838
* `lib/tasks/critical_path_css.rake`
3939

4040

lib/critical-path-css-rails.rb

+7-3
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,12 @@ module CriticalPathCss
44
CACHE_NAMESPACE = 'critical-path-css'
55

66
def self.generate(route)
7-
Rails.cache.write(route, CssFetcher.new.fetch_route(route),
8-
namespace: CACHE_NAMESPACE, expires_in: nil)
7+
Rails.cache.write(
8+
route,
9+
CssFetcher.new.fetch_route(route),
10+
namespace: CACHE_NAMESPACE,
11+
expires_in: nil
12+
)
913
end
1014

1115
def self.generate_all
@@ -19,7 +23,7 @@ def self.clear(route)
1923
end
2024

2125
def self.clear_matched(routes)
22-
Rails.cache.delete_matched(routes,namespace: CACHE_NAMESPACE)
26+
Rails.cache.delete_matched(routes, namespace: CACHE_NAMESPACE)
2327
end
2428

2529
def self.fetch(route)

lib/critical_path_css/css_fetcher.rb

+10-2
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,18 @@ def fetch_route(route)
1717
css_for_route route
1818
end
1919

20-
protected
20+
protected
2121

2222
def css_for_route(route)
23-
Phantomjs.run(PENTHOUSE_PATH, @config.base_url + route, @config.css_path)
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+
)
2432
end
2533
end
2634
end
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module CriticalPathCSS
22
module Rails
3-
VERSION = '0.3.0'
3+
VERSION = '0.3.1'
44
PENTHOUSE_VERSION = '0.3.4'
55
end
66
end

lib/tasks/critical_path_css.rake

+5-4
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@ namespace :critical_path_css do
55
task generate: :environment do
66
CriticalPathCss.generate_all
77
end
8+
89
desc 'Clear all critical CSS from the cache'
910
task clear_all: :environment do
10-
# Use the following for Redis cache implmentations
11-
CriticalPathCss.clear_matched('*')
12-
# Some other cache implementations may require the following syntax instead
13-
# CriticalPathCss.clear_matched(/.*/)
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(/.*/)
1415
end
1516
end
1617

0 commit comments

Comments
 (0)