Duffy
This is a collection of reusable things I don't want to keep duplicating in tons of projects.
Installation
Add this line to your application's Gemfile:
- This is a work in progress. If someone decides to use this, you may want to lock your version number in your gemfile.
gem 'duffy'
And then execute:
$ bundle
Usage
String Patches:
to_ssn
to_numeric
to_alpha
to_alpha_numeric
pretty_phone
pretty_committer # "bob".pretty_committer => "Robert McLovin"
space2nbsp
nl2br
gender_human
smart_titlecase # Note: Has config options. See lib/duffy.rb
Date Patches:
fiscal_year # Returns fiscal_year for a date. See config to set your organization's fiscal year start.
Active Record Aliases:
accepts => accepts_nested_attributes_for
habtm => has_and_belongs_to_many
Git Access: This one is namespaced in case you use the 'git' gem. I found it to be overkill for what I wanted.
Duffy::Git.log # => Produce tab separated listing of current git log.
Duffy::Git.count # => Count of git commits in current branch
Duffy::Git.email # => Local repo's git user.email or global if none.
Duffy::Git.branch # => Current git branch.
CPU Detection: Linux and Mac only for now, each method returns 1 on unsupported hosts. Example results for my dual core i5 with hyperthreading.
Duffy::System.cpus # => 1
Duffy::System.cores # => 2
Duffy::System.threads # => 4
Duffy::System.sane_load # => 3
View Helpers: This is a work in progress. I'm going to try to put all my generic helpers here.
excel_icon
icon
CSS Reset & Print Styles: Very barebones CSS Reset / Sensible defaults and Print stylesheets.
require duffy/reset
require duffy/print
Contributing
- Fork it ( https://github.com/[my-github-username]/duffy/fork )
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request