critical-path-css-rails 4.0.0 → 4.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: '08ec0e946568daafe54e1f4ba27b0929b7bc35e8'
4
- data.tar.gz: 79e1df6faa04e11317606cb17fb441fe807ed553
3
+ metadata.gz: c0977819dee8b4d3adb090674cd192ec08305a5a
4
+ data.tar.gz: bc12acec227acf35e7feb97c3029f9cd85bfb03e
5
5
  SHA512:
6
- metadata.gz: 7346465c020d963768750f88c72104adc7e4ed0e4db4c025f7f8e46e7fa57d6073bf9f5eeb4cd7d4d9ef1788fe6023c48ca486dd1df34247ba4db5c7c96bbb16
7
- data.tar.gz: 26a51e85ba3d431c26924e66f85aceeb15493d1428b36211e5368d3c8b76267a253bf163864da395a7cfb588dfad4e9a597892de9a4c659e615df409eb6c0f7d
6
+ metadata.gz: 545374b679ccd3795afe8c5eb44a1f2b4a60cb5cbbeda1a58b27a8c8f09fce963f68c00010d5cf611b03ef58d01018c7d1547852966caa60a1973a9bd8e623ed
7
+ data.tar.gz: 00074b868a74df74882f751e44533432dc9e1f9332b95b2e08e5d2206a32fe308c4e404b900466b61fe35413317697521bcd93c204740e4d80e357c37923c242
data/README.md CHANGED
@@ -52,9 +52,11 @@ The generator adds the following files:
52
52
 
53
53
  First, you'll need to configue a few things in the YAML file: `config/critical_path_css.yml`
54
54
 
55
+ **Note** that `manifest_name`, `css_path`, `css_paths` are all **mutually exclusive**; if using `css_path`, configuration for `manifest_name` AND `css_paths` should be omitted.
56
+
55
57
  * `manifest_name`: If you're using the asset pipeline, add the manifest name.
56
58
  * `css_path`: If you're not using the asset pipeline, you'll need to define the path to the application's main CSS. The gem assumes your CSS lives in `RAILS_ROOT/public`. If your main CSS file is in `RAILS_ROOT/public/assets/main.css`, you would set the variable to `/assets/main.css`.
57
- * `css_paths`: If you have the need to specify multiple CSS source files, you can do so with `css_paths`. Note that `css_path` and `css_paths` are **mutually exclusive**; if using `css_path`, configuration for `css_paths` should be omitted, and vice versa. When using this option, a separate CSS path must be specified for each route, and they will be matched based on the order specified (the first CSS path will be applied to the first route, the second CSS path to the second route, etc).
59
+ * `css_paths`: If you have the need to specify multiple CSS source files, you can do so with `css_paths`. When using this option, a separate CSS path must be specified for each route, and they will be matched based on the order specified (the first CSS path will be applied to the first route, the second CSS path to the second route, etc).
58
60
  * `routes`: List the routes that you would like to generate the critical CSS for. (i.e. /resources, /resources/show/1, etc.)
59
61
  * `base_url`: Add your application's URL for the necessary environments.
60
62
 
@@ -33,7 +33,9 @@ module CriticalPathCss
33
33
  end
34
34
 
35
35
  def validate_css_paths
36
- if config['css_path'] && config['css_paths']
36
+ if config['manifest_name'] && (config['css_path'] || config['css_paths'])
37
+ raise LoadError, 'Cannot specify both manifest_name and css_path(s)'
38
+ elsif config['css_path'] && config['css_paths']
37
39
  raise LoadError, 'Cannot specify both css_path and css_paths'
38
40
  elsif config['css_paths'] && config['css_paths'].length != config['routes'].length
39
41
  raise LoadError, 'Must specify css_paths for each route'
@@ -1,5 +1,5 @@
1
1
  module CriticalPathCSS
2
2
  module Rails
3
- VERSION = '4.0.0'.freeze
3
+ VERSION = '4.0.1'.freeze
4
4
  end
5
5
  end
@@ -0,0 +1,10 @@
1
+ defaults: &defaults
2
+ base_url: http://0.0.0.0:9292
3
+ manifest_name: application
4
+ css_path: /test.css
5
+
6
+ development:
7
+ <<: *defaults
8
+
9
+ test:
10
+ <<: *defaults
@@ -0,0 +1,15 @@
1
+ defaults: &defaults
2
+ base_url: http://0.0.0.0:9292
3
+ manifest_name: application
4
+ css_paths:
5
+ - /test.css
6
+ - /test2.css
7
+ routes:
8
+ - /
9
+ - /new_route
10
+
11
+ development:
12
+ <<: *defaults
13
+
14
+ test:
15
+ <<: *defaults
@@ -32,6 +32,22 @@ RSpec.describe 'ConfigLoader' do
32
32
  end
33
33
  end
34
34
 
35
+ context 'when manifest name and css path are both specified' do
36
+ let(:config_file) { file_fixture('config/manifest-and-path-both-specified.yml').read }
37
+
38
+ it 'raises an error' do
39
+ expect { subject }.to raise_error LoadError, 'Cannot specify both manifest_name and css_path(s)'
40
+ end
41
+ end
42
+
43
+ context 'when manifest name and css paths are both specified' do
44
+ let(:config_file) { file_fixture('config/manifest-and-paths-both-specified.yml').read }
45
+
46
+ it 'raises an error' do
47
+ expect { subject }.to raise_error LoadError, 'Cannot specify both manifest_name and css_path(s)'
48
+ end
49
+ end
50
+
35
51
  context 'when single css_path and multiple css_paths are both specified' do
36
52
  let(:config_file) { file_fixture('config/paths-both-specified.yml').read }
37
53
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: critical-path-css-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.0
4
+ version: 4.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Misshore
@@ -68,6 +68,8 @@ files:
68
68
  - package-lock.json
69
69
  - package.json
70
70
  - spec/features/generate_and_fetch_critical_css_spec.rb
71
+ - spec/fixtures/files/config/manifest-and-path-both-specified.yml
72
+ - spec/fixtures/files/config/manifest-and-paths-both-specified.yml
71
73
  - spec/fixtures/files/config/mutliple-css-paths.yml
72
74
  - spec/fixtures/files/config/no-paths-specified.yml
73
75
  - spec/fixtures/files/config/paths-and-routes-not-same-length.yml