sie 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/lib/sie/document/financial_years.rb +15 -16
- data/lib/sie/version.rb +1 -1
- data/spec/unit/document/financial_years_spec.rb +15 -5
- data/spec/unit/document_spec.rb +1 -1
- metadata +35 -28
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
NTMyNmZiYTNmZTkzZTg3OWM2ODkzNmI2N2FmNjdjMzc1Yjc0OGJiZg==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
OTA3ODk3MjY5MThjOTE4ODU0MGNjNzM1YTQ5MjkxNGYzZmY1MzZhMQ==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
YzE2ODEzZmYyNDMzZThlNTVjZWNjZmVkOTM4NjE3NWQ0Zjc0MDhkZTY5OGM4
|
10
|
+
M2IxNjBjZWNkMzlkZjMzMzMxMWExODNlY2MyYzU0OWI5NjFmOGJkMjEzMTJj
|
11
|
+
MGYzODQzZDkxMmY2ZDA4ZmY0ZGQ5M2U2NDY3OTQ3MGE2YWU2NjQ=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
YjA4NDlkY2IxYjJmOGVkM2NmYWJmYTVmYmUxMGQ4ZTJkMTViZDg4ZGFiNjgz
|
14
|
+
NjM4NGQ4NTJlMGEyZWI4ZWFiOWUyMTE5ZTU2MGMzMWY0Nzk4ODk0YzBmZGI2
|
15
|
+
MTczYmQzYzhlNzM5NTAyYTJjYmU1MzQ2ZTZkMmVmMjk1YTYzNjM=
|
@@ -7,32 +7,31 @@ class Sie::Document
|
|
7
7
|
:start_month, :from_date, :to_date
|
8
8
|
|
9
9
|
def between
|
10
|
-
from_date.upto(to_date).map { |
|
11
|
-
financial_year = FinancialYear.new(
|
12
|
-
financial_year.date_range
|
13
|
-
|
10
|
+
from_date.year.upto(to_date.year).map { |year|
|
11
|
+
financial_year = FinancialYear.new(year, start_month)
|
12
|
+
financial_year_date_range = financial_year.date_range
|
13
|
+
financial_year_date_range unless out_of_year_range(financial_year_date_range)
|
14
|
+
}.compact
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def out_of_year_range(range)
|
20
|
+
range.last.year > to_date.year
|
14
21
|
end
|
15
22
|
end
|
16
23
|
|
17
24
|
class FinancialYear
|
18
|
-
pattr_initialize :
|
25
|
+
pattr_initialize :year, :start_month
|
19
26
|
|
20
|
-
def date_range
|
21
|
-
|
22
|
-
last_date = [ end_of_year, to_date ].min
|
23
|
-
(first_date.beginning_of_month..last_date.end_of_month)
|
27
|
+
def date_range
|
28
|
+
(start_of_year.beginning_of_month..end_of_year.end_of_month)
|
24
29
|
end
|
25
30
|
|
26
31
|
private
|
27
32
|
|
28
33
|
def start_of_year
|
29
|
-
start_of_year = Date.new(
|
30
|
-
|
31
|
-
if start_of_year <= date
|
32
|
-
start_of_year
|
33
|
-
else
|
34
|
-
start_of_year << 12
|
35
|
-
end
|
34
|
+
start_of_year = Date.new(year, start_month, 1)
|
36
35
|
end
|
37
36
|
|
38
37
|
def end_of_year
|
data/lib/sie/version.rb
CHANGED
@@ -7,7 +7,7 @@ describe Sie::Document::FinancialYears, ".between" do
|
|
7
7
|
Date.new(2011, 9, 1),
|
8
8
|
Date.new(2012, 12, 31)
|
9
9
|
).should == [
|
10
|
-
Date.new(2011,
|
10
|
+
Date.new(2011, 1, 1)..Date.new(2011, 12, 31),
|
11
11
|
Date.new(2012, 1, 1)..Date.new(2012, 12, 31),
|
12
12
|
]
|
13
13
|
end
|
@@ -18,7 +18,7 @@ describe Sie::Document::FinancialYears, ".between" do
|
|
18
18
|
Date.new(2011, 9, 1),
|
19
19
|
Date.new(2013, 12, 31)
|
20
20
|
).should == [
|
21
|
-
Date.new(2011,
|
21
|
+
Date.new(2011, 1, 1)..Date.new(2011, 12, 31),
|
22
22
|
Date.new(2012, 1, 1)..Date.new(2012, 12, 31),
|
23
23
|
Date.new(2013, 1, 1)..Date.new(2013, 12, 31),
|
24
24
|
]
|
@@ -30,9 +30,9 @@ describe Sie::Document::FinancialYears, ".between" do
|
|
30
30
|
Date.new(2011, 9, 1),
|
31
31
|
Date.new(2014, 1, 31)
|
32
32
|
).should == [
|
33
|
-
Date.new(2011,
|
33
|
+
Date.new(2011, 5, 1)..Date.new(2012, 4, 30),
|
34
34
|
Date.new(2012, 5, 1)..Date.new(2013, 4, 30),
|
35
|
-
Date.new(2013, 5, 1)..Date.new(2014,
|
35
|
+
Date.new(2013, 5, 1)..Date.new(2014, 4, 30),
|
36
36
|
]
|
37
37
|
end
|
38
38
|
|
@@ -42,7 +42,17 @@ describe Sie::Document::FinancialYears, ".between" do
|
|
42
42
|
Date.new(2011, 9, 15),
|
43
43
|
Date.new(2011, 10, 10)
|
44
44
|
).should == [
|
45
|
-
Date.new(2011,
|
45
|
+
Date.new(2011, 1, 1)..Date.new(2011, 12, 31),
|
46
|
+
]
|
47
|
+
end
|
48
|
+
|
49
|
+
it "gives us the financial years between from_date and to_date" do
|
50
|
+
Sie::Document::FinancialYears.between(
|
51
|
+
1,
|
52
|
+
Date.new(2011, 1, 1),
|
53
|
+
Date.new(2011, 12, 31)
|
54
|
+
).should == [
|
55
|
+
Date.new(2011, 1, 1)..Date.new(2011, 12, 31)
|
46
56
|
]
|
47
57
|
end
|
48
58
|
end
|
data/spec/unit/document_spec.rb
CHANGED
@@ -95,7 +95,7 @@ describe Sie::Document, "#render" do
|
|
95
95
|
expect(indexed_entry_attribute("rar", 1, "start")).to eq("20120101")
|
96
96
|
expect(indexed_entry_attribute("rar", 1, "slut")).to eq("20121231")
|
97
97
|
expect(indexed_entry_attribute("rar", 2, "arsnr")).to eq("-2")
|
98
|
-
expect(indexed_entry_attribute("rar", 2, "start")).to eq("
|
98
|
+
expect(indexed_entry_attribute("rar", 2, "start")).to eq("20110101")
|
99
99
|
expect(indexed_entry_attribute("rar", 2, "slut")).to eq("20111231")
|
100
100
|
end
|
101
101
|
|
metadata
CHANGED
@@ -1,71 +1,85 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sie
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
5
|
-
prerelease:
|
4
|
+
version: 1.0.3
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Barsoom AB
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2014-03-
|
11
|
+
date: 2014-03-13 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: attr_extras
|
16
|
-
requirement:
|
17
|
-
none: false
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
18
16
|
requirements:
|
19
17
|
- - ! '>='
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '0'
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
|
-
version_requirements:
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ! '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
25
27
|
- !ruby/object:Gem::Dependency
|
26
28
|
name: activesupport
|
27
|
-
requirement:
|
28
|
-
none: false
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
29
30
|
requirements:
|
30
31
|
- - ! '>='
|
31
32
|
- !ruby/object:Gem::Version
|
32
33
|
version: '0'
|
33
34
|
type: :runtime
|
34
35
|
prerelease: false
|
35
|
-
version_requirements:
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ! '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
36
41
|
- !ruby/object:Gem::Dependency
|
37
42
|
name: bundler
|
38
|
-
requirement:
|
39
|
-
none: false
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
40
44
|
requirements:
|
41
45
|
- - ~>
|
42
46
|
- !ruby/object:Gem::Version
|
43
47
|
version: '1.3'
|
44
48
|
type: :development
|
45
49
|
prerelease: false
|
46
|
-
version_requirements:
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.3'
|
47
55
|
- !ruby/object:Gem::Dependency
|
48
56
|
name: rake
|
49
|
-
requirement:
|
50
|
-
none: false
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
51
58
|
requirements:
|
52
59
|
- - ! '>='
|
53
60
|
- !ruby/object:Gem::Version
|
54
61
|
version: '0'
|
55
62
|
type: :development
|
56
63
|
prerelease: false
|
57
|
-
version_requirements:
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ! '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
58
69
|
- !ruby/object:Gem::Dependency
|
59
70
|
name: rspec
|
60
|
-
requirement:
|
61
|
-
none: false
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
62
72
|
requirements:
|
63
73
|
- - ! '>='
|
64
74
|
- !ruby/object:Gem::Version
|
65
75
|
version: '0'
|
66
76
|
type: :development
|
67
77
|
prerelease: false
|
68
|
-
version_requirements:
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ! '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
69
83
|
description: SIE parser and generator
|
70
84
|
email:
|
71
85
|
- all@barsoom.se
|
@@ -111,33 +125,26 @@ files:
|
|
111
125
|
homepage: ''
|
112
126
|
licenses:
|
113
127
|
- MIT
|
128
|
+
metadata: {}
|
114
129
|
post_install_message:
|
115
130
|
rdoc_options: []
|
116
131
|
require_paths:
|
117
132
|
- lib
|
118
133
|
required_ruby_version: !ruby/object:Gem::Requirement
|
119
|
-
none: false
|
120
134
|
requirements:
|
121
135
|
- - ! '>='
|
122
136
|
- !ruby/object:Gem::Version
|
123
137
|
version: '0'
|
124
|
-
segments:
|
125
|
-
- 0
|
126
|
-
hash: -3882600270749227957
|
127
138
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
128
|
-
none: false
|
129
139
|
requirements:
|
130
140
|
- - ! '>='
|
131
141
|
- !ruby/object:Gem::Version
|
132
142
|
version: '0'
|
133
|
-
segments:
|
134
|
-
- 0
|
135
|
-
hash: -3882600270749227957
|
136
143
|
requirements: []
|
137
144
|
rubyforge_project:
|
138
|
-
rubygems_version:
|
145
|
+
rubygems_version: 2.2.1
|
139
146
|
signing_key:
|
140
|
-
specification_version:
|
147
|
+
specification_version: 4
|
141
148
|
summary: Parses and generates SIE files (http://sie.se/)
|
142
149
|
test_files:
|
143
150
|
- spec/fixtures/sie_file.se
|