chrono_model 0.8.2 → 0.9.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.
- checksums.yaml +4 -4
- data/.travis.yml +11 -10
- data/Gemfile +0 -19
- data/README.md +55 -26
- data/chrono_model.gemspec +11 -3
- data/lib/chrono_model.rb +10 -0
- data/lib/chrono_model/adapter.rb +46 -26
- data/lib/chrono_model/patches.rb +69 -6
- data/lib/chrono_model/schema_format.rake +23 -7
- data/lib/chrono_model/schema_format.rb +2 -1
- data/lib/chrono_model/time_gate.rb +3 -11
- data/lib/chrono_model/time_machine.rb +53 -102
- data/lib/chrono_model/version.rb +1 -1
- data/spec/adapter_spec.rb +115 -111
- data/spec/json_ops_spec.rb +5 -5
- data/spec/spec_helper.rb +3 -2
- data/spec/support/matchers/base.rb +5 -8
- data/spec/support/matchers/column.rb +22 -9
- data/spec/support/matchers/index.rb +8 -4
- data/spec/support/matchers/schema.rb +5 -1
- data/spec/support/matchers/table.rb +55 -24
- data/spec/time_machine_spec.rb +195 -176
- data/spec/time_query_spec.rb +39 -39
- metadata +116 -18
data/spec/time_query_spec.rb
CHANGED
@@ -22,37 +22,37 @@ describe ChronoModel::TimeMachine::TimeQuery do
|
|
22
22
|
|
23
23
|
context 'no records' do
|
24
24
|
let(:time) { 16.days.ago }
|
25
|
-
it {
|
25
|
+
it { is_expected.to be_empty }
|
26
26
|
end
|
27
27
|
|
28
28
|
context 'single record' do
|
29
29
|
let(:time) { 15.days.ago }
|
30
|
-
it {
|
30
|
+
it { is_expected.to eq [think] }
|
31
31
|
end
|
32
32
|
|
33
33
|
context 'multiple overlapping records' do
|
34
34
|
let(:time) { 14.days.ago }
|
35
|
-
it {
|
35
|
+
it { is_expected.to match_array [think, plan] }
|
36
36
|
end
|
37
37
|
|
38
38
|
context 'on an edge of an open interval' do
|
39
39
|
let(:time) { 10.days.ago }
|
40
|
-
it {
|
40
|
+
it { is_expected.to be_empty }
|
41
41
|
end
|
42
42
|
|
43
43
|
context 'in an hole' do
|
44
44
|
let(:time) { 9.days.ago }
|
45
|
-
it {
|
45
|
+
it { is_expected.to be_empty }
|
46
46
|
end
|
47
47
|
|
48
48
|
context 'today' do
|
49
49
|
let(:time) { Date.today }
|
50
|
-
it {
|
50
|
+
it { is_expected.to be_empty }
|
51
51
|
end
|
52
52
|
|
53
53
|
context 'server-side :today' do
|
54
54
|
let(:time) { :today }
|
55
|
-
it {
|
55
|
+
it { is_expected.to be_empty }
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
@@ -61,27 +61,27 @@ describe ChronoModel::TimeMachine::TimeQuery do
|
|
61
61
|
|
62
62
|
context 'that is empty' do
|
63
63
|
let(:times) { [ 14.days.ago, 14.days.ago ] }
|
64
|
-
it {
|
64
|
+
it { is_expected.to_not be_empty }
|
65
65
|
end
|
66
66
|
|
67
67
|
context 'overlapping no records' do
|
68
68
|
let(:times) { [ 20.days.ago, 16.days.ago ] }
|
69
|
-
it {
|
69
|
+
it { is_expected.to be_empty }
|
70
70
|
end
|
71
71
|
|
72
72
|
context 'overlapping a single record' do
|
73
73
|
let(:times) { [ 16.days.ago, 14.days.ago ] }
|
74
|
-
it {
|
74
|
+
it { is_expected.to eq [think] }
|
75
75
|
end
|
76
76
|
|
77
77
|
context 'overlapping more records' do
|
78
78
|
let(:times) { [ 16.days.ago, 11.days.ago ] }
|
79
|
-
it {
|
79
|
+
it { is_expected.to match_array [think, plan, collect] }
|
80
80
|
end
|
81
81
|
|
82
82
|
context 'on the edge of an open interval and an hole' do
|
83
83
|
let(:times) { [ 10.days.ago, 9.days.ago ] }
|
84
|
-
it {
|
84
|
+
it { is_expected.to be_empty }
|
85
85
|
end
|
86
86
|
end
|
87
87
|
end
|
@@ -92,47 +92,47 @@ describe ChronoModel::TimeMachine::TimeQuery do
|
|
92
92
|
|
93
93
|
context '16 days ago' do
|
94
94
|
let(:time) { 16.days.ago }
|
95
|
-
it {
|
95
|
+
it { is_expected.to be_empty }
|
96
96
|
end
|
97
97
|
|
98
98
|
context '14 days ago' do
|
99
99
|
let(:time) { 14.days.ago }
|
100
|
-
it {
|
100
|
+
it { is_expected.to eq [think] }
|
101
101
|
|
102
102
|
context 'not inclusive' do
|
103
103
|
let(:inclusive) { false }
|
104
|
-
it {
|
104
|
+
it { is_expected.to be_empty }
|
105
105
|
end
|
106
106
|
end
|
107
107
|
|
108
108
|
context '11 days ago' do
|
109
109
|
let(:time) { 11.days.ago }
|
110
|
-
it {
|
110
|
+
it { is_expected.to match_array [think, plan, collect] }
|
111
111
|
|
112
112
|
context 'not inclusive' do
|
113
113
|
let(:inclusive) { false }
|
114
|
-
it {
|
114
|
+
it { is_expected.to eq [think, plan] }
|
115
115
|
end
|
116
116
|
end
|
117
117
|
|
118
118
|
context '10 days ago' do
|
119
119
|
let(:time) { 10.days.ago }
|
120
|
-
it {
|
120
|
+
it { is_expected.to match_array [think, plan, collect] }
|
121
121
|
end
|
122
122
|
|
123
123
|
context '8 days ago' do
|
124
124
|
let(:time) { 8.days.ago }
|
125
|
-
it {
|
125
|
+
it { is_expected.to match_array [think, plan, collect] }
|
126
126
|
end
|
127
127
|
|
128
128
|
context 'today' do
|
129
129
|
let(:time) { Date.today }
|
130
|
-
it {
|
130
|
+
it { is_expected.to match_array [think, plan, collect, start, build] }
|
131
131
|
end
|
132
132
|
|
133
133
|
context ':today' do
|
134
134
|
let(:time) { :today }
|
135
|
-
it {
|
135
|
+
it { is_expected.to match_array [think, plan, collect, start, build] }
|
136
136
|
end
|
137
137
|
end
|
138
138
|
|
@@ -142,47 +142,47 @@ describe ChronoModel::TimeMachine::TimeQuery do
|
|
142
142
|
|
143
143
|
context 'one month ago' do
|
144
144
|
let(:time) { 1.month.ago }
|
145
|
-
it {
|
145
|
+
it { is_expected.to match_array [think, plan, collect, start, build, profit] }
|
146
146
|
end
|
147
147
|
|
148
148
|
context '10 days ago' do
|
149
149
|
let(:time) { 10.days.ago }
|
150
|
-
it {
|
150
|
+
it { is_expected.to match_array [start, build, profit] }
|
151
151
|
end
|
152
152
|
|
153
153
|
context 'yesterday' do
|
154
154
|
let(:time) { Date.yesterday }
|
155
|
-
it {
|
155
|
+
it { is_expected.to eq [profit] }
|
156
156
|
end
|
157
157
|
|
158
158
|
context 'today' do
|
159
159
|
let(:time) { Date.today }
|
160
|
-
it {
|
160
|
+
it { is_expected.to eq [profit] }
|
161
161
|
end
|
162
162
|
|
163
163
|
context 'server-side :today' do
|
164
164
|
let(:time) { :today }
|
165
|
-
it {
|
165
|
+
it { is_expected.to eq [profit] }
|
166
166
|
end
|
167
167
|
|
168
168
|
context 'tomorrow' do
|
169
169
|
let(:time) { Date.tomorrow }
|
170
|
-
it {
|
170
|
+
it { is_expected.to eq [profit] }
|
171
171
|
end
|
172
172
|
|
173
173
|
context 'one month from now' do
|
174
174
|
let(:time) { 1.month.from_now }
|
175
|
-
it {
|
175
|
+
it { is_expected.to eq [profit] }
|
176
176
|
|
177
177
|
context 'not inclusive' do
|
178
178
|
let(:inclusive) { false }
|
179
|
-
it {
|
179
|
+
it { is_expected.to be_empty }
|
180
180
|
end
|
181
181
|
end
|
182
182
|
|
183
183
|
context 'far future' do
|
184
184
|
let(:time) { 1.year.from_now }
|
185
|
-
it {
|
185
|
+
it { is_expected.to be_empty }
|
186
186
|
end
|
187
187
|
end
|
188
188
|
|
@@ -192,32 +192,32 @@ describe ChronoModel::TimeMachine::TimeQuery do
|
|
192
192
|
|
193
193
|
context '14 days ago' do
|
194
194
|
let(:time) { 14.days.ago }
|
195
|
-
it {
|
195
|
+
it { is_expected.to match_array [collect, start, build, profit] }
|
196
196
|
end
|
197
197
|
|
198
198
|
context '9 days ago' do
|
199
199
|
let(:time) { 9.days.ago }
|
200
|
-
it {
|
200
|
+
it { is_expected.to match_array [think, plan, collect, start, build, profit] }
|
201
201
|
end
|
202
202
|
|
203
203
|
context '8 days ago' do
|
204
204
|
let(:time) { 8.days.ago }
|
205
|
-
it {
|
205
|
+
it { is_expected.to match_array [think, plan, collect, build, profit] }
|
206
206
|
end
|
207
207
|
|
208
208
|
context 'today' do
|
209
209
|
let(:time) { Date.today }
|
210
|
-
it {
|
210
|
+
it { is_expected.to match_array [think, plan, collect, start, build, profit] }
|
211
211
|
end
|
212
212
|
|
213
213
|
context ':today' do
|
214
214
|
let(:time) { :today }
|
215
|
-
it {
|
215
|
+
it { is_expected.to match_array [think, plan, collect, start, build, profit] }
|
216
216
|
end
|
217
217
|
|
218
218
|
context '1 month from now' do
|
219
219
|
let(:time) { 1.month.from_now }
|
220
|
-
it {
|
220
|
+
it { is_expected.to match_array [think, plan, collect, start, build] }
|
221
221
|
end
|
222
222
|
end
|
223
223
|
|
@@ -226,17 +226,17 @@ describe ChronoModel::TimeMachine::TimeQuery do
|
|
226
226
|
|
227
227
|
context 'eliminating a single record' do
|
228
228
|
let(:time) { [1.month.ago, 14.days.ago] }
|
229
|
-
it {
|
229
|
+
it { is_expected.to match_array [plan, collect, start, build, profit] }
|
230
230
|
end
|
231
231
|
|
232
232
|
context 'eliminating multiple records' do
|
233
233
|
let(:time) { [1.month.ago, Date.today] }
|
234
|
-
it {
|
234
|
+
it { is_expected.to eq [profit] }
|
235
235
|
end
|
236
236
|
|
237
237
|
context 'from an edge' do
|
238
238
|
let(:time) { [14.days.ago, 10.days.ago] }
|
239
|
-
it {
|
239
|
+
it { is_expected.to eq [start, build, profit] }
|
240
240
|
end
|
241
241
|
end
|
242
242
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chrono_model
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marcello Barnaba
|
@@ -9,52 +9,150 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2015-10-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- - ~>
|
18
|
+
- - "~>"
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: 4.
|
20
|
+
version: 4.2.0
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
|
-
- - ~>
|
25
|
+
- - "~>"
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version: 4.
|
27
|
+
version: 4.2.0
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: pg
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
|
-
- -
|
32
|
+
- - ">="
|
33
33
|
- !ruby/object:Gem::Version
|
34
34
|
version: '0'
|
35
35
|
type: :runtime
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
|
-
- -
|
39
|
+
- - ">="
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: '0'
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: multi_json
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
|
-
- -
|
46
|
+
- - ">="
|
47
47
|
- !ruby/object:Gem::Version
|
48
48
|
version: '0'
|
49
49
|
type: :runtime
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
|
-
- -
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: pry
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: hirb
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
84
|
+
- !ruby/object:Gem::Dependency
|
85
|
+
name: byebug
|
86
|
+
requirement: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0'
|
91
|
+
type: :development
|
92
|
+
prerelease: false
|
93
|
+
version_requirements: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - ">="
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '0'
|
98
|
+
- !ruby/object:Gem::Dependency
|
99
|
+
name: rspec
|
100
|
+
requirement: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - ">="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0'
|
105
|
+
type: :development
|
106
|
+
prerelease: false
|
107
|
+
version_requirements: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - ">="
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '0'
|
112
|
+
- !ruby/object:Gem::Dependency
|
113
|
+
name: rake
|
114
|
+
requirement: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - ">="
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '0'
|
119
|
+
type: :development
|
120
|
+
prerelease: false
|
121
|
+
version_requirements: !ruby/object:Gem::Requirement
|
122
|
+
requirements:
|
123
|
+
- - ">="
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
name: fuubar
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
129
|
+
requirements:
|
130
|
+
- - ">="
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: '0'
|
133
|
+
type: :development
|
134
|
+
prerelease: false
|
135
|
+
version_requirements: !ruby/object:Gem::Requirement
|
136
|
+
requirements:
|
137
|
+
- - ">="
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
version: '0'
|
140
|
+
- !ruby/object:Gem::Dependency
|
141
|
+
name: codeclimate-test-reporter
|
142
|
+
requirement: !ruby/object:Gem::Requirement
|
143
|
+
requirements:
|
144
|
+
- - ">="
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
version: '0'
|
147
|
+
type: :development
|
148
|
+
prerelease: false
|
149
|
+
version_requirements: !ruby/object:Gem::Requirement
|
150
|
+
requirements:
|
151
|
+
- - ">="
|
54
152
|
- !ruby/object:Gem::Version
|
55
153
|
version: '0'
|
56
154
|
description: Give your models as-of date temporal extensions. Built entirely for PostgreSQL
|
57
|
-
>= 9.
|
155
|
+
>= 9.3
|
58
156
|
email:
|
59
157
|
- vjt@openssl.it
|
60
158
|
- p.brindisi@ifad.org
|
@@ -62,9 +160,9 @@ executables: []
|
|
62
160
|
extensions: []
|
63
161
|
extra_rdoc_files: []
|
64
162
|
files:
|
65
|
-
- .gitignore
|
66
|
-
- .rspec
|
67
|
-
- .travis.yml
|
163
|
+
- ".gitignore"
|
164
|
+
- ".rspec"
|
165
|
+
- ".travis.yml"
|
68
166
|
- Gemfile
|
69
167
|
- LICENSE
|
70
168
|
- README.md
|
@@ -98,7 +196,7 @@ files:
|
|
98
196
|
- spec/time_query_spec.rb
|
99
197
|
- sql/json_ops.sql
|
100
198
|
- sql/uninstall-json_ops.sql
|
101
|
-
homepage:
|
199
|
+
homepage: https://github.com/ifad/chronomodel
|
102
200
|
licenses: []
|
103
201
|
metadata: {}
|
104
202
|
post_install_message:
|
@@ -107,17 +205,17 @@ require_paths:
|
|
107
205
|
- lib
|
108
206
|
required_ruby_version: !ruby/object:Gem::Requirement
|
109
207
|
requirements:
|
110
|
-
- -
|
208
|
+
- - ">="
|
111
209
|
- !ruby/object:Gem::Version
|
112
210
|
version: '0'
|
113
211
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
114
212
|
requirements:
|
115
|
-
- -
|
213
|
+
- - ">="
|
116
214
|
- !ruby/object:Gem::Version
|
117
215
|
version: '0'
|
118
216
|
requirements: []
|
119
217
|
rubyforge_project:
|
120
|
-
rubygems_version: 2.
|
218
|
+
rubygems_version: 2.4.8
|
121
219
|
signing_key:
|
122
220
|
specification_version: 4
|
123
221
|
summary: Temporal extensions (SCD Type II) for Active Record
|