Socket
Book a DemoInstallSign in
Socket

run_no_mo

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

run_no_mo

1.0.0
bundlerRubygems
Version published
Maintainers
1
Created
Source

RunNoMo

Helps you rate limit the execution of code!

Installation

Add this line to your application's Gemfile:

gem 'run_no_mo'

And then execute:

$ bundle

Or install it yourself as:

$ gem install run_no_mo

Usage (look at the test files for usage)

require "test_helper"

class RunNoMoTest < Minitest::Test
  def test_that_it_has_a_version_number
    refute_nil ::RunNoMo::VERSION
  end

  def test_limiter_limits__count
    #  create a limiter using factory
    limiter = RunNoMo.limit times: 5, raises: true
    
    # run 4 times
    4.times do
      limiter.run { noop }
    end

    # run 1 more time
    limiter.run { noop }
    
    # run once again NO-MO
    assert_raises RunNoMo::LimitExceeded do
      # does not get executed
      limiter.run { noop }
    end
  end

  def test_limiter__limiters__count__within
    limiter = RunNoMo::limit times: 2, within: 3.seconds, raises: true

    assert_raises RunNoMo::LimitExceeded do
      3.times do
        limiter.run { noop }
      end
    end

    limiter = RunNoMo::limit times: 2, within: 1.second, raises: true

    3.times do
      limiter.run { sleep 1 }
    end
  end

  def test_limiter_no_throw
    limiter = RunNoMo::limit times: 3

    count = 0

    5.times do
      limiter.run { count += 1 }
    end

    assert_equal 3, count
  end

  private

  def noop; end
end

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.

License

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

FAQs

Package last updated on 09 May 2020

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.