state_of_the_nation 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8a7bf5dd3a9bfc0c8c15d558a46594f14d4eb47b
4
- data.tar.gz: 8b73505ca25d4e9e9e91c73bf559ad6f3dd51b84
3
+ metadata.gz: 72a6818e2ace1bf60670b197c86a09d4dc925ed5
4
+ data.tar.gz: bb28045766320c669452430634fe58cfda921304
5
5
  SHA512:
6
- metadata.gz: 7937461afed4eb819048e69b80470e37be82fa36fb6ef2b7ab682046a211dd4795da438f4733a5984f34df512d421c5773ea045b8dfc64a73947ec3b77ec1ad6
7
- data.tar.gz: 89f51ee65eddb178034ad41618bc697157d0edca9b9d0bd9b582eff54a337356c35f40f73b650871d06102a5f3466af8caf28252555d8327fa93940562f05cc9
6
+ metadata.gz: ec3602725f892040ae4c022a68b85b0a35e8efc5c3126818769a390ce6fc253dd8d9c3bf7db2dbbed0668c38ff15f1044d139c1da26d4d15827a324bd11c963c
7
+ data.tar.gz: a2afdc5264ef33b14dfe0a82f1c5ee03c260174bca002c634663ac885dbf0c60731d028757a3ce8be6b922ae341c2c7c610f998851be28bfe4a447d9b5056368
data/README.md CHANGED
@@ -1,8 +1,10 @@
1
1
  # StateOfTheNation
2
2
 
3
- State of the Nation is a Gem that makes modeling state that changes over time easy with ActiveRecord, allowing you to ensure that you to easily query the value at any point in time, as well as ensuring that your records don't overlap at any point.
3
+ [![Build Status](https://travis-ci.com/intercom/state_of_the_nation.svg?token=Z1aavhs79p7e6XpUgjv5&branch=master)](https://travis-ci.com/intercom/state_of_the_nation)
4
4
 
5
- Take for example modeling the history of elected officials in the United States government. You would want to allow multiple Senators to be considered active at any point in time, while ensuring that only one President is active. Modeling this with StateOfTheNation is easy like so:
5
+ StateOfTheNation makes modeling state that changes over time easy with ActiveRecord, allowing you to query the active value at any point in time, as well as ensure that your records don't overlap at any point.
6
+
7
+ Take for example modeling the history of elected officials in the United States Government where multiple Senators and only one President may be "active" for any point in time. Modeling this with StateOfTheNation is easy like so:
6
8
 
7
9
  ```ruby
8
10
  class Country < ActiveRecord::Base
@@ -24,19 +26,29 @@ class Senator < ActiveRecord::Base
24
26
  considered_active.from(:entered_office_at).until(:left_office_at)
25
27
  end
26
28
 
29
+
27
30
  ```
28
31
 
29
32
  With this collection of models we can easy record and query the list of elected officials at any point in time, and be confident that any new records that we create don't collide.
30
33
 
31
34
  ```ruby
32
- country.active_president(Date.new(2015, 1, 1))
35
+
36
+ usa = Country.create(name: "United States of America")
37
+ obama = usa.presidents.create!(entered_office_at: Date.new(2009, 1, 20), left_office_at: nil)
38
+
39
+ wyden = usa.senators.create!(entered_office_at: Date.new(1996, 2, 6), left_office_at: nil, name: "Ron Wyden")
40
+ boxer = usa.senators.create!(entered_office_at: Date.new(1993, 1, 3), left_office_at: nil, name: "Barbara Boxer")
41
+
42
+ usa.active_president(Date.new(2015, 1, 1))
43
+
33
44
  # => President(id: 1, name: "Barack Obama")
34
45
 
35
- country.active_senators(Date.new(2015, 1, 1))
46
+ usa.active_senators(Date.new(2015, 1, 1))
36
47
  # => [
37
- Senator(id: 1, name: "Ron Wyden"),
38
- ...
39
- ]
48
+ # Senator(id: 1, name: "Ron Wyden"),
49
+ # Senator(id: 2, name: "Barbara Boxer")
50
+ # ...
51
+ # ]
40
52
 
41
53
 
42
54
  ```
@@ -1,3 +1,3 @@
1
1
  module StateOfTheNation
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
9
9
  spec.authors = ["Patrick O'Doherty", "Stephen O'Brien"]
10
10
  spec.email = ["patrick@intercom.io", "stephen@intercom.io"]
11
11
 
12
- spec.summary = %q{An easy way to model state changes over time}
12
+ spec.summary = %q{An easy way to model state that changes over time with ActiveRecord}
13
13
  spec.description = %q{State of the Nation makes modeling object history easy.}
14
14
  spec.homepage = "https://github.com/intercom/state_of_the_nation"
15
15
  spec.licenses = ["Apache License, Version 2.0"]
@@ -32,6 +32,6 @@ Gem::Specification.new do |spec|
32
32
  spec.add_development_dependency "shoulda-matchers"
33
33
  spec.add_development_dependency "sqlite3"
34
34
 
35
- spec.add_runtime_dependency "activesupport", "~> 4.2"
36
- spec.add_runtime_dependency "activerecord", "~> 4.2"
35
+ spec.add_runtime_dependency "activesupport", ">= 4.0.0"
36
+ spec.add_runtime_dependency "activerecord", ">= 4.0.0"
37
37
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: state_of_the_nation
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Patrick O'Doherty
@@ -141,30 +141,30 @@ dependencies:
141
141
  name: activesupport
142
142
  requirement: !ruby/object:Gem::Requirement
143
143
  requirements:
144
- - - "~>"
144
+ - - ">="
145
145
  - !ruby/object:Gem::Version
146
- version: '4.2'
146
+ version: 4.0.0
147
147
  type: :runtime
148
148
  prerelease: false
149
149
  version_requirements: !ruby/object:Gem::Requirement
150
150
  requirements:
151
- - - "~>"
151
+ - - ">="
152
152
  - !ruby/object:Gem::Version
153
- version: '4.2'
153
+ version: 4.0.0
154
154
  - !ruby/object:Gem::Dependency
155
155
  name: activerecord
156
156
  requirement: !ruby/object:Gem::Requirement
157
157
  requirements:
158
- - - "~>"
158
+ - - ">="
159
159
  - !ruby/object:Gem::Version
160
- version: '4.2'
160
+ version: 4.0.0
161
161
  type: :runtime
162
162
  prerelease: false
163
163
  version_requirements: !ruby/object:Gem::Requirement
164
164
  requirements:
165
- - - "~>"
165
+ - - ">="
166
166
  - !ruby/object:Gem::Version
167
- version: '4.2'
167
+ version: 4.0.0
168
168
  description: State of the Nation makes modeling object history easy.
169
169
  email:
170
170
  - patrick@intercom.io
@@ -210,6 +210,6 @@ rubyforge_project:
210
210
  rubygems_version: 2.2.5
211
211
  signing_key:
212
212
  specification_version: 4
213
- summary: An easy way to model state changes over time
213
+ summary: An easy way to model state that changes over time with ActiveRecord
214
214
  test_files: []
215
215
  has_rdoc: