0.0
No commit activity in last 3 years
No release in over 3 years
Enable Proc level Refinements forcibly.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.16
~> 10.0
~> 3.0

Runtime

 Project Readme

sin_refinements

This gem enables Proc level refinements forcibly.

But it is too slow!! Please don't use in production.

sin means that this gem uses very sinned way (eval, AST, instance_exec). And sin (真) means True in Japanese.

Installation

Add this line to your application's Gemfile:

gem 'sin_refinements'

And then execute:

$ bundle

Or install it yourself as:

$ gem install sin_refinements

Usage

module ExtMod
  refine String do
    def bang
      "#{self}!!"
    end
  end
end

SinRefinements.refining(ExtMod) do
  expect("foo".bang).to eq("foo!!")
end

Performance

SinRefinements.refining

Warming up --------------------------------------
    plain   153.770k i/100ms
 refining    56.000  i/100ms
Calculating -------------------------------------
    plain    2.094M (± 3.3%) 
 refining  560.413  (± 1.2%) 

Comparison:
    plain:  2093833.1 i/s
 refining:      560.4 i/s - 3736.23x  slower

SinRefinements.light_refining

This version does not support local variables.

Warming up --------------------------------------
    plain   145.078k i/100ms
 refining    18.123k i/100ms
Calculating -------------------------------------
    plain      1.941M (± 3.0)
 refining    189.518k (± 2.6)

Comparison:
    plain:  1941491.1 i/s
 refining:   189518.0 i/s - 10.24x  slower

Development

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.

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/joker1007/sin_refinements.

License

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