Ruby gem that takes code as input (HTML, JavaScript, or CSS), determines the code language, validates it, and then minifies it.
Go to file
2024-02-28 21:18:26 -07:00
bin Change name from Miniparse to Miniparser 2023-08-24 06:41:11 -06:00
lib Update gemspec and gitignore 2023-09-20 00:13:32 -06:00
sig Change name from Miniparse to Miniparser 2023-08-24 06:41:11 -06:00
spec Change name from Miniparse to Miniparser 2023-08-24 06:41:11 -06:00
.gitignore testing webhook 2023-10-06 16:14:48 -06:00
.rspec Upload finished Gem V1.0 2023-08-24 06:26:44 -06:00
.rubocop.yml Upload finished Gem V1.0 2023-08-24 06:26:44 -06:00
CHANGELOG.md Upload finished Gem V1.0 2023-08-24 06:26:44 -06:00
CODE_OF_CONDUCT.md Upload finished Gem V1.0 2023-08-24 06:26:44 -06:00
Gemfile Upload finished Gem V1.0 2023-08-24 06:26:44 -06:00
Gemfile.lock Update License and Bundle 2023-09-19 22:57:37 -06:00
LICENSE Update License and Bundle 2023-09-19 22:57:37 -06:00
Miniparser.gemspec Update gemspec and gitignore 2023-09-20 00:13:32 -06:00
Rakefile Upload finished Gem V1.0 2023-08-24 06:26:44 -06:00
README.md Update README.md 2024-02-28 21:18:26 -07:00

Miniparser

Miniparser is a Ruby gem that takes code as input (HTML, JavaScript, or CSS), determines the code language, validates it, and then minifies it. It returns whether the code is valid or not, and if valid, provides the minified code.

If you'd like to support PixelRidge Softworks OpenSource Development, check out our Patreon
If you need more direct help, join our Discord

Installation

Add this line to your application's Gemfile:

gem 'Miniparser'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install Miniparser

Usage

Miniparser provides two main methods to process either a file or a string containing HTML, JavaScript, or CSS code.

Processing a File

You can process a file by calling the type_file method and passing the file path as an argument:

result = Miniparser::Processor.type_file('path/to/yourfile.html')

Processing a String

You can process a string containing code by calling the type_string method:

result = Miniparser::Processor.type_string('<html><head></head><body></body></html>')

Both methods return a hash containing the validation status, any errors, and the minified code if the input was valid:

{
  valid: true or false,
  errors: "Error message if any",
  minified_code: "Minified code if valid"
}

Contributing

Bug reports and pull requests are welcome. Please adhere to the code of conduct.

License

The gem is available as open source under the terms of the MIT License.