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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f110250b84230ebf229b53f681aa383c067f1a852753c9de17d4bb301463b3b9
4
- data.tar.gz: b07d7704ba9620c86177528c075c5bdc41e568e8173d83afa11ac5b8236cc654
3
+ metadata.gz: 96adb71b1316030a44d192230add79fa7092107bacecaed687648fc6dfedd522
4
+ data.tar.gz: b7365dc0225d9fce7e87f12ac9654c3591b91c2103bae188953a4733e94369fd
5
5
  SHA512:
6
- metadata.gz: f7f7587f90c3c6f317db08d7e844eb151cf14921acf4570be397c048e0d3311b5ec31fa9433d5a7f4dc408d166e38274e81fbcca683fa8f812465e0f77b9d38a
7
- data.tar.gz: 611fc8e5cdc302c03a563ed17d2812752ef7dbe622fd32a5dcb95fbd17e07d6b86075dd746473d92c6036d8adf353eccf2a895fd85470faa5e0fab3c711bbfe6
6
+ metadata.gz: ad928fa19f709f194af85f2120c74e765c159878b84fa65dbafab046c8a092612b800116443d945d4ce5d04da64f414eab16abf1d335b69401619911cf30996a
7
+ data.tar.gz: b5e861e8fe734aaecf229d4914eb51d7bfb9a3b7be8c91a3aca23186bd46ef1a3e644d06a6bc03e98571bd357013b5173ca8027b548f8798972ba457f1ab9c68
data/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
- ## [Unreleased]
1
+ ## Unreleased
2
2
 
3
- ## [0.1.0] - 2023-07-11
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
- - Initial release
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
@@ -7,4 +7,3 @@ gemspec
7
7
 
8
8
  gem "minitest", "~> 5.15"
9
9
  gem "rake", "~> 13.0"
10
- gem "rubocop", "~> 1.21"
data/Gemfile.lock CHANGED
@@ -1,53 +1,28 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- slim-embedded-minify (0.1.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
- # Slim::Embedded::Minify
1
+ # SlimEmbeddedMinify
2
2
 
3
- TODO: Delete this and the text below, and describe your gem
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
- TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
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
- ## Development
9
+ ```
10
+ gem install slim-embedded-minify
11
+ ```
24
12
 
25
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
13
+ or if you use bundler put this in your `Gemfile`
26
14
 
27
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
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/[USERNAME]/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/[USERNAME]/slim-embedded-minify/blob/main/CODE_OF_CONDUCT.md).
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/[USERNAME]/slim-embedded-minify/blob/main/CODE_OF_CONDUCT.md).
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.filter do |line|
17
+ body.map do |line|
18
18
  if line.instance_of?(Array) && line.first == :slim
19
- if line.last.match?(%r{\A/\*})
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 false
25
+ next
22
26
  elsif multiline_comment
23
- multiline_comment = false if line.last.match?(%r{\*/})
24
- next false
27
+ multiline_comment = false if stripped_quotes.match?(%r{\*/})
28
+ next
25
29
  end
26
- !line.last.match?(%r{//})
30
+ line
27
31
  else
28
- true
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SlimEmbeddedMinify
4
- VERSION = "0.1.2"
4
+ VERSION = "0.1.3"
5
5
  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.6.0"
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.2
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 00:00:00.000000000 Z
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.6.0
60
+ version: 2.7.0
62
61
  required_rubygems_version: !ruby/object:Gem::Requirement
63
62
  requirements:
64
63
  - - ">="
data/.rubocop.yml DELETED
@@ -1,13 +0,0 @@
1
- AllCops:
2
- TargetRubyVersion: 2.6
3
-
4
- Style/StringLiterals:
5
- Enabled: true
6
- EnforcedStyle: double_quotes
7
-
8
- Style/StringLiteralsInInterpolation:
9
- Enabled: true
10
- EnforcedStyle: double_quotes
11
-
12
- Layout/LineLength:
13
- Max: 120