From ca0e18e6774b3d1b87353fcdd429f1b5332a6b9c Mon Sep 17 00:00:00 2001
From: Larry Botha
Date: Thu, 23 Oct 2014 01:12:17 +0200
Subject: [PATCH 01/43] Update README.md
---
README.md | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/README.md b/README.md
index a847dfe..f1ac2c4 100644
--- a/README.md
+++ b/README.md
@@ -85,6 +85,16 @@ If you have more questions about how it works, look at the code or contact us.
Note that if you used versions below `0.4.0` of this gem, the naming and contents of the split files have changed. Split files no longer need to have the `.split2` extension and now use the `require` directive rather than the `include` directive. The previous prohibition against using `require_tree .` and `require_self` directives also no longer applies. For more details see the [CHANGELOG.md](CHANGELOG.md#040)
+#### Empty *_split2.css file
+
+In development the `?body=1` parameter tells Sprockets to retrieve the non-precompiled version of the file for debugging. If your `*_split2.css` file is empty, open the file in a new tab, and remove the `?body=1` parameter. If your generated CSS is showing, you can temporarily disable debugging (and thus serve the compiled versions) for your split file:
+
+```
+<%= split_stylesheet_link_tag "application", debug: false %>
+```
+
+Note that it's probably a good idea not to set `debug: false` on your assets indefinitely. Discussion at [issue #37](https://github.com/zweilove/css_splitter/issues/37).
+
## Credits & License
This is a joint project by the two German Rails shops [Zweitag](http://zweitag.de) and [Railslove](http://railslove.com), therefore the GitHub name "Zweilove".
From e39735a369bf6b67a3901281e47a020d6c1ec20e Mon Sep 17 00:00:00 2001
From: Bartek Kruszczynski
Date: Mon, 24 Nov 2014 00:56:24 +0100
Subject: [PATCH 02/43] Add default debug: false for development.
Triigger travis build.
---
app/helpers/css_splitter/application_helper.rb | 8 ++++++--
test/dummy/app/views/layouts/application.html.erb | 2 +-
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/app/helpers/css_splitter/application_helper.rb b/app/helpers/css_splitter/application_helper.rb
index af5061d..ecfd2ef 100644
--- a/app/helpers/css_splitter/application_helper.rb
+++ b/app/helpers/css_splitter/application_helper.rb
@@ -6,7 +6,11 @@ def split_stylesheet_link_tag(*sources)
sources.map do |source|
split_sources = (2..split_count).map { |index| "#{source}_split#{index}" }
- split_sources << options
+ split_options = options.dup
+ if Rails.env == 'development' && !split_options.key?(:debug)
+ split_options[:debug] = false
+ end
+ split_sources << split_options
[
stylesheet_link_tag(source, options),
@@ -17,4 +21,4 @@ def split_stylesheet_link_tag(*sources)
end.flatten.join("\n").html_safe
end
end
-end
\ No newline at end of file
+end
diff --git a/test/dummy/app/views/layouts/application.html.erb b/test/dummy/app/views/layouts/application.html.erb
index 9fa37cd..f9e8544 100644
--- a/test/dummy/app/views/layouts/application.html.erb
+++ b/test/dummy/app/views/layouts/application.html.erb
@@ -5,7 +5,7 @@
<%= stylesheet_link_tag "application", :media => "all" %>
- <%= split_stylesheet_link_tag "too_big_stylesheet", :media => "all" %>
+ <%= split_stylesheet_link_tag "too_big_stylesheet", :media => "all", :debug => true %>
<%= csrf_meta_tags %>
From 7f2bd956590f6434835d2cc993a6480905cb11d6 Mon Sep 17 00:00:00 2001
From: Bartek Kruszczynski
Date: Thu, 27 Nov 2014 00:21:40 +0100
Subject: [PATCH 03/43] Test new conditional debug.
---
.../css_splitter/application_helper_test.rb | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/test/unit/helpers/css_splitter/application_helper_test.rb b/test/unit/helpers/css_splitter/application_helper_test.rb
index e42a401..421980a 100644
--- a/test/unit/helpers/css_splitter/application_helper_test.rb
+++ b/test/unit/helpers/css_splitter/application_helper_test.rb
@@ -18,5 +18,24 @@ class ApplicationHelperTest < ActionView::TestCase
assert_equal "\n", output
end
+ test "should default to false on splits" do
+ Rails.env = 'development'
+ output = split_stylesheet_link_tag("too_big_stylesheet")
+ Rails.env = 'test'
+ assert_equal "\n", output
+ end
+
+ test "should respect the debug=true option" do
+ Rails.env = 'development'
+ output = split_stylesheet_link_tag("too_big_stylesheet", debug: true)
+ Rails.env = 'test'
+ assert_equal "\n", output
+ end
+ test "should respect the debug=false option" do
+ Rails.env = 'development'
+ output = split_stylesheet_link_tag("too_big_stylesheet", debug: false)
+ Rails.env = 'test'
+ assert_equal "\n", output
+ end
end
end
From e12a836a574d45e9aa8f1447a57d320b767150cc Mon Sep 17 00:00:00 2001
From: Bartek Kruszczynski
Date: Thu, 27 Nov 2014 00:27:26 +0100
Subject: [PATCH 04/43] Change README and CHANGELOG to reflect changes.
---
CHANGELOG.md | 4 ++++
README.md | 4 +---
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index e81b980..97ad6ee 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,7 @@
+# 0.4.1
+
+* [Improvement] All `*_splitN.css` files default to `debug: false` in development to prevent empty file bug.
+
# 0.4.0
* **Breaking changes!**
diff --git a/README.md b/README.md
index f1ac2c4..fef27db 100644
--- a/README.md
+++ b/README.md
@@ -87,14 +87,12 @@ Note that if you used versions below `0.4.0` of this gem, the naming and content
#### Empty *_split2.css file
-In development the `?body=1` parameter tells Sprockets to retrieve the non-precompiled version of the file for debugging. If your `*_split2.css` file is empty, open the file in a new tab, and remove the `?body=1` parameter. If your generated CSS is showing, you can temporarily disable debugging (and thus serve the compiled versions) for your split file:
+Since 0.4.1 in development split stylesheets have `debug: false` option by default. This prevents the empty `*_split2.css` file issue. You can always explicitly go one way or the other setting `debug` option directly in the `split_stylesheet_link_tag` like this:
```
<%= split_stylesheet_link_tag "application", debug: false %>
```
-Note that it's probably a good idea not to set `debug: false` on your assets indefinitely. Discussion at [issue #37](https://github.com/zweilove/css_splitter/issues/37).
-
## Credits & License
This is a joint project by the two German Rails shops [Zweitag](http://zweitag.de) and [Railslove](http://railslove.com), therefore the GitHub name "Zweilove".
From 0d4651eb530e8559d4097c142110e96e7b45ebf8 Mon Sep 17 00:00:00 2001
From: Bartek Kruszczynski
Date: Thu, 27 Nov 2014 10:46:50 +0100
Subject: [PATCH 05/43] Group tests for better readability.
---
.../css_splitter/application_helper_test.rb | 38 ++++++++++---------
1 file changed, 21 insertions(+), 17 deletions(-)
diff --git a/test/unit/helpers/css_splitter/application_helper_test.rb b/test/unit/helpers/css_splitter/application_helper_test.rb
index 421980a..2d2a75c 100644
--- a/test/unit/helpers/css_splitter/application_helper_test.rb
+++ b/test/unit/helpers/css_splitter/application_helper_test.rb
@@ -18,24 +18,28 @@ class ApplicationHelperTest < ActionView::TestCase
assert_equal "\n", output
end
- test "should default to false on splits" do
- Rails.env = 'development'
- output = split_stylesheet_link_tag("too_big_stylesheet")
- Rails.env = 'test'
- assert_equal "\n", output
- end
+ class RailsEnvDefault < ActionView::TestCase
+ setup do
+ Rails.env = 'development'
+ end
- test "should respect the debug=true option" do
- Rails.env = 'development'
- output = split_stylesheet_link_tag("too_big_stylesheet", debug: true)
- Rails.env = 'test'
- assert_equal "\n", output
- end
- test "should respect the debug=false option" do
- Rails.env = 'development'
- output = split_stylesheet_link_tag("too_big_stylesheet", debug: false)
- Rails.env = 'test'
- assert_equal "\n", output
+ teardown do
+ Rails.env = 'test'
+ end
+
+ test "should default to false on splits" do
+ output = split_stylesheet_link_tag("too_big_stylesheet")
+ assert_equal "\n", output
+ end
+
+ test "should respect the debug=true option" do
+ output = split_stylesheet_link_tag("too_big_stylesheet", debug: true)
+ assert_equal "\n", output
+ end
+ test "should respect the debug=false option" do
+ output = split_stylesheet_link_tag("too_big_stylesheet", debug: false)
+ assert_equal "\n", output
+ end
end
end
end
From bdc6008766b8e3250a568aa4e6ab7bff23511900 Mon Sep 17 00:00:00 2001
From: Jakob Hilden
Date: Thu, 5 Mar 2015 19:02:36 +0100
Subject: [PATCH 06/43] bump version
---
lib/css_splitter/version.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/css_splitter/version.rb b/lib/css_splitter/version.rb
index 1c14b2c..18e0de4 100644
--- a/lib/css_splitter/version.rb
+++ b/lib/css_splitter/version.rb
@@ -1,3 +1,3 @@
module CssSplitter
- VERSION = "0.4.0"
+ VERSION = "0.4.1"
end
From 8f142c27f8573c2d657eb1ce4ff2bc410baef6df Mon Sep 17 00:00:00 2001
From: Jakob Hilden
Date: Thu, 5 Mar 2015 19:04:06 +0100
Subject: [PATCH 07/43] update contributors
---
README.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/README.md b/README.md
index fef27db..0a86631 100644
--- a/README.md
+++ b/README.md
@@ -102,6 +102,7 @@ The original code was written by [Christian Peters](mailto:christian.peters@zwei
**Major Contributors**
* [@Umofomia](https://github.com/Umofomia)
+* [@kruszczynski](https://github.com/kruszczynski)
This project rocks and uses MIT-LICENSE.
From 30a23e3ac5ab530f78d3d57113e269ff539f857b Mon Sep 17 00:00:00 2001
From: Bartek Kruszczynski
Date: Sun, 12 Apr 2015 17:03:22 +0200
Subject: [PATCH 08/43] Fix ApplicationHelper test to play well with rails 4.2
---
.../helpers/css_splitter/application_helper_test.rb | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/test/unit/helpers/css_splitter/application_helper_test.rb b/test/unit/helpers/css_splitter/application_helper_test.rb
index 2d2a75c..4dc8d39 100644
--- a/test/unit/helpers/css_splitter/application_helper_test.rb
+++ b/test/unit/helpers/css_splitter/application_helper_test.rb
@@ -5,17 +5,17 @@ class ApplicationHelperTest < ActionView::TestCase
test "should work w/out options" do
output = split_stylesheet_link_tag("too_big_stylesheet")
- assert_equal "\n", output
+ assert_equal "\n", output
end
test "should work with options and multiple stylesheets" do
output = split_stylesheet_link_tag("too_big_stylesheet", "foo", media: "print")
- assert_equal "\n\n\n", output
+ assert_equal "\n\n\n", output
end
test "should work with split_count option" do
output = split_stylesheet_link_tag("too_big_stylesheet", split_count: 3)
- assert_equal "\n", output
+ assert_equal "\n", output
end
class RailsEnvDefault < ActionView::TestCase
@@ -29,16 +29,16 @@ class RailsEnvDefault < ActionView::TestCase
test "should default to false on splits" do
output = split_stylesheet_link_tag("too_big_stylesheet")
- assert_equal "\n", output
+ assert_equal "\n", output
end
test "should respect the debug=true option" do
output = split_stylesheet_link_tag("too_big_stylesheet", debug: true)
- assert_equal "\n", output
+ assert_equal "\n", output
end
test "should respect the debug=false option" do
output = split_stylesheet_link_tag("too_big_stylesheet", debug: false)
- assert_equal "\n", output
+ assert_equal "\n", output
end
end
end
From 166ac592b0728647d8d2a262f22ccbb579396718 Mon Sep 17 00:00:00 2001
From: Steven van der Vegt
Date: Fri, 28 Aug 2015 20:57:36 +0200
Subject: [PATCH 09/43] Add failing test for css with keyframes
---
test/unit/keyframes.css | 16 ++++++++++++++++
test/unit/splitter_test.rb | 4 ++++
2 files changed, 20 insertions(+)
create mode 100644 test/unit/keyframes.css
diff --git a/test/unit/keyframes.css b/test/unit/keyframes.css
new file mode 100644
index 0000000..deeb3e3
--- /dev/null
+++ b/test/unit/keyframes.css
@@ -0,0 +1,16 @@
+.red {
+ color: red;
+}
+
+@keyframes my-animation {
+ 0% { top: 0px; }
+ 20% { top: 20px; }
+ 40% { top: 40px; }
+ 60% { top: 60px; }
+ 80% { top: 80px; }
+ 100% { top: 100px; }
+}
+
+.blue {
+ background-color: blue;
+}
diff --git a/test/unit/splitter_test.rb b/test/unit/splitter_test.rb
index b5c4b59..26b1abb 100644
--- a/test/unit/splitter_test.rb
+++ b/test/unit/splitter_test.rb
@@ -40,6 +40,10 @@ class CssSplitterTest < ActiveSupport::TestCase
assert_equal ["a{foo:bar;}", "@media print{b{baz:qux;}", "c{quux:corge;}", "}", "d{grault:garply;}"], CssSplitter::Splitter.split_string_into_rules(has_media)
end
+ test "#split_string_into_rules containing @keyframes" do
+ assert_equal 3, CssSplitter::Splitter.count_selectors('test/unit/keyframes.css')
+ end
+
# --- extract_charset ---
test '#extract_charset with no charset' do
From c2ea8f3e84cca52215e3e686095b0505cd414ae8 Mon Sep 17 00:00:00 2001
From: Ruben Swieringa
Date: Fri, 28 Aug 2015 22:05:03 +0200
Subject: [PATCH 10/43] Prevent CssSplitter::Splitter.split_string_into_rules
from breaking up @keyframes & @media blocks
---
lib/css_splitter/splitter.rb | 20 +++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)
diff --git a/lib/css_splitter/splitter.rb b/lib/css_splitter/splitter.rb
index fdb0f7c..dcf73ef 100644
--- a/lib/css_splitter/splitter.rb
+++ b/lib/css_splitter/splitter.rb
@@ -12,7 +12,21 @@ def self.split_string(css_string, split = 1, max_selectors = MAX_SELECTORS_DEFAU
# splits string into array of rules (also strips comments)
def self.split_string_into_rules(css_string)
- strip_comments(css_string).chomp.scan /[^}]*}/
+ partial_rules = strip_comments(css_string).chomp.scan /[^}]*}/
+ whole_rules = []
+ bracket_balance = 0
+
+ partial_rules.each do |rule|
+ if bracket_balance == 0
+ whole_rules << rule
+ else
+ whole_rules.last << rule
+ end
+
+ bracket_balance += get_rule_bracket_balance rule
+ end
+
+ whole_rules
end
# extracts the specified part of an overlong CSS string
@@ -107,6 +121,10 @@ def self.strip_comments(s)
s.gsub(/\/\*.*?\*\//m, "")
end
+ def self.get_rule_bracket_balance ( rule )
+ rule.scan( /}/ ).size - rule.scan( /{/ ).size
+ end
+
end
end
From 8418978262bd803788966b0df67730de9029303e Mon Sep 17 00:00:00 2001
From: Ruben Swieringa
Date: Sat, 29 Aug 2015 12:20:35 +0200
Subject: [PATCH 11/43] Allow for @media blocks to be split up
Conform to tests.
---
lib/css_splitter/splitter.rb | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/lib/css_splitter/splitter.rb b/lib/css_splitter/splitter.rb
index dcf73ef..1cf7a10 100644
--- a/lib/css_splitter/splitter.rb
+++ b/lib/css_splitter/splitter.rb
@@ -15,9 +15,16 @@ def self.split_string_into_rules(css_string)
partial_rules = strip_comments(css_string).chomp.scan /[^}]*}/
whole_rules = []
bracket_balance = 0
+ in_media_query = false
partial_rules.each do |rule|
- if bracket_balance == 0
+ if rule =~ /^@media/
+ in_media_query = true
+ elsif bracket_balance == 0
+ in_media_query = false
+ end
+
+ if bracket_balance == 0 || in_media_query
whole_rules << rule
else
whole_rules.last << rule
From 0b319d09bea60346085980a97550ddd3c58d9af0 Mon Sep 17 00:00:00 2001
From: Ruben Swieringa
Date: Sat, 29 Aug 2015 12:44:09 +0200
Subject: [PATCH 12/43] Set config.active_support.test_order to get rid of
deprecation warning for Rails 5
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
“DEPRECATION WARNING: You did not specify a value for the configuration option ‘active_support.test_order’. In Rails 5, the default value of this option will change from ‘:sorted’ to ‘:random’.
To disable this warning and keep the current behavior, you can add the following line to your ‘config/environments/test.rb’:”
---
test/dummy/config/environments/test.rb | 3 +++
1 file changed, 3 insertions(+)
diff --git a/test/dummy/config/environments/test.rb b/test/dummy/config/environments/test.rb
index 284daa5..7d5d219 100644
--- a/test/dummy/config/environments/test.rb
+++ b/test/dummy/config/environments/test.rb
@@ -29,6 +29,9 @@
# ActionMailer::Base.deliveries array.
config.action_mailer.delivery_method = :test
+ # run tests in a random order
+ config.active_support.test_order = :random
+
# Raise exception on mass assignment protection for Active Record models
# config.active_record.mass_assignment_sanitizer = :strict
From 8ea6dcc8e7eb4e7453ce1555d3b2e06b59656308 Mon Sep 17 00:00:00 2001
From: Ruben Swieringa
Date: Mon, 31 Aug 2015 19:45:09 +0200
Subject: [PATCH 13/43] Rename deprecated config.serve_static_assets to
config.serve_static_files
---
test/dummy/config/environments/test.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/test/dummy/config/environments/test.rb b/test/dummy/config/environments/test.rb
index 7d5d219..3171e7c 100644
--- a/test/dummy/config/environments/test.rb
+++ b/test/dummy/config/environments/test.rb
@@ -8,7 +8,7 @@
config.cache_classes = true
# Configure static asset server for tests with Cache-Control for performance
- config.serve_static_assets = true
+ config.serve_static_files = true
config.static_cache_control = "public, max-age=3600"
# Log error messages when you accidentally call methods on nil
From 3911379daa1058f0c9a5bebbd3d49643a023a9ae Mon Sep 17 00:00:00 2001
From: Ruben Swieringa
Date: Mon, 31 Aug 2015 19:48:45 +0200
Subject: [PATCH 14/43] Rewrite split_string_into_rules() test to compare
actual array-contents returned from @keyframes stylesheet
...rather than just the array length
---
test/unit/keyframes.css | 16 ----------------
test/unit/splitter_test.rb | 5 +++--
2 files changed, 3 insertions(+), 18 deletions(-)
delete mode 100644 test/unit/keyframes.css
diff --git a/test/unit/keyframes.css b/test/unit/keyframes.css
deleted file mode 100644
index deeb3e3..0000000
--- a/test/unit/keyframes.css
+++ /dev/null
@@ -1,16 +0,0 @@
-.red {
- color: red;
-}
-
-@keyframes my-animation {
- 0% { top: 0px; }
- 20% { top: 20px; }
- 40% { top: 40px; }
- 60% { top: 60px; }
- 80% { top: 80px; }
- 100% { top: 100px; }
-}
-
-.blue {
- background-color: blue;
-}
diff --git a/test/unit/splitter_test.rb b/test/unit/splitter_test.rb
index 26b1abb..bcbb8e7 100644
--- a/test/unit/splitter_test.rb
+++ b/test/unit/splitter_test.rb
@@ -40,8 +40,9 @@ class CssSplitterTest < ActiveSupport::TestCase
assert_equal ["a{foo:bar;}", "@media print{b{baz:qux;}", "c{quux:corge;}", "}", "d{grault:garply;}"], CssSplitter::Splitter.split_string_into_rules(has_media)
end
- test "#split_string_into_rules containing @keyframes" do
- assert_equal 3, CssSplitter::Splitter.count_selectors('test/unit/keyframes.css')
+ test "#split_string_into_rules containing keyframes" do
+ has_keyframes = "a{foo:bar;}@keyframes rubes{from{baz:qux;}50%{quux:corge;}}d{grault:garply;}"
+ assert_equal ["a{foo:bar;}", "@keyframes rubes{from{baz:qux;}50%{quux:corge;}}", "d{grault:garply;}"], CssSplitter::Splitter.split_string_into_rules(has_keyframes)
end
# --- extract_charset ---
From 5f9cfbd085703d745d9c0f126a9f6f72cc5afe58 Mon Sep 17 00:00:00 2001
From: Jakob Hilden
Date: Tue, 1 Sep 2015 18:57:35 +0200
Subject: [PATCH 15/43] prevent deprecation warnings inside dummy app
---
test/dummy/config/environments/production.rb | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/test/dummy/config/environments/production.rb b/test/dummy/config/environments/production.rb
index 5f2d7d7..7ad11fe 100644
--- a/test/dummy/config/environments/production.rb
+++ b/test/dummy/config/environments/production.rb
@@ -9,7 +9,7 @@
config.action_controller.perform_caching = true
# Disable Rails's static asset server (Apache or nginx will already do this)
- config.serve_static_assets = false
+ config.serve_static_files = false
# Compress JavaScripts and CSS
config.assets.compress = true
@@ -31,7 +31,7 @@
# config.force_ssl = true
# See everything in the log (default is :info)
- # config.log_level = :debug
+ config.log_level = :debug
# Prepend all log lines with the following tags
# config.log_tags = [ :subdomain, :uuid ]
From f7459364677353e48cbed39898df567bd4eeeba5 Mon Sep 17 00:00:00 2001
From: Jakob Hilden
Date: Thu, 3 Sep 2015 19:52:58 +0200
Subject: [PATCH 16/43] version 0.4.2
---
CHANGELOG.md | 4 ++++
lib/css_splitter/version.rb | 2 +-
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 97ad6ee..9aff500 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,7 @@
+# 0.4.2
+
+* [bugfix] correctly split stylesheets even if @keyframes are directly on the rule limit #55 by [@rubenswieringa](https://github.com/rubenswieringa)
+
# 0.4.1
* [Improvement] All `*_splitN.css` files default to `debug: false` in development to prevent empty file bug.
diff --git a/lib/css_splitter/version.rb b/lib/css_splitter/version.rb
index 18e0de4..22c192c 100644
--- a/lib/css_splitter/version.rb
+++ b/lib/css_splitter/version.rb
@@ -1,3 +1,3 @@
module CssSplitter
- VERSION = "0.4.1"
+ VERSION = "0.4.2"
end
From 87ab0fbb8ae48e79778272d3d861c70b39fd3bf4 Mon Sep 17 00:00:00 2001
From: Ernesto Acevedo
Date: Thu, 8 Oct 2015 12:36:59 -0300
Subject: [PATCH 17/43] Fix regex comparison for media queries
---
lib/css_splitter/splitter.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/css_splitter/splitter.rb b/lib/css_splitter/splitter.rb
index 1cf7a10..f5f6a25 100644
--- a/lib/css_splitter/splitter.rb
+++ b/lib/css_splitter/splitter.rb
@@ -18,7 +18,7 @@ def self.split_string_into_rules(css_string)
in_media_query = false
partial_rules.each do |rule|
- if rule =~ /^@media/
+ if rule =~ /^\s*@media/
in_media_query = true
elsif bracket_balance == 0
in_media_query = false
From bf64b9d6c192c06793864780fd8bc50c52ccbee7 Mon Sep 17 00:00:00 2001
From: Gareth Adams
Date: Mon, 7 Dec 2015 22:26:54 +0000
Subject: [PATCH 18/43] Add a secret_key_base to the test app config
Avoids a deprecation warning with Rails 4
---
test/dummy/config/secrets.yml | 2 ++
1 file changed, 2 insertions(+)
create mode 100644 test/dummy/config/secrets.yml
diff --git a/test/dummy/config/secrets.yml b/test/dummy/config/secrets.yml
new file mode 100644
index 0000000..7eb2e7e
--- /dev/null
+++ b/test/dummy/config/secrets.yml
@@ -0,0 +1,2 @@
+test:
+ secret_key_base: c2a98602cc1537b2e38d4f279f20d24db66ff86fe523ab5197529f2ea907b6d70e2dca2fa3da50dcc9cad7bb1b861f0c45b6920fc576cc3e170d8c1ded61887f
From 579cdca79370b1602b2e5ea43ef960309fc301b0 Mon Sep 17 00:00:00 2001
From: Gareth Adams
Date: Tue, 8 Dec 2015 01:09:42 +0000
Subject: [PATCH 19/43] Allow debugger in test environment too
---
Gemfile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Gemfile b/Gemfile
index 8a91985..866d014 100644
--- a/Gemfile
+++ b/Gemfile
@@ -5,7 +5,7 @@ source "http://rubygems.org"
# development dependencies will be added by default to the :development group.
gemspec
-group :development do
+group :development, :test do
gem 'pry-byebug'
end
From 10ce82e23ccc95838e7d4c6b40df12ccb65f4cdf Mon Sep 17 00:00:00 2001
From: Gareth Adams
Date: Tue, 8 Dec 2015 08:39:27 +0000
Subject: [PATCH 20/43] Add a test for media query with leading whitespace
---
test/unit/splitter_test.rb | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/test/unit/splitter_test.rb b/test/unit/splitter_test.rb
index bcbb8e7..f9713ea 100644
--- a/test/unit/splitter_test.rb
+++ b/test/unit/splitter_test.rb
@@ -40,6 +40,11 @@ class CssSplitterTest < ActiveSupport::TestCase
assert_equal ["a{foo:bar;}", "@media print{b{baz:qux;}", "c{quux:corge;}", "}", "d{grault:garply;}"], CssSplitter::Splitter.split_string_into_rules(has_media)
end
+ test '#split_string_into_rules containing media queries with leading whitespace' do
+ has_media = "a{foo:bar;}\n @media print{b{baz:qux;}c{quux:corge;}}d{grault:garply;}"
+ assert_equal ["a{foo:bar;}", "\n @media print{b{baz:qux;}", "c{quux:corge;}", "}", "d{grault:garply;}"], CssSplitter::Splitter.split_string_into_rules(has_media)
+ end
+
test "#split_string_into_rules containing keyframes" do
has_keyframes = "a{foo:bar;}@keyframes rubes{from{baz:qux;}50%{quux:corge;}}d{grault:garply;}"
assert_equal ["a{foo:bar;}", "@keyframes rubes{from{baz:qux;}50%{quux:corge;}}", "d{grault:garply;}"], CssSplitter::Splitter.split_string_into_rules(has_keyframes)
From c2a5b42714ace4d63ecd00fe6ca3742a25102360 Mon Sep 17 00:00:00 2001
From: Jakob Hilden
Date: Fri, 11 Dec 2015 09:51:04 +0100
Subject: [PATCH 21/43] version 0.4.3
---
CHANGELOG.md | 4 ++++
lib/css_splitter/version.rb | 2 +-
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9aff500..7c63865 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,7 @@
+# 0.4.3
+
+* [bugfix] for media queries with whitespace in front of them #57
+
# 0.4.2
* [bugfix] correctly split stylesheets even if @keyframes are directly on the rule limit #55 by [@rubenswieringa](https://github.com/rubenswieringa)
diff --git a/lib/css_splitter/version.rb b/lib/css_splitter/version.rb
index 22c192c..ae6eecc 100644
--- a/lib/css_splitter/version.rb
+++ b/lib/css_splitter/version.rb
@@ -1,3 +1,3 @@
module CssSplitter
- VERSION = "0.4.2"
+ VERSION = "0.4.3"
end
From 4ffc2d4814c2b87d6641cd6787b0ebf0ccc8321d Mon Sep 17 00:00:00 2001
From: Jakob Hilden
Date: Mon, 21 Dec 2015 10:26:57 +0100
Subject: [PATCH 22/43] limited maintenance mode
---
README.md | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/README.md b/README.md
index 0a86631..c8348c9 100644
--- a/README.md
+++ b/README.md
@@ -2,6 +2,11 @@
Gem for splitting up stylesheets that go beyond the IE limit of 4096 selectors, for Rails 3.1+ apps using the Asset Pipeline. You can read this [blogpost](http://railslove.com/blog/2013/03/08/overcoming-ies-4096-selector-limit-using-the-css-splitter-gem) for an explanation of this gem's background story.
+### Development status
+
+Since the original developers of this gem are not actively using it in any project at the moment, it is currently in **limited maintenance** mode. Issues are read and pull requests will be reviewed and merged, but there is currently no acitve maintenance/development.
+
+If you are an active user of the gem and would able to help out maintaining it, it would be greatly appreciated.
## Installation
From fb677509c97456bb5f7b4a2ce2f02b000faa490b Mon Sep 17 00:00:00 2001
From: Jakob Hilden
Date: Mon, 21 Dec 2015 10:27:51 +0100
Subject: [PATCH 23/43] Update README.md
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index c8348c9..77af792 100644
--- a/README.md
+++ b/README.md
@@ -6,7 +6,7 @@ Gem for splitting up stylesheets that go beyond the IE limit of 4096 selectors,
Since the original developers of this gem are not actively using it in any project at the moment, it is currently in **limited maintenance** mode. Issues are read and pull requests will be reviewed and merged, but there is currently no acitve maintenance/development.
-If you are an active user of the gem and would able to help out maintaining it, it would be greatly appreciated.
+If you are an active user of the gem and would be able to help out maintaining it, it would be greatly appreciated. Just look at the current issues/pull requests.
## Installation
From 8b5e2025045e9a0009e5c1ff961036f0b7116a4d Mon Sep 17 00:00:00 2001
From: Keenan Brock
Date: Wed, 23 Dec 2015 12:26:33 -0500
Subject: [PATCH 24/43] use recent ruby version
---
.travis.yml | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/.travis.yml b/.travis.yml
index f21f396..344b67b 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,5 +1,6 @@
+sudo: false
language: ruby
bundler_args: --without development
rvm:
- "1.9.3"
- - "2.1.1"
\ No newline at end of file
+ - "2.2"
From c5e37a8141c628a9eaddb55bfce5b96cb615f191 Mon Sep 17 00:00:00 2001
From: Stephen Eckenrode
Date: Mon, 28 Dec 2015 14:03:45 -0500
Subject: [PATCH 25/43] Gracefully handle when assets are not configured
In sprockets-rails v3, app.assets is now only set when assets.compile is
set to true. This is currently causing an error when upgrading to Rails
4.2.5.
This change will cause CSS Splitter to only be registered when assets
themselves are configured.
Fixes #60
---
lib/css_splitter/engine.rb | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/lib/css_splitter/engine.rb b/lib/css_splitter/engine.rb
index c51574e..335a5b1 100644
--- a/lib/css_splitter/engine.rb
+++ b/lib/css_splitter/engine.rb
@@ -3,7 +3,9 @@ class Engine < ::Rails::Engine
isolate_namespace CssSplitter
initializer 'css_splitter.sprockets_engine', after: 'sprockets.environment', group: :all do |app|
- app.assets.register_bundle_processor 'text/css', CssSplitter::SprocketsEngine
+ app.config.assets.configure do |assets|
+ assets.register_bundle_processor 'text/css', CssSplitter::SprocketsEngine
+ end
end
initializer 'css_splitter.action_controller' do |app|
From 632ee76ae907469455780d60d253b5b64f218695 Mon Sep 17 00:00:00 2001
From: Stephen Eckenrode
Date: Mon, 28 Dec 2015 14:12:11 -0500
Subject: [PATCH 26/43] Upgrade bundler before running Travis tests
---
.travis.yml | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/.travis.yml b/.travis.yml
index f21f396..7ae037c 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -2,4 +2,6 @@ language: ruby
bundler_args: --without development
rvm:
- "1.9.3"
- - "2.1.1"
\ No newline at end of file
+ - "2.1.1"
+before_install:
+ - gem update bundler
From 9a813e780cfd10034b9ecd00f0f191ac903596e6 Mon Sep 17 00:00:00 2001
From: Jakob Hilden
Date: Mon, 4 Jan 2016 15:05:10 +0100
Subject: [PATCH 27/43] installing byebug in test environment will break on
travis + ruby 1.9.x
---
Gemfile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Gemfile b/Gemfile
index 866d014..8a91985 100644
--- a/Gemfile
+++ b/Gemfile
@@ -5,7 +5,7 @@ source "http://rubygems.org"
# development dependencies will be added by default to the :development group.
gemspec
-group :development, :test do
+group :development do
gem 'pry-byebug'
end
From e10be4daaefde2bbde12145c93371af74e2e8820 Mon Sep 17 00:00:00 2001
From: Jakob Hilden
Date: Mon, 4 Jan 2016 15:09:04 +0100
Subject: [PATCH 28/43] test against multiple rails versions
---
.travis.yml | 2 ++
Gemfile | 8 --------
Gemfile.rails3 | 15 +++++++++++++++
3 files changed, 17 insertions(+), 8 deletions(-)
create mode 100644 Gemfile.rails3
diff --git a/.travis.yml b/.travis.yml
index 2839d69..2f483a7 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -5,3 +5,5 @@ rvm:
- "1.9.3"
- "2.1.1"
- "2.2"
+gemfile:
+ - "Gemfile.rails3"
\ No newline at end of file
diff --git a/Gemfile b/Gemfile
index 8a91985..74fab5c 100644
--- a/Gemfile
+++ b/Gemfile
@@ -13,11 +13,3 @@ gem "rails"
gem "sass-rails"
gem "jquery-rails"
gem "uglifier"
-
-# Declare any dependencies that are still in development here instead of in
-# your gemspec. These might include edge Rails or gems from your path or
-# Git. Remember to move these dependencies to your gemspec before releasing
-# your gem to rubygems.org.
-
-# To use debugger
-# gem 'debugger'
diff --git a/Gemfile.rails3 b/Gemfile.rails3
new file mode 100644
index 0000000..f511920
--- /dev/null
+++ b/Gemfile.rails3
@@ -0,0 +1,15 @@
+source "http://rubygems.org"
+
+# Declare your gem's dependencies in css_splitter.gemspec.
+# Bundler will treat runtime dependencies like base dependencies, and
+# development dependencies will be added by default to the :development group.
+gemspec
+
+group :development do
+ gem 'pry-byebug'
+end
+
+gem "rails", '~> 3.1'
+gem "sass-rails"
+gem "jquery-rails"
+gem "uglifier"
From 01f3adf265a8de0545817266ffbe06f12fa44d89 Mon Sep 17 00:00:00 2001
From: Jakob Hilden
Date: Mon, 4 Jan 2016 15:12:50 +0100
Subject: [PATCH 29/43] test both Gemfiles
---
.travis.yml | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/.travis.yml b/.travis.yml
index 2f483a7..eabf7de 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -3,7 +3,8 @@ language: ruby
bundler_args: --without development
rvm:
- "1.9.3"
- - "2.1.1"
+ - "2.1"
- "2.2"
gemfile:
+ - "Gemfile"
- "Gemfile.rails3"
\ No newline at end of file
From b8bf7e8d1583591a08cbf115dfd9a58ca4398859 Mon Sep 17 00:00:00 2001
From: Jakob Hilden
Date: Mon, 4 Jan 2016 15:21:41 +0100
Subject: [PATCH 30/43] don't install byebug for rails3 because travis is
failing
---
.gitignore | 1 +
Gemfile.rails3 | 4 ----
2 files changed, 1 insertion(+), 4 deletions(-)
diff --git a/.gitignore b/.gitignore
index a9ecfb8..8757807 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,6 @@
.bundle/
Gemfile.lock
+Gemfile.rails3.lock
log/*.log
pkg/
test/dummy/db/*.sqlite3
diff --git a/Gemfile.rails3 b/Gemfile.rails3
index f511920..a744df7 100644
--- a/Gemfile.rails3
+++ b/Gemfile.rails3
@@ -5,10 +5,6 @@ source "http://rubygems.org"
# development dependencies will be added by default to the :development group.
gemspec
-group :development do
- gem 'pry-byebug'
-end
-
gem "rails", '~> 3.1'
gem "sass-rails"
gem "jquery-rails"
From 5eee3181099ca2cfb824d9fa62cff8245b96ce63 Mon Sep 17 00:00:00 2001
From: Jakob Hilden
Date: Mon, 4 Jan 2016 15:29:00 +0100
Subject: [PATCH 31/43] remove 2nd rails 3 gemfile again
---
.gitignore | 1 -
.travis.yml | 3 +--
Gemfile.rails3 | 11 -----------
3 files changed, 1 insertion(+), 14 deletions(-)
delete mode 100644 Gemfile.rails3
diff --git a/.gitignore b/.gitignore
index 8757807..a9ecfb8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,5 @@
.bundle/
Gemfile.lock
-Gemfile.rails3.lock
log/*.log
pkg/
test/dummy/db/*.sqlite3
diff --git a/.travis.yml b/.travis.yml
index eabf7de..f09ded4 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -6,5 +6,4 @@ rvm:
- "2.1"
- "2.2"
gemfile:
- - "Gemfile"
- - "Gemfile.rails3"
\ No newline at end of file
+ - "Gemfile"
\ No newline at end of file
diff --git a/Gemfile.rails3 b/Gemfile.rails3
deleted file mode 100644
index a744df7..0000000
--- a/Gemfile.rails3
+++ /dev/null
@@ -1,11 +0,0 @@
-source "http://rubygems.org"
-
-# Declare your gem's dependencies in css_splitter.gemspec.
-# Bundler will treat runtime dependencies like base dependencies, and
-# development dependencies will be added by default to the :development group.
-gemspec
-
-gem "rails", '~> 3.1'
-gem "sass-rails"
-gem "jquery-rails"
-gem "uglifier"
From 0235df33c75e8154859fa40d4d0c1a816c44f36e Mon Sep 17 00:00:00 2001
From: Jakob Hilden
Date: Mon, 4 Jan 2016 15:42:10 +0100
Subject: [PATCH 32/43] fix up dummy app
---
test/dummy/config/initializers/assets.rb | 8 ++++++++
test/dummy/config/secrets.yml | 2 ++
2 files changed, 10 insertions(+)
create mode 100644 test/dummy/config/initializers/assets.rb
diff --git a/test/dummy/config/initializers/assets.rb b/test/dummy/config/initializers/assets.rb
new file mode 100644
index 0000000..b4de740
--- /dev/null
+++ b/test/dummy/config/initializers/assets.rb
@@ -0,0 +1,8 @@
+# Be sure to restart your server when you modify this file.
+
+# Version of your assets, change this if you want to expire all your assets.
+Rails.application.config.assets.version = '1.0'
+
+# Precompile additional assets.
+# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
+Rails.application.config.assets.precompile += %w( too_big_stylesheet.css too_big_stylesheet_split2.css )
\ No newline at end of file
diff --git a/test/dummy/config/secrets.yml b/test/dummy/config/secrets.yml
index 7eb2e7e..5dc368e 100644
--- a/test/dummy/config/secrets.yml
+++ b/test/dummy/config/secrets.yml
@@ -1,2 +1,4 @@
test:
secret_key_base: c2a98602cc1537b2e38d4f279f20d24db66ff86fe523ab5197529f2ea907b6d70e2dca2fa3da50dcc9cad7bb1b861f0c45b6920fc576cc3e170d8c1ded61887f
+development:
+ secret_key_base: c2a98602cc1537b2e38d4f279f20d24db66ff86fe523ab5197529f2ea907b6d70e2dca2fa3da50dcc9cad7bb1b861f0c45b6920fc576cc3e170d8c1ded61887f
\ No newline at end of file
From 3a953b285a3e03a02061e5072239f1756e4f15c0 Mon Sep 17 00:00:00 2001
From: Jakob Hilden
Date: Mon, 4 Jan 2016 15:46:54 +0100
Subject: [PATCH 33/43] move some options in the config file
---
test/dummy/config/application.rb | 3 ---
test/dummy/config/environments/production.rb | 3 ---
test/dummy/config/initializers/assets.rb | 2 +-
3 files changed, 1 insertion(+), 7 deletions(-)
diff --git a/test/dummy/config/application.rb b/test/dummy/config/application.rb
index 6a0af91..4e42755 100644
--- a/test/dummy/config/application.rb
+++ b/test/dummy/config/application.rb
@@ -55,9 +55,6 @@ class Application < Rails::Application
# Enable the asset pipeline
config.assets.enabled = true
-
- # Version of your assets, change this if you want to expire all your assets
- config.assets.version = '1.0'
end
end
diff --git a/test/dummy/config/environments/production.rb b/test/dummy/config/environments/production.rb
index 7ad11fe..d92c150 100644
--- a/test/dummy/config/environments/production.rb
+++ b/test/dummy/config/environments/production.rb
@@ -45,9 +45,6 @@
# Enable serving of images, stylesheets, and JavaScripts from an asset server
# config.action_controller.asset_host = "http://assets.example.com"
- # Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
- config.assets.precompile += %w( too_big_stylesheet.css too_big_stylesheet_split2.css test_stylesheet_with_media_queries.css test_stylesheet_with_media_queries_split2.css )
-
# Disable delivery errors, bad email addresses will be ignored
# config.action_mailer.raise_delivery_errors = false
diff --git a/test/dummy/config/initializers/assets.rb b/test/dummy/config/initializers/assets.rb
index b4de740..91073da 100644
--- a/test/dummy/config/initializers/assets.rb
+++ b/test/dummy/config/initializers/assets.rb
@@ -5,4 +5,4 @@
# Precompile additional assets.
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
-Rails.application.config.assets.precompile += %w( too_big_stylesheet.css too_big_stylesheet_split2.css )
\ No newline at end of file
+Rails.application.config.assets.precompile += %w( too_big_stylesheet.css too_big_stylesheet_split2.css test_stylesheet_with_media_queries.css test_stylesheet_with_media_queries_split2.css )
\ No newline at end of file
From c4b6e78e406a4c3145ac9265298c631471f3a4ff Mon Sep 17 00:00:00 2001
From: Jakob Hilden
Date: Mon, 4 Jan 2016 15:50:00 +0100
Subject: [PATCH 34/43] bump version to 0.4.4
---
CHANGELOG.md | 4 ++++
lib/css_splitter/version.rb | 2 +-
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 7c63865..bf1f58c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,7 @@
+# 0.4.4
+
+* [bugfix] fix compatibility with with sprockts-rails version 3.x, see #62
+
# 0.4.3
* [bugfix] for media queries with whitespace in front of them #57
diff --git a/lib/css_splitter/version.rb b/lib/css_splitter/version.rb
index ae6eecc..06e4f4e 100644
--- a/lib/css_splitter/version.rb
+++ b/lib/css_splitter/version.rb
@@ -1,3 +1,3 @@
module CssSplitter
- VERSION = "0.4.3"
+ VERSION = "0.4.4"
end
From 5e805e110b84e1b44a01e86832c44ac5b5ae1890 Mon Sep 17 00:00:00 2001
From: Scott Ringwelski
Date: Thu, 21 Jan 2016 21:41:24 -0800
Subject: [PATCH 35/43] Fix issue with ActionController::API:Class
Fix an issue where helper is not a defined method
---
lib/css_splitter/engine.rb | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/lib/css_splitter/engine.rb b/lib/css_splitter/engine.rb
index 335a5b1..4cdaba0 100644
--- a/lib/css_splitter/engine.rb
+++ b/lib/css_splitter/engine.rb
@@ -10,7 +10,8 @@ class Engine < ::Rails::Engine
initializer 'css_splitter.action_controller' do |app|
ActiveSupport.on_load :action_controller do
- helper CssSplitter::ApplicationHelper
+ # Not all controllers use helpers (such as API based controllers)
+ helper CssSplitter::ApplicationHelper if respond_to?(:helper)
end
end
end
From 8ba82ab7918ee06a8f1e0ce4af406fd371831dce Mon Sep 17 00:00:00 2001
From: Brad Pardee
Date: Mon, 4 Apr 2016 11:34:03 -0400
Subject: [PATCH 36/43] Remove isolate_namespace to fix unresolved
split_stylesheet_link_tag
---
lib/css_splitter/engine.rb | 2 --
1 file changed, 2 deletions(-)
diff --git a/lib/css_splitter/engine.rb b/lib/css_splitter/engine.rb
index 335a5b1..2f50392 100644
--- a/lib/css_splitter/engine.rb
+++ b/lib/css_splitter/engine.rb
@@ -1,7 +1,5 @@
module CssSplitter
class Engine < ::Rails::Engine
- isolate_namespace CssSplitter
-
initializer 'css_splitter.sprockets_engine', after: 'sprockets.environment', group: :all do |app|
app.config.assets.configure do |assets|
assets.register_bundle_processor 'text/css', CssSplitter::SprocketsEngine
From 45cb5bcf460afd0ed4ded6570e1b6d2a470312a1 Mon Sep 17 00:00:00 2001
From: achernyshev
Date: Thu, 14 Apr 2016 17:58:16 +0300
Subject: [PATCH 37/43] fix sprockets engine registering for older
sprocket-rails versions
---
lib/css_splitter/engine.rb | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/lib/css_splitter/engine.rb b/lib/css_splitter/engine.rb
index 2f50392..17122f3 100644
--- a/lib/css_splitter/engine.rb
+++ b/lib/css_splitter/engine.rb
@@ -1,8 +1,12 @@
module CssSplitter
class Engine < ::Rails::Engine
initializer 'css_splitter.sprockets_engine', after: 'sprockets.environment', group: :all do |app|
- app.config.assets.configure do |assets|
- assets.register_bundle_processor 'text/css', CssSplitter::SprocketsEngine
+ if app.config.assets.public_methods.include? :configure
+ app.config.assets.configure do |assets|
+ assets.register_bundle_processor 'text/css', CssSplitter::SprocketsEngine
+ end
+ else
+ app.assets.register_bundle_processor 'text/css', CssSplitter::SprocketsEngine
end
end
From 2a240553362fafa799f96b6bf6a5f343104df0df Mon Sep 17 00:00:00 2001
From: Jakob Hilden
Date: Wed, 25 May 2016 11:19:33 +0200
Subject: [PATCH 38/43] version 0.4.5
---
CHANGELOG.md | 4 ++++
lib/css_splitter/version.rb | 2 +-
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index bf1f58c..44ba31a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,7 @@
+# 0.4.5
+
+* [bugfix] fix sprockets engine registering for older sprocket-rails versions #68
+
# 0.4.4
* [bugfix] fix compatibility with with sprockts-rails version 3.x, see #62
diff --git a/lib/css_splitter/version.rb b/lib/css_splitter/version.rb
index 06e4f4e..c6d5586 100644
--- a/lib/css_splitter/version.rb
+++ b/lib/css_splitter/version.rb
@@ -1,3 +1,3 @@
module CssSplitter
- VERSION = "0.4.4"
+ VERSION = "0.4.5"
end
From db0fe7575012e9650c271259e75eb299976ae9f1 Mon Sep 17 00:00:00 2001
From: Jakob Hilden
Date: Wed, 1 Jun 2016 15:08:33 +0200
Subject: [PATCH 39/43] Update CHANGELOG.md
---
CHANGELOG.md | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 44ba31a..fc25e31 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,7 @@
+# 0.4.6 (unreleased)
+
+* [bugfix] Fix issue where helper is not a defined method on controller (e.g. ActionController::API:Class) #65
+
# 0.4.5
* [bugfix] fix sprockets engine registering for older sprocket-rails versions #68
From 24017c19c60739d2d1038e985687117839054150 Mon Sep 17 00:00:00 2001
From: Nick Donald
Date: Mon, 22 Aug 2016 06:13:32 -0400
Subject: [PATCH 40/43] Follow sproket engine interface guidelines (#70)
* Follow sproket engine interface guidelines
* Clarify syntax, add comments
---
lib/css_splitter/sprockets_engine.rb | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/lib/css_splitter/sprockets_engine.rb b/lib/css_splitter/sprockets_engine.rb
index f6ae2a8..551af8c 100644
--- a/lib/css_splitter/sprockets_engine.rb
+++ b/lib/css_splitter/sprockets_engine.rb
@@ -10,6 +10,22 @@ def self.engine_initialized?
def prepare
end
+ def self.call(input)
+ data_in = input[:data]
+
+ # Instantiate Sprockets::Context to pass along helper methods for Tilt
+ # processors
+ context = input[:environment].context_class.new(input)
+
+ # Pass the asset file contents as a block to the template engine,
+ # then get the results of the engine rendering
+ engine = self.new { data_in }
+ rendered_data = engine.render(context, {})
+
+ # Return the data and any metadata (ie file dependencies, etc)
+ context.metadata.merge(data: rendered_data.to_str)
+ end
+
def evaluate(scope, locals, &block)
# Evaluate the split if the asset is named with a trailing _split2, _split3, etc.
if scope.logical_path =~ /_split(\d+)$/
From 5010809517f4ed4fc2379af1c2b2573b5ae8a3f2 Mon Sep 17 00:00:00 2001
From: Jakob Hilden
Date: Sat, 27 Aug 2016 16:31:53 +0200
Subject: [PATCH 41/43] bump version to 0.4.6
---
CHANGELOG.md | 3 ++-
lib/css_splitter/version.rb | 2 +-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index fc25e31..cd411e3 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,6 @@
-# 0.4.6 (unreleased)
+# 0.4.6
+* [fix] Implement new engine interface for future sprockets versions #70
* [bugfix] Fix issue where helper is not a defined method on controller (e.g. ActionController::API:Class) #65
# 0.4.5
diff --git a/lib/css_splitter/version.rb b/lib/css_splitter/version.rb
index c6d5586..57859d1 100644
--- a/lib/css_splitter/version.rb
+++ b/lib/css_splitter/version.rb
@@ -1,3 +1,3 @@
module CssSplitter
- VERSION = "0.4.5"
+ VERSION = "0.4.6"
end
From 749e5410ea67a585b65d75aefbd8c5a0bf1467fd Mon Sep 17 00:00:00 2001
From: khiav reoy
Date: Sat, 22 Oct 2016 17:43:12 +0800
Subject: [PATCH 42/43] fix test in different gem version
---
test/css_splitter_test.rb | 11 +++++------
test/dummy/config/application.rb | 3 ++-
2 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/test/css_splitter_test.rb b/test/css_splitter_test.rb
index 5090a3d..012cf89 100644
--- a/test/css_splitter_test.rb
+++ b/test/css_splitter_test.rb
@@ -13,18 +13,17 @@ class CssSplitterTest < ActiveSupport::TestCase
part2 = "#test{background-color:green}" * CssSplitter::Splitter::MAX_SELECTORS_DEFAULT
part3 = "#test{background-color:blue}"
- assert_equal "#{part1}#{part2}#{part3}\n", assets["erb_stylesheet"].to_s
- assert_equal "#{part2}\n", assets["erb_stylesheet_split2"].to_s
- assert_equal "#{part3}\n", assets["erb_stylesheet_split3"].to_s
+ assert_equal "#{part1}#{part2}#{part3}", assets["erb_stylesheet"].to_s.gsub(/\s/, '')
+ assert_equal "#{part2}", assets["erb_stylesheet_split2"].to_s.gsub(/\s/, '')
+ assert_equal "#{part3}", assets["erb_stylesheet_split3"].to_s.gsub(/\s/, '')
end
test "asset pipeline stylesheet splitting on stylesheet combined using requires" do
red = "#test{background-color:red}" * 100
green = "#test{background-color:green}" * CssSplitter::Splitter::MAX_SELECTORS_DEFAULT
blue = "#test{background-color:blue}"
-
- assert_equal "#{red}#{green}#{blue}\n", assets["combined"].to_s
- assert_equal "#{"#test{background-color:green}" * 100}#{blue}\n", assets["combined_split2"].to_s
+ assert_equal "#{red}#{green}#{blue}", assets["combined"].to_s.gsub(/\s/, '')
+ assert_equal "#{"#test{background-color:green}" * 100}#{blue}", assets["combined_split2"].to_s.gsub(/\s/, '')
end
private
diff --git a/test/dummy/config/application.rb b/test/dummy/config/application.rb
index 4e42755..7a5b60e 100644
--- a/test/dummy/config/application.rb
+++ b/test/dummy/config/application.rb
@@ -38,7 +38,8 @@ class Application < Rails::Application
# Configure sensitive parameters which will be filtered from the log file.
config.filter_parameters += [:password]
-
+ config.sass.line_comments = false
+ config.assets.compress = true
# Enable escaping HTML in JSON.
config.active_support.escape_html_entities_in_json = true
From 6cc4244fdbe6599548bef790dc80c008dca1647e Mon Sep 17 00:00:00 2001
From: Christian Peters
Date: Wed, 22 Feb 2023 13:36:45 +0100
Subject: [PATCH 43/43] Clarify that this gem is dead
---
README.md | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/README.md b/README.md
index 77af792..d1b3805 100644
--- a/README.md
+++ b/README.md
@@ -4,9 +4,8 @@ Gem for splitting up stylesheets that go beyond the IE limit of 4096 selectors,
### Development status
-Since the original developers of this gem are not actively using it in any project at the moment, it is currently in **limited maintenance** mode. Issues are read and pull requests will be reviewed and merged, but there is currently no acitve maintenance/development.
-
-If you are an active user of the gem and would be able to help out maintaining it, it would be greatly appreciated. Just look at the current issues/pull requests.
+Fortunately, the problem of too large CSS files is long gone. This repo is unmaintained.
+It remains as an artefact of dark times in the history of web browsers.
## Installation
@@ -100,14 +99,13 @@ Since 0.4.1 in development split stylesheets have `debug: false` option by defau
## Credits & License
-This is a joint project by the two German Rails shops [Zweitag](http://zweitag.de) and [Railslove](http://railslove.com), therefore the GitHub name "Zweilove".
+This is a joint project by the two German Rails shops [Zweitag](https://zweitag.de) and [Railslove](https://railslove.com), therefore the GitHub name "Zweilove".
-The original code was written by [Christian Peters](mailto:christian.peters@zweitag.de) and [Thomas Hollstegge](mailto:thomas.hollstegge@zweitag.de) (see this [Gist](https://gist.github.com/2398394)) and turned into a gem by [Jakob Hilden](mailto:jakobhilden@gmail.com).
+The original code was written by Christian Peters and Thomas Hollstegge (see this [Gist](https://gist.github.com/2398394)) and turned into a gem by Jakob Hilden.
**Major Contributors**
* [@Umofomia](https://github.com/Umofomia)
* [@kruszczynski](https://github.com/kruszczynski)
-This project rocks and uses MIT-LICENSE.
-
+This project uses MIT-LICENSE.