calculated_attributes 0.0.17 → 0.0.18
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/Appraisals +11 -0
- data/README.md +57 -31
- data/calculated_attributes.gemspec +4 -3
- data/gemfiles/rails3.gemfile +7 -0
- data/gemfiles/rails3.gemfile.lock +73 -0
- data/gemfiles/rails4_1.gemfile +7 -0
- data/gemfiles/rails4_1.gemfile.lock +78 -0
- data/gemfiles/rails4_2.gemfile +7 -0
- data/gemfiles/rails4_2.gemfile.lock +78 -0
- data/lib/calculated_attributes.rb +24 -4
- data/lib/calculated_attributes/version.rb +1 -1
- data/spec/lib/calculated_attributes_spec.rb +16 -10
- data/spec/support/schema.rb +2 -2
- metadata +34 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b751dd8a58b1f4de0e48f23776273daa460cdf81
|
4
|
+
data.tar.gz: 0caef728cf0c2314840f443ee08fd57d50eef14e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 82e7bc56070d8594c59b590a70fbdd7f71445e2fabee1599382e2776c099ced798fce0035bd134ceb0b742a0378804638554555ea55d28ec25df85a2a318abcd
|
7
|
+
data.tar.gz: 02e510a66e63e67f636f1a41a2073a2c952f321974c2ace9e0b4f6eaed6327b45ed23d8d8b243188d927c77bf0dc0529669230aacba99b3801bc878bf9e2710d
|
data/Appraisals
ADDED
data/README.md
CHANGED
@@ -24,51 +24,77 @@ Add each calculated attribute to your model using the `calculated` keyword. It a
|
|
24
24
|
|
25
25
|
For example, if we have two models, `Post` and `Comment`, and `Comment` has a `post_id` attribute, we might write the following code to add a comments count to each `Post` record in a relation:
|
26
26
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
27
|
+
```ruby
|
28
|
+
class Post < ActiveRecord::Base
|
29
|
+
...
|
30
|
+
calculated :comments_count, -> { "select count(*) from comments where comments.post_id = posts.id" }
|
31
|
+
...
|
32
|
+
end
|
33
|
+
```
|
32
34
|
|
33
35
|
Then, the comments count may be accessed as follows:
|
34
36
|
|
35
|
-
|
36
|
-
|
37
|
+
```ruby
|
38
|
+
Post.scoped.calculated(:comments_count).first.comments_count
|
39
|
+
#=> 5
|
40
|
+
```
|
37
41
|
|
38
42
|
Multiple calculated attributes may be attached to each model. If we add a `Tag` model that also has a `post_id`, we can update the Post model as following:
|
39
43
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
44
|
+
```ruby
|
45
|
+
class Post < ActiveRecord::Base
|
46
|
+
...
|
47
|
+
calculated :comments_count, -> { "select count(*) from comments where comments.post_id = posts.id" }
|
48
|
+
calculated :tags_count, -> { "select count(*) from tags where tags.post_id = posts.id" }
|
49
|
+
...
|
50
|
+
end
|
51
|
+
```
|
52
|
+
|
47
53
|
And then access both the `comments_count` and `tags_count` like so:
|
48
54
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
+
```ruby
|
56
|
+
post = Post.scoped.calculated(:comments_count, :tags_count).first
|
57
|
+
post.comments_count
|
58
|
+
#=> 5
|
59
|
+
post.tags_count
|
60
|
+
#=> 2
|
61
|
+
```
|
62
|
+
|
63
|
+
Note that you must call `calculated` on a relation in order to get the desired result. `Post.calculated(:comments_count)` will give you the currently defined lambda for calculating the comments count. `Post.scoped.calculated(:comments_count)` (Rails 3) or `Post.all.calculated(:comments_count)` (Rails 4) will give you an ActiveRecord relation including the calculated attribute.
|
64
|
+
|
55
65
|
You may also use the `calculated` method on a single model instance, like so:
|
56
66
|
|
57
|
-
|
58
|
-
|
59
|
-
|
67
|
+
```ruby
|
68
|
+
Post.first.calculated(:comments_count).comments_count
|
69
|
+
#=> 5
|
70
|
+
```
|
71
|
+
|
60
72
|
If you have defined a `calculated` method, results of that method will be returned rather than throwing a method missing error even if you don't explicitly use the `calculated()` call on the instance:
|
61
73
|
|
62
|
-
|
63
|
-
|
64
|
-
|
74
|
+
```ruby
|
75
|
+
Post.first.comments_count
|
76
|
+
#=> 5
|
77
|
+
```
|
78
|
+
|
65
79
|
If you like, you may define `calculated` lambdas using Arel syntax:
|
66
80
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
81
|
+
```ruby
|
82
|
+
class Post < ActiveRecord::Base
|
83
|
+
...
|
84
|
+
calculated :comments_count, -> { Comment.select(Arel::Nodes::NamedFunction.new("COUNT", [Comment.arel_table[:id]])).where(Comment.arel_table[:post_id].eq(Post.arel_table[:id])) }
|
85
|
+
...
|
86
|
+
end
|
87
|
+
```
|
88
|
+
|
89
|
+
## Known Issues
|
90
|
+
|
91
|
+
In Rails 4.x, you cannot call `count` on a relation with calculated attributes, e.g.
|
92
|
+
|
93
|
+
```ruby
|
94
|
+
`Post.scoped.calculated(:comments_count).count`
|
95
|
+
```
|
96
|
+
|
97
|
+
will error. This is because of an [ActiveRecord issue](https://github.com/rails/rails/blob/master/activerecord/lib/active_record/relation/calculations.rb#L368-L375) that does not permit Arel nodes in the count method.
|
72
98
|
|
73
99
|
## Contributing
|
74
100
|
|
@@ -17,11 +17,12 @@ Gem::Specification.new do |spec|
|
|
17
17
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
18
|
spec.require_paths = ['lib']
|
19
19
|
|
20
|
+
spec.add_development_dependency 'appraisal', '~> 1.0.3'
|
20
21
|
spec.add_development_dependency 'bundler', '~> 1.7'
|
21
22
|
spec.add_development_dependency 'rake', '~> 10.0'
|
22
23
|
spec.add_development_dependency 'rspec', '~> 3.1'
|
23
|
-
spec.add_development_dependency 'rubocop'
|
24
|
-
spec.add_development_dependency 'sqlite3'
|
24
|
+
spec.add_development_dependency 'rubocop', '~> 0.32.0'
|
25
|
+
spec.add_development_dependency 'sqlite3', '~> 1.3.10'
|
25
26
|
|
26
|
-
spec.add_dependency 'activerecord', '
|
27
|
+
spec.add_dependency 'activerecord', '>= 3.2.20'
|
27
28
|
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ../
|
3
|
+
specs:
|
4
|
+
calculated_attributes (0.0.18)
|
5
|
+
activerecord (>= 3.2.20)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
activemodel (3.2.21)
|
11
|
+
activesupport (= 3.2.21)
|
12
|
+
builder (~> 3.0.0)
|
13
|
+
activerecord (3.2.21)
|
14
|
+
activemodel (= 3.2.21)
|
15
|
+
activesupport (= 3.2.21)
|
16
|
+
arel (~> 3.0.2)
|
17
|
+
tzinfo (~> 0.3.29)
|
18
|
+
activesupport (3.2.21)
|
19
|
+
i18n (~> 0.6, >= 0.6.4)
|
20
|
+
multi_json (~> 1.0)
|
21
|
+
appraisal (1.0.3)
|
22
|
+
bundler
|
23
|
+
rake
|
24
|
+
thor (>= 0.14.0)
|
25
|
+
arel (3.0.3)
|
26
|
+
ast (2.0.0)
|
27
|
+
astrolabe (1.3.0)
|
28
|
+
parser (>= 2.2.0.pre.3, < 3.0)
|
29
|
+
builder (3.0.4)
|
30
|
+
diff-lcs (1.2.5)
|
31
|
+
i18n (0.7.0)
|
32
|
+
multi_json (1.11.1)
|
33
|
+
parser (2.3.0.pre.2)
|
34
|
+
ast (>= 1.1, < 3.0)
|
35
|
+
powerpack (0.1.1)
|
36
|
+
rainbow (2.0.0)
|
37
|
+
rake (10.4.2)
|
38
|
+
rspec (3.3.0)
|
39
|
+
rspec-core (~> 3.3.0)
|
40
|
+
rspec-expectations (~> 3.3.0)
|
41
|
+
rspec-mocks (~> 3.3.0)
|
42
|
+
rspec-core (3.3.0)
|
43
|
+
rspec-support (~> 3.3.0)
|
44
|
+
rspec-expectations (3.3.0)
|
45
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
46
|
+
rspec-support (~> 3.3.0)
|
47
|
+
rspec-mocks (3.3.0)
|
48
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
49
|
+
rspec-support (~> 3.3.0)
|
50
|
+
rspec-support (3.3.0)
|
51
|
+
rubocop (0.32.0)
|
52
|
+
astrolabe (~> 1.3)
|
53
|
+
parser (>= 2.2.2.5, < 3.0)
|
54
|
+
powerpack (~> 0.1)
|
55
|
+
rainbow (>= 1.99.1, < 3.0)
|
56
|
+
ruby-progressbar (~> 1.4)
|
57
|
+
ruby-progressbar (1.7.5)
|
58
|
+
sqlite3 (1.3.10)
|
59
|
+
thor (0.19.1)
|
60
|
+
tzinfo (0.3.44)
|
61
|
+
|
62
|
+
PLATFORMS
|
63
|
+
ruby
|
64
|
+
|
65
|
+
DEPENDENCIES
|
66
|
+
activerecord (= 3.2.21)
|
67
|
+
appraisal (~> 1.0.3)
|
68
|
+
bundler (~> 1.7)
|
69
|
+
calculated_attributes!
|
70
|
+
rake (~> 10.0)
|
71
|
+
rspec (~> 3.1)
|
72
|
+
rubocop (~> 0.32.0)
|
73
|
+
sqlite3 (~> 1.3.10)
|
@@ -0,0 +1,78 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ../
|
3
|
+
specs:
|
4
|
+
calculated_attributes (0.0.18)
|
5
|
+
activerecord (>= 3.2.20)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
activemodel (4.1.11)
|
11
|
+
activesupport (= 4.1.11)
|
12
|
+
builder (~> 3.1)
|
13
|
+
activerecord (4.1.11)
|
14
|
+
activemodel (= 4.1.11)
|
15
|
+
activesupport (= 4.1.11)
|
16
|
+
arel (~> 5.0.0)
|
17
|
+
activesupport (4.1.11)
|
18
|
+
i18n (~> 0.6, >= 0.6.9)
|
19
|
+
json (~> 1.7, >= 1.7.7)
|
20
|
+
minitest (~> 5.1)
|
21
|
+
thread_safe (~> 0.1)
|
22
|
+
tzinfo (~> 1.1)
|
23
|
+
appraisal (1.0.3)
|
24
|
+
bundler
|
25
|
+
rake
|
26
|
+
thor (>= 0.14.0)
|
27
|
+
arel (5.0.1.20140414130214)
|
28
|
+
ast (2.0.0)
|
29
|
+
astrolabe (1.3.0)
|
30
|
+
parser (>= 2.2.0.pre.3, < 3.0)
|
31
|
+
builder (3.2.2)
|
32
|
+
diff-lcs (1.2.5)
|
33
|
+
i18n (0.7.0)
|
34
|
+
json (1.8.3)
|
35
|
+
minitest (5.7.0)
|
36
|
+
parser (2.2.2.5)
|
37
|
+
ast (>= 1.1, < 3.0)
|
38
|
+
powerpack (0.1.1)
|
39
|
+
rainbow (2.0.0)
|
40
|
+
rake (10.4.2)
|
41
|
+
rspec (3.3.0)
|
42
|
+
rspec-core (~> 3.3.0)
|
43
|
+
rspec-expectations (~> 3.3.0)
|
44
|
+
rspec-mocks (~> 3.3.0)
|
45
|
+
rspec-core (3.3.1)
|
46
|
+
rspec-support (~> 3.3.0)
|
47
|
+
rspec-expectations (3.3.0)
|
48
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
49
|
+
rspec-support (~> 3.3.0)
|
50
|
+
rspec-mocks (3.3.0)
|
51
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
52
|
+
rspec-support (~> 3.3.0)
|
53
|
+
rspec-support (3.3.0)
|
54
|
+
rubocop (0.32.0)
|
55
|
+
astrolabe (~> 1.3)
|
56
|
+
parser (>= 2.2.2.5, < 3.0)
|
57
|
+
powerpack (~> 0.1)
|
58
|
+
rainbow (>= 1.99.1, < 3.0)
|
59
|
+
ruby-progressbar (~> 1.4)
|
60
|
+
ruby-progressbar (1.7.5)
|
61
|
+
sqlite3 (1.3.10)
|
62
|
+
thor (0.19.1)
|
63
|
+
thread_safe (0.3.5)
|
64
|
+
tzinfo (1.2.2)
|
65
|
+
thread_safe (~> 0.1)
|
66
|
+
|
67
|
+
PLATFORMS
|
68
|
+
ruby
|
69
|
+
|
70
|
+
DEPENDENCIES
|
71
|
+
activerecord (= 4.1.11)
|
72
|
+
appraisal (~> 1.0.3)
|
73
|
+
bundler (~> 1.7)
|
74
|
+
calculated_attributes!
|
75
|
+
rake (~> 10.0)
|
76
|
+
rspec (~> 3.1)
|
77
|
+
rubocop (~> 0.32.0)
|
78
|
+
sqlite3 (~> 1.3.10)
|
@@ -0,0 +1,78 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ../
|
3
|
+
specs:
|
4
|
+
calculated_attributes (0.0.18)
|
5
|
+
activerecord (>= 3.2.20)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
activemodel (4.2.2)
|
11
|
+
activesupport (= 4.2.2)
|
12
|
+
builder (~> 3.1)
|
13
|
+
activerecord (4.2.2)
|
14
|
+
activemodel (= 4.2.2)
|
15
|
+
activesupport (= 4.2.2)
|
16
|
+
arel (~> 6.0)
|
17
|
+
activesupport (4.2.2)
|
18
|
+
i18n (~> 0.7)
|
19
|
+
json (~> 1.7, >= 1.7.7)
|
20
|
+
minitest (~> 5.1)
|
21
|
+
thread_safe (~> 0.3, >= 0.3.4)
|
22
|
+
tzinfo (~> 1.1)
|
23
|
+
appraisal (1.0.3)
|
24
|
+
bundler
|
25
|
+
rake
|
26
|
+
thor (>= 0.14.0)
|
27
|
+
arel (6.0.0)
|
28
|
+
ast (2.0.0)
|
29
|
+
astrolabe (1.3.0)
|
30
|
+
parser (>= 2.2.0.pre.3, < 3.0)
|
31
|
+
builder (3.2.2)
|
32
|
+
diff-lcs (1.2.5)
|
33
|
+
i18n (0.7.0)
|
34
|
+
json (1.8.3)
|
35
|
+
minitest (5.7.0)
|
36
|
+
parser (2.2.2.5)
|
37
|
+
ast (>= 1.1, < 3.0)
|
38
|
+
powerpack (0.1.1)
|
39
|
+
rainbow (2.0.0)
|
40
|
+
rake (10.4.2)
|
41
|
+
rspec (3.3.0)
|
42
|
+
rspec-core (~> 3.3.0)
|
43
|
+
rspec-expectations (~> 3.3.0)
|
44
|
+
rspec-mocks (~> 3.3.0)
|
45
|
+
rspec-core (3.3.1)
|
46
|
+
rspec-support (~> 3.3.0)
|
47
|
+
rspec-expectations (3.3.0)
|
48
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
49
|
+
rspec-support (~> 3.3.0)
|
50
|
+
rspec-mocks (3.3.0)
|
51
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
52
|
+
rspec-support (~> 3.3.0)
|
53
|
+
rspec-support (3.3.0)
|
54
|
+
rubocop (0.32.0)
|
55
|
+
astrolabe (~> 1.3)
|
56
|
+
parser (>= 2.2.2.5, < 3.0)
|
57
|
+
powerpack (~> 0.1)
|
58
|
+
rainbow (>= 1.99.1, < 3.0)
|
59
|
+
ruby-progressbar (~> 1.4)
|
60
|
+
ruby-progressbar (1.7.5)
|
61
|
+
sqlite3 (1.3.10)
|
62
|
+
thor (0.19.1)
|
63
|
+
thread_safe (0.3.5)
|
64
|
+
tzinfo (1.2.2)
|
65
|
+
thread_safe (~> 0.1)
|
66
|
+
|
67
|
+
PLATFORMS
|
68
|
+
ruby
|
69
|
+
|
70
|
+
DEPENDENCIES
|
71
|
+
activerecord (= 4.2.2)
|
72
|
+
appraisal (~> 1.0.3)
|
73
|
+
bundler (~> 1.7)
|
74
|
+
calculated_attributes!
|
75
|
+
rake (~> 10.0)
|
76
|
+
rspec (~> 3.1)
|
77
|
+
rubocop (~> 0.32.0)
|
78
|
+
sqlite3 (~> 1.3.10)
|
@@ -22,11 +22,21 @@ ActiveRecord::Base.extend CalculatedAttributes
|
|
22
22
|
|
23
23
|
ActiveRecord::Base.send(:include, Module.new do
|
24
24
|
def calculated(*args)
|
25
|
-
self.class.scoped
|
25
|
+
if self.class.respond_to? :scoped
|
26
|
+
self.class.scoped.calculated(*args).find(id)
|
27
|
+
else
|
28
|
+
self.class.all.calculated(*args).find(id)
|
29
|
+
end
|
26
30
|
end
|
27
31
|
|
28
32
|
def method_missing(sym, *args, &block)
|
29
|
-
|
33
|
+
no_sym_in_attr =
|
34
|
+
if @attributes.respond_to? :include?
|
35
|
+
!@attributes.include?(sym.to_s)
|
36
|
+
else
|
37
|
+
!@attributes.key?(sym.to_s)
|
38
|
+
end
|
39
|
+
if no_sym_in_attr && (self.class.calculated.calculated[sym] || self.class.base_class.calculated.calculated[sym])
|
30
40
|
Rails.logger.warn("Using calculated value without including it in the relation: #{sym}") if defined? Rails
|
31
41
|
class_with_attr =
|
32
42
|
if self.class.calculated.calculated[sym]
|
@@ -34,14 +44,24 @@ ActiveRecord::Base.send(:include, Module.new do
|
|
34
44
|
else
|
35
45
|
self.class.base_class
|
36
46
|
end
|
37
|
-
class_with_attr.scoped
|
47
|
+
if class_with_attr.respond_to? :scoped
|
48
|
+
class_with_attr.scoped.calculated(sym).find(id).send(sym)
|
49
|
+
else
|
50
|
+
class_with_attr.all.calculated(sym).find(id).send(sym)
|
51
|
+
end
|
38
52
|
else
|
39
53
|
super(sym, *args, &block)
|
40
54
|
end
|
41
55
|
end
|
42
56
|
|
43
57
|
def respond_to?(method, include_private = false)
|
44
|
-
|
58
|
+
no_sym_in_attr =
|
59
|
+
if @attributes.respond_to? :include?
|
60
|
+
!@attributes.include?(method.to_s)
|
61
|
+
else
|
62
|
+
!@attributes.key?(method.to_s)
|
63
|
+
end
|
64
|
+
super || (no_sym_in_attr && (self.class.calculated.calculated[method] || self.class.base_class.calculated.calculated[method]))
|
45
65
|
end
|
46
66
|
end)
|
47
67
|
|
@@ -1,18 +1,26 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
+
def model_scoped(klass)
|
4
|
+
if klass.respond_to? :scoped
|
5
|
+
klass.scoped
|
6
|
+
else
|
7
|
+
klass.all
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
3
11
|
describe 'calculated_attributes' do
|
4
12
|
it 'includes calculated attributes' do
|
5
|
-
expect(Post.
|
13
|
+
expect(model_scoped(Post).calculated(:comments).first.comments).to eq(1)
|
6
14
|
end
|
7
15
|
|
8
16
|
it 'includes multiple calculated attributes' do
|
9
|
-
post = Post.
|
17
|
+
post = model_scoped(Post).calculated(:comments, :comments_two).first
|
10
18
|
expect(post.comments).to eq(1)
|
11
19
|
expect(post.comments_two).to eq(1)
|
12
20
|
end
|
13
21
|
|
14
22
|
it 'includes chained calculated attributes' do
|
15
|
-
post = Post.
|
23
|
+
post = model_scoped(Post).calculated(:comments).calculated(:comments_two).first
|
16
24
|
expect(post.comments).to eq(1)
|
17
25
|
expect(post.comments_two).to eq(1)
|
18
26
|
end
|
@@ -56,26 +64,24 @@ describe 'calculated_attributes' do
|
|
56
64
|
end
|
57
65
|
|
58
66
|
it 'allows attributes to be defined using AREL' do
|
59
|
-
expect(Post.
|
67
|
+
expect(model_scoped(Post).calculated(:comments_arel).first.comments_arel).to eq(1)
|
60
68
|
end
|
61
69
|
|
62
70
|
it 'maintains previous scope' do
|
63
|
-
expect(Post.where(text: 'First post!').calculated(:comments).count).to eq(1)
|
64
71
|
expect(Post.where(text: 'First post!').calculated(:comments).first.comments).to eq(1)
|
65
72
|
expect(Post.where("posts.text = 'First post!'").calculated(:comments).first.comments).to eq(1)
|
66
73
|
end
|
67
74
|
|
68
75
|
it 'maintains subsequent scope' do
|
69
|
-
expect(Post.
|
70
|
-
expect(Post.
|
71
|
-
expect(Post.scoped.calculated(:comments).where("posts.text = 'First post!'").first.comments).to eq(1)
|
76
|
+
expect(model_scoped(Post).calculated(:comments).where(text: 'First post!').first.comments).to eq(1)
|
77
|
+
expect(model_scoped(Post).calculated(:comments).where("posts.text = 'First post!'").first.comments).to eq(1)
|
72
78
|
end
|
73
79
|
|
74
80
|
it 'includes calculated attributes with STI and lambda on base class' do
|
75
|
-
expect(Tutorial.
|
81
|
+
expect(model_scoped(Tutorial).calculated(:comments).first.comments).to eq(1)
|
76
82
|
end
|
77
83
|
|
78
84
|
it 'includes calculated attributes with STI and lambda on subclass' do
|
79
|
-
expect(Article.
|
85
|
+
expect(model_scoped(Article).calculated(:sub_comments).first.sub_comments).to eq(1)
|
80
86
|
end
|
81
87
|
end
|
data/spec/support/schema.rb
CHANGED
@@ -3,12 +3,12 @@ ActiveRecord::Schema.define do
|
|
3
3
|
|
4
4
|
create_table :posts, force: true do |t|
|
5
5
|
t.string :text
|
6
|
-
t.timestamps
|
6
|
+
t.timestamps null: false
|
7
7
|
end
|
8
8
|
|
9
9
|
create_table :comments, force: true do |t|
|
10
10
|
t.integer :post_id
|
11
11
|
t.string :text
|
12
|
-
t.timestamps
|
12
|
+
t.timestamps null: false
|
13
13
|
end
|
14
14
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: calculated_attributes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.18
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zach Schneider
|
@@ -10,6 +10,20 @@ bindir: bin
|
|
10
10
|
cert_chain: []
|
11
11
|
date: 2015-06-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: appraisal
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.0.3
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.0.3
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: bundler
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -56,44 +70,44 @@ dependencies:
|
|
56
70
|
name: rubocop
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
58
72
|
requirements:
|
59
|
-
- - "
|
73
|
+
- - "~>"
|
60
74
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
75
|
+
version: 0.32.0
|
62
76
|
type: :development
|
63
77
|
prerelease: false
|
64
78
|
version_requirements: !ruby/object:Gem::Requirement
|
65
79
|
requirements:
|
66
|
-
- - "
|
80
|
+
- - "~>"
|
67
81
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
82
|
+
version: 0.32.0
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: sqlite3
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
72
86
|
requirements:
|
73
|
-
- - "
|
87
|
+
- - "~>"
|
74
88
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
89
|
+
version: 1.3.10
|
76
90
|
type: :development
|
77
91
|
prerelease: false
|
78
92
|
version_requirements: !ruby/object:Gem::Requirement
|
79
93
|
requirements:
|
80
|
-
- - "
|
94
|
+
- - "~>"
|
81
95
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
96
|
+
version: 1.3.10
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
98
|
name: activerecord
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
86
100
|
requirements:
|
87
|
-
- - "
|
101
|
+
- - ">="
|
88
102
|
- !ruby/object:Gem::Version
|
89
|
-
version: 3.2.
|
103
|
+
version: 3.2.20
|
90
104
|
type: :runtime
|
91
105
|
prerelease: false
|
92
106
|
version_requirements: !ruby/object:Gem::Requirement
|
93
107
|
requirements:
|
94
|
-
- - "
|
108
|
+
- - ">="
|
95
109
|
- !ruby/object:Gem::Version
|
96
|
-
version: 3.2.
|
110
|
+
version: 3.2.20
|
97
111
|
description:
|
98
112
|
email:
|
99
113
|
- zach@aha.io
|
@@ -104,11 +118,18 @@ files:
|
|
104
118
|
- ".gitignore"
|
105
119
|
- ".rspec"
|
106
120
|
- ".rubocop.yml"
|
121
|
+
- Appraisals
|
107
122
|
- Gemfile
|
108
123
|
- LICENSE.txt
|
109
124
|
- README.md
|
110
125
|
- Rakefile
|
111
126
|
- calculated_attributes.gemspec
|
127
|
+
- gemfiles/rails3.gemfile
|
128
|
+
- gemfiles/rails3.gemfile.lock
|
129
|
+
- gemfiles/rails4_1.gemfile
|
130
|
+
- gemfiles/rails4_1.gemfile.lock
|
131
|
+
- gemfiles/rails4_2.gemfile
|
132
|
+
- gemfiles/rails4_2.gemfile.lock
|
112
133
|
- lib/calculated_attributes.rb
|
113
134
|
- lib/calculated_attributes/version.rb
|
114
135
|
- spec/lib/calculated_attributes_spec.rb
|