kasket 3.1.5 → 3.2.0

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: ce801eb80f7eda453f07735fd934423d4fb925ca
4
- data.tar.gz: 5815830b14132e65b2f0395dfb5eef1a1fcaa344
3
+ metadata.gz: 8fd8b1112932a3d14ed1e43ab61ad826ba02c5f0
4
+ data.tar.gz: 997f6891f0df65c1299a3d0da4f1e990a0c6a0fc
5
5
  SHA512:
6
- metadata.gz: 89cbd7cb351b9e25af6b5f02afe1715e0c5a56556303161ee00846a1e087822eec8ca591d67a9e63dea6e80bbcae15cec901195567dd1c1cb800fa960a4fb017
7
- data.tar.gz: 5bf55e25bfbe743cc1dc6a1236cda1afc1cc3df0b34513acbc99d3f15973593fcf11a639e306f02beecfa6add59f665277dd774167293910888d07906a74710c
6
+ metadata.gz: 9eb57e261693839d9b4d81060fadf64737f528c8d37adcc3d3f98459e2947832dbcc3ac96379c2775cde2486731ccf5f1a3178a9ac49e376f93574154a1f7b90
7
+ data.tar.gz: 19c1289828483003fb8a979969aee6198ac4cbdbe47452b82cbbaa15dee26280c31f7a91559994afa4b856f960fce4411daa1ba9297bac265d6092f347173d32
@@ -1,4 +1,3 @@
1
- # -*- encoding: utf-8 -*-
2
1
  require 'active_record'
3
2
  require 'active_support'
4
3
 
@@ -16,8 +15,6 @@ module Kasket
16
15
  autoload :SelectManagerMixin, 'kasket/select_manager_mixin'
17
16
  autoload :RelationMixin, 'kasket/relation_mixin'
18
17
 
19
- AR30 = (ActiveRecord::VERSION::MAJOR == 3 && ActiveRecord::VERSION::MINOR == 0)
20
-
21
18
  CONFIGURATION = {:max_collection_size => 100}
22
19
 
23
20
  module_function
@@ -36,9 +33,6 @@ module Kasket
36
33
 
37
34
  if options[:assoliations_reload_hack]
38
35
  ActiveRecord::Associations::BelongsToAssociation.send(:include, Kasket::ReloadAssociationMixin)
39
- if ActiveRecord::VERSION::MAJOR == 2 || AR30
40
- ActiveRecord::Associations::BelongsToPolymorphicAssociation.send(:include, Kasket::ReloadAssociationMixin)
41
- end
42
36
  ActiveRecord::Associations::HasOneThroughAssociation.send(:include, Kasket::ReloadAssociationMixin)
43
37
  end
44
38
  end
@@ -1,4 +1,3 @@
1
- # -*- encoding: utf-8 -*-
2
1
  require 'active_support'
3
2
  require "digest/md5"
4
3
 
@@ -1,4 +1,3 @@
1
- # -*- encoding: utf-8 -*-
2
1
  module Kasket
3
2
  module DirtyMixin
4
3
  def kasket_dirty_methods(*method_names)
@@ -1,4 +1,3 @@
1
- # -*- encoding: utf-8 -*-
2
1
  module Kasket
3
2
  class QueryParser
4
3
  # Examples:
@@ -11,11 +10,7 @@ module Kasket
11
10
 
12
11
  def initialize(model_class)
13
12
  @model_class = model_class
14
- @supported_query_pattern = if AR30
15
- /^select\s+(?:`#{@model_class.table_name}`.)?\* from (?:`|")#{@model_class.table_name}(?:`|") where (.*?)\s*$/i
16
- else
17
- /^select \* from (?:`|")#{@model_class.table_name}(?:`|") where \((.*)\)(|\s+limit 1)\s*$/i
18
- end
13
+ @supported_query_pattern = /^select \* from (?:`|")#{@model_class.table_name}(?:`|") where \((.*)\)(|\s+limit 1)\s*$/i
19
14
  @table_and_column_pattern = /(?:(?:`|")?#{@model_class.table_name}(?:`|")?\.)?(?:`|")?([a-zA-Z]\w*)(?:`|")?/ # Matches: `users`.id, `users`.`id`, users.id, id
20
15
  @key_eq_value_pattern = /^[\(\s]*#{@table_and_column_pattern}\s+(=|IN)\s+#{VALUE}[\)\s]*$/ # Matches: KEY = VALUE, (KEY = VALUE), ()(KEY = VALUE))
21
16
  end
@@ -23,14 +18,6 @@ module Kasket
23
18
  def parse(sql)
24
19
  if match = @supported_query_pattern.match(sql)
25
20
  where, limit = match[1], match[2]
26
- if AR30
27
- return if where =~ / (order by|group by|join|having) /i
28
- if where =~ /limit \d+\s*$/i
29
- # limit is harder to find in rails 3.0 since where does not use surrounding braces
30
- return unless where =~ /(.*?)(\s+limit 1)\s*$/i
31
- where, limit = $1, $2
32
- end
33
- end
34
21
 
35
22
  query = Hash.new
36
23
  query[:attributes] = sorted_attribute_value_pairs(where)
@@ -1,4 +1,3 @@
1
- # -*- encoding: utf-8 -*-
2
1
  module Kasket
3
2
  module ReadMixin
4
3
 
@@ -55,7 +54,7 @@ module Kasket
55
54
 
56
55
  id_key_map = Hash[missing_keys.map{|key| [key.split('=').last.to_i, key] }]
57
56
 
58
- found = without_kasket { find_all_by_id(id_key_map.keys) }
57
+ found = without_kasket { where(:id => id_key_map.keys).to_a }
59
58
  found.each(&:store_in_kasket)
60
59
  Hash[found.map{|record| [id_key_map[record.id], record] }]
61
60
  end
@@ -1,12 +1,10 @@
1
- # -*- encoding: utf-8 -*-
2
1
  module Kasket
3
2
  module ReloadAssociationMixin
4
3
  def reload_with_kasket_clearing(*args)
5
4
  if loaded?
6
5
  Kasket.clear_local if target.class.include?(WriteMixin)
7
6
  else
8
- refl = (ActiveRecord::VERSION::MAJOR == 2 || AR30) ? proxy_reflection : reflection
9
- target_class = (refl.options[:polymorphic] ? (respond_to?(:klass) ? klass : association_class) : refl.klass)
7
+ target_class = (reflection.options[:polymorphic] ? (respond_to?(:klass) ? klass : association_class) : reflection.klass)
10
8
  Kasket.clear_local if target_class && target_class.include?(WriteMixin)
11
9
  end
12
10
 
@@ -1,9 +1,8 @@
1
- # -*- encoding: utf-8 -*-
2
1
  module Kasket
3
2
  class Version
4
3
  MAJOR = 3
5
- MINOR = 1
6
- PATCH = 5
4
+ MINOR = 2
5
+ PATCH = 0
7
6
  STRING = "#{MAJOR}.#{MINOR}.#{PATCH}"
8
7
  PROTOCOL = 4
9
8
  end
@@ -24,8 +24,8 @@ module Kasket
24
24
  @model_class.columns_hash[name.to_s]
25
25
  end
26
26
 
27
- def visit_Arel_Nodes_SelectStatement(node)
28
- return :unsupported if !AR30 && node.with
27
+ def visit_Arel_Nodes_SelectStatement(node, *_)
28
+ return :unsupported if node.with
29
29
  return :unsupported if node.offset
30
30
  return :unsupported if node.lock
31
31
  return :unsupported if node.orders.any?
@@ -42,11 +42,11 @@ module Kasket
42
42
  query
43
43
  end
44
44
 
45
- def visit_Arel_Nodes_SelectCore(node)
45
+ def visit_Arel_Nodes_SelectCore(node, *_)
46
46
  return :unsupported if node.groups.any?
47
47
  return :unsupported if node.having
48
- return :unsupported if !AR30 && node.set_quantifier
49
- return :unsupported if !AR30 && (!node.source || node.source.empty?)
48
+ return :unsupported if node.set_quantifier
49
+ return :unsupported if (!node.source || node.source.empty?)
50
50
  return :unsupported if node.projections.size != 1
51
51
 
52
52
  select = node.projections[0]
@@ -60,45 +60,45 @@ module Kasket
60
60
  parts.include?(:unsupported) ? :unsupported : parts
61
61
  end
62
62
 
63
- def visit_Arel_Nodes_Limit(node)
63
+ def visit_Arel_Nodes_Limit(node, *_)
64
64
  {:limit => node.value.to_i}
65
65
  end
66
66
 
67
- def visit_Arel_Nodes_JoinSource(node)
67
+ def visit_Arel_Nodes_JoinSource(node, *_)
68
68
  return :unsupported if !node.left || node.right.any?
69
69
  return :unsupported if !node.left.is_a?(Arel::Table)
70
70
  visit(node.left)
71
71
  end
72
72
 
73
- def visit_Arel_Table(node)
73
+ def visit_Arel_Table(node, *_)
74
74
  {:from => node.name}
75
75
  end
76
76
 
77
- def visit_Arel_Nodes_And(node)
77
+ def visit_Arel_Nodes_And(node, *_)
78
78
  attributes = node.children.map { |child| visit(child) }
79
79
  return :unsupported if attributes.include?(:unsupported)
80
80
  attributes.sort! { |pair1, pair2| pair1[0].to_s <=> pair2[0].to_s }
81
81
  { :attributes => attributes }
82
82
  end
83
83
 
84
- def visit_Arel_Nodes_In(node)
84
+ def visit_Arel_Nodes_In(node, *_)
85
85
  left = visit(node.left)
86
86
  return :unsupported if left != :id
87
87
 
88
88
  [left, visit(node.right)]
89
89
  end
90
90
 
91
- def visit_Arel_Nodes_Equality(node)
91
+ def visit_Arel_Nodes_Equality(node, *_)
92
92
  right = node.right
93
93
  [visit(node.left), right ? visit(right) : nil]
94
94
  end
95
95
 
96
- def visit_Arel_Attributes_Attribute(node)
96
+ def visit_Arel_Attributes_Attribute(node, *_)
97
97
  self.last_column = column_for(node.name)
98
98
  node.name.to_sym
99
99
  end
100
100
 
101
- def literal(node)
101
+ def literal(node, *_)
102
102
  if node == '?'
103
103
  column, value = @binds.shift
104
104
  value.to_s
@@ -108,11 +108,11 @@ module Kasket
108
108
  end
109
109
 
110
110
  # only gets used on 1.8.7
111
- def visit_Arel_Nodes_BindParam(x)
111
+ def visit_Arel_Nodes_BindParam(x, *_)
112
112
  @binds.shift[1]
113
113
  end
114
114
 
115
- def visit_Array(node)
115
+ def visit_Array(node, *_)
116
116
  node.map {|value| quoted(value) }
117
117
  end
118
118
 
@@ -1,4 +1,3 @@
1
- # -*- encoding: utf-8 -*-
2
1
  module Kasket
3
2
  module WriteMixin
4
3
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kasket
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.5
4
+ version: 3.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mick Staugaard
@@ -9,112 +9,126 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-11-22 00:00:00.000000000 Z
12
+ date: 2014-05-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - '>='
18
+ - - ">="
19
19
  - !ruby/object:Gem::Version
20
- version: 2.3.6
21
- - - <
20
+ version: '3.2'
21
+ - - "<"
22
22
  - !ruby/object:Gem::Version
23
- version: '3.3'
23
+ version: '4.2'
24
24
  type: :runtime
25
25
  prerelease: false
26
26
  version_requirements: !ruby/object:Gem::Requirement
27
27
  requirements:
28
- - - '>='
28
+ - - ">="
29
29
  - !ruby/object:Gem::Version
30
- version: 2.3.6
31
- - - <
30
+ version: '3.2'
31
+ - - "<"
32
32
  - !ruby/object:Gem::Version
33
- version: '3.3'
33
+ version: '4.2'
34
34
  - !ruby/object:Gem::Dependency
35
35
  name: rake
36
36
  requirement: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  type: :development
42
42
  prerelease: false
43
43
  version_requirements: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: bundler
50
50
  requirement: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
57
  version_requirements: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  - !ruby/object:Gem::Dependency
63
63
  name: appraisal
64
64
  requirement: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ~>
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '0.5'
68
+ version: 0.5.0
69
69
  type: :development
70
70
  prerelease: false
71
71
  version_requirements: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ~>
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '0.5'
75
+ version: 0.5.0
76
76
  - !ruby/object:Gem::Dependency
77
- name: shoulda
77
+ name: mocha
78
78
  requirement: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - '>='
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  type: :development
84
84
  prerelease: false
85
85
  version_requirements: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - '>='
87
+ - - ">="
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0'
90
90
  - !ruby/object:Gem::Dependency
91
- name: mocha
91
+ name: wwtd
92
92
  requirement: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - '>='
94
+ - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  type: :development
98
98
  prerelease: false
99
99
  version_requirements: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - '>='
101
+ - - ">="
102
102
  - !ruby/object:Gem::Version
103
103
  version: '0'
104
104
  - !ruby/object:Gem::Dependency
105
- name: test-unit
105
+ name: minitest
106
106
  requirement: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - ~>
108
+ - - ">="
109
109
  - !ruby/object:Gem::Version
110
- version: '2.5'
110
+ version: '0'
111
111
  type: :development
112
112
  prerelease: false
113
113
  version_requirements: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - ~>
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ - !ruby/object:Gem::Dependency
119
+ name: minitest-rg
120
+ requirement: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
116
123
  - !ruby/object:Gem::Version
117
- version: '2.5'
124
+ version: '0'
125
+ type: :development
126
+ prerelease: false
127
+ version_requirements: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
118
132
  description: puts a cap on your queries
119
133
  email:
120
134
  - mick@zendesk.com
@@ -123,6 +137,8 @@ executables: []
123
137
  extensions: []
124
138
  extra_rdoc_files: []
125
139
  files:
140
+ - README.rdoc
141
+ - lib/kasket.rb
126
142
  - lib/kasket/configuration_mixin.rb
127
143
  - lib/kasket/dirty_mixin.rb
128
144
  - lib/kasket/query_parser.rb
@@ -133,27 +149,6 @@ files:
133
149
  - lib/kasket/version.rb
134
150
  - lib/kasket/visitor.rb
135
151
  - lib/kasket/write_mixin.rb
136
- - lib/kasket.rb
137
- - README.rdoc
138
- - test/cache_expiry_test.rb
139
- - test/cacheable_test.rb
140
- - test/configuration_mixin_test.rb
141
- - test/database.yml
142
- - test/dirty_test.rb
143
- - test/find_one_test.rb
144
- - test/find_some_test.rb
145
- - test/fixtures/authors.yml
146
- - test/fixtures/blogs.yml
147
- - test/fixtures/comments.yml
148
- - test/fixtures/posts.yml
149
- - test/helper.rb
150
- - test/parser_test.rb
151
- - test/read_mixin_test.rb
152
- - test/reload_test.rb
153
- - test/schema.rb
154
- - test/test_models.rb
155
- - test/transaction_test.rb
156
- - test/visitor_test.rb
157
152
  homepage: http://github.com/zendesk/kasket
158
153
  licenses:
159
154
  - Apache License Version 2.0
@@ -164,37 +159,18 @@ require_paths:
164
159
  - lib
165
160
  required_ruby_version: !ruby/object:Gem::Requirement
166
161
  requirements:
167
- - - '>='
162
+ - - ">="
168
163
  - !ruby/object:Gem::Version
169
164
  version: '0'
170
165
  required_rubygems_version: !ruby/object:Gem::Requirement
171
166
  requirements:
172
- - - '>='
167
+ - - ">="
173
168
  - !ruby/object:Gem::Version
174
169
  version: '0'
175
170
  requirements: []
176
171
  rubyforge_project:
177
- rubygems_version: 2.0.3
172
+ rubygems_version: 2.2.2
178
173
  signing_key:
179
174
  specification_version: 4
180
175
  summary: A write back caching layer on active record
181
- test_files:
182
- - test/cache_expiry_test.rb
183
- - test/cacheable_test.rb
184
- - test/configuration_mixin_test.rb
185
- - test/database.yml
186
- - test/dirty_test.rb
187
- - test/find_one_test.rb
188
- - test/find_some_test.rb
189
- - test/fixtures/authors.yml
190
- - test/fixtures/blogs.yml
191
- - test/fixtures/comments.yml
192
- - test/fixtures/posts.yml
193
- - test/helper.rb
194
- - test/parser_test.rb
195
- - test/read_mixin_test.rb
196
- - test/reload_test.rb
197
- - test/schema.rb
198
- - test/test_models.rb
199
- - test/transaction_test.rb
200
- - test/visitor_test.rb
176
+ test_files: []