fyuk 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +4 -0
- data/Gemfile.lock +9 -0
- data/VERSION +1 -1
- data/fyuk.gemspec +6 -3
- data/lib/uk_financial_year.rb +11 -0
- data/spec/uk_financial_year_spec.rb +30 -0
- metadata +20 -4
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,6 +1,14 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
+
columnize (0.3.6)
|
5
|
+
debugger (1.1.3)
|
6
|
+
columnize (>= 0.3.1)
|
7
|
+
debugger-linecache (~> 1.1.1)
|
8
|
+
debugger-ruby_core_source (~> 1.1.2)
|
9
|
+
debugger-linecache (1.1.1)
|
10
|
+
debugger-ruby_core_source (>= 1.1.1)
|
11
|
+
debugger-ruby_core_source (1.1.2)
|
4
12
|
diff-lcs (1.1.3)
|
5
13
|
git (1.2.5)
|
6
14
|
jeweler (1.6.4)
|
@@ -25,6 +33,7 @@ PLATFORMS
|
|
25
33
|
|
26
34
|
DEPENDENCIES
|
27
35
|
bundler (~> 1.0.0)
|
36
|
+
debugger
|
28
37
|
jeweler (~> 1.6.4)
|
29
38
|
rcov
|
30
39
|
rspec (~> 2.9.0)
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.6.0
|
data/fyuk.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "fyuk"
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.6.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Nigel Lowry"]
|
12
|
-
s.date = "2012-
|
12
|
+
s.date = "2012-06-27"
|
13
13
|
s.description = "Small library with methods for finding the financial or fiscal year for a particular date and suchlike"
|
14
14
|
s.email = "nigel-lowry@ultra.eclipse.co.uk"
|
15
15
|
s.extra_rdoc_files = [
|
@@ -34,7 +34,7 @@ Gem::Specification.new do |s|
|
|
34
34
|
s.homepage = "http://github.com/nigel-lowry/fyuk"
|
35
35
|
s.licenses = ["MIT"]
|
36
36
|
s.require_paths = ["lib"]
|
37
|
-
s.rubygems_version = "1.8.
|
37
|
+
s.rubygems_version = "1.8.24"
|
38
38
|
s.summary = "Small Ruby gem for dealing with dates in the UK financial year"
|
39
39
|
|
40
40
|
if s.respond_to? :specification_version then
|
@@ -46,12 +46,14 @@ Gem::Specification.new do |s|
|
|
46
46
|
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
|
47
47
|
s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
|
48
48
|
s.add_development_dependency(%q<rcov>, [">= 0"])
|
49
|
+
s.add_development_dependency(%q<debugger>, [">= 0"])
|
49
50
|
else
|
50
51
|
s.add_dependency(%q<rspec>, ["~> 2.9.0"])
|
51
52
|
s.add_dependency(%q<yard>, ["~> 0.6.0"])
|
52
53
|
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
53
54
|
s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
|
54
55
|
s.add_dependency(%q<rcov>, [">= 0"])
|
56
|
+
s.add_dependency(%q<debugger>, [">= 0"])
|
55
57
|
end
|
56
58
|
else
|
57
59
|
s.add_dependency(%q<rspec>, ["~> 2.9.0"])
|
@@ -59,6 +61,7 @@ Gem::Specification.new do |s|
|
|
59
61
|
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
60
62
|
s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
|
61
63
|
s.add_dependency(%q<rcov>, [">= 0"])
|
64
|
+
s.add_dependency(%q<debugger>, [">= 0"])
|
62
65
|
end
|
63
66
|
end
|
64
67
|
|
data/lib/uk_financial_year.rb
CHANGED
@@ -90,6 +90,17 @@ class UkFinancialYear
|
|
90
90
|
self.first_day.after?(date_to_compare date_or_fy)
|
91
91
|
end
|
92
92
|
|
93
|
+
# returns the period before this date in the financial year
|
94
|
+
# @param [Date] date a date in the financial year
|
95
|
+
# @return [Range<Date>] the period before this date in the the
|
96
|
+
# financial year
|
97
|
+
def period_before date
|
98
|
+
raise "#{date} is before FY #{to_s}" if date < first_day
|
99
|
+
raise "#{date} is after FY #{to_s}" if date > last_day
|
100
|
+
|
101
|
+
first_day...date
|
102
|
+
end
|
103
|
+
|
93
104
|
# equality method
|
94
105
|
def == other
|
95
106
|
self.first_day == other.first_day
|
@@ -109,4 +109,34 @@ describe UkFinancialYear do
|
|
109
109
|
end
|
110
110
|
end
|
111
111
|
end
|
112
|
+
|
113
|
+
describe "#fy_before" do
|
114
|
+
before :each do
|
115
|
+
@fy = UkFinancialYear.from_s '2012/13'
|
116
|
+
end
|
117
|
+
|
118
|
+
subject { @fy }
|
119
|
+
|
120
|
+
it "raises an error for a date before the FY" do
|
121
|
+
expect {
|
122
|
+
@fy.period_before(Date.parse '5 Apr 2012')
|
123
|
+
}.to raise_error(
|
124
|
+
RuntimeError,
|
125
|
+
/2012-04-05 is before FY 2012\/13/
|
126
|
+
)
|
127
|
+
end
|
128
|
+
|
129
|
+
it "raises an error for a date after the FY" do
|
130
|
+
expect {
|
131
|
+
@fy.period_before(Date.parse '6 Apr 2013')
|
132
|
+
}.to raise_error(
|
133
|
+
RuntimeError,
|
134
|
+
/2013-04-06 is after FY 2012\/13/
|
135
|
+
)
|
136
|
+
end
|
137
|
+
|
138
|
+
specify { @fy.period_before(Date.parse '6 Apr 2012').should == (Date.parse('6 Apr 2012')...Date.parse('6 Apr 2012')) }
|
139
|
+
specify { @fy.period_before(Date.parse '7 Apr 2012').should == (Date.parse('6 Apr 2012')...Date.parse('7 Apr 2012')) }
|
140
|
+
specify { @fy.period_before(Date.parse '8 Apr 2012').should == (Date.parse('6 Apr 2012')...Date.parse('8 Apr 2012')) }
|
141
|
+
end
|
112
142
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fyuk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-06-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
@@ -91,6 +91,22 @@ dependencies:
|
|
91
91
|
- - ! '>='
|
92
92
|
- !ruby/object:Gem::Version
|
93
93
|
version: '0'
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: debugger
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
94
110
|
description: Small library with methods for finding the financial or fiscal year for
|
95
111
|
a particular date and suchlike
|
96
112
|
email: nigel-lowry@ultra.eclipse.co.uk
|
@@ -128,7 +144,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
128
144
|
version: '0'
|
129
145
|
segments:
|
130
146
|
- 0
|
131
|
-
hash: -
|
147
|
+
hash: -341857106633386202
|
132
148
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
133
149
|
none: false
|
134
150
|
requirements:
|
@@ -137,7 +153,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
137
153
|
version: '0'
|
138
154
|
requirements: []
|
139
155
|
rubyforge_project:
|
140
|
-
rubygems_version: 1.8.
|
156
|
+
rubygems_version: 1.8.24
|
141
157
|
signing_key:
|
142
158
|
specification_version: 3
|
143
159
|
summary: Small Ruby gem for dealing with dates in the UK financial year
|