From 43b3b9ac61cefa848878a5424baa89830b339370 Mon Sep 17 00:00:00 2001 From: Luca Guidi Date: Thu, 7 Jan 2016 13:36:19 +0100 Subject: [PATCH] Fix closing bracket for builtin stylesheet compiler --- .../assets/compressors/builtin_stylesheet.rb | 2 +- test/compressors/builtin_stylesheet_test.rb | 16 ++++++ test/fixtures/compressed-reset.css | 7 +++ test/fixtures/deploy/assets-builtin.json | 2 +- test/fixtures/reset.css | 49 +++++++++++++++++++ 5 files changed, 74 insertions(+), 2 deletions(-) create mode 100644 test/compressors/builtin_stylesheet_test.rb create mode 100644 test/fixtures/compressed-reset.css create mode 100644 test/fixtures/reset.css diff --git a/lib/lotus/assets/compressors/builtin_stylesheet.rb b/lib/lotus/assets/compressors/builtin_stylesheet.rb index b451db59..187eddd7 100644 --- a/lib/lotus/assets/compressors/builtin_stylesheet.rb +++ b/lib/lotus/assets/compressors/builtin_stylesheet.rb @@ -20,7 +20,7 @@ class BuiltinStylesheet < Stylesheet LINE_BREAKS_REPLACEMENT = "}\n".freeze LAST_BREAK_REPLACEMENT = "".freeze INSIDE_LEFT_BRACKET_REPLACEMENT = " {".freeze - INSIDE_RIGHT_BRACKET_REPLACEMENT = " {".freeze + INSIDE_RIGHT_BRACKET_REPLACEMENT = "}".freeze def compress(filename) result = read(filename) diff --git a/test/compressors/builtin_stylesheet_test.rb b/test/compressors/builtin_stylesheet_test.rb new file mode 100644 index 00000000..a813d6ec --- /dev/null +++ b/test/compressors/builtin_stylesheet_test.rb @@ -0,0 +1,16 @@ +require 'test_helper' +require 'lotus/assets/compressors/builtin_stylesheet' + +describe Lotus::Assets::Compressors::BuiltinStylesheet do + let(:compressor) { Lotus::Assets::Compressors::BuiltinStylesheet.new } + + describe '#compress' do + it 'compresses given file' do + asset = __dir__ + '/../fixtures/reset.css' + expected = File.read(__dir__ + '/../fixtures/compressed-reset.css') + actual = compressor.compress(asset) + + actual.must_equal(expected) + end + end +end diff --git a/test/fixtures/compressed-reset.css b/test/fixtures/compressed-reset.css new file mode 100644 index 00000000..1d0f092d --- /dev/null +++ b/test/fixtures/compressed-reset.css @@ -0,0 +1,7 @@ +html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, embed, figure, figcaption, footer, header, hgroup, menu, nav, output, ruby, section, summary, time, mark, audio, video {margin: 0; padding: 0; border: 0; font-size: 100%; font: inherit; vertical-align: baseline} +article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section {display: block} +body {line-height: 1} +ol, ul {list-style: none} +blockquote, q {quotes: none} +blockquote:before, blockquote:after, q:before, q:after {content: ''; content: none} +table {border-collapse: collapse; border-spacing: 0} \ No newline at end of file diff --git a/test/fixtures/deploy/assets-builtin.json b/test/fixtures/deploy/assets-builtin.json index 493ef2dd..8a8c5c84 100644 --- a/test/fixtures/deploy/assets-builtin.json +++ b/test/fixtures/deploy/assets-builtin.json @@ -1 +1 @@ -{"/assets/admin/jquery-ui.css":"/assets/admin/jquery-ui-e3109c9142279ee60cc50171f662858f.css","/assets/admin/jquery-ui.js":"/assets/admin/jquery-ui-ad41f3480c470e2b64c1b0357cfd78c5.js","/assets/admin/jquery-ui.structure.css":"/assets/admin/jquery-ui.structure-a3468f038c15cf741a15011576d1fef0.css","/assets/admin/jquery-ui.theme.css":"/assets/admin/jquery-ui.theme-b4ede477425ff79b75aeb1c710a7ff2f.css","/assets/admin/jquery.js":"/assets/admin/jquery-6f2e5c9e6a867fb492c33eb045e5c84a.js","/assets/admin/ui-bg_diagonals-thick_18_b81900_40x40.png":"/assets/admin/ui-bg_diagonals-thick_18_b81900_40x40-4d4e638960a1a29b0d6b693b445087da.png","/assets/admin/ui-bg_diagonals-thick_20_666666_40x40.png":"/assets/admin/ui-bg_diagonals-thick_20_666666_40x40-d0cc3ffc3dc84d3a7c48867c75e2485f.png","/assets/admin/ui-bg_flat_10_000000_40x100.png":"/assets/admin/ui-bg_flat_10_000000_40x100-c31d5fc3eb7d82c628a82e3b87024cd1.png","/assets/admin/ui-bg_glass_100_f6f6f6_1x400.png":"/assets/admin/ui-bg_glass_100_f6f6f6_1x400-c17f552e8f4697d7608c57653af36df0.png","/assets/admin/ui-bg_glass_100_fdf5ce_1x400.png":"/assets/admin/ui-bg_glass_100_fdf5ce_1x400-fe58c3539111d3021776e6833169c5e1.png","/assets/admin/ui-bg_glass_65_ffffff_1x400.png":"/assets/admin/ui-bg_glass_65_ffffff_1x400-b624f702075cd719a38f428e143025ea.png","/assets/admin/ui-bg_gloss-wave_35_f6a828_500x100.png":"/assets/admin/ui-bg_gloss-wave_35_f6a828_500x100-23932de7c235b03187b8a5de3d024490.png","/assets/admin/ui-bg_highlight-soft_100_eeeeee_1x100.png":"/assets/admin/ui-bg_highlight-soft_100_eeeeee_1x100-0b708185ce8927f18c7b3b82a7e7c247.png","/assets/admin/ui-bg_highlight-soft_75_ffe45c_1x100.png":"/assets/admin/ui-bg_highlight-soft_75_ffe45c_1x100-53acc69aaee6e2cb73b2021317e24af3.png","/assets/admin/ui-icons_222222_256x240.png":"/assets/admin/ui-icons_222222_256x240-4c27b34156b7a3776f31cc456ca01c10.png","/assets/admin/ui-icons_228ef1_256x240.png":"/assets/admin/ui-icons_228ef1_256x240-2f257489d9600ddf56d195a179ebc9df.png","/assets/admin/ui-icons_ef8c08_256x240.png":"/assets/admin/ui-icons_ef8c08_256x240-772a64d6df4b93d230e9b38e1ab7522a.png","/assets/admin/ui-icons_ffd27a_256x240.png":"/assets/admin/ui-icons_ffd27a_256x240-6686d21b904e18b100210169bb1c04ad.png","/assets/admin/ui-icons_ffffff_256x240.png":"/assets/admin/ui-icons_ffffff_256x240-a19fe1b2d726e920c12e43a65df9039a.png","/assets/bootstrap-theme.css":"/assets/bootstrap-theme-0a26e950c6586286a456de94bbb7e5a4.css","/assets/bootstrap.css":"/assets/bootstrap-481ec32a0d15c8cfa0d835ffb3f1f23c.css","/assets/bootstrap.js":"/assets/bootstrap-89d5416bc7c63b5eacc04086a12e7711.js"} \ No newline at end of file +{"/assets/admin/jquery-ui.css":"/assets/admin/jquery-ui-449ca93abddb957382e0d157395dce8d.css","/assets/admin/jquery-ui.js":"/assets/admin/jquery-ui-ad41f3480c470e2b64c1b0357cfd78c5.js","/assets/admin/jquery-ui.structure.css":"/assets/admin/jquery-ui.structure-5a0c4be3549c8fe4b131282690b09b12.css","/assets/admin/jquery-ui.theme.css":"/assets/admin/jquery-ui.theme-9bf307200d9e4bc7efdb0ca1bb314368.css","/assets/admin/jquery.js":"/assets/admin/jquery-6f2e5c9e6a867fb492c33eb045e5c84a.js","/assets/admin/ui-bg_diagonals-thick_18_b81900_40x40.png":"/assets/admin/ui-bg_diagonals-thick_18_b81900_40x40-4d4e638960a1a29b0d6b693b445087da.png","/assets/admin/ui-bg_diagonals-thick_20_666666_40x40.png":"/assets/admin/ui-bg_diagonals-thick_20_666666_40x40-d0cc3ffc3dc84d3a7c48867c75e2485f.png","/assets/admin/ui-bg_flat_10_000000_40x100.png":"/assets/admin/ui-bg_flat_10_000000_40x100-c31d5fc3eb7d82c628a82e3b87024cd1.png","/assets/admin/ui-bg_glass_100_f6f6f6_1x400.png":"/assets/admin/ui-bg_glass_100_f6f6f6_1x400-c17f552e8f4697d7608c57653af36df0.png","/assets/admin/ui-bg_glass_100_fdf5ce_1x400.png":"/assets/admin/ui-bg_glass_100_fdf5ce_1x400-fe58c3539111d3021776e6833169c5e1.png","/assets/admin/ui-bg_glass_65_ffffff_1x400.png":"/assets/admin/ui-bg_glass_65_ffffff_1x400-b624f702075cd719a38f428e143025ea.png","/assets/admin/ui-bg_gloss-wave_35_f6a828_500x100.png":"/assets/admin/ui-bg_gloss-wave_35_f6a828_500x100-23932de7c235b03187b8a5de3d024490.png","/assets/admin/ui-bg_highlight-soft_100_eeeeee_1x100.png":"/assets/admin/ui-bg_highlight-soft_100_eeeeee_1x100-0b708185ce8927f18c7b3b82a7e7c247.png","/assets/admin/ui-bg_highlight-soft_75_ffe45c_1x100.png":"/assets/admin/ui-bg_highlight-soft_75_ffe45c_1x100-53acc69aaee6e2cb73b2021317e24af3.png","/assets/admin/ui-icons_222222_256x240.png":"/assets/admin/ui-icons_222222_256x240-4c27b34156b7a3776f31cc456ca01c10.png","/assets/admin/ui-icons_228ef1_256x240.png":"/assets/admin/ui-icons_228ef1_256x240-2f257489d9600ddf56d195a179ebc9df.png","/assets/admin/ui-icons_ef8c08_256x240.png":"/assets/admin/ui-icons_ef8c08_256x240-772a64d6df4b93d230e9b38e1ab7522a.png","/assets/admin/ui-icons_ffd27a_256x240.png":"/assets/admin/ui-icons_ffd27a_256x240-6686d21b904e18b100210169bb1c04ad.png","/assets/admin/ui-icons_ffffff_256x240.png":"/assets/admin/ui-icons_ffffff_256x240-a19fe1b2d726e920c12e43a65df9039a.png","/assets/bootstrap-theme.css":"/assets/bootstrap-theme-26504b58ee0ef4e1003b4d592805e861.css","/assets/bootstrap.css":"/assets/bootstrap-ee15a45d225bd56ff40767458d10a7c4.css","/assets/bootstrap.js":"/assets/bootstrap-89d5416bc7c63b5eacc04086a12e7711.js"} \ No newline at end of file diff --git a/test/fixtures/reset.css b/test/fixtures/reset.css new file mode 100644 index 00000000..0b27ac70 --- /dev/null +++ b/test/fixtures/reset.css @@ -0,0 +1,49 @@ +/* http://meyerweb.com/eric/tools/css/reset/ + v2.0 | 20110126 + License: none (public domain) +*/ + +html, body, div, span, applet, object, iframe, +h1, h2, h3, h4, h5, h6, p, blockquote, pre, +a, abbr, acronym, address, big, cite, code, +del, dfn, em, img, ins, kbd, q, s, samp, +small, strike, strong, sub, sup, tt, var, +b, u, i, center, +dl, dt, dd, ol, ul, li, +fieldset, form, label, legend, +table, caption, tbody, tfoot, thead, tr, th, td, +article, aside, canvas, details, embed, +figure, figcaption, footer, header, hgroup, +menu, nav, output, ruby, section, summary, +time, mark, audio, video { + margin: 0; + padding: 0; + border: 0; + font-size: 100%; + font: inherit; + vertical-align: baseline; +} +/* HTML5 display-role reset for older browsers */ +article, aside, details, figcaption, figure, +footer, header, hgroup, menu, nav, section { + display: block; +} +body { + line-height: 1; +} +ol, ul { + list-style: none; +} +blockquote, q { + quotes: none; +} +blockquote:before, blockquote:after, +q:before, q:after { + content: ''; + content: none; +} +table { + border-collapse: collapse; + border-spacing: 0; +} +