constant_table_saver 4.1.1 → 4.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README +4 -2
- data/constant_table_saver.gemspec +7 -4
- data/lib/constant_table_saver/version.rb +1 -1
- data/lib/constant_table_saver.rb +3 -1
- data/test/constant_table_saver_test.rb +5 -2
- data/test/test_helper.rb +2 -0
- data/test_all.rb +13 -0
- metadata +18 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e2578ce8faa60c69b0c71cac907a097168fefcda
|
4
|
+
data.tar.gz: 8b53a074ed7d5f9d919de2b0de4e8d1a8cbb8140
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ce00c64f33fe8a7aee4291579ecddd24d5d18f0aadaeafbaf4d7cd3b7074f11c8a32e97c154d9e6a769fb7b664e18bb08343bfe72c0dd642b5c1419dfea247ec
|
7
|
+
data.tar.gz: bd8e42cdf8dc69619c13b195799fe886c0d41873ed061229c95b37c3ec30fda113ed9964871d5781bf829e0ff3504158a481525253673332bf649774406f7d39
|
data/README
CHANGED
@@ -11,8 +11,10 @@ named after the name field you specify.
|
|
11
11
|
Compatibility
|
12
12
|
=============
|
13
13
|
|
14
|
-
Currently tested against Rails
|
15
|
-
|
14
|
+
Currently tested against Rails 4.2 (up to 4.2.3), 4.1 (up to 4.1.12), 4.0 (up to 4.0.13), and 3.2 (3.2.18), on Ruby 2.1.5.
|
15
|
+
|
16
|
+
Was also previously tested compatible with 2.3.14, 3.0.17, and 3.1.8 on Ruby 2.0.0
|
17
|
+
or 1.8.7 as appropriate, and may still work for them.
|
16
18
|
|
17
19
|
|
18
20
|
Example
|
@@ -16,19 +16,22 @@ named after the name field you specify.
|
|
16
16
|
Compatibility
|
17
17
|
=============
|
18
18
|
|
19
|
-
Currently tested against Rails
|
20
|
-
|
19
|
+
Currently tested against Rails 4.2 (up to 4.2.3), 4.1 (up to 4.1.12), 4.0 (up to 4.0.13), and 3.2 (3.2.18), on Ruby 2.1.5.
|
20
|
+
|
21
|
+
Was also previously tested compatible with 2.3.14, 3.0.17, and 3.1.8 on Ruby 2.0.0
|
22
|
+
or 1.8.7 as appropriate, and may still work for them.
|
21
23
|
EOF
|
22
24
|
gem.has_rdoc = false
|
23
25
|
gem.author = "Will Bryant"
|
24
26
|
gem.email = "will.bryant@gmail.com"
|
25
27
|
gem.homepage = "http://github.com/willbryant/constant_table_saver"
|
26
|
-
|
28
|
+
gem.license = "MIT"
|
29
|
+
|
27
30
|
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
28
31
|
gem.files = `git ls-files`.split("\n")
|
29
32
|
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
30
33
|
gem.require_path = "lib"
|
31
|
-
|
34
|
+
|
32
35
|
gem.add_dependency "activerecord"
|
33
36
|
gem.add_development_dependency "rake"
|
34
37
|
gem.add_development_dependency "sqlite3"
|
data/lib/constant_table_saver.rb
CHANGED
@@ -53,7 +53,9 @@ module ConstantTableSaver
|
|
53
53
|
def find_by_sql(sql, binds = [])
|
54
54
|
@find_by_sql ||= {
|
55
55
|
:all => all.to_sql,
|
56
|
-
:id => relation.where(relation.table[primary_key].eq(connection.substitute_at(columns_hash[primary_key],
|
56
|
+
:id => relation.where(relation.table[primary_key].eq(connection.substitute_at(columns_hash[primary_key], 0))).limit(1).
|
57
|
+
tap {|r| r.bind_values += [[columns_hash[primary_key], :undefined]]}. # work around AR 4.1.9-4.1.x (but not 4.2.x) calling nil.first if there's no bind_values
|
58
|
+
arel,
|
57
59
|
:first => relation.order(relation.table[primary_key].asc).limit(1).to_sql,
|
58
60
|
:last => relation.order(relation.table[primary_key].desc).limit(1).to_sql,
|
59
61
|
}
|
@@ -45,9 +45,9 @@ class ConstantTableSaverTest < ActiveSupport::TestCase
|
|
45
45
|
|
46
46
|
def assert_queries(num = 1)
|
47
47
|
::SQLCounter.clear_log
|
48
|
-
yield
|
49
|
-
ensure
|
48
|
+
result = yield
|
50
49
|
assert_equal num, ::SQLCounter.log.size, "#{::SQLCounter.log.size} instead of #{num} queries were executed.#{::SQLCounter.log.size == 0 ? '' : "\nQueries:\n#{::SQLCounter.log.join("\n")}"}"
|
50
|
+
result
|
51
51
|
end
|
52
52
|
|
53
53
|
def assert_no_queries(&block)
|
@@ -78,11 +78,14 @@ class ConstantTableSaverTest < ActiveSupport::TestCase
|
|
78
78
|
|
79
79
|
test "it caches find(id) results" do
|
80
80
|
@pie = StandardPie.find(1)
|
81
|
+
@other_pie = StandardPie.find(2)
|
81
82
|
assert_queries(1) do
|
82
83
|
assert_equal @pie.attributes, ConstantPie.find(1).attributes
|
84
|
+
assert_equal @other_pie.attributes, ConstantPie.find(2).attributes
|
83
85
|
end
|
84
86
|
assert_no_queries do
|
85
87
|
assert_equal @pie.attributes, ConstantPie.find(1).attributes
|
88
|
+
assert_equal @other_pie.attributes, ConstantPie.find(2).attributes
|
86
89
|
end
|
87
90
|
end
|
88
91
|
|
data/test/test_helper.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
|
3
|
+
puts "Rails: #{ENV['RAILS_VERSION'] || 'default'}"
|
4
|
+
puts "Env: #{ENV['RAILS_ENV'] || 'not set'}"
|
3
5
|
gem 'minitest', (ENV['RAILS_VERSION'] =~ /^(3\.|4\.0)/ ? '~> 4.0' : nil)
|
4
6
|
gem 'activesupport', ENV['RAILS_VERSION']
|
5
7
|
gem 'activerecord', ENV['RAILS_VERSION']
|
data/test_all.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'yaml'
|
4
|
+
|
5
|
+
rails_versions = ["4.2.0".."4.2.3", "4.1.07".."4.1.12", "4.0.13", "3.2.18"].flat_map {|spec| Array(spec).collect {|v| v.gsub /.0(\d)/, '.\\1'}}
|
6
|
+
rails_envs = YAML.load(File.read("test/database.yml")).keys
|
7
|
+
|
8
|
+
rails_envs.each do |env|
|
9
|
+
rails_versions.each do |version|
|
10
|
+
puts "*"*40
|
11
|
+
system "RAILS_ENV=#{env} RAILS_VERSION=#{version} rake" or exit(1)
|
12
|
+
end
|
13
|
+
end
|
metadata
CHANGED
@@ -1,55 +1,55 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: constant_table_saver
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Will Bryant
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-07-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: sqlite3
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
description: |
|
@@ -63,14 +63,16 @@ description: |
|
|
63
63
|
Compatibility
|
64
64
|
=============
|
65
65
|
|
66
|
-
Currently tested against Rails
|
67
|
-
|
66
|
+
Currently tested against Rails 4.2 (up to 4.2.3), 4.1 (up to 4.1.12), 4.0 (up to 4.0.13), and 3.2 (3.2.18), on Ruby 2.1.5.
|
67
|
+
|
68
|
+
Was also previously tested compatible with 2.3.14, 3.0.17, and 3.1.8 on Ruby 2.0.0
|
69
|
+
or 1.8.7 as appropriate, and may still work for them.
|
68
70
|
email: will.bryant@gmail.com
|
69
71
|
executables: []
|
70
72
|
extensions: []
|
71
73
|
extra_rdoc_files: []
|
72
74
|
files:
|
73
|
-
- .gitignore
|
75
|
+
- ".gitignore"
|
74
76
|
- Gemfile
|
75
77
|
- MIT-LICENSE
|
76
78
|
- README
|
@@ -86,8 +88,10 @@ files:
|
|
86
88
|
- test/fixtures/pies.yml
|
87
89
|
- test/schema.rb
|
88
90
|
- test/test_helper.rb
|
91
|
+
- test_all.rb
|
89
92
|
homepage: http://github.com/willbryant/constant_table_saver
|
90
|
-
licenses:
|
93
|
+
licenses:
|
94
|
+
- MIT
|
91
95
|
metadata: {}
|
92
96
|
post_install_message:
|
93
97
|
rdoc_options: []
|
@@ -95,12 +99,12 @@ require_paths:
|
|
95
99
|
- lib
|
96
100
|
required_ruby_version: !ruby/object:Gem::Requirement
|
97
101
|
requirements:
|
98
|
-
- -
|
102
|
+
- - ">="
|
99
103
|
- !ruby/object:Gem::Version
|
100
104
|
version: '0'
|
101
105
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
102
106
|
requirements:
|
103
|
-
- -
|
107
|
+
- - ">="
|
104
108
|
- !ruby/object:Gem::Version
|
105
109
|
version: '0'
|
106
110
|
requirements: []
|