critical-path-css-rails 1.0.1 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +0 -1
- data/.rubocop_todo.yml +23 -7
- data/BACKLOG.md +0 -4
- data/Gemfile +4 -0
- data/README.md +32 -13
- data/app_container_name +1 -0
- data/config.ru +6 -0
- data/critical-path-css-rails.gemspec +14 -14
- data/docker-compose.yml +21 -0
- data/docker/ruby/.env +1 -0
- data/docker/ruby/Dockerfile +21 -0
- data/docker/ruby/startup.dev +6 -0
- data/ext/npm/extconf.rb +0 -1
- data/lib/critical-path-css-rails.rb +1 -1
- data/lib/critical_path_css/configuration.rb +0 -1
- data/lib/critical_path_css/css_fetcher.rb +1 -6
- data/lib/critical_path_css/rails/config_loader.rb +2 -2
- data/lib/critical_path_css/rails/version.rb +1 -1
- data/lib/npm_commands.rb +2 -3
- data/package-lock.json +194 -622
- data/package.json +2 -2
- data/spec/features/generate_and_fetch_critical_css_spec.rb +16 -0
- data/spec/internal/app/controllers/root_controller.rb +3 -0
- data/spec/internal/app/views/layouts/application.html.erb +4 -0
- data/spec/internal/app/views/root/index.html.erb +1 -0
- data/spec/internal/config/critical_path_css.yml +11 -0
- data/spec/internal/config/database.yml +3 -0
- data/spec/internal/config/routes.rb +3 -0
- data/spec/internal/db/schema.rb +3 -0
- data/spec/internal/log/.gitignore +1 -0
- data/spec/internal/public/favicon.ico +0 -0
- data/spec/{fixtures/static → internal/public}/test.css +1 -1
- data/spec/spec_helper.rb +9 -3
- metadata +22 -9
- data/spec/css_fetcher_spec.rb +0 -25
- data/spec/fixtures/static/test.html +0 -7
- data/spec/support/static_file_server.rb +0 -45
data/package.json
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
{
|
2
2
|
"name": "critical-path-css-rails",
|
3
|
-
"version": "
|
3
|
+
"version": "2.3.0",
|
4
4
|
"description": "NPM dependencies of critical-path-css-rails",
|
5
5
|
"private": true,
|
6
6
|
"directories": {
|
7
7
|
"lib": "lib"
|
8
8
|
},
|
9
9
|
"dependencies": {
|
10
|
-
"penthouse": "=
|
10
|
+
"penthouse": "=1.3.0"
|
11
11
|
},
|
12
12
|
"license": "MIT"
|
13
13
|
}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'spec_helper.rb'
|
2
|
+
|
3
|
+
RSpec.describe 'generate and fetch the critical css' do
|
4
|
+
before do
|
5
|
+
CriticalPathCss.generate_all
|
6
|
+
end
|
7
|
+
|
8
|
+
context 'on the root page' do
|
9
|
+
let(:route) { '/' }
|
10
|
+
|
11
|
+
it 'displays the correct critical CSS' do
|
12
|
+
visit route
|
13
|
+
expect(page).to have_content 'p{color:red}'
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
<p><%= CriticalPathCss.fetch(request.path) %></p>
|
@@ -0,0 +1 @@
|
|
1
|
+
*.log
|
File without changes
|
data/spec/spec_helper.rb
CHANGED
@@ -1,11 +1,17 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'bundler
|
4
|
-
require 'critical-path-css-rails'
|
3
|
+
require 'bundler'
|
5
4
|
|
6
|
-
require
|
5
|
+
Bundler.require :default, :development
|
6
|
+
|
7
|
+
Combustion.initialize! :action_controller, :action_view
|
8
|
+
|
9
|
+
require 'rspec/rails'
|
10
|
+
require 'capybara/rails'
|
7
11
|
|
8
12
|
RSpec.configure do |config|
|
13
|
+
config.use_transactional_fixtures = true
|
14
|
+
|
9
15
|
# Enable flags like --only-failures and --next-failure
|
10
16
|
config.example_status_persistence_file_path = '.rspec_status'
|
11
17
|
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: critical-path-css-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Misshore
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-01-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: combustion
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 0.7.0
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 0.7.0
|
27
27
|
description: Only load the CSS you need for the initial viewport in Rails!
|
28
28
|
email: mmisshore@gmail.com
|
29
29
|
executables: []
|
@@ -39,7 +39,13 @@ files:
|
|
39
39
|
- Gemfile
|
40
40
|
- LICENSE
|
41
41
|
- README.md
|
42
|
+
- app_container_name
|
43
|
+
- config.ru
|
42
44
|
- critical-path-css-rails.gemspec
|
45
|
+
- docker-compose.yml
|
46
|
+
- docker/ruby/.env
|
47
|
+
- docker/ruby/Dockerfile
|
48
|
+
- docker/ruby/startup.dev
|
43
49
|
- ext/npm/extconf.rb
|
44
50
|
- ext/npm/install.rb
|
45
51
|
- lib/config/critical_path_css.yml
|
@@ -55,11 +61,18 @@ files:
|
|
55
61
|
- lib/tasks/critical_path_css.rake
|
56
62
|
- package-lock.json
|
57
63
|
- package.json
|
58
|
-
- spec/
|
59
|
-
- spec/
|
60
|
-
- spec/
|
64
|
+
- spec/features/generate_and_fetch_critical_css_spec.rb
|
65
|
+
- spec/internal/app/controllers/root_controller.rb
|
66
|
+
- spec/internal/app/views/layouts/application.html.erb
|
67
|
+
- spec/internal/app/views/root/index.html.erb
|
68
|
+
- spec/internal/config/critical_path_css.yml
|
69
|
+
- spec/internal/config/database.yml
|
70
|
+
- spec/internal/config/routes.rb
|
71
|
+
- spec/internal/db/schema.rb
|
72
|
+
- spec/internal/log/.gitignore
|
73
|
+
- spec/internal/public/favicon.ico
|
74
|
+
- spec/internal/public/test.css
|
61
75
|
- spec/spec_helper.rb
|
62
|
-
- spec/support/static_file_server.rb
|
63
76
|
homepage:
|
64
77
|
licenses:
|
65
78
|
- MIT
|
data/spec/css_fetcher_spec.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
RSpec.describe 'CssFetcher' do
|
6
|
-
before :all do
|
7
|
-
StaticFileServer.start
|
8
|
-
end
|
9
|
-
|
10
|
-
after :all do
|
11
|
-
StaticFileServer.stop
|
12
|
-
end
|
13
|
-
|
14
|
-
it 'fetches css' do
|
15
|
-
config = CriticalPathCss::Configuration.new(
|
16
|
-
'base_url' => StaticFileServer.url,
|
17
|
-
'css_path' => 'spec/fixtures/static/test.css',
|
18
|
-
'routes' => ['/test.html']
|
19
|
-
)
|
20
|
-
fetcher = CriticalPathCss::CssFetcher.new(config)
|
21
|
-
expect(fetcher.fetch).to(
|
22
|
-
eq('/test.html' => "p {\n color: red;\n}\n")
|
23
|
-
)
|
24
|
-
end
|
25
|
-
end
|
@@ -1,45 +0,0 @@
|
|
1
|
-
require 'socket'
|
2
|
-
|
3
|
-
module StaticFileServer
|
4
|
-
class << self
|
5
|
-
def start # rubocop:disable Metrics/MethodLength,Metrics/AbcSize
|
6
|
-
@port = get_free_port
|
7
|
-
rd, wt = IO.pipe
|
8
|
-
@pid = fork do
|
9
|
-
require 'webrick'
|
10
|
-
rd.close
|
11
|
-
server = WEBrick::HTTPServer.new(
|
12
|
-
DocumentRoot: File.expand_path('spec/fixtures/static'),
|
13
|
-
Port: @port,
|
14
|
-
BindAddress: '127.0.0.1',
|
15
|
-
StartCallback: lambda do
|
16
|
-
# write "1", signal a server start message
|
17
|
-
wt.write(1)
|
18
|
-
wt.close
|
19
|
-
end
|
20
|
-
)
|
21
|
-
trap('INT') { server.shutdown }
|
22
|
-
server.start
|
23
|
-
end
|
24
|
-
wt.close
|
25
|
-
# read a byte for the server start signal
|
26
|
-
rd.read(1)
|
27
|
-
rd.close
|
28
|
-
end
|
29
|
-
|
30
|
-
def stop
|
31
|
-
Process.kill('INT', @pid)
|
32
|
-
end
|
33
|
-
|
34
|
-
def url
|
35
|
-
"http://localhost:#{@port}"
|
36
|
-
end
|
37
|
-
|
38
|
-
def get_free_port
|
39
|
-
server = TCPServer.new('127.0.0.1', 0)
|
40
|
-
port = server.addr[1]
|
41
|
-
server.close
|
42
|
-
port
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|