flounder 0.11.7 → 0.12.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: 40563f93ef03c6003326865768ad7c1b9db8e8f5
4
- data.tar.gz: 2b98f903f37a846635937120b5fda6747be4fd5d
3
+ metadata.gz: 89027cfd2718cdb12b179408c60d7597333b8f35
4
+ data.tar.gz: 94b4670b43b45137c6c7d111ded56903b1dc514d
5
5
  SHA512:
6
- metadata.gz: 3fa1f0d537188df5b47f953193172267b34df442f88bd1c9ec066f40d38c5febd3ff3c54bf9d155366c488e7ca614cf1f53f7246c5c3273a60f864fa10b49a4e
7
- data.tar.gz: c8aee48a61009a255747fd3d80728661fd47087c4ac5a2f5e72b0aa385f357655c1c97492b109ace3a17bfa9d789999f002eee1b0ce7efdb325661bbdb6a8a33
6
+ metadata.gz: cc55bcecfa205bd8c7897b2a1b71201cc8fcc06907ac2d10f7609230a23bfde2e7fe9e765a2ed300722a3e78b49b758a4815b50f5411eb318353ee72394290d1
7
+ data.tar.gz: 60b493884663840097701f8bfb8f9707c214e5a2ac85c05f25ec36d1ab144f567e928618d317f1c5fe0f5c1c24997241fe8f76126226d825b2667510ede96313
data/Gemfile.lock CHANGED
@@ -1,7 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- flounder (0.11.5)
4
+ flounder (0.11.7)
5
+ aggregate
5
6
  arel (~> 5, > 5.0.1)
6
7
  connection_pool (~> 2)
7
8
  hashie (~> 3, >= 3.2)
@@ -13,6 +14,7 @@ GEM
13
14
  specs:
14
15
  ae (1.8.2)
15
16
  ansi
17
+ aggregate (0.2.2)
16
18
  ansi (1.4.3)
17
19
  arel (5.0.1.20140414130214)
18
20
  brass (1.2.1)
data/HISTORY CHANGED
@@ -1,3 +1,6 @@
1
+ # 0.12
2
+ + domain#stats keeps a histogram of execution times.
3
+
1
4
  # 0.11
2
5
 
3
6
  + #anchor now only affects the interpretation of #on, doesn't modify return
data/flounder.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "flounder"
5
- s.version = '0.11.7'
5
+ s.version = '0.12.0'
6
6
  s.summary = "Flounder is a way to write SQL simply in Ruby. It deals with everything BUT object relational mapping. "
7
7
  s.email = "kaspar.schiess@technologyastronauts.ch"
8
8
  s.homepage = "https://bitbucket.org/technologyastronauts/oss_flounder"
@@ -19,6 +19,7 @@ Gem::Specification.new do |s|
19
19
  s.add_runtime_dependency 'hashie', '~> 3', '>= 3.2'
20
20
  s.add_runtime_dependency 'connection_pool', '~> 2'
21
21
  s.add_runtime_dependency 'pg-hstore', '~> 1.2', '>= 1.2.0'
22
+ s.add_runtime_dependency 'aggregate', '~> 0.2', '>= 0.2.2'
22
23
 
23
24
  s.files = Dir['**/*']
24
25
  s.test_files = Dir['qed/**/*']
@@ -1,6 +1,7 @@
1
1
 
2
2
  require 'forwardable'
3
3
  require 'logger'
4
+ require 'aggregate'
4
5
 
5
6
  module Flounder
6
7
  class Domain
@@ -48,6 +49,22 @@ module Flounder
48
49
  end
49
50
  end
50
51
 
52
+ # Returns an aggregate of all query wall clock times. Please see
53
+ # https://github.com/josephruscio/aggregate for more information on this
54
+ # object.
55
+ #
56
+ # @return [Aggregate] statistics for this thread
57
+ #
58
+ def stats
59
+ Thread.current[:__flounder_stats] ||= Aggregate.new
60
+ end
61
+
62
+ # Resets this threads stats.
63
+ #
64
+ def reset_stats
65
+ Thread.current[:__flounder_stats] = nil
66
+ end
67
+
51
68
  # Returns the entity with the given plural name.
52
69
  #
53
70
  def [] name
@@ -72,6 +89,7 @@ module Flounder
72
89
  @logger.info sql
73
90
  end
74
91
  def log_bm measure
92
+ stats << measure.total * 1_000
75
93
  @logger.info "Query took #{measure}."
76
94
  end
77
95
 
@@ -48,4 +48,39 @@ When connecting to a database, you can use the `search_path` argument to install
48
48
  path = result.to_a.first.first.last
49
49
  path.assert == 'public, test'
50
50
  end
51
+ ~~~
52
+
53
+ # Benchmarking
54
+
55
+ The time taken for each query is measured and aggregated. If you want to get data about how many queries you've executed and what time it took to execute them, please look at the following methods.
56
+
57
+ ~~~ruby
58
+ stats = domain.stats
59
+
60
+ # Please see https://github.com/josephruscio/aggregate for more documentation.
61
+ stats.count.assert > 0
62
+
63
+ # Can be printed to look nice
64
+ stats.count
65
+ stats.mean # kept in miliseconds
66
+ stats.to_s # binary histogram!
67
+ ~~~
68
+
69
+ Statistics are per thread.
70
+
71
+ ~~~ruby
72
+ # stats are per thread:
73
+ t = Thread.start do
74
+ Thread.current.abort_on_exception = true
75
+ domain.stats.count.assert == 0
76
+ domain.stats.refute == stats
77
+ end
78
+ t.join
79
+ ~~~
80
+
81
+ They can be reset, again per thread.
82
+
83
+ ~~~ruby
84
+ domain.reset_stats
85
+ domain.stats.count.assert == 0
51
86
  ~~~
data/qed/index.md CHANGED
@@ -72,10 +72,5 @@ By default, symbols are interpreted as field names in the entity that you start
72
72
  assert generates_sql("SELECT [fields] FROM \"users\" WHERE \"posts\".\"id\" = 1")
73
73
  ~~~
74
74
 
75
- # Selective projection
76
-
77
- ~~~ruby
78
- domain[:users].where(id: 2013).project(domain[:users][:id]).
79
- to_sql.assert == %Q(SELECT "users"."id" FROM "users" WHERE "users"."id" = 2013)
80
- ~~~
75
+ TODO links to other documentation
81
76
 
data/qed/projection.md CHANGED
@@ -12,6 +12,9 @@ Without projection, result objects will be packaged in a subhash.
12
12
  When projecting, all result data will be toplevel and only the projected data is loaded.
13
13
 
14
14
  ~~~ruby
15
+ domain[:users].where(id: 2013).project(domain[:users][:id]).
16
+ to_sql.assert == %Q(SELECT "users"."id" FROM "users" WHERE "users"."id" = 2013)
17
+
15
18
  result = posts.join(users).on(:user_id => :id).
16
19
  project(users[:name]).first
17
20
 
@@ -22,8 +25,11 @@ When projecting, all result data will be toplevel and only the projected data is
22
25
  Otherwise a projected query can be treated like an ordinary query, including appending stuff by joining it in.
23
26
 
24
27
  ~~~ruby
25
- posts.
26
- project(users[:name]).
27
- join(users).on(:user_id => :id).
28
- first
28
+ post = posts.
29
+ join(users).on(:user_id => :id).
30
+ join(users.as(:approvers, :approver)).on(:approver_id => :id).
31
+ first
32
+
33
+ post.user.name.assert == 'John Snow'
34
+ post.approver.name.assert == 'John Doe'
29
35
  ~~~
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flounder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.7
4
+ version: 0.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kaspar Schiess
@@ -9,96 +9,116 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-09-17 00:00:00.000000000 Z
12
+ date: 2014-09-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: arel
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - ~>
18
+ - - "~>"
19
19
  - !ruby/object:Gem::Version
20
20
  version: '5'
21
- - - '>'
21
+ - - ">"
22
22
  - !ruby/object:Gem::Version
23
23
  version: 5.0.1
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
30
  version: '5'
31
- - - '>'
31
+ - - ">"
32
32
  - !ruby/object:Gem::Version
33
33
  version: 5.0.1
34
34
  - !ruby/object:Gem::Dependency
35
35
  name: pg
36
36
  requirement: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0.17'
41
41
  type: :runtime
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.17'
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: hashie
50
50
  requirement: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ~>
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '3'
55
- - - '>='
55
+ - - ">="
56
56
  - !ruby/object:Gem::Version
57
57
  version: '3.2'
58
58
  type: :runtime
59
59
  prerelease: false
60
60
  version_requirements: !ruby/object:Gem::Requirement
61
61
  requirements:
62
- - - ~>
62
+ - - "~>"
63
63
  - !ruby/object:Gem::Version
64
64
  version: '3'
65
- - - '>='
65
+ - - ">="
66
66
  - !ruby/object:Gem::Version
67
67
  version: '3.2'
68
68
  - !ruby/object:Gem::Dependency
69
69
  name: connection_pool
70
70
  requirement: !ruby/object:Gem::Requirement
71
71
  requirements:
72
- - - ~>
72
+ - - "~>"
73
73
  - !ruby/object:Gem::Version
74
74
  version: '2'
75
75
  type: :runtime
76
76
  prerelease: false
77
77
  version_requirements: !ruby/object:Gem::Requirement
78
78
  requirements:
79
- - - ~>
79
+ - - "~>"
80
80
  - !ruby/object:Gem::Version
81
81
  version: '2'
82
82
  - !ruby/object:Gem::Dependency
83
83
  name: pg-hstore
84
84
  requirement: !ruby/object:Gem::Requirement
85
85
  requirements:
86
- - - ~>
86
+ - - "~>"
87
87
  - !ruby/object:Gem::Version
88
88
  version: '1.2'
89
- - - '>='
89
+ - - ">="
90
90
  - !ruby/object:Gem::Version
91
91
  version: 1.2.0
92
92
  type: :runtime
93
93
  prerelease: false
94
94
  version_requirements: !ruby/object:Gem::Requirement
95
95
  requirements:
96
- - - ~>
96
+ - - "~>"
97
97
  - !ruby/object:Gem::Version
98
98
  version: '1.2'
99
- - - '>='
99
+ - - ">="
100
100
  - !ruby/object:Gem::Version
101
101
  version: 1.2.0
102
+ - !ruby/object:Gem::Dependency
103
+ name: aggregate
104
+ requirement: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - "~>"
107
+ - !ruby/object:Gem::Version
108
+ version: '0.2'
109
+ - - ">="
110
+ - !ruby/object:Gem::Version
111
+ version: 0.2.2
112
+ type: :runtime
113
+ prerelease: false
114
+ version_requirements: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - "~>"
117
+ - !ruby/object:Gem::Version
118
+ version: '0.2'
119
+ - - ">="
120
+ - !ruby/object:Gem::Version
121
+ version: 0.2.2
102
122
  description: " Flounder is the missing piece between the database and your Ruby
103
123
  code. It \n allows very simple access to database tables without going all the
104
124
  way to\n begin an object mapper. \n"
@@ -107,11 +127,14 @@ executables: []
107
127
  extensions: []
108
128
  extra_rdoc_files: []
109
129
  files:
110
- - flounder.gemspec
111
130
  - Gemfile
112
131
  - Gemfile.lock
113
132
  - HACKING
114
133
  - HISTORY
134
+ - LICENSE
135
+ - README
136
+ - flounder.gemspec
137
+ - lib/flounder.rb
115
138
  - lib/flounder/connection.rb
116
139
  - lib/flounder/connection_pool.rb
117
140
  - lib/flounder/domain.rb
@@ -129,8 +152,6 @@ files:
129
152
  - lib/flounder/query/select.rb
130
153
  - lib/flounder/query/update.rb
131
154
  - lib/flounder/symbol_extensions.rb
132
- - lib/flounder.rb
133
- - LICENSE
134
155
  - qed/applique/ae.rb
135
156
  - qed/applique/flounder.rb
136
157
  - qed/applique/setup_domain.rb
@@ -146,10 +167,8 @@ files:
146
167
  - qed/joins.md
147
168
  - qed/ordering.md
148
169
  - qed/projection.md
149
- - qed/results.md
150
170
  - qed/selects.md
151
171
  - qed/updates.md
152
- - README
153
172
  homepage: https://bitbucket.org/technologyastronauts/oss_flounder
154
173
  licenses:
155
174
  - MIT
@@ -160,17 +179,17 @@ require_paths:
160
179
  - lib
161
180
  required_ruby_version: !ruby/object:Gem::Requirement
162
181
  requirements:
163
- - - '>='
182
+ - - ">="
164
183
  - !ruby/object:Gem::Version
165
184
  version: '0'
166
185
  required_rubygems_version: !ruby/object:Gem::Requirement
167
186
  requirements:
168
- - - '>='
187
+ - - ">="
169
188
  - !ruby/object:Gem::Version
170
189
  version: '0'
171
190
  requirements: []
172
191
  rubyforge_project:
173
- rubygems_version: 2.0.14
192
+ rubygems_version: 2.2.2
174
193
  signing_key:
175
194
  specification_version: 4
176
195
  summary: Flounder is a way to write SQL simply in Ruby. It deals with everything BUT
@@ -191,6 +210,6 @@ test_files:
191
210
  - qed/joins.md
192
211
  - qed/ordering.md
193
212
  - qed/projection.md
194
- - qed/results.md
195
213
  - qed/selects.md
196
214
  - qed/updates.md
215
+ has_rdoc:
data/qed/results.md DELETED
@@ -1,21 +0,0 @@
1
-
2
-
3
-
4
- ~~~ruby
5
- post = posts.
6
- join(users).on(:user_id => :id).
7
- join(users.as(:approvers, :approver)).on(:approver_id => :id).
8
- first
9
-
10
- post.user.name.assert == 'John Snow'
11
- post.approver.name.assert == 'John Doe'
12
- ~~~
13
-
14
- # Custom Projections
15
-
16
- TBD: Describes how to do custom projections and how these results will be available in the resulting object.
17
-
18
-
19
- # Aliasing
20
-
21
- TBD: Describes to join a table multiple times and how to deal with the results.