duffy 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 22b179e054fe7229fd44535f087c9ab8b3d90c97
4
- data.tar.gz: 76219dc6b0d31b663361d6c4d74965c3d0471d42
3
+ metadata.gz: 96eeac69472d545eb850cd92b52896f386a82ee6
4
+ data.tar.gz: 1b2ff4d0e8628918f2cab3080da6b14da94579be
5
5
  SHA512:
6
- metadata.gz: e9f3cc09d73b88b3bee6dbf51666a843379fe8dd50737adda3d0ac87f5a24aa35df2912d045670ba0749df3fda9736b95a692ec59ca627bf641e735ede6c5323
7
- data.tar.gz: f8c75b91a04cd5c670845dea886c7015d46821e4003e6c779219f1b53e748d12aba715dfa6b9e0c9f74750122ca9b977aa9d32f71669356b950b707b5bbfba4a
6
+ metadata.gz: 374da46815f90ac5b63501bb74e89bf296fa69c46360c4c8a01f191879239fdc8823bd6fa91399fc8e727ab0b9223597574da84aedce87fec5203f6a75bde2b6
7
+ data.tar.gz: ab58ee610db03e93da864b2419f1cbb1aab9bb20482d62db51bc464322273241a06f9293a17ae7b6e938c3a846b723133a2d879339ca33146f295a814423ed00
data/README.md CHANGED
@@ -15,69 +15,86 @@ gem 'duffy'
15
15
  ```
16
16
 
17
17
  And then execute:
18
-
19
- $ bundle
18
+ ```shell
19
+ $ bundle
20
+ ```
20
21
 
21
22
  ## Usage
22
23
 
23
24
  String Patches:
24
- ```ruby
25
- to_ssn
26
- to_numeric
27
- to_alpha
28
- to_alpha_numeric
29
- pretty_phone
30
- pretty_committer # "bob".pretty_committer => "Robert McLovin"
31
- space2nbsp
32
- nl2br
33
- gender_human
34
- smart_titlecase # Note: Has config options. See lib/duffy.rb
35
- ```
25
+
26
+ Method | Example | Output
27
+ ------------------|-----------------|-------
28
+ date! | "2014-07-16" | #< Date: 2015-07-16 >
29
+ md5 | "duffy" | "904bc6e21e4799ce276200117215b88b"
30
+ md5sum | "duffy" | "904bc6e21e4799ce276200117215b88b"
31
+ to_ssn | "123456789" | "123-45-6789"
32
+ to_numeric | "abc123" | "123"
33
+ to_alpha | "abc123" | "abc"
34
+ to_alpha_numeric | "abc#$%123" | "abc123
35
+ pretty_phone | "1234567890" | "(123) 456-7890"
36
+ pretty_committer | "bart" | "Bartholomew Simpson" (See config)
37
+ space2nbsp | "space out" | "space&nbsp;out" (requires rails)
38
+ nl2br | "space\nout" | "space<br/>out" (requires rails)
39
+ gender_human | "F" | "Female"
40
+ smart_titlecase | "this and that" | "This and That" (Note: Has config options. See lib/duffy.rb)
41
+
36
42
 
37
43
  Date Patches:
38
- ```ruby
39
- fiscal_year # Returns fiscal_year for a date. See config to set your organization's fiscal year start.
40
- ```
44
+
45
+ Method | Example | Output
46
+ ------------------|-----------------|-------
47
+ date! | Date.today | self
48
+ fiscal_year | Date.today | 2015 (See config to set your organization's fiscal year start.)
49
+
50
+
51
+ NilClass Patches:
52
+
53
+ Method | Example | Output
54
+ ------------------|-----------------|-------
55
+ date! | nil | self (Exists so you can call .date! on Date, String or nil
56
+
41
57
 
42
58
  Active Record Aliases:
43
- ```ruby
44
- accepts => accepts_nested_attributes_for
45
- habtm => has_and_belongs_to_many
46
- ```
59
+
60
+ Alias | Standard
61
+ ------------------|---------
62
+ accepts | accepts_nested_attributes_for
63
+ habtm | has_and_belongs_to_many
47
64
 
48
65
 
49
66
  Git Access:
50
67
  This one is namespaced in case you use the 'git' gem. I found it to be overkill for what I wanted.
51
68
  ```ruby
52
- Duffy::Git.log # => Produce tab separated listing of current git log.
53
- Duffy::Git.count # => Count of git commits in current branch
54
- Duffy::Git.email # => Local repo's git user.email or global if none.
55
- Duffy::Git.branch # => Current git branch.
69
+ Duffy::Git.log # => Produce tab separated listing of current git log.
70
+ Duffy::Git.count # => Count of git commits in current branch
71
+ Duffy::Git.email # => Local repo's git user.email or global if none.
72
+ Duffy::Git.branch # => Current git branch.
56
73
  ```
57
74
 
58
75
  CPU Detection:
59
76
  Linux and Mac only for now, each method returns 1 on unsupported hosts.
60
77
  Example results for my dual core i5 with hyperthreading.
61
78
  ```ruby
62
- Duffy::System.cpus # => 1
63
- Duffy::System.cores # => 2
64
- Duffy::System.threads # => 4
65
- Duffy::System.sane_load # => 3
79
+ Duffy::System.cpus # => 1
80
+ Duffy::System.cores # => 2
81
+ Duffy::System.threads # => 4
82
+ Duffy::System.sane_load # => 3
66
83
  ```
67
84
 
68
85
 
69
86
  View Helpers:
70
87
  This is a work in progress. I'm going to try to put all my generic helpers here.
71
88
  ```ruby
72
- menu_tag
73
- excel_icon
74
- icon
89
+ menu_tag
90
+ excel_icon
91
+ icon
75
92
  ```
76
93
 
77
94
  CSS Reset & Print Styles: Very barebones CSS Reset / Sensible defaults and Print stylesheets.
78
95
  ```ruby
79
- require duffy/reset
80
- require duffy/print
96
+ require duffy/reset
97
+ require duffy/print
81
98
  ```
82
99
 
83
100
  ## Contributing
data/lib/duffy/date.rb CHANGED
@@ -6,4 +6,14 @@ class Date
6
6
  def fiscal_year
7
7
  (self < Date.new(year, Duffy.configuration.fiscal_month, Duffy.configuration.fiscal_day)) ? year : year + 1
8
8
  end
9
+
10
+ def date!
11
+ self
12
+ end
9
13
  end
14
+
15
+ class NilClass
16
+ def date!
17
+ self
18
+ end
19
+ end
data/lib/duffy/string.rb CHANGED
@@ -1,6 +1,12 @@
1
1
  # Monkey Patch String adding useful methods.
2
2
  class String
3
3
 
4
+ # Cast a String to Date
5
+ def date!
6
+ Date.parse(self)
7
+ end
8
+
9
+
4
10
  # Easier way to calculate the md5sum of a string.
5
11
  def md5
6
12
  Digest::MD5.hexdigest(self)
data/lib/duffy/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Duffy
2
- VERSION = "0.2.2"
2
+ VERSION = "0.2.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: duffy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jacob Duffy
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-19 00:00:00.000000000 Z
11
+ date: 2015-08-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport