rails_critical_css 0.3.1 → 0.3.3

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
  SHA256:
3
- metadata.gz: 84662f8f4410652f07058871afd1cfd07fe33b4d421794f9de6e7ddc3faf792a
4
- data.tar.gz: 67bc3f8e124bdcc17d368ae2029d7ae422fd7a758f7deb217c56134752fde4c4
3
+ metadata.gz: a63c607b947a35a265392779b333a367e119d574130f8b7f0b1f745df9535554
4
+ data.tar.gz: 48187a28c02aff8e0aa0877484fe39ea6f4bfbf577b6f38581922d9a433ef24a
5
5
  SHA512:
6
- metadata.gz: 785c0d745864e57f73c3e3174058a5250cabb79c9572cd6e8ea2eb5724bf969f45f4aab398a562ccbaa67799a611e84fafe729520b755e8f6d69032a5e71fb6f
7
- data.tar.gz: c1f42781caba50cd5ee79ee70fd0561a0a87fe360541343b727215bc87ba72ca16ace6706d3ea5c5d6f6295d9a43f0342197811b5cf0a9dda8549669fd3b7153
6
+ metadata.gz: c24f929a7f0d865307a15007e7a250506e4e7876c4e76c4711a8651ab99b497f6b81b173ba86e10308bb637d8a6f24985d5ed1cddee548f565beec6dc06749df
7
+ data.tar.gz: 6da026a319d05b614c0ea0f346f1c62df9fcc65dd265eb6e23df7c7965c619e0e798afd63d3fe3d4679abe75ce87bbc071e71dce6a34064a7ac7758e0090bd7b
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rails_critical_css (0.3.1)
4
+ rails_critical_css (0.3.3)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -20,7 +20,7 @@ Install `penthouse` NPM package in your project. Be sure that node_modules/ dire
20
20
  In initializer:
21
21
 
22
22
  ```ruby
23
- CriticalCssGenerator.config do |c|
23
+ RailsCriticalCss.config do |c|
24
24
  c.keep_larger_media_queries = true
25
25
  c.height = 19999 # prevent CLS on for example footer
26
26
  end
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module CriticalCssGenerator::Actions
3
+ module RailsCriticalCss::Actions
4
4
  class AfterRender
5
- include CriticalCssGenerator::Actions::Helpers
5
+ include RailsCriticalCss::Actions::Helpers
6
6
 
7
7
  def initialize(filter_options)
8
8
  @packed_options = filter_options.slice(
@@ -19,7 +19,7 @@ module CriticalCssGenerator::Actions
19
19
 
20
20
  return if cache_path == false
21
21
 
22
- CriticalCssGenerator::Jobs::Extractor.perform_if_semaphore_is_released(
22
+ RailsCriticalCss::Jobs::Extractor.perform_if_semaphore_is_released(
23
23
  html: controller.full_html_response,
24
24
  cache: {
25
25
  path: cache_path,
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module CriticalCssGenerator::Actions
3
+ module RailsCriticalCss::Actions
4
4
  class BeforeRender
5
- include CriticalCssGenerator::Actions::Helpers
5
+ include RailsCriticalCss::Actions::Helpers
6
6
 
7
7
  def initialize(filter_options)
8
8
  @packed_options = filter_options.slice(:css, :cache_key, :cache_prefix)
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module CriticalCssGenerator::Actions::Helpers
3
+ module RailsCriticalCss::Actions::Helpers
4
4
  def group_assets_by_type(assets)
5
5
  return [] unless assets.present?
6
6
 
@@ -1,10 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module CriticalCssGenerator::Actions
3
+ module RailsCriticalCss::Actions
4
4
  extend ActiveSupport::Concern
5
5
 
6
6
  included do
7
- include CriticalCssGenerator::Helpers
7
+ include RailsCriticalCss::Helpers
8
8
 
9
9
  attr_accessor :lazy_css_blocks,
10
10
  :critical_css_assets,
@@ -50,8 +50,8 @@ module CriticalCssGenerator::Actions
50
50
  options[:cache_prefix] ||= 'critical-css'
51
51
 
52
52
  filter_options = options.extract!(:if, :unless).merge(only: actions)
53
- around_action CriticalCssGenerator::Actions::BeforeRender.new(options), filter_options
54
- after_action CriticalCssGenerator::Actions::AfterRender.new(options), filter_options
53
+ around_action RailsCriticalCss::Actions::BeforeRender.new(options), filter_options
54
+ after_action RailsCriticalCss::Actions::AfterRender.new(options), filter_options
55
55
  end
56
56
  end
57
57
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module CriticalCssGenerator
3
+ module RailsCriticalCss
4
4
  class Config
5
5
  class << self
6
6
  attr_writer :width, :height, :keep_larger_media_queries,
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module CriticalCssGenerator
3
+ module RailsCriticalCss
4
4
  class Extractor
5
- include CriticalCssGenerator::Actions::Helpers
5
+ include RailsCriticalCss::Actions::Helpers
6
6
 
7
7
  def initialize(options)
8
8
  @html, @css = options.values_at(:html, :css)
@@ -14,7 +14,7 @@ module CriticalCssGenerator
14
14
  return nil unless tmp_html_file.present? && tmp_css_file.present?
15
15
 
16
16
  stdout, stderr = Open3.capture2e(
17
- 'node lib/critical_css_generator/js/css-extractor.js',
17
+ 'node lib/rails_critical_css/js/css-extractor.js',
18
18
  stdin_data: Extractor.extractor_process_input(
19
19
  html_path: tmp_html_file.path,
20
20
  css_path: tmp_css_file.path,
@@ -37,7 +37,7 @@ module CriticalCssGenerator
37
37
  end
38
38
 
39
39
  def self.extractor_process_input(html_path:, css_path:)
40
- config = ::CriticalCssGenerator::Config.as_json_config({
40
+ config = ::RailsCriticalCss::Config.as_json_config({
41
41
  url: "file://#{html_path}",
42
42
  css: css_path,
43
43
  })
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module CriticalCssGenerator::Helpers
3
+ module RailsCriticalCss::Helpers
4
4
  def critical_css
5
5
  @critical_css_cache.try(:[], :css)
6
6
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module CriticalCssGenerator::Jobs
3
+ module RailsCriticalCss::Jobs
4
4
  class Extractor < ActiveJob::Base
5
5
  class << self
6
6
  def semaphore_key(cache_path)
@@ -18,7 +18,7 @@ module CriticalCssGenerator::Jobs
18
18
 
19
19
  def perform(cache:, css:, html:)
20
20
  semaphore = self.class.semaphore_key(cache[:path])
21
- critical_css = ::CriticalCssGenerator::Extractor.new(css: css, html: html).try_extract
21
+ critical_css = ::RailsCriticalCss::Extractor.new(css: css, html: html).try_extract
22
22
 
23
23
  # store it as wrapped css, do not regenerate for
24
24
  # each request critical_css if something go wrong
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
  require 'rails/railtie'
3
3
 
4
- module CriticalCssGenerator
4
+ module RailsCriticalCss
5
5
  class Railtie < Rails::Railtie
6
- config.eager_load_namespaces << CriticalCssGenerator
6
+ config.eager_load_namespaces << RailsCriticalCss
7
7
  end
8
8
  end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RailsCriticalCss
4
+ VERSION = '0.3.3'
5
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'open3'
4
+ require 'rails_critical_css/version'
5
+ require 'rails_critical_css/config'
6
+ require 'rails_critical_css/actions'
7
+ require 'rails_critical_css/actions/helpers'
8
+ require 'rails_critical_css/extractor'
9
+ require 'rails_critical_css/jobs/extractor'
10
+ require 'rails_critical_css/actions/after_render'
11
+ require 'rails_critical_css/actions/before_render'
12
+ require 'rails_critical_css/helpers'
13
+
14
+ module RailsCriticalCss
15
+ def self.config
16
+ yield RailsCriticalCss::Config
17
+ end
18
+ end
19
+
20
+ ActionController::Base.send(:include, RailsCriticalCss::Actions)
21
+ ActionView::Base.send(:include, RailsCriticalCss::Helpers)
@@ -1,8 +1,11 @@
1
- $:.push File.expand_path("../lib", __FILE__)
1
+ lib = File.expand_path('lib', __dir__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+
4
+ require 'rails_critical_css/version'
2
5
 
3
6
  Gem::Specification.new do |s|
4
7
  s.name = 'rails_critical_css'
5
- s.version = '0.3.1'
8
+ s.version = RailsCriticalCss::VERSION
6
9
  s.summary = 'Critical CSS rails generator'
7
10
  s.authors = ['Mateusz Bagiński']
8
11
 
@@ -11,6 +14,6 @@ Gem::Specification.new do |s|
11
14
  s.homepage = 'https://github.com/Mati365/rails-critical-css'
12
15
  s.files = `git ls-files`.split($/)
13
16
 
14
- s.require_paths << 'lib'
17
+ s.require_paths = ['lib']
15
18
  s.required_ruby_version = '>= 2.4.0'
16
19
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_critical_css
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mateusz Bagiński
@@ -22,17 +22,18 @@ files:
22
22
  - LICENSE
23
23
  - README.md
24
24
  - Rakefile
25
- - lib/critical_css_generator.rb
26
- - lib/critical_css_generator/actions.rb
27
- - lib/critical_css_generator/actions/after_render.rb
28
- - lib/critical_css_generator/actions/before_render.rb
29
- - lib/critical_css_generator/actions/helpers.rb
30
- - lib/critical_css_generator/config.rb
31
- - lib/critical_css_generator/extractor.rb
32
- - lib/critical_css_generator/helpers.rb
33
- - lib/critical_css_generator/jobs/extractor.rb
34
- - lib/critical_css_generator/railtie.rb
35
25
  - lib/js/css-extractor.js
26
+ - lib/rails_critical_css.rb
27
+ - lib/rails_critical_css/actions.rb
28
+ - lib/rails_critical_css/actions/after_render.rb
29
+ - lib/rails_critical_css/actions/before_render.rb
30
+ - lib/rails_critical_css/actions/helpers.rb
31
+ - lib/rails_critical_css/config.rb
32
+ - lib/rails_critical_css/extractor.rb
33
+ - lib/rails_critical_css/helpers.rb
34
+ - lib/rails_critical_css/jobs/extractor.rb
35
+ - lib/rails_critical_css/railtie.rb
36
+ - lib/rails_critical_css/version.rb
36
37
  - rails_critical_css.gemspec
37
38
  homepage: https://github.com/Mati365/rails-critical-css
38
39
  licenses:
@@ -42,7 +43,6 @@ post_install_message:
42
43
  rdoc_options: []
43
44
  require_paths:
44
45
  - lib
45
- - lib
46
46
  required_ruby_version: !ruby/object:Gem::Requirement
47
47
  requirements:
48
48
  - - ">="
@@ -1,21 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'open3'
4
- require 'critical_css_generator/config'
5
- require 'critical_css_generator/actions'
6
- require 'critical_css_generator/actions/helpers'
7
- require 'critical_css_generator/extractor'
8
- require 'critical_css_generator/jobs/extractor'
9
- require 'critical_css_generator/actions/after_render'
10
- require 'critical_css_generator/actions/before_render'
11
- require 'critical_css_generator/helpers'
12
- require 'critical_css_generator/railtie'
13
-
14
- module CriticalCssGenerator
15
- def self.config
16
- yield CriticalCssGenerator::Config
17
- end
18
- end
19
-
20
- ActionController::Base.send(:include, CriticalCssGenerator::Actions)
21
- ActionView::Base.send(:include, CriticalCssGenerator::Helpers)