sequel_bitemporal 0.3.1 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,2 +1,3 @@
1
1
  source "http://rubygems.org"
2
- gemspec
2
+ gemspec
3
+ gem "sequel", git: "https://github.com/jeremyevans/sequel.git"
@@ -33,10 +33,10 @@ module Sequel
33
33
  raise Error, "bitemporal plugin requires the following missing column#{"s" if missing.size>1} on version class: #{missing.join(", ")}" unless missing.empty?
34
34
  master.instance_eval do
35
35
  @version_class = version
36
- @current_version_name = "#{name ? underscore(demodulize(name)) : table_name}_current_version".to_sym
36
+ @current_version_alias_name = "#{name ? underscore(demodulize(name)) : table_name}_current_version".to_sym
37
37
  end
38
38
  master.one_to_many :versions, class: version, key: :master_id
39
- master.one_to_one master.current_version_name, class: version, key: :master_id, :graph_block=>(proc do |j, lj, js|
39
+ master.one_to_one :current_version, class: version, key: :master_id, graph_alias_base: master.current_version_alias_name, :graph_block=>(proc do |j, lj, js|
40
40
  t = ::Sequel::Plugins::Bitemporal.point_in_time
41
41
  n = ::Sequel::Plugins::Bitemporal.now
42
42
  e = :expired_at.qualify(j)
@@ -47,7 +47,7 @@ module Sequel
47
47
  ds.where{(created_at <= t) & ({expired_at=>nil} | (expired_at > t)) & (valid_from <= n) & (valid_to > n)}
48
48
  end
49
49
  master.def_dataset_method :with_current_version do
50
- eager_graph(model.current_version_name).where({:id.qualify(model.current_version_name) => nil}.sql_negate)
50
+ eager_graph(:current_version).where({:id.qualify(model.current_version_alias_name) => nil}.sql_negate)
51
51
  end
52
52
  master.one_to_many :current_or_future_versions, class: version, key: :master_id, :graph_block=>(proc do |j, lj, js|
53
53
  t = ::Sequel::Plugins::Bitemporal.point_in_time
@@ -88,7 +88,7 @@ module Sequel
88
88
  end
89
89
  end
90
90
  module ClassMethods
91
- attr_reader :version_class, :current_version_name
91
+ attr_reader :version_class, :current_version_alias_name
92
92
  end
93
93
  module DatasetMethods
94
94
  end
@@ -107,10 +107,6 @@ module Sequel
107
107
  end if pending_version && !pending_version.valid?
108
108
  end
109
109
 
110
- def current_version(*args)
111
- send(self.class.current_version_name, *args)
112
- end
113
-
114
110
  def pending_or_current_version
115
111
  pending_version || current_version
116
112
  end
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "sequel_bitemporal"
6
- s.version = "0.3.1"
6
+ s.version = "0.4.0"
7
7
  s.authors = ["Joseph HALTER", "Jonathan TRON"]
8
8
  s.email = ["joseph.halter@thetalentbox.com", "jonathan.tron@thetalentbox.com"]
9
9
  s.homepage = "https://github.com/TalentBox/sequel_bitemporal"
@@ -15,7 +15,7 @@ Gem::Specification.new do |s|
15
15
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
16
16
  s.require_paths = ["lib"]
17
17
 
18
- s.add_runtime_dependency "sequel"
18
+ s.add_runtime_dependency "sequel", "~> 3.30.0"
19
19
 
20
20
  s.add_development_dependency "sqlite3"
21
21
  s.add_development_dependency "rspec", "~> 2.8.0.rc1"
@@ -46,7 +46,7 @@ describe "Sequel::Plugins::Bitemporal" do
46
46
  end
47
47
  it "checks required columns are present" do
48
48
  lambda{
49
- @version_class.plugin :bitemporal, :version_class => @master_class
49
+ @version_class.plugin :bitemporal, version_class: @master_class
50
50
  }.should raise_error Sequel::Error, "bitemporal plugin requires the following missing columns on version class: master_id, valid_from, valid_to, created_at, expired_at"
51
51
  end
52
52
  it "propagates errors from version to master" do
@@ -296,10 +296,10 @@ describe "Sequel::Plugins::Bitemporal" do
296
296
  master = @master_class.new
297
297
  master.update_attributes name: "Single Standard", price: 98
298
298
  master.update_attributes name: "Single Standard", price: 94, valid_from: Date.today+2
299
- @master_class.eager_graph(:rooms_current_version).where("rooms_current_version.id IS NOT NULL").first.should be
299
+ @master_class.eager_graph(:current_version).where("rooms_current_version.id IS NOT NULL").first.should be
300
300
  Timecop.freeze Date.today+1
301
301
  master.destroy
302
- @master_class.eager_graph(:rooms_current_version).where("rooms_current_version.id IS NOT NULL").first.should be_nil
302
+ @master_class.eager_graph(:current_version).where("rooms_current_version.id IS NOT NULL").first.should be_nil
303
303
  end
304
304
  it "allows loading masters with a current version" do
305
305
  master_destroyed = @master_class.new
@@ -421,7 +421,7 @@ describe "Sequel::Plugins::Bitemporal" do
421
421
  plugin :bitemporal, version_class: MyNameVersion
422
422
  end
423
423
  expect do
424
- MyName.eager_graph :my_name_current_version
424
+ MyName.eager_graph(:current_version).where("my_name_current_version.id IS NOT NULL").first
425
425
  end.not_to raise_error
426
426
  Object.send :remove_const, :MyName
427
427
  Object.send :remove_const, :MyNameVersion
@@ -297,10 +297,10 @@ describe "Sequel::Plugins::Bitemporal" do
297
297
  master = @master_class.new
298
298
  master.update_attributes name: "Single Standard", price: 98
299
299
  master.update_attributes name: "Single Standard", price: 94, valid_from: Time.now+2*hour
300
- @master_class.eager_graph(:current_version).where("current_version.id IS NOT NULL").first.should be
300
+ @master_class.eager_graph(:current_version).where("rooms_current_version.id IS NOT NULL").first.should be
301
301
  Timecop.freeze Time.now+hour
302
302
  master.destroy
303
- @master_class.eager_graph(:current_version).where("current_version.id IS NOT NULL").first.should be_nil
303
+ @master_class.eager_graph(:current_version).where("rooms_current_version.id IS NOT NULL").first.should be_nil
304
304
  end
305
305
  it "allows loading masters with a current version" do
306
306
  master_destroyed = @master_class.new
@@ -364,4 +364,4 @@ describe "Sequel::Plugins::Bitemporal" do
364
364
  master_with_future.update_attributes name: "Single Standard", price: 94, valid_from: Time.now+2*hour
365
365
  @master_class.with_current_or_future_versions.all.should have(2).item
366
366
  end
367
- end
367
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sequel_bitemporal
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,22 +10,22 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2011-11-30 00:00:00.000000000 Z
13
+ date: 2011-12-03 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: sequel
17
- requirement: &2154462680 !ruby/object:Gem::Requirement
17
+ requirement: &70323408143320 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
- - - ! '>='
20
+ - - ~>
21
21
  - !ruby/object:Gem::Version
22
- version: '0'
22
+ version: 3.30.0
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *2154462680
25
+ version_requirements: *70323408143320
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: sqlite3
28
- requirement: &2154461840 !ruby/object:Gem::Requirement
28
+ requirement: &70323408141540 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ! '>='
@@ -33,10 +33,10 @@ dependencies:
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
- version_requirements: *2154461840
36
+ version_requirements: *70323408141540
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: rspec
39
- requirement: &2154461340 !ruby/object:Gem::Requirement
39
+ requirement: &70323408139620 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ~>
@@ -44,10 +44,10 @@ dependencies:
44
44
  version: 2.8.0.rc1
45
45
  type: :development
46
46
  prerelease: false
47
- version_requirements: *2154461340
47
+ version_requirements: *70323408139620
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: timecop
50
- requirement: &2154460800 !ruby/object:Gem::Requirement
50
+ requirement: &70323408138300 !ruby/object:Gem::Requirement
51
51
  none: false
52
52
  requirements:
53
53
  - - ! '>='
@@ -55,10 +55,10 @@ dependencies:
55
55
  version: '0'
56
56
  type: :development
57
57
  prerelease: false
58
- version_requirements: *2154460800
58
+ version_requirements: *70323408138300
59
59
  - !ruby/object:Gem::Dependency
60
60
  name: rake
61
- requirement: &2154460340 !ruby/object:Gem::Requirement
61
+ requirement: &70323408148700 !ruby/object:Gem::Requirement
62
62
  none: false
63
63
  requirements:
64
64
  - - ! '>='
@@ -66,7 +66,7 @@ dependencies:
66
66
  version: '0'
67
67
  type: :development
68
68
  prerelease: false
69
- version_requirements: *2154460340
69
+ version_requirements: *70323408148700
70
70
  description: Bitemporal versioning for sequel, fully tested.
71
71
  email:
72
72
  - joseph.halter@thetalentbox.com
@@ -101,7 +101,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
101
101
  version: '0'
102
102
  segments:
103
103
  - 0
104
- hash: -3713605019709846076
104
+ hash: -2408522317545363465
105
105
  required_rubygems_version: !ruby/object:Gem::Requirement
106
106
  none: false
107
107
  requirements:
@@ -110,7 +110,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
110
110
  version: '0'
111
111
  segments:
112
112
  - 0
113
- hash: -3713605019709846076
113
+ hash: -2408522317545363465
114
114
  requirements: []
115
115
  rubyforge_project:
116
116
  rubygems_version: 1.8.10