glimmer-dsl-css 1.3.0 → 1.4.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a00ff31e682fcc94d72464388bec42ba14ee932dda12bb3c6013b8dd8e406db5
4
- data.tar.gz: f78b7fe8fab6e01321ffffb4af61321470e131ccd4da523fed318e753e1b90c6
3
+ metadata.gz: 96e2646830dfe42a2cfe0ea91ea369b558d0873917071e963349856b129c1278
4
+ data.tar.gz: 1948d00677cdf1aa4df5cbb90a4632edbd06c03c6162dce55ca2ebb94baa0dff
5
5
  SHA512:
6
- metadata.gz: 278840c459c817881f89642c343ceb56cf201604adbb7d4b26e6f2d6676f9716245c196269422696d9936cc3795c296d48e52127fe1afb05b26b0c8f91bbfefa
7
- data.tar.gz: 6e191a28c199a17b44c7e3b5e154d87bb6f36d945eb5e9aafe536fd3db2f87953f79fd99f80af53ef555782052ab822299bfa51ed38308ddec42da9726b723ab
6
+ metadata.gz: 4dac6e584522cc6d193aac0ff4cf6fac528e4fa940bf1d95de6c35e657333852627248fc783e20d9844313a43a82b05915dbd1b457304bfc15124575cf8323ed
7
+ data.tar.gz: 595521b5d0d22be9ff481db6bc0a7a18ad0bc4d5958d9e69a77886b03961b6ea9d1a79d74f4e783ce418cdceb2cf53fb0190656d84eabe95e5f8039908cadb59
data/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # Change Log
2
2
 
3
+ ## 1.4.1
4
+
5
+ - Optimize performance (mostly in Opal) by re-ordering dsl.rb to give preference to dynamic property expressions, removing media from its chain of responsibility (it does not need to be there because it is a static expression), and re-ordering conditional checks in dynamic property expression and element rule expression.
6
+
7
+ ## 1.4.0
8
+
9
+ - `css_to_glimmer` converter command for automatically converting CSS to Glimmer DSL Ruby code
10
+ - `css_to_glimmer` -r=rule_keyword option to customize rule keyword (rule has aliases: rul, ru, r, s, _)
11
+ - `minifier` converter command for automatically minifying CSS
12
+ - Fix issue with `display` CSS property not getting interpreted successfully in Glimmer DSL Ruby code
13
+
3
14
  ## 1.3.0
4
15
 
5
16
  - Support media queries
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=85 />](https://github.com/AndyObtiva/glimmer) Glimmer DSL for CSS 1.3.0
1
+ # [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=85 />](https://github.com/AndyObtiva/glimmer) Glimmer DSL for CSS 1.4.1
2
2
  ## Ruby Programmable Cascading Style Sheets
3
3
  [![Gem Version](https://badge.fury.io/rb/glimmer-dsl-css.svg)](http://badge.fury.io/rb/glimmer-dsl-css)
4
4
  [![Travis CI](https://travis-ci.com/AndyObtiva/glimmer-dsl-css.svg?branch=master)](https://travis-ci.com/github/AndyObtiva/glimmer-dsl-css)
@@ -6,13 +6,15 @@
6
6
  [![Maintainability](https://api.codeclimate.com/v1/badges/c7365cdb8556be433115/maintainability)](https://codeclimate.com/github/AndyObtiva/glimmer-dsl-css/maintainability)
7
7
  [![Join the chat at https://gitter.im/AndyObtiva/glimmer](https://badges.gitter.im/AndyObtiva/glimmer.svg)](https://gitter.im/AndyObtiva/glimmer?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
8
8
 
9
- [Glimmer](https://github.com/AndyObtiva/glimmer) DSL for CSS provides Ruby syntax for building CSS (Cascading Style Sheets). It used to be part of the [Glimmer](https://github.com/AndyObtiva/glimmer) library (created in 2007), but eventually got extracted into its own project.
9
+ [Glimmer](https://github.com/AndyObtiva/glimmer) DSL for CSS provides Ruby syntax for building CSS (Cascading Style Sheets), included in [Glimmer DSL for Web](https://github.com/AndyObtiva/glimmer-dsl-web) (Ruby in the Browser Web Frontend Framework) to use in Rails Frontend Development. It used to be part of the [Glimmer](https://github.com/AndyObtiva/glimmer) library (created in 2007), but eventually got extracted into its own project. The Ruby gem also includes a [CSS to Glimmer converter](#css-to-glimmer-converter) (`css_to_glimmer`) to automatically convert legacy CSS code into Glimmer DSL syntax.
10
10
 
11
11
  Example (you can try in IRB):
12
12
 
13
13
  ```ruby
14
14
  require 'glimmer-dsl-css'
15
+
15
16
  include Glimmer
17
+
16
18
  @css = css {
17
19
  body {
18
20
  font_size '1.1em'
@@ -31,6 +33,7 @@ include Glimmer
31
33
  }
32
34
  }
33
35
  }
36
+
34
37
  puts @css
35
38
  ```
36
39
 
@@ -61,7 +64,7 @@ Please follow these instructions to make the `glimmer` command available on your
61
64
 
62
65
  Run this command to install directly:
63
66
  ```
64
- gem install glimmer-dsl-css -v 1.3.0
67
+ gem install glimmer-dsl-css -v 1.4.1
65
68
  ```
66
69
 
67
70
  Note: In case you are using JRuby, `jgem` is JRuby's version of the `gem` command. RVM allows running `gem` as an alias in JRuby. Otherwise, you may also run `jruby -S gem install ...`
@@ -76,7 +79,7 @@ That's it! Requiring the gem activates the Glimmer CSS DSL automatically.
76
79
 
77
80
  Add the following to `Gemfile` (after `glimmer-dsl-swt` and/or `glimmer-dsl-opal` if included too):
78
81
  ```
79
- gem 'glimmer-dsl-css', '~> 1.3.0'
82
+ gem 'glimmer-dsl-css', '~> 1.4.1'
80
83
  ```
81
84
 
82
85
  And, then run:
@@ -115,17 +118,21 @@ Example (you can try in IRB):
115
118
 
116
119
  ```ruby
117
120
  require 'glimmer-dsl-css'
121
+
118
122
  include Glimmer
123
+
119
124
  @css = css {
120
125
  body {
121
126
  font_size '1.1em'
122
127
  background 'white'
123
128
  }
129
+
124
130
  r('body > h1') {
125
131
  background_color :red
126
132
  font_size 24
127
133
  }
128
134
  }
135
+
129
136
  puts @css
130
137
  ```
131
138
 
@@ -171,7 +178,9 @@ As you saw above, numeric values (e.g. `24` in `font_size 24`) automatically get
171
178
 
172
179
  ```ruby
173
180
  require 'glimmer-dsl-css'
181
+
174
182
  include Glimmer
183
+
175
184
  @css = css {
176
185
  body {
177
186
  font_size '1.1em'
@@ -182,6 +191,7 @@ include Glimmer
182
191
  font_size 24
183
192
  end
184
193
  }
194
+
185
195
  puts @css
186
196
  ```
187
197
 
@@ -191,6 +201,114 @@ Output (minified CSS):
191
201
  body{font-size:1.1em;background:white}body > h1{background-color:red;font-size:24px}
192
202
  ```
193
203
 
204
+ ### CSS to Glimmer Converter
205
+
206
+ The Ruby gem includes a CSS to Glimmer converter (`css_to_glimmer`) to automatically convert legacy CSS code into Glimmer DSL syntax.
207
+
208
+ Script:
209
+
210
+ [bin/css_to_glimmer](/bin/css_to_glimmer)
211
+
212
+ Usage:
213
+
214
+ ```
215
+ css_to_glimmer [-r=rule_keyword] path_to_css_file
216
+ ```
217
+
218
+ Example:
219
+
220
+ Suppose we have a CSS file called `input.css`:
221
+
222
+ ```css
223
+ html, body {
224
+ margin:0;
225
+ padding:0;
226
+ }
227
+
228
+ @media (max-width: 430px) {
229
+ .footer {
230
+ height:50px;
231
+ }
232
+
233
+ .filters {
234
+ bottom:10px;
235
+ }
236
+ }
237
+ ```
238
+
239
+ We can run this command:
240
+
241
+ ```
242
+ css_to_glimmer input.css
243
+ ```
244
+
245
+ Printout:
246
+
247
+ ```
248
+ Converting from CSS syntax to Glimmer DSL Ruby syntax for input file: input.css
249
+ Converted output file: input.css.glimmer.rb
250
+ ```
251
+
252
+ Output file (`input.css.glimmer.rb`) is a runnable Ruby file containing Glimmer DSL for CSS syntax:
253
+
254
+ ```ruby
255
+ require 'glimmer-dsl-css'
256
+
257
+ include Glimmer
258
+
259
+ style_sheet = css {
260
+ rule('html,body') {
261
+ margin '0'
262
+ padding '0'
263
+ }
264
+
265
+ media('(max-width: 430px)') {
266
+ rule('.footer') {
267
+ height '50px'
268
+ }
269
+
270
+ rule('.filters') {
271
+ bottom '10px'
272
+ }
273
+ }
274
+ }
275
+
276
+ puts style_sheet.to_s
277
+ ```
278
+
279
+ If you would rather customize the `rule` keyword with a shorter alias like `rul`, `ru`, `r`, `s` (for selector), or `_`, you can run the following command:
280
+
281
+ ```
282
+ css_to_glimmer -r=ru input.css
283
+ ```
284
+
285
+ Output file (`input.css.glimmer.rb`) is a runnable Ruby file containing Glimmer DSL for CSS syntax:
286
+
287
+ ```ruby
288
+ require 'glimmer-dsl-css'
289
+
290
+ include Glimmer
291
+
292
+ style_sheet = css {
293
+ ru('html,body') {
294
+ margin '0'
295
+ padding '0'
296
+ }
297
+
298
+ media('(max-width: 430px)') {
299
+ ru('.footer') {
300
+ height '50px'
301
+ }
302
+
303
+ ru('.filters') {
304
+ bottom '10px'
305
+ }
306
+ }
307
+ }
308
+
309
+ puts style_sheet.to_s
310
+ ```
311
+
194
312
  ## Multi-DSL Support
195
313
 
196
314
  Learn more about how to use this DSL alongside other Glimmer DSLs:
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.3.0
1
+ 1.4.1
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative '../lib/glimmer/css/css_to_glimmer_converter'
4
+
5
+ usage = "***Glimmer DSL for CSS - CSS to Glimmer Converter***\nUsage: css_to_glimmer path_to_css_file"
6
+
7
+ if ARGV.empty?
8
+ puts usage
9
+ else
10
+ css_file_path = ARGV.last
11
+ puts "Converting from CSS syntax to Glimmer DSL Ruby syntax for input file: #{css_file_path}"
12
+ css = File.read(css_file_path)
13
+ rule_keyword = ARGV.find { |arg| arg.start_with?("-r=") }.to_s.split('=')[1].to_s
14
+ converter = rule_keyword.empty? ? Glimmer::CSS::CSSToGlimmerConverter.new : Glimmer::CSS::CSSToGlimmerConverter.new(rule_keyword: rule_keyword)
15
+ glimmer = converter.convert(css)
16
+ glimmer_file_path = "#{css_file_path}.glimmer.rb"
17
+ File.write(glimmer_file_path, glimmer)
18
+ puts "Converted output file: #{glimmer_file_path}"
19
+ end
data/bin/minify_css ADDED
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative '../lib/glimmer/css/css_minifier'
4
+
5
+ usage = "***Glimmer DSL for CSS - CSS Minifier***\nUsage: minify_css path_to_css_file"
6
+
7
+ # TODO support option to select rule, or rul, or r
8
+
9
+ if ARGV.empty?
10
+ puts usage
11
+ else
12
+ css_file_path = ARGV.first
13
+ puts "Minifying CSS for input file: #{css_file_path}"
14
+ css = File.read(css_file_path)
15
+ converter = Glimmer::CSS::CSSMinifier.new
16
+ minified_css = converter.convert(css)
17
+ minified_css_file_path = "#{File.basename(css_file_path, '.css')}.minified.css"
18
+ File.write(minified_css_file_path, minified_css)
19
+ puts "Converted output file: #{minified_css_file_path}"
20
+ end
@@ -2,18 +2,19 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: glimmer-dsl-css 1.3.0 ruby lib
5
+ # stub: glimmer-dsl-css 1.4.1 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "glimmer-dsl-css".freeze
9
- s.version = "1.3.0"
9
+ s.version = "1.4.1"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib".freeze]
13
13
  s.authors = ["AndyMaleh".freeze]
14
- s.date = "2024-05-18"
14
+ s.date = "2024-07-05"
15
15
  s.description = "Glimmer DSL for CSS (Ruby Programmable Cascading Style Sheets)".freeze
16
16
  s.email = "andy.am@gmail.com".freeze
17
+ s.executables = ["css_to_glimmer".freeze, "minify_css".freeze]
17
18
  s.extra_rdoc_files = [
18
19
  "CHANGELOG.md",
19
20
  "LICENSE.txt",
@@ -25,13 +26,18 @@ Gem::Specification.new do |s|
25
26
  "LICENSE.txt",
26
27
  "README.md",
27
28
  "VERSION",
29
+ "bin/css_to_glimmer",
30
+ "bin/minify_css",
28
31
  "glimmer-dsl-css.gemspec",
29
32
  "lib/glimmer-dsl-css.rb",
33
+ "lib/glimmer/css/css_minifier.rb",
34
+ "lib/glimmer/css/css_to_glimmer_converter.rb",
30
35
  "lib/glimmer/css/media_query.rb",
31
36
  "lib/glimmer/css/rule.rb",
32
37
  "lib/glimmer/css/rule_composite.rb",
33
38
  "lib/glimmer/css/style_sheet.rb",
34
39
  "lib/glimmer/dsl/css/css_expression.rb",
40
+ "lib/glimmer/dsl/css/display_expression.rb",
35
41
  "lib/glimmer/dsl/css/dsl.rb",
36
42
  "lib/glimmer/dsl/css/dynamic_property_expression.rb",
37
43
  "lib/glimmer/dsl/css/element_rule_expression.rb",
@@ -52,6 +58,7 @@ Gem::Specification.new do |s|
52
58
  s.specification_version = 4
53
59
 
54
60
  s.add_runtime_dependency(%q<glimmer>.freeze, [">= 2.0.0", "< 3.0.0"])
61
+ s.add_runtime_dependency(%q<css_parser>.freeze, [">= 1.0.0", "< 2.0.0"])
55
62
  s.add_development_dependency(%q<rspec-mocks>.freeze, ["~> 3.0"])
56
63
  s.add_development_dependency(%q<rspec>.freeze, ["~> 3.0"])
57
64
  s.add_development_dependency(%q<puts_debuggerer>.freeze, [">= 0"])
@@ -0,0 +1,30 @@
1
+ # Copyright (c) 2020-2024 - Andy Maleh
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining
4
+ # a copy of this software and associated documentation files (the
5
+ # "Software"), to deal in the Software without restriction, including
6
+ # without limitation the rights to use, copy, modify, merge, publish,
7
+ # distribute, sublicense, and/or sell copies of the Software, and to
8
+ # permit persons to whom the Software is furnished to do so, subject to
9
+ # the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be
12
+ # included in all copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
22
+ module Glimmer
23
+ module CSS
24
+ class CSSMinifier
25
+ def convert(css)
26
+ css.lines.map(&:chomp).map(&:strip).join
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,121 @@
1
+ # Copyright (c) 2020-2024 - Andy Maleh
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining
4
+ # a copy of this software and associated documentation files (the
5
+ # "Software"), to deal in the Software without restriction, including
6
+ # without limitation the rights to use, copy, modify, merge, publish,
7
+ # distribute, sublicense, and/or sell copies of the Software, and to
8
+ # permit persons to whom the Software is furnished to do so, subject to
9
+ # the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be
12
+ # included in all copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
22
+ require 'css_parser'
23
+ require_relative 'css_minifier'
24
+
25
+ module Glimmer
26
+ module CSS
27
+ class CSSToGlimmerConverter
28
+ include CssParser
29
+
30
+ RULE_KEYWORDS = %w[rule rul ru r s _]
31
+
32
+ # This option specifies if we want to use the default rule keyword or an alias like rul or r
33
+ attr_reader :rule_keyword
34
+
35
+ def initialize(rule_keyword: 'rule')
36
+ @rule_keyword = rule_keyword.to_s
37
+ validate_rule_keyword
38
+ end
39
+
40
+ def convert(css)
41
+ glimmer = ''
42
+ glimmer += "require 'glimmer-dsl-css'\n\n"
43
+ glimmer += "include Glimmer\n\n"
44
+ glimmer += "style_sheet = css {\n"
45
+ glimmer += convert_css(css).lines.map { |line| " #{line}" }.join
46
+ glimmer += "}\n\n"
47
+ glimmer += "puts style_sheet.to_s\n"
48
+ end
49
+
50
+ def minify(css)
51
+ CSSMinifier.new.convert(css)
52
+ end
53
+
54
+ def remove_charset(css)
55
+ css.sub(/@charset[^;]*;/, '')
56
+ end
57
+
58
+ def remove_comments(css)
59
+ output = ''
60
+ comment = false
61
+ current_two_characters = [];
62
+ css.chars.each do |character|
63
+ output << character if !comment
64
+ current_two_characters.shift if current_two_characters.size == 2
65
+ current_two_characters << character
66
+ if !comment && current_two_characters.join == '/*'
67
+ comment = true
68
+ output = output[0...-2]
69
+ elsif comment && current_two_characters.join == '*/'
70
+ comment = false
71
+ end
72
+ end
73
+ output
74
+ end
75
+
76
+ private
77
+
78
+ def convert_css(css)
79
+ parser = CssParser::Parser.new
80
+ parser.load_string!(css)
81
+ parser.rules_by_media_query.map do |media_query, rule_set|
82
+ if media_query == :all
83
+ convert_rule_set_to_glimmer(rule_set)
84
+ else
85
+ convert_media_query_rule_set_to_glimmer(rule_set, media_query)
86
+ end
87
+ end.join("\n")
88
+ end
89
+
90
+ def convert_rule_set_to_glimmer(rule_set)
91
+ glimmer = ''
92
+ rule_set.each_with_index do |rule, index|
93
+ glimmer += "\n" if index > 0
94
+ rule_selector = rule.selectors.join(', ').gsub("'", '"')
95
+ glimmer += "#{rule_keyword}('#{rule_selector}') {\n"
96
+ rule.each_declaration do |declaration, value|
97
+ property_name = declaration.gsub('-', '_')
98
+ property_value = value.sub(/^("|')/, '').sub(/("|')$/, '').gsub("'", '"')
99
+ glimmer += " #{property_name} '#{property_value}'\n"
100
+ end
101
+ glimmer += "}\n"
102
+ end
103
+ glimmer
104
+ end
105
+
106
+ def convert_media_query_rule_set_to_glimmer(rule_set, media_query)
107
+ glimmer = ''
108
+ glimmer += "media('#{media_query.to_s.gsub("'", '"')}') {\n"
109
+ glimmer += convert_rule_set_to_glimmer(rule_set).lines.map { |line| " #{line}" }.join
110
+ glimmer += "}\n"
111
+ glimmer
112
+ end
113
+
114
+ private
115
+
116
+ def validate_rule_keyword
117
+ raise "rule_keyword '#{rule_keyword}' is invalid! It must be 'rule', 'rul', 'ru', 'r', 's', or '_'" if !RULE_KEYWORDS.include?(rule_keyword)
118
+ end
119
+ end
120
+ end
121
+ end
@@ -19,6 +19,9 @@
19
19
  # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
20
  # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
21
 
22
+ require 'glimmer/css/rule_composite'
23
+ require 'glimmer/css/rule'
24
+
22
25
  module Glimmer
23
26
  module CSS
24
27
  class MediaQuery < Rule
@@ -0,0 +1,33 @@
1
+ # Copyright (c) 2020-2024 - Andy Maleh
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining
4
+ # a copy of this software and associated documentation files (the
5
+ # "Software"), to deal in the Software without restriction, including
6
+ # without limitation the rights to use, copy, modify, merge, publish,
7
+ # distribute, sublicense, and/or sell copies of the Software, and to
8
+ # permit persons to whom the Software is furnished to do so, subject to
9
+ # the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be
12
+ # included in all copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
22
+ require 'glimmer/dsl/static_expression'
23
+ require 'glimmer/dsl/css/property_expression'
24
+
25
+ module Glimmer
26
+ module DSL
27
+ module CSS
28
+ class DisplayExpression < StaticExpression
29
+ include PropertyExpression
30
+ end
31
+ end
32
+ end
33
+ end
@@ -29,6 +29,7 @@ require 'glimmer/dsl/css/rul_expression'
29
29
  require 'glimmer/dsl/css/ru_expression'
30
30
  require 'glimmer/dsl/css/s_expression'
31
31
  require 'glimmer/dsl/css/pv_expression'
32
+ require 'glimmer/dsl/css/display_expression'
32
33
  require 'glimmer/dsl/css/media_expression'
33
34
 
34
35
  module Glimmer
@@ -37,9 +38,8 @@ module Glimmer
37
38
  Engine.add_dynamic_expressions(
38
39
  CSS,
39
40
  %w[
40
- media
41
- element_rule
42
41
  dynamic_property
42
+ element_rule
43
43
  ]
44
44
  )
45
45
  end
@@ -31,9 +31,9 @@ module Glimmer
31
31
  include ParentExpression
32
32
 
33
33
  def can_interpret?(parent, keyword, *args, &block)
34
- parent.is_a?(Glimmer::CSS::StyleSheet) and
35
- block_given? and
36
- args.empty?
34
+ block_given? and
35
+ args.empty? and
36
+ parent.is_a?(Glimmer::CSS::StyleSheet)
37
37
  end
38
38
 
39
39
  def interpret(parent, keyword, *args, &block)
@@ -29,9 +29,9 @@ module Glimmer
29
29
  include ParentExpression
30
30
 
31
31
  def can_interpret?(parent, keyword, *args, &block)
32
- parent.is_a?(Glimmer::CSS::Rule) and
33
- !block_given? and
34
- !args.empty?
32
+ !block_given? and
33
+ !args.empty? and
34
+ parent.is_a?(Glimmer::CSS::Rule)
35
35
  end
36
36
 
37
37
  def interpret(parent, keyword, *args, &block)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glimmer-dsl-css
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - AndyMaleh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-05-18 00:00:00.000000000 Z
11
+ date: 2024-07-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: glimmer
@@ -30,6 +30,26 @@ dependencies:
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
32
  version: 3.0.0
33
+ - !ruby/object:Gem::Dependency
34
+ name: css_parser
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: 1.0.0
40
+ - - "<"
41
+ - !ruby/object:Gem::Version
42
+ version: 2.0.0
43
+ type: :runtime
44
+ prerelease: false
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: 1.0.0
50
+ - - "<"
51
+ - !ruby/object:Gem::Version
52
+ version: 2.0.0
33
53
  - !ruby/object:Gem::Dependency
34
54
  name: rspec-mocks
35
55
  requirement: !ruby/object:Gem::Requirement
@@ -190,7 +210,9 @@ dependencies:
190
210
  version: '0'
191
211
  description: Glimmer DSL for CSS (Ruby Programmable Cascading Style Sheets)
192
212
  email: andy.am@gmail.com
193
- executables: []
213
+ executables:
214
+ - css_to_glimmer
215
+ - minify_css
194
216
  extensions: []
195
217
  extra_rdoc_files:
196
218
  - CHANGELOG.md
@@ -202,13 +224,18 @@ files:
202
224
  - LICENSE.txt
203
225
  - README.md
204
226
  - VERSION
227
+ - bin/css_to_glimmer
228
+ - bin/minify_css
205
229
  - glimmer-dsl-css.gemspec
206
230
  - lib/glimmer-dsl-css.rb
231
+ - lib/glimmer/css/css_minifier.rb
232
+ - lib/glimmer/css/css_to_glimmer_converter.rb
207
233
  - lib/glimmer/css/media_query.rb
208
234
  - lib/glimmer/css/rule.rb
209
235
  - lib/glimmer/css/rule_composite.rb
210
236
  - lib/glimmer/css/style_sheet.rb
211
237
  - lib/glimmer/dsl/css/css_expression.rb
238
+ - lib/glimmer/dsl/css/display_expression.rb
212
239
  - lib/glimmer/dsl/css/dsl.rb
213
240
  - lib/glimmer/dsl/css/dynamic_property_expression.rb
214
241
  - lib/glimmer/dsl/css/element_rule_expression.rb