fyuk 0.1.0 → 0.1.1
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.
- data/README.rdoc +1 -1
- data/VERSION +1 -1
- data/fyuk.gemspec +1 -1
- data/lib/uk_financial_year.rb +14 -1
- data/spec/uk_financial_year_spec.rb +20 -6
- metadata +12 -12
data/README.rdoc
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.1.1
|
data/fyuk.gemspec
CHANGED
data/lib/uk_financial_year.rb
CHANGED
@@ -17,6 +17,7 @@ class UkFinancialYear
|
|
17
17
|
# @param [String] s the two years of the financial year in the form
|
18
18
|
# of the first year as four digits, a '/', then the last year as
|
19
19
|
# two digits
|
20
|
+
# @raise [RuntimeError] if the string cannot be parsed to a financial year
|
20
21
|
# @return [UkFinancialYear] the financial year specified by the string
|
21
22
|
def UkFinancialYear.from_s s
|
22
23
|
if /^(?<year1>\d{4})\/(?<year2>\d{2})$/ =~ s
|
@@ -50,6 +51,18 @@ class UkFinancialYear
|
|
50
51
|
@range.include? date
|
51
52
|
end
|
52
53
|
|
54
|
+
# returns the next financial year
|
55
|
+
# @return [UkFinancialYear] the next financial year
|
56
|
+
def next
|
57
|
+
UkFinancialYear.new self.first_day.next_year
|
58
|
+
end
|
59
|
+
|
60
|
+
# returns the previous financial year
|
61
|
+
# @return [UkFinancialYear] the previous financial year
|
62
|
+
def previous
|
63
|
+
UkFinancialYear.new self.first_day.prev_year
|
64
|
+
end
|
65
|
+
|
53
66
|
# returns string representation of the financial year in the form '2000/01'
|
54
67
|
# @return [String] representation in the form of the first year as four
|
55
68
|
# digits, a '/', then the last year as two digits
|
@@ -62,7 +75,7 @@ class UkFinancialYear
|
|
62
75
|
self.first_day == other.first_day
|
63
76
|
end
|
64
77
|
|
65
|
-
# lesser financial years are those which occur
|
78
|
+
# lesser financial years are those which occur earliest
|
66
79
|
def <=>(other)
|
67
80
|
self.first_day <=> other.first_day
|
68
81
|
end
|
@@ -66,37 +66,37 @@ describe UkFinancialYear do
|
|
66
66
|
|
67
67
|
describe "#to_s" do
|
68
68
|
it "is the four-digit year then a '/' then a two-digit year" do
|
69
|
-
fy = UkFinancialYear.new
|
69
|
+
fy = UkFinancialYear.new Date.parse '7 Apr 2011'
|
70
70
|
fy.to_s.should == '2011/12'
|
71
71
|
end
|
72
72
|
|
73
73
|
it "is 1999/00 for the turn of the millenium" do
|
74
|
-
fy = UkFinancialYear.new
|
74
|
+
fy = UkFinancialYear.new Date.parse '7 Apr 1999'
|
75
75
|
fy.to_s.should == '1999/00'
|
76
76
|
end
|
77
77
|
end
|
78
78
|
|
79
79
|
describe "#from_s" do
|
80
80
|
it "is 2010/11 for '2010/11'" do
|
81
|
-
fy = UkFinancialYear.from_s
|
81
|
+
fy = UkFinancialYear.from_s '2010/11'
|
82
82
|
fy.first_day.should == Date.parse('6 Apr 2010')
|
83
83
|
fy.last_day.should == Date.parse('5 Apr 2011')
|
84
84
|
end
|
85
85
|
|
86
86
|
it "is 2002/03 for '2002/03'" do
|
87
|
-
fy = UkFinancialYear.from_s
|
87
|
+
fy = UkFinancialYear.from_s '2002/03'
|
88
88
|
fy.first_day.should == Date.parse('6 Apr 2002')
|
89
89
|
fy.last_day.should == Date.parse('5 Apr 2003')
|
90
90
|
end
|
91
91
|
|
92
92
|
it "is 1998/99 for '1998/99'" do
|
93
|
-
fy = UkFinancialYear.from_s
|
93
|
+
fy = UkFinancialYear.from_s '1998/99'
|
94
94
|
fy.first_day.should == Date.parse('6 Apr 1998')
|
95
95
|
fy.last_day.should == Date.parse('5 Apr 1999')
|
96
96
|
end
|
97
97
|
|
98
98
|
it "is 1999/00 for '1999/00'" do
|
99
|
-
fy = UkFinancialYear.from_s
|
99
|
+
fy = UkFinancialYear.from_s '1999/00'
|
100
100
|
fy.first_day.should == Date.parse('6 Apr 1999')
|
101
101
|
fy.last_day.should == Date.parse('5 Apr 2000')
|
102
102
|
end
|
@@ -120,6 +120,20 @@ describe UkFinancialYear do
|
|
120
120
|
end
|
121
121
|
end
|
122
122
|
|
123
|
+
describe "#next" do
|
124
|
+
it "returns the next financial year" do
|
125
|
+
fy = UkFinancialYear.from_s '2011/12'
|
126
|
+
fy.next.should == UkFinancialYear.from_s('2012/13')
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
describe "#previous" do
|
131
|
+
it "returns the previous financial year" do
|
132
|
+
fy = UkFinancialYear.from_s '2011/12'
|
133
|
+
fy.previous.should == UkFinancialYear.from_s('2010/11')
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
123
137
|
describe "object comparison" do
|
124
138
|
it "is less than for earlier FYs" do
|
125
139
|
UkFinancialYear.new(Date.parse '5 Apr 2011').should be < UkFinancialYear.new(Date.parse '6 Apr 2011')
|
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.1.
|
4
|
+
version: 0.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-01-21 00:00:00.000000000Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement: &
|
16
|
+
requirement: &70299305466680 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 2.3.0
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70299305466680
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: yard
|
27
|
-
requirement: &
|
27
|
+
requirement: &70299305466200 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 0.6.0
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70299305466200
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: bundler
|
38
|
-
requirement: &
|
38
|
+
requirement: &70299305465700 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: 1.0.0
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70299305465700
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: jeweler
|
49
|
-
requirement: &
|
49
|
+
requirement: &70299305465180 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: 1.6.4
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70299305465180
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: rcov
|
60
|
-
requirement: &
|
60
|
+
requirement: &70299305464660 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,7 +65,7 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70299305464660
|
69
69
|
description: Small library with methods for finding the financial or fiscal year for
|
70
70
|
a particular date and suchlike
|
71
71
|
email: nigel-lowry@ultra.eclipse.co.uk
|
@@ -102,7 +102,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
102
102
|
version: '0'
|
103
103
|
segments:
|
104
104
|
- 0
|
105
|
-
hash:
|
105
|
+
hash: 4011342982725739789
|
106
106
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
107
107
|
none: false
|
108
108
|
requirements:
|