ProductPromotion
Logo

Ruby

made by https://0x3d.site

GitHub - kddnewton/fast_underscore: Fast String#underscore implementation
Fast String#underscore implementation. Contribute to kddnewton/fast_underscore development by creating an account on GitHub.
Visit Site

GitHub - kddnewton/fast_underscore: Fast String#underscore implementation

GitHub - kddnewton/fast_underscore: Fast String#underscore implementation

String#underscore Ruby Extension

Build Status Gem Version

fast_underscore is a C extension that provides a fast implementation of ActiveSupport's String#underscore method.

Is it fast?

At last check, these were the benchmarks (obtained by running bin/bench with Rails 6.0.2):

Warming up --------------------------------------
       ActiveSupport     5.000  i/100ms
      FastUnderscore    70.000  i/100ms
Calculating -------------------------------------
       ActiveSupport     50.564  (± 9.9%) i/s -    250.000  in   5.012563s
      FastUnderscore    707.691  (± 1.3%) i/s -      3.570k in   5.045375s

Comparison:
      FastUnderscore:      707.7 i/s
       ActiveSupport:       50.6 i/s - 14.00x  slower

Installation

Add this line to your application's Gemfile:

gem "fast_underscore"

And then execute:

$ bundle

Or install it yourself as:

$ gem install fast_underscore

Usage with Rails

ActiveSupport::Inflector#underscore, in addition to underscoring the input will additionally take into account known acronyms. Since this can't be done at compile time, FastUnderscore will detect when ActiveSupport is loaded and take advantage of its knowledge of acronyms while still using the native extension.

Since the #underscore method is used so much throughout the Rails boot process (for autoloading dependencies, determining table names, determining inverse associations, etc.), it's best to hook into Rails as early as possible. As such, for the best results in your Gemfile add require: false to the gem 'fast_underscore' declaration and add require 'fast_underscore' to the bottom of config/boot.rb.

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake test to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

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 tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/kddnewton/fast_underscore.

License

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

More Resources
to explore the angular.

mail [email protected] to add your project or resources here 🔥.

Related Articles
to learn about angular.

FAQ's
to learn more about Angular JS.

mail [email protected] to add more queries here 🔍.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory