sequel_tools 0.1.12 → 0.1.14

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
  SHA256:
3
- metadata.gz: 3668a069d02fe15d3bb54d054ad64dd0eab240ba4f6e65023aa8a6f92b3008cf
4
- data.tar.gz: '019eefc9bf0565c54126fd54670da7623094a133dcddf34cbcaf75498f282c9e'
3
+ metadata.gz: 06cfd2214117b4cdfb808527ff3c611d55e3c661270460f04cf8f9b87effb60e
4
+ data.tar.gz: 0ab06e31e27d5781b820c783a10f41c9a54eb12df033611be3fdfad1fabbc896
5
5
  SHA512:
6
- metadata.gz: bf9dcaa9cea96bbcec7afaf439e9b32d95baa36181769dd0a954e9a7da25a4f04594483757aedea620bd1fd2899e83d4553682c3e6e193e7463dc26615db03af
7
- data.tar.gz: ef6078623ab39f8d58f78c1f836b08081b4c4ab1b94981cf9fea6d3a47efb7d1c887af77d381e55c9c79f8d9f9dcf695c401eec1a14906612f57b15a04c84885
6
+ metadata.gz: e9a44d46447c25dfd7380286812e32725f958aac419b02a6d8d3e38a83a421186762a539e3b5ed3c61de81580ad8752de911a046ad69817395b18f63a37f0d5d
7
+ data.tar.gz: 9fd7486aae118ff74d43bb0d797778d26d7dab0b93b69c2e0dcb4f49fc986da9d5ea3913b205e7844b71f4e6f41635451cb1d4f08c1d51d4d3afb8942dc7fb4f
data/README.md CHANGED
@@ -40,8 +40,8 @@ Here's a sample Rakefile supporting migrate actions:
40
40
  require 'bundler/setup'
41
41
  require 'sequel_tools'
42
42
 
43
- base_config = SequelTools.base_config(
44
- project_root: File.expand_path(__dir__),
43
+ base_config = {
44
+ # project_root: Dir.pwd,
45
45
  dbadapter: 'postgres',
46
46
  dbname: 'mydb',
47
47
  username: 'myuser',
@@ -63,7 +63,14 @@ base_config = SequelTools.base_config(
63
63
  # when nil, defaults to the value of the :dbadapter config.
64
64
  # This is the database we should connect to before executing "create database dbname"
65
65
  maintenancedb: :default,
66
- )
66
+ # migrations_table: 'schema_migrations',
67
+ # allow other tables data to be included in the dump file generated by rake db:schema_dump
68
+ # extra_tables_in_dump: nil
69
+ # for example, if you want to keep migrations from ActiveRecord in the dump file, while using
70
+ # another table for Sequel migrations:
71
+ # migrations_table: 'sequel_schema_migrations',
72
+ # extra_tables_in_dump: ['schema_migrations'],
73
+ }
67
74
 
68
75
  namespace 'db' do
69
76
  SequelTools.inject_rake_tasks base_config.merge(dump_schema_on_migrate: true), self
@@ -120,7 +127,7 @@ PGPASSWORD=$DBPASSWORD
120
127
  psql
121
128
  ```
122
129
 
123
- Then you may pass `shell_command: '~/bin/opensql'` to `SequelTools.base_config`.
130
+ Then you may set `shell_command: '~/bin/opensql'` in config.
124
131
 
125
132
  Alternatively you can define the `shell_#{dbadapter}` action if you prefer. Take a look at
126
133
  the implementation for `shell_postgres` to see how to do that. If you want to share that action
@@ -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.12'
4
+ VERSION = '0.1.14'
5
5
  end
data/lib/sequel_tools.rb CHANGED
@@ -4,7 +4,7 @@ require 'sequel_tools/version'
4
4
 
5
5
  module SequelTools
6
6
  DEFAULT_CONFIG = {
7
- project_root: nil,
7
+ project_root: Dir.pwd,
8
8
  pg_dump: 'pg_dump', # command used to run pg_dump
9
9
  psql: 'psql', # command used to run psql
10
10
  maintenancedb: :default, # DB to connect to for creating/dropping databases
@@ -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 = [ :project_root, :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
@@ -40,7 +40,7 @@ module SequelTools
40
40
  def self.inject_rake_tasks(config = {}, rake_context)
41
41
  require_relative 'sequel_tools/actions_manager'
42
42
  require_relative 'sequel_tools/all_actions'
43
- actions_manager = ActionsManager.new config
43
+ actions_manager = ActionsManager.new base_config(config)
44
44
  actions_manager.load_all
45
45
  actions_manager.export_as_rake_tasks rake_context
46
46
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sequel_tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.12
4
+ version: 0.1.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rodrigo Rosenfeld Rosas
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-09-05 00:00:00.000000000 Z
11
+ date: 2022-10-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sequel