slim-embedded-minify 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +15 -3
- data/Gemfile +0 -1
- data/Gemfile.lock +3 -28
- data/README.md +12 -22
- data/lib/slim/embedded/minify/java_script_engine.rb +26 -7
- data/lib/slim/embedded/minify/version.rb +1 -1
- data/slim-embedded-minify.gemspec +1 -1
- metadata +3 -4
- data/.rubocop.yml +0 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 96adb71b1316030a44d192230add79fa7092107bacecaed687648fc6dfedd522
|
4
|
+
data.tar.gz: b7365dc0225d9fce7e87f12ac9654c3591b91c2103bae188953a4733e94369fd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ad928fa19f709f194af85f2120c74e765c159878b84fa65dbafab046c8a092612b800116443d945d4ce5d04da64f414eab16abf1d335b69401619911cf30996a
|
7
|
+
data.tar.gz: b5e861e8fe734aaecf229d4914eb51d7bfb9a3b7be8c91a3aca23186bd46ef1a3e644d06a6bc03e98571bd357013b5173ca8027b548f8798972ba457f1ab9c68
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,17 @@
|
|
1
|
-
##
|
1
|
+
## Unreleased
|
2
2
|
|
3
|
-
|
3
|
+
- Fix to disregard comments if enclosed in quotation marks.
|
4
|
+
- Fix deletion of lines when a line is not just a comment.
|
4
5
|
|
5
|
-
-
|
6
|
+
## 0.1.2 - 2023-07-11
|
7
|
+
|
8
|
+
- Fix to remove comments after the second line.
|
9
|
+
|
10
|
+
## 0.1.1 - 2023-07-11
|
11
|
+
|
12
|
+
- Fix bundle install error.
|
13
|
+
- Fix dependency error.
|
14
|
+
|
15
|
+
## 0.1.0 - 2023-07-11
|
16
|
+
|
17
|
+
- Initial release.
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,53 +1,28 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
slim-embedded-minify (0.1.
|
4
|
+
slim-embedded-minify (0.1.2)
|
5
5
|
slim (~> 5.1)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
-
ast (2.4.2)
|
11
|
-
json (2.6.3)
|
12
|
-
language_server-protocol (3.17.0.3)
|
13
10
|
minitest (5.18.1)
|
14
|
-
parallel (1.23.0)
|
15
|
-
parser (3.2.2.3)
|
16
|
-
ast (~> 2.4.1)
|
17
|
-
racc
|
18
|
-
racc (1.7.1)
|
19
|
-
rainbow (3.1.1)
|
20
11
|
rake (13.0.6)
|
21
|
-
regexp_parser (2.8.1)
|
22
|
-
rexml (3.2.5)
|
23
|
-
rubocop (1.54.1)
|
24
|
-
json (~> 2.3)
|
25
|
-
language_server-protocol (>= 3.17.0)
|
26
|
-
parallel (~> 1.10)
|
27
|
-
parser (>= 3.2.2.3)
|
28
|
-
rainbow (>= 2.2.2, < 4.0)
|
29
|
-
regexp_parser (>= 1.8, < 3.0)
|
30
|
-
rexml (>= 3.2.5, < 4.0)
|
31
|
-
rubocop-ast (>= 1.28.0, < 2.0)
|
32
|
-
ruby-progressbar (~> 1.7)
|
33
|
-
unicode-display_width (>= 2.4.0, < 3.0)
|
34
|
-
rubocop-ast (1.29.0)
|
35
|
-
parser (>= 3.2.1.0)
|
36
|
-
ruby-progressbar (1.13.0)
|
37
12
|
slim (5.1.1)
|
38
13
|
temple (~> 0.10.0)
|
39
14
|
tilt (>= 2.1.0)
|
40
15
|
temple (0.10.2)
|
41
16
|
tilt (2.2.0)
|
42
|
-
unicode-display_width (2.4.2)
|
43
17
|
|
44
18
|
PLATFORMS
|
19
|
+
universal-java-11
|
45
20
|
x86_64-darwin-21
|
21
|
+
x86_64-linux
|
46
22
|
|
47
23
|
DEPENDENCIES
|
48
24
|
minitest (~> 5.15)
|
49
25
|
rake (~> 13.0)
|
50
|
-
rubocop (~> 1.21)
|
51
26
|
slim-embedded-minify!
|
52
27
|
|
53
28
|
BUNDLED WITH
|
data/README.md
CHANGED
@@ -1,34 +1,24 @@
|
|
1
|
-
#
|
1
|
+
# SlimEmbeddedMinify
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/slim/embedded/minify`. To experiment with that code, run `bin/console` for an interactive prompt.
|
3
|
+
A slim file to minify embedded code.
|
6
4
|
|
7
5
|
## Installation
|
8
6
|
|
9
|
-
|
10
|
-
|
11
|
-
Install the gem and add to the application's Gemfile by executing:
|
12
|
-
|
13
|
-
$ bundle add UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
|
14
|
-
|
15
|
-
If bundler is not being used to manage dependencies, install the gem by executing:
|
16
|
-
|
17
|
-
$ gem install UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
|
18
|
-
|
19
|
-
## Usage
|
20
|
-
|
21
|
-
TODO: Write usage instructions here
|
7
|
+
Just install the slim-embedded-minify gem
|
22
8
|
|
23
|
-
|
9
|
+
```
|
10
|
+
gem install slim-embedded-minify
|
11
|
+
```
|
24
12
|
|
25
|
-
|
13
|
+
or if you use bundler put this in your `Gemfile`
|
26
14
|
|
27
|
-
|
15
|
+
```
|
16
|
+
gem 'slim-embedded-minify'
|
17
|
+
```
|
28
18
|
|
29
19
|
## Contributing
|
30
20
|
|
31
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
21
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/ydah/slim-embedded-minify. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/ydah/slim-embedded-minify/blob/main/CODE_OF_CONDUCT.md).
|
32
22
|
|
33
23
|
## License
|
34
24
|
|
@@ -36,4 +26,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
36
26
|
|
37
27
|
## Code of Conduct
|
38
28
|
|
39
|
-
Everyone interacting in the Slim::Embedded::Minify project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/
|
29
|
+
Everyone interacting in the Slim::Embedded::Minify project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/ydah/slim-embedded-minify/blob/main/CODE_OF_CONDUCT.md).
|
@@ -14,21 +14,40 @@ module Slim
|
|
14
14
|
|
15
15
|
def minify(body)
|
16
16
|
multiline_comment = false
|
17
|
-
body.
|
17
|
+
body.map do |line|
|
18
18
|
if line.instance_of?(Array) && line.first == :slim
|
19
|
-
|
19
|
+
remove_comments!(line)
|
20
|
+
remove_whitespace!(line)
|
21
|
+
|
22
|
+
stripped_quotes = stripped_quotes(line)
|
23
|
+
if stripped_quotes.match?(%r{/\*})
|
20
24
|
multiline_comment = true
|
21
|
-
next
|
25
|
+
next
|
22
26
|
elsif multiline_comment
|
23
|
-
multiline_comment = false if
|
24
|
-
next
|
27
|
+
multiline_comment = false if stripped_quotes.match?(%r{\*/})
|
28
|
+
next
|
25
29
|
end
|
26
|
-
|
30
|
+
line
|
27
31
|
else
|
28
|
-
|
32
|
+
line
|
29
33
|
end
|
34
|
+
end.compact
|
35
|
+
end
|
36
|
+
|
37
|
+
def remove_comments!(line)
|
38
|
+
line.last.gsub!(/((?<!['"])\/\*[^*\/]*\*\/?(?<!['"]))/, '')
|
39
|
+
line.last.gsub!(/((?<!['"])\/\/.*[^'"]+)/, '')
|
40
|
+
end
|
41
|
+
|
42
|
+
def remove_whitespace!(line)
|
43
|
+
if line.last.gsub(/\n/, '').match?(/^\s*$/)
|
44
|
+
line.last.gsub!(/^\s*$/, '')
|
30
45
|
end
|
31
46
|
end
|
47
|
+
|
48
|
+
def stripped_quotes(line)
|
49
|
+
line.last.gsub(/(['"]).*?\1/, '')
|
50
|
+
end
|
32
51
|
end
|
33
52
|
end
|
34
53
|
end
|
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
|
|
11
11
|
spec.summary = "A slim file to minify embedded code."
|
12
12
|
spec.homepage = "https://github.com/ydah/slim-embedded-minify"
|
13
13
|
spec.license = "MIT"
|
14
|
-
spec.required_ruby_version = ">= 2.
|
14
|
+
spec.required_ruby_version = ">= 2.7.0"
|
15
15
|
|
16
16
|
spec.metadata["homepage_uri"] = spec.homepage
|
17
17
|
spec.metadata["source_code_uri"] = spec.homepage
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slim-embedded-minify
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yudai Takada
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-07-
|
11
|
+
date: 2023-07-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: slim
|
@@ -31,7 +31,6 @@ executables: []
|
|
31
31
|
extensions: []
|
32
32
|
extra_rdoc_files: []
|
33
33
|
files:
|
34
|
-
- ".rubocop.yml"
|
35
34
|
- CHANGELOG.md
|
36
35
|
- CODE_OF_CONDUCT.md
|
37
36
|
- Gemfile
|
@@ -58,7 +57,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
58
57
|
requirements:
|
59
58
|
- - ">="
|
60
59
|
- !ruby/object:Gem::Version
|
61
|
-
version: 2.
|
60
|
+
version: 2.7.0
|
62
61
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
63
62
|
requirements:
|
64
63
|
- - ">="
|
data/.rubocop.yml
DELETED