fyuk 0.1.1 → 0.2.0
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/VERSION +1 -1
- data/fyuk.gemspec +1 -1
- data/lib/uk_financial_year.rb +10 -5
- data/spec/uk_financial_year_spec.rb +26 -0
- metadata +12 -12
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.
|
|
1
|
+
0.2.0
|
data/fyuk.gemspec
CHANGED
data/lib/uk_financial_year.rb
CHANGED
|
@@ -13,6 +13,14 @@ class UkFinancialYear
|
|
|
13
13
|
@range = start_date...start_date.next_year
|
|
14
14
|
end
|
|
15
15
|
|
|
16
|
+
# returns string representation of the financial year in the form '2000/01'.
|
|
17
|
+
# This is the form HMRC use.
|
|
18
|
+
# @return [String] representation in the form of the first year as four
|
|
19
|
+
# digits, a '/', then the last year as two digits
|
|
20
|
+
def to_s
|
|
21
|
+
"#{self.first_day.year}/#{self.last_day.year.to_s[-2..-1]}"
|
|
22
|
+
end
|
|
23
|
+
|
|
16
24
|
# creates a new UkFinancialYear from a string in the form '2000/01'
|
|
17
25
|
# @param [String] s the two years of the financial year in the form
|
|
18
26
|
# of the first year as four digits, a '/', then the last year as
|
|
@@ -63,11 +71,8 @@ class UkFinancialYear
|
|
|
63
71
|
UkFinancialYear.new self.first_day.prev_year
|
|
64
72
|
end
|
|
65
73
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
# digits, a '/', then the last year as two digits
|
|
69
|
-
def to_s
|
|
70
|
-
"#{self.first_day.year}/#{self.last_day.year.to_s[-2..-1]}"
|
|
74
|
+
def adjacent? other_financial_year
|
|
75
|
+
self.first_day.next_year == other_financial_year.first_day || self.first_day.prev_year == other_financial_year.first_day
|
|
71
76
|
end
|
|
72
77
|
|
|
73
78
|
# equality method
|
|
@@ -134,6 +134,32 @@ describe UkFinancialYear do
|
|
|
134
134
|
end
|
|
135
135
|
end
|
|
136
136
|
|
|
137
|
+
describe "#adjacent" do
|
|
138
|
+
it "is true for two consecutive financial years in date order" do
|
|
139
|
+
fy1 = UkFinancialYear.from_s '2011/12'
|
|
140
|
+
fy2 = UkFinancialYear.from_s '2012/13'
|
|
141
|
+
|
|
142
|
+
fy1.should be_adjacent fy2
|
|
143
|
+
fy2.should be_adjacent fy1
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
it "is false for financial years which do not run together" do
|
|
147
|
+
fy1 = UkFinancialYear.from_s '2011/12'
|
|
148
|
+
fy2 = UkFinancialYear.from_s '2013/14'
|
|
149
|
+
|
|
150
|
+
fy1.should_not be_adjacent fy2
|
|
151
|
+
fy2.should_not be_adjacent fy1
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
it "is false for the same financial year" do
|
|
155
|
+
fy1 = UkFinancialYear.from_s '2011/12'
|
|
156
|
+
fy2 = UkFinancialYear.from_s '2011/12'
|
|
157
|
+
|
|
158
|
+
fy1.should_not be_adjacent fy2
|
|
159
|
+
fy2.should_not be_adjacent fy1
|
|
160
|
+
end
|
|
161
|
+
end
|
|
162
|
+
|
|
137
163
|
describe "object comparison" do
|
|
138
164
|
it "is less than for earlier FYs" do
|
|
139
165
|
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.
|
|
4
|
+
version: 0.2.0
|
|
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: &70272143533980 !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: *70272143533980
|
|
25
25
|
- !ruby/object:Gem::Dependency
|
|
26
26
|
name: yard
|
|
27
|
-
requirement: &
|
|
27
|
+
requirement: &70272143533320 !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: *70272143533320
|
|
36
36
|
- !ruby/object:Gem::Dependency
|
|
37
37
|
name: bundler
|
|
38
|
-
requirement: &
|
|
38
|
+
requirement: &70272143523480 !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: *70272143523480
|
|
47
47
|
- !ruby/object:Gem::Dependency
|
|
48
48
|
name: jeweler
|
|
49
|
-
requirement: &
|
|
49
|
+
requirement: &70272143522880 !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: *70272143522880
|
|
58
58
|
- !ruby/object:Gem::Dependency
|
|
59
59
|
name: rcov
|
|
60
|
-
requirement: &
|
|
60
|
+
requirement: &70272143522280 !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: *70272143522280
|
|
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: 2899375031864654896
|
|
106
106
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
107
107
|
none: false
|
|
108
108
|
requirements:
|