baza 0.0.31 → 0.0.32

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: 70b254c816708c8d1a509600dfd0c5fc43fad6ce
4
- data.tar.gz: 25c386eba844b6b7df1f621fcfa98efa505d4903
3
+ metadata.gz: 29581ed5677e51c2208d9d6084fa5a49afc40dc9
4
+ data.tar.gz: 92362dc85f0d2593a4f14ed119d4d0d6e33989a4
5
5
  SHA512:
6
- metadata.gz: 917fd582151288c9a93875fe252910f4ba13c60f14b711b922d99586f4a8cedbcd5c97125af9c80a510e2763261776e4963c3da23045589285a9851bfaf4da69
7
- data.tar.gz: 362224377526dfbd73b2021fb3a76da7cfc8fe38b059177f4af8197a801e3353303f92e3f825965d9c1eec04edca54b1132167afc60ba43ef2337c6f2219875a
6
+ metadata.gz: b5277487bb87290cd3512b916d531cc8a9a0d3806349c9f83b122fccef6fb3804abdc5ed9aae837e617c4d6df4b4ac7d6941de1627f112f621bd8e1f4bfaa821
7
+ data.tar.gz: 78dacdfc195b83d5d982176fa7465dc217bd57bdd36d5e9260c9a3c95dad5e62ad0a3f7ae938fd8599f1f4d4f4064c90246453c9b04172cded58a3ede3a75737
@@ -1,39 +1,39 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2016-04-08 08:46:33 +0200 using RuboCop version 0.39.0.
3
+ # on 2018-03-28 08:43:21 +0000 using RuboCop version 0.39.0.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
7
7
  # versions of RuboCop, may require this file to be generated again.
8
8
 
9
- # Offense count: 69
9
+ # Offense count: 79
10
10
  Metrics/AbcSize:
11
- Max: 66
11
+ Max: 81
12
12
 
13
- # Offense count: 3
13
+ # Offense count: 1
14
14
  Metrics/BlockNesting:
15
15
  Max: 4
16
16
 
17
- # Offense count: 13
17
+ # Offense count: 17
18
18
  # Configuration parameters: CountComments.
19
19
  Metrics/ClassLength:
20
- Max: 473
20
+ Max: 313
21
21
 
22
- # Offense count: 20
22
+ # Offense count: 52
23
23
  Metrics/CyclomaticComplexity:
24
24
  Max: 25
25
25
 
26
- # Offense count: 252
26
+ # Offense count: 288
27
27
  # Configuration parameters: AllowHeredoc, AllowURI, URISchemes.
28
28
  # URISchemes: http, https
29
29
  Metrics/LineLength:
30
30
  Max: 254
31
31
 
32
- # Offense count: 111
32
+ # Offense count: 125
33
33
  # Configuration parameters: CountComments.
34
34
  Metrics/MethodLength:
35
- Max: 61
35
+ Max: 60
36
36
 
37
- # Offense count: 47
37
+ # Offense count: 51
38
38
  Metrics/PerceivedComplexity:
39
- Max: 27
39
+ Max: 26
data/Gemfile CHANGED
@@ -4,7 +4,7 @@ source "http://rubygems.org"
4
4
  # gem "activesupport", ">= 2.3.5"
5
5
 
6
6
  gem "array_enumerator", "~> 0.0.10"
7
- gem "auto_autoloader", "~> 0.0.1"
7
+ gem "auto_autoloader", "~> 0.0.5"
8
8
  gem "datet", "~> 0.0.25"
9
9
  gem "event_handler", "~> 0.0.0"
10
10
  gem "simple_delegate", "~> 0.0.2"
@@ -20,15 +20,13 @@ group :development, :test do
20
20
  gem "bundler"
21
21
  gem "jdbc-mysql", platform: :jruby
22
22
  gem "jdbc-sqlite3", platform: :jruby
23
- gem "jeweler", "2.3.3"
24
- gem "mysql", "2.9.1", platform: :ruby
25
- gem "mysql2", "0.4.2", platform: :ruby
26
- gem "pg", "0.18.4", platform: :ruby
23
+ gem "jeweler", "2.3.9"
24
+ # gem "mysql", "2.9.1", platform: :ruby
25
+ gem "mysql2", "0.4.10", platform: :ruby
26
+ gem "pg", "0.21.0", platform: :ruby
27
27
  gem "pry"
28
28
  gem "rdoc"
29
29
  gem "rspec", "3.4.0"
30
30
  gem "rubocop", "0.39.0", require: false
31
31
  gem "sqlite3", platform: :ruby
32
32
  end
33
-
34
- gem "codeclimate-test-reporter", group: :test, require: nil
@@ -8,7 +8,7 @@ GEM
8
8
  activemodel (= 4.2.5)
9
9
  activesupport (= 4.2.5)
10
10
  arel (~> 6.0)
11
- activerecord-jdbc-adapter (1.3.19)
11
+ activerecord-jdbc-adapter (50.0)
12
12
  activerecord (>= 2.2)
13
13
  activesupport (4.2.5)
14
14
  i18n (~> 0.7)
@@ -16,96 +16,91 @@ GEM
16
16
  minitest (~> 5.1)
17
17
  thread_safe (~> 0.3, >= 0.3.4)
18
18
  tzinfo (~> 1.1)
19
- addressable (2.5.0)
20
- public_suffix (~> 2.0, >= 2.0.2)
21
- arel (6.0.3)
19
+ addressable (2.4.0)
20
+ arel (6.0.4)
22
21
  array_enumerator (0.0.10)
23
- ast (2.2.0)
24
- auto_autoloader (0.0.1)
22
+ ast (2.4.0)
23
+ auto_autoloader (0.0.5)
25
24
  string-cases
26
25
  best_practice_project (0.0.9)
27
26
  auto_autoloader
28
- builder (3.2.2)
29
- codeclimate-test-reporter (0.4.7)
30
- simplecov (>= 0.7.1, < 1.0.0)
31
- coderay (1.1.0)
27
+ builder (3.2.3)
28
+ coderay (1.1.2)
29
+ concurrent-ruby (1.0.5)
30
+ concurrent-ruby (1.0.5-java)
32
31
  datet (0.0.25)
33
32
  descendants_tracker (0.0.4)
34
33
  thread_safe (~> 0.3, >= 0.3.1)
35
- diff-lcs (1.2.5)
36
- docile (1.1.5)
34
+ diff-lcs (1.3)
37
35
  event_handler (0.0.0)
38
36
  faraday (0.9.2)
39
37
  multipart-post (>= 1.2, < 3)
40
- ffi (1.9.10-java)
38
+ ffi (1.9.23-java)
41
39
  git (1.3.0)
42
- github_api (0.11.3)
43
- addressable (~> 2.3)
44
- descendants_tracker (~> 0.0.1)
40
+ github_api (0.16.0)
41
+ addressable (~> 2.4.0)
42
+ descendants_tracker (~> 0.0.4)
45
43
  faraday (~> 0.8, < 0.10)
46
- hashie (>= 1.2)
47
- multi_json (>= 1.7.5, < 2.0)
48
- nokogiri (~> 1.6.0)
49
- oauth2
50
- hashie (3.4.6)
51
- highline (1.7.8)
52
- i18n (0.7.0)
53
- jar-dependencies (0.3.9)
54
- jdbc-mysql (5.1.37)
55
- jdbc-sqlite3 (3.8.11.2)
56
- jeweler (2.3.3)
44
+ hashie (>= 3.4)
45
+ mime-types (>= 1.16, < 3.0)
46
+ oauth2 (~> 1.0)
47
+ hashie (3.5.7)
48
+ highline (1.7.10)
49
+ i18n (0.9.5)
50
+ concurrent-ruby (~> 1.0)
51
+ jar-dependencies (0.3.12)
52
+ jdbc-mysql (5.1.44)
53
+ jdbc-sqlite3 (3.20.1)
54
+ jeweler (2.3.9)
57
55
  builder
58
- bundler (>= 1.0)
56
+ bundler
59
57
  git (>= 1.2.5)
60
- github_api (~> 0.11.0)
58
+ github_api (~> 0.16.0)
61
59
  highline (>= 1.6.15)
62
60
  nokogiri (>= 1.5.10)
63
- psych (~> 2.2)
61
+ psych
64
62
  rake
65
63
  rdoc
66
64
  semver2
67
- json (1.8.3)
68
- json (1.8.3-java)
65
+ json (1.8.6)
66
+ json (1.8.6-java)
69
67
  jwt (1.5.6)
70
- method_source (0.8.2)
71
- mini_portile2 (2.1.0)
72
- minitest (5.8.3)
73
- multi_json (1.12.1)
68
+ method_source (0.9.0)
69
+ mime-types (2.99.3)
70
+ mini_portile2 (2.3.0)
71
+ minitest (5.11.3)
72
+ multi_json (1.13.1)
74
73
  multi_xml (0.6.0)
75
74
  multipart-post (2.0.0)
76
- mysql (2.9.1)
77
- mysql2 (0.4.2)
78
- nokogiri (1.6.8.1)
79
- mini_portile2 (~> 2.1.0)
80
- nokogiri (1.6.8.1-java)
81
- oauth2 (1.3.0)
82
- faraday (>= 0.8, < 0.11)
75
+ mysql2 (0.4.10)
76
+ nokogiri (1.8.2)
77
+ mini_portile2 (~> 2.3.0)
78
+ nokogiri (1.8.2-java)
79
+ oauth2 (1.4.0)
80
+ faraday (>= 0.8, < 0.13)
83
81
  jwt (~> 1.0)
84
82
  multi_json (~> 1.3)
85
83
  multi_xml (~> 0.5)
86
84
  rack (>= 1.2, < 3)
87
- parser (2.3.0.7)
88
- ast (~> 2.2)
89
- pg (0.18.4)
85
+ parser (2.5.0.5)
86
+ ast (~> 2.4.0)
87
+ pg (0.21.0)
90
88
  powerpack (0.1.1)
91
- pry (0.10.1)
89
+ pry (0.11.3)
92
90
  coderay (~> 1.1.0)
93
- method_source (~> 0.8.1)
94
- slop (~> 3.4)
95
- pry (0.10.1-java)
91
+ method_source (~> 0.9.0)
92
+ pry (0.11.3-java)
96
93
  coderay (~> 1.1.0)
97
- method_source (~> 0.8.1)
98
- slop (~> 3.4)
94
+ method_source (~> 0.9.0)
99
95
  spoon (~> 0.0)
100
- psych (2.2.2)
101
- psych (2.2.2-java)
96
+ psych (3.0.2)
97
+ psych (3.0.2-java)
102
98
  jar-dependencies (>= 0.1.7)
103
- public_suffix (2.0.5)
104
- rack (2.0.1)
105
- rainbow (2.1.0)
106
- rake (12.0.0)
107
- rdoc (4.2.0)
108
- json (~> 1.4)
99
+ rack (2.0.4)
100
+ rainbow (2.2.2)
101
+ rake
102
+ rake (12.3.1)
103
+ rdoc (6.0.3)
109
104
  rspec (3.4.0)
110
105
  rspec-core (~> 3.4.0)
111
106
  rspec-expectations (~> 3.4.0)
@@ -125,24 +120,18 @@ GEM
125
120
  rainbow (>= 1.99.1, < 3.0)
126
121
  ruby-progressbar (~> 1.7)
127
122
  unicode-display_width (~> 1.0, >= 1.0.1)
128
- ruby-progressbar (1.7.5)
123
+ ruby-progressbar (1.9.0)
129
124
  semver2 (3.4.2)
130
125
  simple_delegate (0.0.2)
131
- simplecov (0.10.0)
132
- docile (~> 1.1.0)
133
- json (~> 1.8)
134
- simplecov-html (~> 0.10.0)
135
- simplecov-html (0.10.0)
136
- slop (3.6.0)
137
- spoon (0.0.4)
126
+ spoon (0.0.6)
138
127
  ffi
139
- sqlite3 (1.3.10)
128
+ sqlite3 (1.3.13)
140
129
  string-cases (0.0.4)
141
- thread_safe (0.3.5)
142
- thread_safe (0.3.5-java)
143
- tzinfo (1.2.2)
130
+ thread_safe (0.3.6)
131
+ thread_safe (0.3.6-java)
132
+ tzinfo (1.2.5)
144
133
  thread_safe (~> 0.1)
145
- unicode-display_width (1.0.3)
134
+ unicode-display_width (1.3.0)
146
135
  wref (0.0.8)
147
136
 
148
137
  PLATFORMS
@@ -153,18 +142,16 @@ DEPENDENCIES
153
142
  activerecord (= 4.2.5)
154
143
  activerecord-jdbc-adapter
155
144
  array_enumerator (~> 0.0.10)
156
- auto_autoloader (~> 0.0.1)
145
+ auto_autoloader (~> 0.0.5)
157
146
  best_practice_project (= 0.0.9)
158
147
  bundler
159
- codeclimate-test-reporter
160
148
  datet (~> 0.0.25)
161
149
  event_handler (~> 0.0.0)
162
150
  jdbc-mysql
163
151
  jdbc-sqlite3
164
- jeweler (= 2.3.3)
165
- mysql (= 2.9.1)
166
- mysql2 (= 0.4.2)
167
- pg (= 0.18.4)
152
+ jeweler (= 2.3.9)
153
+ mysql2 (= 0.4.10)
154
+ pg (= 0.21.0)
168
155
  pry
169
156
  rdoc
170
157
  rspec (= 3.4.0)
@@ -175,4 +162,4 @@ DEPENDENCIES
175
162
  wref (~> 0.0.8)
176
163
 
177
164
  BUNDLED WITH
178
- 1.13.7
165
+ 1.16.1
data/README.md CHANGED
@@ -1,7 +1,3 @@
1
- [![Code Climate](https://codeclimate.com/github/kaspernj/baza/badges/gpa.svg)](https://codeclimate.com/github/kaspernj/baza)
2
- [![Test Coverage](https://codeclimate.com/github/kaspernj/baza/badges/coverage.svg)](https://codeclimate.com/github/kaspernj/baza)
3
- [![Build Status](https://travis-ci.org/kaspernj/baza.svg?branch=master)](https://travis-ci.org/kaspernj/baza)
4
-
5
1
  # baza
6
2
 
7
3
  A database abstraction layer for Ruby. Also supports JRuby.
@@ -106,6 +102,12 @@ db.databases.list.each do |database|
106
102
  end
107
103
  ```
108
104
 
105
+ ### Dropping a database
106
+ ```ruby
107
+ database = db.databases["test-db"]
108
+ database.drop
109
+ ```
110
+
109
111
  ### Listing tables on non-used-database
110
112
  ```ruby
111
113
  database = db.database["test-db"]
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.31
1
+ 0.0.32
@@ -2,16 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: baza 0.0.31 ruby lib
5
+ # stub: baza 0.0.32 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "baza".freeze
9
- s.version = "0.0.31"
9
+ s.version = "0.0.32"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib".freeze]
13
13
  s.authors = ["Kasper Johansen".freeze]
14
- s.date = "2018-01-09"
14
+ s.date = "2018-03-28"
15
15
  s.description = "A database abstraction layer, model framework and database framework.".freeze
16
16
  s.email = "kj@gfish.com".freeze
17
17
  s.extra_rdoc_files = [
@@ -24,7 +24,6 @@ Gem::Specification.new do |s|
24
24
  ".rubocop.yml",
25
25
  ".rubocop_todo.yml",
26
26
  ".ruby-version",
27
- ".travis.yml",
28
27
  "Gemfile",
29
28
  "Gemfile.lock",
30
29
  "LICENSE.txt",
@@ -160,9 +159,12 @@ Gem::Specification.new do |s|
160
159
  "lib/baza/sql_queries/sqlite_upsert_duplicate_key.rb",
161
160
  "lib/baza/sqlspecs.rb",
162
161
  "lib/baza/table.rb",
162
+ "lib/baza/tables.rb",
163
+ "peak_flow.yml",
163
164
  "spec/active_record/models/user.rb",
164
165
  "spec/baza/cloner_spec.rb",
165
166
  "spec/baza/sql_queries/generic_insert_spec.rb",
167
+ "spec/baza/sql_queries/select_spec.rb",
166
168
  "spec/drivers/active_record_mysql2_spec.rb",
167
169
  "spec/drivers/active_record_mysql_spec.rb",
168
170
  "spec/drivers/active_record_pg_spec.rb",
@@ -174,18 +176,18 @@ Gem::Specification.new do |s|
174
176
  "spec/drivers/sqlite3_spec.rb",
175
177
  "spec/info_active_record_example.rb",
176
178
  "spec/info_active_record_mysql2_example.rb",
177
- "spec/info_active_record_mysql2_travis.rb",
179
+ "spec/info_active_record_mysql2_peak_flow.rb",
178
180
  "spec/info_active_record_mysql_example.rb",
179
- "spec/info_active_record_mysql_travis.rb",
181
+ "spec/info_active_record_mysql_peak_flow.rb",
180
182
  "spec/info_active_record_pg_example.rb",
181
- "spec/info_active_record_pg_travis.rb",
183
+ "spec/info_active_record_pg_peak_flow.rb",
182
184
  "spec/info_active_record_sqlite3.rb",
183
185
  "spec/info_mysql2_example.rb",
184
- "spec/info_mysql2_travis.rb",
186
+ "spec/info_mysql2_peak_flow.rb",
185
187
  "spec/info_mysql_example.rb",
186
- "spec/info_mysql_travis.rb",
188
+ "spec/info_mysql_peak_flow.rb",
187
189
  "spec/info_pg_example.rb",
188
- "spec/info_pg_travis.rb",
190
+ "spec/info_pg_peak_flow.rb",
189
191
  "spec/info_sqlite3.rb",
190
192
  "spec/spec_helper.rb",
191
193
  "spec/support/driver_active_record_collection.rb",
@@ -208,7 +210,7 @@ Gem::Specification.new do |s|
208
210
 
209
211
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
210
212
  s.add_runtime_dependency(%q<array_enumerator>.freeze, ["~> 0.0.10"])
211
- s.add_runtime_dependency(%q<auto_autoloader>.freeze, ["~> 0.0.1"])
213
+ s.add_runtime_dependency(%q<auto_autoloader>.freeze, ["~> 0.0.5"])
212
214
  s.add_runtime_dependency(%q<datet>.freeze, ["~> 0.0.25"])
213
215
  s.add_runtime_dependency(%q<event_handler>.freeze, ["~> 0.0.0"])
214
216
  s.add_runtime_dependency(%q<simple_delegate>.freeze, ["~> 0.0.2"])
@@ -220,10 +222,9 @@ Gem::Specification.new do |s|
220
222
  s.add_development_dependency(%q<bundler>.freeze, [">= 0"])
221
223
  s.add_development_dependency(%q<jdbc-mysql>.freeze, [">= 0"])
222
224
  s.add_development_dependency(%q<jdbc-sqlite3>.freeze, [">= 0"])
223
- s.add_development_dependency(%q<jeweler>.freeze, ["= 2.3.3"])
224
- s.add_development_dependency(%q<mysql>.freeze, ["= 2.9.1"])
225
- s.add_development_dependency(%q<mysql2>.freeze, ["= 0.4.2"])
226
- s.add_development_dependency(%q<pg>.freeze, ["= 0.18.4"])
225
+ s.add_development_dependency(%q<jeweler>.freeze, ["= 2.3.9"])
226
+ s.add_development_dependency(%q<mysql2>.freeze, ["= 0.4.10"])
227
+ s.add_development_dependency(%q<pg>.freeze, ["= 0.21.0"])
227
228
  s.add_development_dependency(%q<pry>.freeze, [">= 0"])
228
229
  s.add_development_dependency(%q<rdoc>.freeze, [">= 0"])
229
230
  s.add_development_dependency(%q<rspec>.freeze, ["= 3.4.0"])
@@ -231,7 +232,7 @@ Gem::Specification.new do |s|
231
232
  s.add_development_dependency(%q<sqlite3>.freeze, [">= 0"])
232
233
  else
233
234
  s.add_dependency(%q<array_enumerator>.freeze, ["~> 0.0.10"])
234
- s.add_dependency(%q<auto_autoloader>.freeze, ["~> 0.0.1"])
235
+ s.add_dependency(%q<auto_autoloader>.freeze, ["~> 0.0.5"])
235
236
  s.add_dependency(%q<datet>.freeze, ["~> 0.0.25"])
236
237
  s.add_dependency(%q<event_handler>.freeze, ["~> 0.0.0"])
237
238
  s.add_dependency(%q<simple_delegate>.freeze, ["~> 0.0.2"])
@@ -243,10 +244,9 @@ Gem::Specification.new do |s|
243
244
  s.add_dependency(%q<bundler>.freeze, [">= 0"])
244
245
  s.add_dependency(%q<jdbc-mysql>.freeze, [">= 0"])
245
246
  s.add_dependency(%q<jdbc-sqlite3>.freeze, [">= 0"])
246
- s.add_dependency(%q<jeweler>.freeze, ["= 2.3.3"])
247
- s.add_dependency(%q<mysql>.freeze, ["= 2.9.1"])
248
- s.add_dependency(%q<mysql2>.freeze, ["= 0.4.2"])
249
- s.add_dependency(%q<pg>.freeze, ["= 0.18.4"])
247
+ s.add_dependency(%q<jeweler>.freeze, ["= 2.3.9"])
248
+ s.add_dependency(%q<mysql2>.freeze, ["= 0.4.10"])
249
+ s.add_dependency(%q<pg>.freeze, ["= 0.21.0"])
250
250
  s.add_dependency(%q<pry>.freeze, [">= 0"])
251
251
  s.add_dependency(%q<rdoc>.freeze, [">= 0"])
252
252
  s.add_dependency(%q<rspec>.freeze, ["= 3.4.0"])
@@ -255,7 +255,7 @@ Gem::Specification.new do |s|
255
255
  end
256
256
  else
257
257
  s.add_dependency(%q<array_enumerator>.freeze, ["~> 0.0.10"])
258
- s.add_dependency(%q<auto_autoloader>.freeze, ["~> 0.0.1"])
258
+ s.add_dependency(%q<auto_autoloader>.freeze, ["~> 0.0.5"])
259
259
  s.add_dependency(%q<datet>.freeze, ["~> 0.0.25"])
260
260
  s.add_dependency(%q<event_handler>.freeze, ["~> 0.0.0"])
261
261
  s.add_dependency(%q<simple_delegate>.freeze, ["~> 0.0.2"])
@@ -267,10 +267,9 @@ Gem::Specification.new do |s|
267
267
  s.add_dependency(%q<bundler>.freeze, [">= 0"])
268
268
  s.add_dependency(%q<jdbc-mysql>.freeze, [">= 0"])
269
269
  s.add_dependency(%q<jdbc-sqlite3>.freeze, [">= 0"])
270
- s.add_dependency(%q<jeweler>.freeze, ["= 2.3.3"])
271
- s.add_dependency(%q<mysql>.freeze, ["= 2.9.1"])
272
- s.add_dependency(%q<mysql2>.freeze, ["= 0.4.2"])
273
- s.add_dependency(%q<pg>.freeze, ["= 0.18.4"])
270
+ s.add_dependency(%q<jeweler>.freeze, ["= 2.3.9"])
271
+ s.add_dependency(%q<mysql2>.freeze, ["= 0.4.10"])
272
+ s.add_dependency(%q<pg>.freeze, ["= 0.21.0"])
274
273
  s.add_dependency(%q<pry>.freeze, [">= 0"])
275
274
  s.add_dependency(%q<rdoc>.freeze, [">= 0"])
276
275
  s.add_dependency(%q<rspec>.freeze, ["= 3.4.0"])
@@ -1,7 +1,7 @@
1
1
  require "monitor"
2
2
 
3
3
  # This class handels various MySQL-table-specific behaviour.
4
- class Baza::Driver::Mysql::Tables
4
+ class Baza::Driver::Mysql::Tables < Baza::Tables
5
5
  attr_reader :db, :list
6
6
 
7
7
  # Constructor. This should not be called manually.
@@ -66,6 +66,8 @@ class Baza::Driver::Pg < Baza::BaseSqlDriver
66
66
  def reconnect
67
67
  require "pg" unless ::Object.const_defined?(:PG)
68
68
 
69
+ close if @conn && !@conn.finished?
70
+
69
71
  args = {dbname: db.opts.fetch(:db)}
70
72
  args[:port] = db.opts.fetch(:port) if db.opts[:port]
71
73
  args[:hostaddr] = db.opts.fetch(:host) if db.opts[:host]
@@ -182,6 +182,13 @@ class Baza::Driver::Pg::Table < Baza::Table
182
182
  self
183
183
  end
184
184
 
185
+ def rows_count
186
+ @db.databases.with_database(database_name) do
187
+ sql = "SELECT COUNT(*) AS count FROM #{@db.sep_table}#{@db.escape_table(name)}#{@db.sep_table}"
188
+ return @db.query(sql).fetch.fetch(:count).to_i
189
+ end
190
+ end
191
+
185
192
  def optimize
186
193
  @db.query("VACUUM #{@db.sep_table}#{@db.escape_table(name)}#{@db.sep_table}")
187
194
  self
@@ -1,4 +1,4 @@
1
- class Baza::Driver::Pg::Tables
1
+ class Baza::Driver::Pg::Tables < Baza::Tables
2
2
  attr_reader :db
3
3
 
4
4
  def initialize(args)
@@ -1,6 +1,6 @@
1
1
  require "monitor"
2
2
 
3
- class Baza::Driver::Sqlite3::Tables
3
+ class Baza::Driver::Sqlite3::Tables < Baza::Tables
4
4
  attr_reader :db, :driver
5
5
 
6
6
  def initialize(args)
@@ -9,6 +9,18 @@ class Baza::SqlQueries::Select
9
9
  @orders = []
10
10
  end
11
11
 
12
+ def count
13
+ @count = true
14
+
15
+ begin
16
+ result = query.fetch.fetch(:count).to_i
17
+ ensure
18
+ @count = false
19
+ end
20
+
21
+ result
22
+ end
23
+
12
24
  def select(arg)
13
25
  @selects << arg
14
26
  self
@@ -39,6 +51,11 @@ class Baza::SqlQueries::Select
39
51
  self
40
52
  end
41
53
 
54
+ def per_page(number)
55
+ @per_page = number
56
+ self
57
+ end
58
+
42
59
  def limit(limit)
43
60
  @limit = limit
44
61
  self
@@ -57,6 +74,11 @@ class Baza::SqlQueries::Select
57
74
  each.to_a
58
75
  end
59
76
 
77
+ def total_pages
78
+ per_page_value = @per_page
79
+ (count.to_f / per_page_value.to_f).ceil
80
+ end
81
+
60
82
  def each(&blk)
61
83
  query(&blk)
62
84
  end
@@ -88,7 +110,9 @@ private
88
110
  def select_sql
89
111
  sql = "SELECT"
90
112
 
91
- if @selects.empty?
113
+ if @count
114
+ sql << " COUNT(*) AS count"
115
+ elsif @selects.empty?
92
116
  sql << " *"
93
117
  else
94
118
  first = true
@@ -0,0 +1,5 @@
1
+ class Baza::Tables
2
+ def exists?(name)
3
+ list.any? { |table| table.name.to_s == name.to_s }
4
+ end
5
+ end
@@ -0,0 +1,13 @@
1
+ before_script:
2
+ - cp spec/info_mysql_peak_flow.rb spec/info_mysql.rb
3
+ - cp spec/info_mysql2_peak_flow.rb spec/info_mysql2.rb
4
+ - cp spec/info_pg_peak_flow.rb spec/info_pg.rb
5
+ - cp spec/info_active_record_mysql_peak_flow.rb spec/info_active_record_mysql.rb
6
+ - cp spec/info_active_record_mysql2_peak_flow.rb spec/info_active_record_mysql2.rb
7
+ - cp spec/info_active_record_pg_peak_flow.rb spec/info_active_record_pg.rb
8
+ - mysql -e 'CREATE DATABASE IF NOT EXISTS baza;'
9
+ - psql -c 'DROP DATABASE IF EXISTS "baza";' -U postgres
10
+ - psql -c 'CREATE DATABASE "baza";' -U postgres
11
+ script:
12
+ - bundle exec rspec --tag ~@mysql
13
+ - bundle exec rake best_practice_project:run
@@ -2,8 +2,8 @@ require "spec_helper"
2
2
 
3
3
  describe Baza::Cloner do
4
4
  it "can clone drivers" do
5
- require "info_active_record_mysql"
6
- conn = Baza::InfoActiveRecordMysql.connection
5
+ require "info_active_record_mysql2"
6
+ conn = Baza::InfoActiveRecordMysql2.connection
7
7
  baza_db = Baza::Cloner.from_active_record_connection(conn[:conn])
8
8
  expect(baza_db.query("SELECT 1 AS test").fetch[:test].to_s).to eq "1"
9
9
  end
@@ -0,0 +1,38 @@
1
+ require "spec_helper"
2
+
3
+ describe Baza::SqlQueries::Select do
4
+ let(:constant) do
5
+ const_name = "InfoPg"
6
+ require StringCases.camel_to_snake(const_name)
7
+ raise "Constant was not defined: '#{const_name}'." unless Baza.const_defined?(const_name)
8
+ Baza.const_get(const_name)
9
+ end
10
+ let(:db) { constant.new.db }
11
+
12
+ before do
13
+ db.tables[:test].drop if db.tables.exists?(:test)
14
+
15
+ db.tables.create(
16
+ "test",
17
+ columns: [
18
+ {name: "id", type: :int, autoincr: true, primarykey: true},
19
+ {name: "text", type: :varchar},
20
+ {name: "number", type: :int, default: 0},
21
+ {name: "float", type: :float, default: 0.0},
22
+ {name: "created_at", type: :datetime}
23
+ ]
24
+ )
25
+
26
+ 1000.times do |count|
27
+ db.insert("test", text: "Test #{count}", number: count, float: count)
28
+ end
29
+ end
30
+
31
+ describe "#total_pages" do
32
+ it "returns the correct amount of pages" do
33
+ query = db.new_query.from("test").per_page(30)
34
+
35
+ expect(query.total_pages).to eq 34
36
+ end
37
+ end
38
+ end
@@ -1,6 +1,6 @@
1
1
  require "spec_helper"
2
2
 
3
- describe Baza::Driver::ActiveRecord do
3
+ describe Baza::Driver::ActiveRecord, :mysql do
4
4
  let(:constant) do
5
5
  const_name = "InfoActiveRecordMysql"
6
6
  require "#{File.dirname(__FILE__)}/../#{StringCases.camel_to_snake(const_name)}"
@@ -1,6 +1,6 @@
1
1
  require "spec_helper"
2
2
 
3
- describe Baza.const_get(:Driver).const_get(:Mysql) do
3
+ describe Baza.const_get(:Driver).const_get(:Mysql), :mysql do
4
4
  let(:constant) do
5
5
  const_name = "InfoMysql"
6
6
  require "#{File.dirname(__FILE__)}/../#{StringCases.camel_to_snake(const_name)}"
@@ -1,6 +1,3 @@
1
- require "codeclimate-test-reporter"
2
- CodeClimate::TestReporter.start
3
-
4
1
  require "baza"
5
2
 
6
3
  if RUBY_PLATFORM == "java"
@@ -29,9 +29,7 @@ shared_examples_for "a baza databases driver" do
29
29
  end
30
30
 
31
31
  it "creates tables" do
32
- if test_database.table_exists?("test")
33
- test_database.table("test").drop
34
- end
32
+ test_database.table("test").drop if test_database.table_exists?("test")
35
33
 
36
34
  test_database.create_table(
37
35
  "test",
@@ -27,6 +27,17 @@ shared_examples_for "a baza tables driver" do
27
27
  expect(db.tables[:test].name).to eq "test"
28
28
  end
29
29
 
30
+ describe "#exists?" do
31
+ it "returns true for tables that exists" do
32
+ test_table
33
+ expect(db.tables.exists?("test")).to eq true
34
+ end
35
+
36
+ it "returns false for tables that doesnt exist" do
37
+ expect(db.tables.exists?("testtest")).to eq false
38
+ end
39
+ end
40
+
30
41
  it "#list" do
31
42
  test_table
32
43
  expect(db.tables.list).to include test_table
@@ -95,4 +106,11 @@ shared_examples_for "a baza tables driver" do
95
106
  expect { test_table.reload }.to raise_error(Baza::Errors::TableNotFound)
96
107
  end
97
108
  end
109
+
110
+ describe "Baza::Table#rows_count" do
111
+ it "returns the number of rows in the table" do
112
+ 3.times { |n| test_table.insert(text: "Test #{n}") }
113
+ expect(test_table.rows_count).to eq 3
114
+ end
115
+ end
98
116
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: baza
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.31
4
+ version: 0.0.32
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kasper Johansen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-01-09 00:00:00.000000000 Z
11
+ date: 2018-03-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: array_enumerator
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 0.0.1
33
+ version: 0.0.5
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 0.0.1
40
+ version: 0.0.5
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: datet
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -198,56 +198,42 @@ dependencies:
198
198
  requirements:
199
199
  - - '='
200
200
  - !ruby/object:Gem::Version
201
- version: 2.3.3
201
+ version: 2.3.9
202
202
  type: :development
203
203
  prerelease: false
204
204
  version_requirements: !ruby/object:Gem::Requirement
205
205
  requirements:
206
206
  - - '='
207
207
  - !ruby/object:Gem::Version
208
- version: 2.3.3
209
- - !ruby/object:Gem::Dependency
210
- name: mysql
211
- requirement: !ruby/object:Gem::Requirement
212
- requirements:
213
- - - '='
214
- - !ruby/object:Gem::Version
215
- version: 2.9.1
216
- type: :development
217
- prerelease: false
218
- version_requirements: !ruby/object:Gem::Requirement
219
- requirements:
220
- - - '='
221
- - !ruby/object:Gem::Version
222
- version: 2.9.1
208
+ version: 2.3.9
223
209
  - !ruby/object:Gem::Dependency
224
210
  name: mysql2
225
211
  requirement: !ruby/object:Gem::Requirement
226
212
  requirements:
227
213
  - - '='
228
214
  - !ruby/object:Gem::Version
229
- version: 0.4.2
215
+ version: 0.4.10
230
216
  type: :development
231
217
  prerelease: false
232
218
  version_requirements: !ruby/object:Gem::Requirement
233
219
  requirements:
234
220
  - - '='
235
221
  - !ruby/object:Gem::Version
236
- version: 0.4.2
222
+ version: 0.4.10
237
223
  - !ruby/object:Gem::Dependency
238
224
  name: pg
239
225
  requirement: !ruby/object:Gem::Requirement
240
226
  requirements:
241
227
  - - '='
242
228
  - !ruby/object:Gem::Version
243
- version: 0.18.4
229
+ version: 0.21.0
244
230
  type: :development
245
231
  prerelease: false
246
232
  version_requirements: !ruby/object:Gem::Requirement
247
233
  requirements:
248
234
  - - '='
249
235
  - !ruby/object:Gem::Version
250
- version: 0.18.4
236
+ version: 0.21.0
251
237
  - !ruby/object:Gem::Dependency
252
238
  name: pry
253
239
  requirement: !ruby/object:Gem::Requirement
@@ -331,7 +317,6 @@ files:
331
317
  - ".rubocop.yml"
332
318
  - ".rubocop_todo.yml"
333
319
  - ".ruby-version"
334
- - ".travis.yml"
335
320
  - Gemfile
336
321
  - Gemfile.lock
337
322
  - LICENSE.txt
@@ -467,9 +452,12 @@ files:
467
452
  - lib/baza/sql_queries/sqlite_upsert_duplicate_key.rb
468
453
  - lib/baza/sqlspecs.rb
469
454
  - lib/baza/table.rb
455
+ - lib/baza/tables.rb
456
+ - peak_flow.yml
470
457
  - spec/active_record/models/user.rb
471
458
  - spec/baza/cloner_spec.rb
472
459
  - spec/baza/sql_queries/generic_insert_spec.rb
460
+ - spec/baza/sql_queries/select_spec.rb
473
461
  - spec/drivers/active_record_mysql2_spec.rb
474
462
  - spec/drivers/active_record_mysql_spec.rb
475
463
  - spec/drivers/active_record_pg_spec.rb
@@ -481,18 +469,18 @@ files:
481
469
  - spec/drivers/sqlite3_spec.rb
482
470
  - spec/info_active_record_example.rb
483
471
  - spec/info_active_record_mysql2_example.rb
484
- - spec/info_active_record_mysql2_travis.rb
472
+ - spec/info_active_record_mysql2_peak_flow.rb
485
473
  - spec/info_active_record_mysql_example.rb
486
- - spec/info_active_record_mysql_travis.rb
474
+ - spec/info_active_record_mysql_peak_flow.rb
487
475
  - spec/info_active_record_pg_example.rb
488
- - spec/info_active_record_pg_travis.rb
476
+ - spec/info_active_record_pg_peak_flow.rb
489
477
  - spec/info_active_record_sqlite3.rb
490
478
  - spec/info_mysql2_example.rb
491
- - spec/info_mysql2_travis.rb
479
+ - spec/info_mysql2_peak_flow.rb
492
480
  - spec/info_mysql_example.rb
493
- - spec/info_mysql_travis.rb
481
+ - spec/info_mysql_peak_flow.rb
494
482
  - spec/info_pg_example.rb
495
- - spec/info_pg_travis.rb
483
+ - spec/info_pg_peak_flow.rb
496
484
  - spec/info_sqlite3.rb
497
485
  - spec/spec_helper.rb
498
486
  - spec/support/driver_active_record_collection.rb
@@ -1,21 +0,0 @@
1
- language: ruby
2
- cache: bundler
3
- rvm:
4
- - 1.9.3
5
- - 2.1.7
6
- - jruby-1.7.13
7
- before_script:
8
- - cp spec/info_mysql_travis.rb spec/info_mysql.rb
9
- - cp spec/info_mysql2_travis.rb spec/info_mysql2.rb
10
- - cp spec/info_pg_travis.rb spec/info_pg.rb
11
- - cp spec/info_active_record_mysql_travis.rb spec/info_active_record_mysql.rb
12
- - cp spec/info_active_record_mysql2_travis.rb spec/info_active_record_mysql2.rb
13
- - cp spec/info_active_record_pg_travis.rb spec/info_active_record_pg.rb
14
- - mysql -e 'CREATE DATABASE IF NOT EXISTS baza;'
15
- - psql -c 'DROP DATABASE IF EXISTS "baza";' -U postgres
16
- - psql -c 'CREATE DATABASE "baza";' -U postgres
17
- script:
18
- - CODECLIMATE_REPO_TOKEN=98c06de7271764c9cd7bbde7cee4ddfa0d3e7db4bd9933f17779100276672e5f bundle exec rspec
19
- - bundle exec rake best_practice_project:run
20
- notifications:
21
- email: false