event_attribute 1.0.0 → 1.0.1
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/.gitignore +3 -1
- data/README.md +19 -16
- data/event_attribute.gemspec +2 -3
- data/lib/event_attribute/version.rb +1 -1
- metadata +2 -4
- data/Gemfile.lock +0 -47
- data/RUNNING_UNIT_TESTS +0 -42
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b40fa05c1b336762c61738470e8dcfd0f37a381b
|
4
|
+
data.tar.gz: 4853cda282d917d26122199d22f6cd63b71ed614
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ca504634fe19194dcf25b090cf3d9f90935d7ddbb1cda7c70fd3039e3e59796e2168f82ec8b152289bfb140ca89e78c4873875f7f06ba0c2f5998003dc22af65
|
7
|
+
data.tar.gz: 0d60627d8e7707eaf9f1504cf1d16fcf82dcb5d54dfa38d893d5233ef947f512450a1b8ba27b5480098d396699ad1d155db975b33cb4f3d27acd359791fb695e
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -20,24 +20,27 @@ Or install it yourself as:
|
|
20
20
|
## Usage
|
21
21
|
|
22
22
|
```ruby
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
23
|
+
class Referral < ActiveRecord::Base
|
24
|
+
event_attribute :applied_at, :attribute => 'pending', :nil_equals => true
|
25
|
+
event_attribute :subscribed_on
|
26
|
+
end
|
27
|
+
|
28
|
+
referral = Referral.create(:applied_at => Time.now)
|
29
|
+
referral.pending? # => false
|
30
|
+
referral.subscribed? # => false
|
31
|
+
|
32
|
+
referral.pending = true
|
33
|
+
referral.applied_at # => nil
|
34
|
+
referral.pending? # => true
|
35
|
+
|
36
|
+
referral.subscribed = true
|
37
|
+
referral.subscribed_on # => Date.today
|
38
|
+
referral.subscribed? # => true
|
39
39
|
```
|
40
40
|
|
41
|
+
In this example, subscribed_on is defined in the schema as being a Date type column, and applied_at is defined in the schema as being a DateTime.
|
42
|
+
|
43
|
+
|
41
44
|
## Contributing
|
42
45
|
|
43
46
|
1. Fork it
|
data/event_attribute.gemspec
CHANGED
@@ -10,12 +10,11 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.email = ["chris@prx.org"]
|
11
11
|
spec.description = %q{EventAttribute allows you to turn your date/datetime columns in to boolean attributes in ActiveRecord.}
|
12
12
|
spec.summary = %q{Idea for this was taken from http://jamis.jamisbuck.org/articles/2005/12/14/two-tips-for-working-with-databases-in-rails}
|
13
|
-
spec.homepage = ""
|
13
|
+
spec.homepage = "http://github.com/PRX/event_attribute"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
16
16
|
spec.files = `git ls-files`.split($/)
|
17
|
-
spec.
|
18
|
-
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
17
|
+
spec.test_files = spec.files.grep(%r{^test/})
|
19
18
|
spec.require_paths = ["lib"]
|
20
19
|
spec.add_dependency "activesupport", ">= 3.0.0"
|
21
20
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: event_attribute
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonathan Younger
|
@@ -106,10 +106,8 @@ extra_rdoc_files: []
|
|
106
106
|
files:
|
107
107
|
- .gitignore
|
108
108
|
- Gemfile
|
109
|
-
- Gemfile.lock
|
110
109
|
- LICENSE.txt
|
111
110
|
- README.md
|
112
|
-
- RUNNING_UNIT_TESTS
|
113
111
|
- Rakefile
|
114
112
|
- event_attribute.gemspec
|
115
113
|
- lib/event_attribute.rb
|
@@ -118,7 +116,7 @@ files:
|
|
118
116
|
- test/database.yml
|
119
117
|
- test/event_attribute_test.rb
|
120
118
|
- test/schema.rb
|
121
|
-
homepage:
|
119
|
+
homepage: http://github.com/PRX/event_attribute
|
122
120
|
licenses:
|
123
121
|
- MIT
|
124
122
|
metadata: {}
|
data/Gemfile.lock
DELETED
@@ -1,47 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
event_attribute (1.0.0)
|
5
|
-
activesupport (>= 3.0.0)
|
6
|
-
|
7
|
-
GEM
|
8
|
-
remote: https://rubygems.org/
|
9
|
-
specs:
|
10
|
-
activemodel (4.0.0)
|
11
|
-
activesupport (= 4.0.0)
|
12
|
-
builder (~> 3.1.0)
|
13
|
-
activerecord (4.0.0)
|
14
|
-
activemodel (= 4.0.0)
|
15
|
-
activerecord-deprecated_finders (~> 1.0.2)
|
16
|
-
activesupport (= 4.0.0)
|
17
|
-
arel (~> 4.0.0)
|
18
|
-
activerecord-deprecated_finders (1.0.3)
|
19
|
-
activesupport (4.0.0)
|
20
|
-
i18n (~> 0.6, >= 0.6.4)
|
21
|
-
minitest (~> 4.2)
|
22
|
-
multi_json (~> 1.3)
|
23
|
-
thread_safe (~> 0.1)
|
24
|
-
tzinfo (~> 0.3.37)
|
25
|
-
arel (4.0.0)
|
26
|
-
atomic (1.1.10)
|
27
|
-
builder (3.1.4)
|
28
|
-
i18n (0.6.4)
|
29
|
-
minitest (4.7.5)
|
30
|
-
multi_json (1.7.7)
|
31
|
-
mysql2 (0.3.11)
|
32
|
-
rake (10.1.0)
|
33
|
-
sqlite3 (1.3.7)
|
34
|
-
thread_safe (0.1.0)
|
35
|
-
atomic
|
36
|
-
tzinfo (0.3.37)
|
37
|
-
|
38
|
-
PLATFORMS
|
39
|
-
ruby
|
40
|
-
|
41
|
-
DEPENDENCIES
|
42
|
-
activerecord
|
43
|
-
bundler (~> 1.3)
|
44
|
-
event_attribute!
|
45
|
-
mysql2
|
46
|
-
rake
|
47
|
-
sqlite3
|
data/RUNNING_UNIT_TESTS
DELETED
@@ -1,42 +0,0 @@
|
|
1
|
-
== Creating the test database
|
2
|
-
|
3
|
-
The default name for the test databases is "event_attribute_plugin_test". If you
|
4
|
-
want to use another database name then be sure to update the connection
|
5
|
-
adapter setups you want to test with in test/database.yml.
|
6
|
-
|
7
|
-
Make sure that you create database objects with the same user that you specified in
|
8
|
-
database.yml otherwise (on Postgres, at least) tests for default values will fail.
|
9
|
-
|
10
|
-
== Running with Rake
|
11
|
-
|
12
|
-
The easiest way to run the unit tests is through Rake. The default task runs
|
13
|
-
the entire test suite for the sqlite3 adapter. You can also run the suite on just
|
14
|
-
one adapter by passing the DB environment variable.
|
15
|
-
|
16
|
-
rake test DB=mysql
|
17
|
-
|
18
|
-
For more information, checkout the full array of rake tasks with "rake -T"
|
19
|
-
|
20
|
-
Rake can be found at http://rake.rubyforge.org
|
21
|
-
|
22
|
-
== Running by hand
|
23
|
-
|
24
|
-
Unit tests are located in test directory. If you only want to run a single test suite,
|
25
|
-
or don't want to bother with Rake, you can do so with something like:
|
26
|
-
|
27
|
-
cd test; DB=mysql ruby base_test.rb
|
28
|
-
|
29
|
-
That'll run the base suite using the MySQL adapter. Change the adapter
|
30
|
-
and test suite name as needed.
|
31
|
-
|
32
|
-
== Faster tests
|
33
|
-
|
34
|
-
If you are using a database that supports transactions, you can set the
|
35
|
-
"AR_TX_FIXTURES" environment variable to "yes" to use transactional fixtures.
|
36
|
-
This gives a very large speed boost. With rake:
|
37
|
-
|
38
|
-
rake AR_TX_FIXTURES=yes
|
39
|
-
|
40
|
-
Or, by hand:
|
41
|
-
|
42
|
-
AR_TX_FIXTURES=yes ruby -I connections/native_sqlite3 base_test.rb
|