Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

compact_enc_det

Package Overview
Dependencies
Maintainers
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

compact_enc_det

  • 1.0.0
  • Rubygems
  • Socket score

Version published
Maintainers
2
Created
Source

Compact Encoding Detection for Ruby

Ruby bindings for Google's Compact Encoding Detection (CED for short) C++ library

Usage

You will need CMake to build the C++ native extension.

 macOS

You can use Homebrew to install it:

brew install cmake

Then you can install the gem from RubyGems.org.

Either add this to your Gemfile:

gem 'compact_enc_det', '~> 0.1'

or run the following command to install it:

gem install compact_enc_det

Now you can detect the encoding via the CompactEncDet.detect_encoding, which is a thin wrapper around CompactEncDet::DetectEncoding and MimeEncodingName functions from the C++ library.

file = File.read("unknown-encoding.txt", mode: "rb")
result = CompactEncDet.detect_encoding(file)
result.encoding
# => #<Encoding:Windows-1250>
result.bytes_consumed
# => 239
result.is_reliable?
# => true

Contributing

Any contributions are welcome! Feel free to open an issue or a pull request.

Repository

The google/compact_enc_det repository is linked as a Git submodule at ext/compact_enc_det/compact_enc_det.

You need to clone the repository with --recurse-submodules flag:

git clone --recurse-submodules git@github.com:cloudaper/compact_enc_det.git

Or initialize and update the submodule after cloning with the following commands:

git submodule init && git submodule update

Testing

Tests located at tests use the minitest framework.

Run the tests via test Rake task:

rake test

The gem will be compiled to lib/compact_enc_det/compact_enc_det.bundle first.

License

This gem is released under MIT license, while the original Google's Compact Encoding Detection library source code, located at ext/compact_enc_det/compact_enc_det, is under the Apache-2.0 license.

FAQs

Package last updated on 19 Mar 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc