duffy 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1e0035fd1678d2bc2c4e6bcad1429a3fc9fc1fa9
4
- data.tar.gz: ec504588e66ea7dfafa7090dede5b8d1e872e901
3
+ metadata.gz: 27b9a5bf4d430558299ac0752859081b77266e2c
4
+ data.tar.gz: 3df3f6e3f78f55f272a3034f78b818451e959236
5
5
  SHA512:
6
- metadata.gz: c6d56016fdbc81816dc4cb753777f730d819e7dad69b80690971afdb8fc3decf85c66687c5321ba3d2f42cfc69647bd8651cebb8424bbdb5d94d145044a7273f
7
- data.tar.gz: f67d6f42090a26e34cb25385ba6594327e68abe329fd0e04374a826e24f94efda48b589cc9363efc94ced1f0de533222f13ec421aa12dfe970488d7676b0ae15
6
+ metadata.gz: d34d78f2e9564458c0c6e6af9972205170cb847b075a783535b809d34ff53abf8db2e3d6978c03a323c5d32122598024f9caf387893c13c9caf585cbe0f52040
7
+ data.tar.gz: fc4c763e052d4880f821793d6d21172d2d4547bb038e69cd1baec94e8c762c909dec617ae7b5b3019016ceb9625315ffb3ec60acc1fcc80cb5e24f6560a5543f
data/README.md CHANGED
@@ -31,6 +31,11 @@ String Patches:
31
31
  smart_titlecase # Note: Has config options. See lib/duffy.rb
32
32
  ```
33
33
 
34
+ Date Patches:
35
+ ```ruby
36
+ fiscal_year # Returns fiscal_year for a date. See config to set your organization's fiscal year start.
37
+ ```
38
+
34
39
  Git Access:
35
40
  This one is namespaced in case you use the 'git' gem. I found it to be overkill for what I wanted.
36
41
  ```ruby
data/duffy.gemspec CHANGED
@@ -18,6 +18,7 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
+ spec.add_dependency 'activesupport' # Required for ActiveSupport::Configurable
21
22
  spec.add_development_dependency "bundler", "~> 1.7"
22
23
  spec.add_development_dependency "rake", "~> 10.0"
23
24
  spec.add_development_dependency "rails"
data/lib/duffy/date.rb ADDED
@@ -0,0 +1,9 @@
1
+ class Date
2
+
3
+ # Return the fiscal year for a given date.
4
+ # See config to set the start of your fiscal year.
5
+ # Example: Date.new(2015,10,1).fiscal_year => 2016
6
+ def fiscal_year
7
+ (self < Date.new(year, Duffy.configuration.fiscal_month, Duffy.configuration.fiscal_day)) ? year : year + 1
8
+ end
9
+ end
data/lib/duffy/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Duffy
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
data/lib/duffy.rb CHANGED
@@ -1,10 +1,16 @@
1
- require File.dirname(__FILE__) + "/duffy/engine"
2
- require File.dirname(__FILE__) + "/duffy/railtie" if defined?(Rails)
1
+ # External Requirements
2
+ require 'active_support'
3
+ require 'date'
3
4
 
5
+ # Rails Only Requirements
6
+ require File.dirname(__FILE__) + "/duffy/engine" if defined?(Rails)
7
+ require File.dirname(__FILE__) + "/duffy/railtie" if defined?(Rails)
4
8
 
9
+ # Normal Requirements
5
10
  require File.dirname(__FILE__) + "/duffy/version"
6
11
  require File.dirname(__FILE__) + "/duffy/git"
7
12
  require File.dirname(__FILE__) + "/duffy/string"
13
+ require File.dirname(__FILE__) + "/duffy/date"
8
14
 
9
15
 
10
16
  # Required to add assets to pipeline
@@ -40,9 +46,11 @@ module Duffy
40
46
  # Pretty Committer
41
47
  config_accessor(:committers) # {"jpd" => "Jacob", "ers|Eric" => "Eric"}
42
48
 
49
+ # Fiscal Year Start: Default July 1st.
50
+ config_accessor(:fiscal_month) {7}
51
+ config_accessor(:fiscal_day) {1}
43
52
  end
44
53
 
45
-
46
54
  end
47
55
 
48
56
 
data/spec/date_spec.rb ADDED
@@ -0,0 +1,26 @@
1
+ require 'spec_helper'
2
+ describe Date do
3
+
4
+ describe "fiscal_year (Assuming July 1st Start)" do
5
+
6
+ it "2000-07-01 => 2001" do
7
+ Date.new(2000,7,1).fiscal_year.should == 2001
8
+ end
9
+
10
+ it "2000-06-30 => 2000" do
11
+ Date.new(2000,6,30).fiscal_year.should == 2000
12
+ end
13
+
14
+ it "2000-01-01 => 2000" do
15
+ Date.new(2000,1,1).fiscal_year.should == 2000
16
+ end
17
+
18
+ it "1999-12-31 => 2000" do
19
+ Date.new(1999,12,31).fiscal_year.should == 2000
20
+ end
21
+
22
+ end
23
+
24
+
25
+ end
26
+
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: duffy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
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-02-17 00:00:00.000000000 Z
11
+ date: 2015-03-11 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activesupport
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: bundler
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -81,12 +95,14 @@ files:
81
95
  - Rakefile
82
96
  - duffy.gemspec
83
97
  - lib/duffy.rb
98
+ - lib/duffy/date.rb
84
99
  - lib/duffy/duffy_helper.rb
85
100
  - lib/duffy/engine.rb
86
101
  - lib/duffy/git.rb
87
102
  - lib/duffy/railtie.rb
88
103
  - lib/duffy/string.rb
89
104
  - lib/duffy/version.rb
105
+ - spec/date_spec.rb
90
106
  - spec/spec_helper.rb
91
107
  - spec/string_spec.rb
92
108
  - vendor/assets/stylesheets/duffy/print.css
@@ -111,10 +127,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
111
127
  version: '0'
112
128
  requirements: []
113
129
  rubyforge_project:
114
- rubygems_version: 2.4.3
130
+ rubygems_version: 2.4.2
115
131
  signing_key:
116
132
  specification_version: 4
117
133
  summary: Library of things
118
134
  test_files:
135
+ - spec/date_spec.rb
119
136
  - spec/spec_helper.rb
120
137
  - spec/string_spec.rb