sequel_tools 0.1.13 → 0.2.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dbc03d963faeda496049e1e3a8cc111bb68a18eeca2986b9b18a872280c6520a
4
- data.tar.gz: c498ec036d519fcc585e39c7dd32af341884138b108bf0baf08e7f5da73cd0bb
3
+ metadata.gz: 1b6264c7fe1b4a594f3a9a46941c6911e9e8fff7adfa4d666018a2ef788964cd
4
+ data.tar.gz: 04a24489253cc82f8cc181b98651ed3b106f1f179f9323b69395bbf8a5afd597
5
5
  SHA512:
6
- metadata.gz: 65dc15bc47c0eba4f5fa067bc8ee521bebe3926a7e423e3dd9d1b7b5bda0ea65ea2cb925edc41ceac8e9e762df276873f92ce00a0687638e0e42b347b7c4d076
7
- data.tar.gz: 84a43de92472aaca2c48814b2a92f8305711103bc4c402d31e8ddc5fd3e6047ec1b11e3a70f408fae2f1a10e7d0665befaba7ec346db1b9ae5c9dc330bdc32ca
6
+ metadata.gz: 05520ffcf91642c38dfe000c1f307a50de32737c6e5cb9279fa7b3a6bf5b8feff98a91cc3fc1b7a81214509f1d3f1ab2b9c07180061894f5cfd75ed2f6ba41fd
7
+ data.tar.gz: 1302a8a08dfc0bb6cc73fa4b70d79fce6ca248b3e3a7b15b3b306dd2e61e58252dc0cdd51c97f4cf5511836b934ec7fc8baa1cb9c1d6754bde81f9714913a56c
data/README.md CHANGED
@@ -127,7 +127,7 @@ PGPASSWORD=$DBPASSWORD
127
127
  psql
128
128
  ```
129
129
 
130
- Then you may pass `shell_command: '~/bin/opensql'` to `SequelTools.base_config`.
130
+ Then you may set `shell_command: '~/bin/opensql'` in config.
131
131
 
132
132
  Alternatively you can define the `shell_#{dbadapter}` action if you prefer. Take a look at
133
133
  the implementation for `shell_postgres` to see how to do that. If you want to share that action
@@ -9,7 +9,7 @@ class SequelTools::ActionsManager
9
9
  pg_dump = c[:pg_dump]
10
10
  schema_location = c[:schema_location]
11
11
 
12
- stdout, stderr, success = PgHelper.run_pg_command c, "#{pg_dump} -s"
12
+ stdout, _stderr, success = PgHelper.run_pg_command c, "#{pg_dump} -s"
13
13
  return unless success
14
14
  content = stdout
15
15
  migrations_table = c[:migrations_table]
@@ -20,13 +20,14 @@ class SequelTools::ActionsManager
20
20
  extra_tables = c[:extra_tables_in_dump]
21
21
  include_tables.concat extra_tables if extra_tables
22
22
  table_options = include_tables.map{|t| "-t #{t}"}.join(' ')
23
- stdout, stderr, success =
23
+ stdout, _stderr, success =
24
24
  PgHelper.run_pg_command c, "#{pg_dump} -a #{table_options} --inserts"
25
25
  unless success
26
26
  puts 'failed to dump data for schema_migrations and schema_info. Aborting.'
27
27
  exit 1
28
28
  end
29
- content = [content, stdout].join "\n\n"
29
+ content = [content, stdout].join("\n\n")
30
+ .gsub(/^\\(un)?restrict [A-Za-z0-9]+$/m, "")
30
31
  end
31
32
  require 'fileutils'
32
33
  FileUtils.mkdir_p File.dirname schema_location
@@ -8,8 +8,8 @@ class SequelTools::ActionsManager
8
8
  psql = c[:psql]
9
9
  env = {
10
10
  'PGDATABASE' => c[:dbname],
11
- 'PGHOST' => c[:dbhost],
12
- 'PGPORT' => c[:dbport].to_s,
11
+ 'PGHOST' => c[:dbhost] || 'localhost',
12
+ 'PGPORT' => (c[:dbport] || 5432).to_s,
13
13
  'PGUSER' => c[:username],
14
14
  'PGPASSWORD' => c[:password].to_s,
15
15
  }
@@ -9,9 +9,14 @@ module SequelTools
9
9
  uri_parts = []
10
10
  uri_parts << 'jdbc:' if RUBY_PLATFORM == 'java'
11
11
  uri_parts << "#{c[:jdbc_adapter] || c[:dbadapter]}://"
12
- uri_parts << c[:dbhost]
13
- uri_parts << ':' << c[:dbport] if c[:dbport]
14
- uri_parts << '/' << dbname
12
+ host = c[:dbhost]
13
+ host ||= 'localhost' unless (c[:dbadapter] == 'sqlite') || c[:no_dbhost]
14
+ if host
15
+ uri_parts << host
16
+ uri_parts << ':' << c[:dbport] if c[:dbport]
17
+ uri_parts << '/'
18
+ end
19
+ uri_parts << dbname
15
20
  if user = c[:username]
16
21
  uri_parts << '?user=' << user
17
22
  uri_parts << '&password=' << c[:password] if c[:password]
@@ -7,12 +7,14 @@ class PgHelper
7
7
  Tempfile.open 'pgpass' do |file|
8
8
  c = config
9
9
  file.chmod 0600
10
- file.write "#{c[:dbhost]}:#{c[:dbport]}:#{c[:dbname]}:#{c[:username]}:#{c[:password]}"
10
+ host = c[:dbhost] || 'localhost'
11
+ port = c[:dbport] || '5432'
12
+ file.write "#{host}:#{port}:#{c[:dbname]}:#{c[:username]}:#{c[:password]}"
11
13
  file.close
12
14
  env = {
13
15
  'PGDATABASE' => connect_database || c[:dbname],
14
- 'PGHOST' => c[:dbhost],
15
- 'PGPORT' => c[:dbport].to_s,
16
+ 'PGHOST' => host,
17
+ 'PGPORT' => port.to_s,
16
18
  'PGUSER' => c[:username],
17
19
  'PGPASSFILE' => file.path
18
20
  }
@@ -1,5 +1,5 @@
1
1
  # frozen-string-literal: true
2
2
 
3
3
  module SequelTools
4
- VERSION = '0.1.13'
4
+ VERSION = '0.2.0'
5
5
  end
data/lib/sequel_tools.rb CHANGED
@@ -12,7 +12,7 @@ module SequelTools
12
12
  schema_location: 'db/migrations/schema.sql',
13
13
  seeds_location: 'db/seeds.rb',
14
14
  dbname: nil,
15
- dbhost: 'localhost',
15
+ dbhost: nil,
16
16
  dbadapter: 'postgres',
17
17
  dbport: nil,
18
18
  username: nil,
@@ -24,7 +24,7 @@ module SequelTools
24
24
  extra_tables_in_dump: nil,
25
25
  } # unfrozen on purpose so that one might want to update the defaults
26
26
 
27
- REQUIRED_KEYS = [ :dbadapter, :dbname, :username ]
27
+ REQUIRED_KEYS = [ :dbadapter, :dbname ]
28
28
  class MissingConfigError < StandardError; end
29
29
  def self.base_config(extra_config = {})
30
30
  config = DEFAULT_CONFIG.merge extra_config
data/sequel_tools.gemspec CHANGED
@@ -32,9 +32,13 @@ Gem::Specification.new do |spec|
32
32
  spec.require_paths = ['lib']
33
33
 
34
34
  spec.add_runtime_dependency 'sequel'
35
+ spec.add_runtime_dependency 'logger'
36
+ spec.add_runtime_dependency 'irb'
35
37
  spec.add_development_dependency 'pg' unless RUBY_PLATFORM == 'java'
36
38
  spec.add_development_dependency 'jdbc-postgres' if RUBY_PLATFORM == 'java'
37
39
  spec.add_development_dependency 'bundler'
38
40
  spec.add_development_dependency 'rake'
39
41
  spec.add_development_dependency 'rspec'
42
+
43
+ spec.add_development_dependency 'benchmark'
40
44
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sequel_tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.13
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rodrigo Rosenfeld Rosas
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2022-10-20 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: sequel
@@ -24,6 +23,34 @@ dependencies:
24
23
  - - ">="
25
24
  - !ruby/object:Gem::Version
26
25
  version: '0'
26
+ - !ruby/object:Gem::Dependency
27
+ name: logger
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ - !ruby/object:Gem::Dependency
41
+ name: irb
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ type: :runtime
48
+ prerelease: false
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
27
54
  - !ruby/object:Gem::Dependency
28
55
  name: pg
29
56
  requirement: !ruby/object:Gem::Requirement
@@ -80,6 +107,20 @@ dependencies:
80
107
  - - ">="
81
108
  - !ruby/object:Gem::Version
82
109
  version: '0'
110
+ - !ruby/object:Gem::Dependency
111
+ name: benchmark
112
+ requirement: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ type: :development
118
+ prerelease: false
119
+ version_requirements: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
83
124
  description: |
84
125
  Offer tooling for common database operations, such as running Sequel migrations, store and
85
126
  load from the database schema, rollback, redo some migration, rerun all migrations, display
@@ -140,7 +181,6 @@ homepage: https://github.com/rosenfeld/sequel_tools
140
181
  licenses:
141
182
  - MIT
142
183
  metadata: {}
143
- post_install_message:
144
184
  rdoc_options: []
145
185
  require_paths:
146
186
  - lib
@@ -155,8 +195,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
155
195
  - !ruby/object:Gem::Version
156
196
  version: '0'
157
197
  requirements: []
158
- rubygems_version: 3.3.7
159
- signing_key:
198
+ rubygems_version: 4.0.13
160
199
  specification_version: 4
161
200
  summary: Add Rake tasks to manage Sequel migrations
162
201
  test_files: []