Small TravisCI Dependency Status

Small collection of useful Ruby utilities

Support

  • Ruby 1.9.x
  • JRuby 1.6.x in 1.9 mode
  • Rubinious 1.2.x in 1.9 mode

Classes

  • Math

    • fibanocci(n)
    • factorial(n)
  • String

    • camelize
    • dashize
    • humanize
    • underscore
    • constantize
    • encode64
    • decode64
    • to_sha1
    • to_sha256(provider)
    • to_md5
    • escape
    • unescape
    • html_escape
    • url_encode
  • Integer

    • year, years
    • month, months
    • week, weeks
    • day, days
    • hour, hours
    • minute, minutes
    • second, seconds
  • Array

    • extract_options
    • sample
  • Hash

    • stringify_keys!
    • symbolize_keys!
    • to_params
  • Time

    • since(seconds)
    • ago(seconds)
    • advance(options)
    • change(options)
    • to_date
    • to_datetime
    • to_formatted_s(format)
    • leap_year?
    • weekend?
    • today?
    • future?
    • past?
    • days_in_month
    • days_to_week_start(start_day)
    • weekends
    • business_week(start_day)
    • beginning_of_business_week(start_day)
    • end_of_business_week(start_day)
    • beginning_of_day
    • beginning_of_week(start_day)
    • beginning_of_month
    • beginning_of_year
    • end_of_day
    • end_of_week(start_day)
    • end_of_month
    • end_of_year
    • tomorrow
    • yesterday
    • next_year
    • last_year
    • next_month
    • last_month
    • next_week
    • last_week
  • Object

    • string?
    • boolean?
    • numeric?
    • integer?
    • fixnum?
    • float?
    • proc?
    • blank?
    • present?
    • presence
    • try(method, &block)
  • Benchmark - small DSL for Benchmark class

    • benchmark(&block)
    • measure(&block)
    • realtime(&block)
    • run(n, &block)

      require 'small/benchmark'

      benchmark do |b| b.report("test") do run 50_000 do puts "hello world" end end end

Notes: some codes extracted from ActiveSupport, but some codes are modified

Benchmark

Using a time command execution

Small: time ruby -r small -e 'puts Time.now.end_of_week'

2012-05-06 23:59:59 -0500

real    0m0.167s
user    0m0.113s
sys     0m0.048s

ActiveSupport: time ruby -r active_support/all -e 'puts Time.now.end_of_week'

2012-05-06 23:59:59 -0500

real    0m1.320s
user    0m1.240s
sys     0m0.074s

License

small is licensed under the MIT license