This is a collection of reusable things I don't want to keep duplicating in tons of projects.
Add this line to your application's Gemfile:
gem 'duffy'
And then execute:
$ bundle
Method | Example | Output |
---|---|---|
to_box | ['abc', 123].to_box | |
to_markdown | [[1,2],[3,4]].to_markdown |
- See config to set your organization's fiscal year start.
Method | Example | Output |
---|---|---|
beginning_of_fiscal_year | Date.today.beginning_of_fiscal_year | 2017-07-01 |
end_of_fiscal_year | Date.today.end_of_fiscal_year | 2018-06-30 |
fiscal_year | Date.today.fiscal_year | 2018 |
Method | Example | Output |
---|---|---|
to_date | nil | self (Exists so you can call .to_date on Date, String or nil |
Alias | Standard |
---|---|
accepts | accepts_nested_attributes_for |
habtm | has_and_belongs_to_many |
Method | Result |
---|---|
Duffy::Git.branch | Current git branch. |
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.log | Produce tab separated listing of current git log. |
- Linux and Mac only for now, numeric methods return 1 on unsupported hosts.
virtual?
detects if the system is hypervisor guest. Will return false if unable to determine.- Example results for my dual core i5 with hyperthreading.
Method | Result |
---|---|
Duffy::System.cpus | 1 |
Duffy::System.cores | 2 |
Duffy::System.threads | 4 |
Duffy::System.sane_load | 3 |
Duffy::System.cpu_percent | 16 |
Duffy::System.virtual? | true |
- All values returned in Megabytes.
- Available + Used always exactly adds up to Total.
Method | Result |
---|---|
Duffy::System.mem_total | 4096 |
Duffy::System.mem_available | 3072 |
Duffy::System.mem_used | 1024 |
Duffy::System.mem_percent | 25 |
- Rails
Method | Example | Result |
---|---|---|
beast_mode | beast_mode tags | renders tag partial in parallel. Only available if you have the Parallel gem in your Gemfile. You must also wrap your partial in a cache block. |
- 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