osmosis 0.1.5 → 0.1.7

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: 1c32c42fe854c9f29544cb890cc72db30bfb01d705fcd81bf0be4ce011b20881
4
- data.tar.gz: 2f4a60dd5df8ebad2577f8a04f44532a6b9c67f80ba425915d0c9062b9ae0329
3
+ metadata.gz: 71ac09cfd040c7360d2933ad76965fe5aa13fdeac749109975b8dbad0d8b313d
4
+ data.tar.gz: 0b957d2a60d2598bd3ebf2905f1b083031acea53c3c2db8fb95c5686f65d9d84
5
5
  SHA512:
6
- metadata.gz: 3a6e583c73707be4c9ce5f2524515fdf2bbc02173862a8f28c2ef538a5bdd7451ab6210907587f433f754948db3ff284183b17e55d2b6a3366d84f5d22e56085
7
- data.tar.gz: 4f1e5458d0e5079ffa823f8b8bba4363033f788a646750245342561b157b294db412d9bf4a571b2721c29956ad29752ebf9666a1f4c3d92cad0ae25d311267d7
6
+ metadata.gz: 2bcc855f967c3f7e355bdcc44e7422066014a5d4e2572000d64663a6a04a75e9241a97579af9be78617cd38593f1d45544c2c834b8fc32406e516bd11e2d4370
7
+ data.tar.gz: a49afe1e290c5b8c9499ba2d0fa33d0f8c9c0933e7a5bea9dcb90484c4be4d3faf6f6a82beccfbe5b2f423a11aa987694f3dd17e6e2b415e294d8aeaaabbf0b4
data/README.md CHANGED
@@ -18,18 +18,18 @@ Osmosis provides you with different rake tasks that simplify the management of y
18
18
 
19
19
  ### Database import
20
20
 
21
- The import command takes the `.dump` file provided and restores it to the PostgreSQL database. Any pre-existing data is dropped.
21
+ The import command will ask you for a `.dump` file and restores it to the PostgreSQL database. Any pre-existing data is dropped.
22
22
 
23
23
  ```bash
24
- bundle exec rails db:import <filename>
24
+ bundle exec rails db:import
25
25
  ```
26
26
 
27
27
  ### Database export
28
28
 
29
- The export command exports the PostgreSQL database into a `.dump` file. If the file already exists, it is overwritten.
29
+ The export command will ask you for a `.dump` file and exports the PostgreSQL database into the file. If the file already exists, it is overwritten.
30
30
 
31
31
  ```bash
32
- bundle exec rails db:export <filename>
32
+ bundle exec rails db:export
33
33
  ```
34
34
 
35
35
  ## Development
@@ -4,19 +4,20 @@ require 'pty'
4
4
 
5
5
  module Osmosis
6
6
  class Command
7
- def self.import(argv)
8
- file = argv[0]
9
- if file.nil?
10
- return [OpenStruct.new(type: :print, command: "Please provide a filename parameter: rails db:import <filename>")]
7
+ def self.import()
8
+ print "Filename: (db.dump): "
9
+ filename = gets.chomp
10
+ if filename == ""
11
+ filename = "db.dump"
11
12
  end
12
- if !File.exist?(file)
13
- return [OpenStruct.new(type: :print, command: "File #{file} does not exist")]
13
+ if !File.exist?(filename)
14
+ return [OpenStruct.new(type: :print, command: "File #{filename} does not exist")]
14
15
  end
15
16
  host = ActiveRecord::Base.connection_db_config.host
16
17
  database = ActiveRecord::Base.connection_db_config.database
17
18
  username = ActiveRecord::Base.connection_db_config.configuration_hash[:username]
18
19
  password = ActiveRecord::Base.connection_db_config.configuration_hash[:password]
19
- cmd = "PGPASSWORD=#{password} pg_restore -U #{username} -h #{host} -d #{database} -cO --if-exists -w < #{file}"
20
+ cmd = "PGPASSWORD=#{password} pg_restore -U #{username} -h #{host} -d #{database} -cO --if-exists -w < #{filename}"
20
21
  return [
21
22
  OpenStruct.new(type: :rake, command: 'db:drop'),
22
23
  OpenStruct.new(type: :rake, command: 'db:create'),
@@ -25,23 +26,24 @@ module Osmosis
25
26
  ]
26
27
  end
27
28
 
28
- def self.export(argv)
29
- file = argv[0]
30
- if file.nil?
31
- return [OpenStruct.new(type: :print, command: "Please provide a filename parameter: rails db:export <filename>")]
29
+ def self.export()
30
+ print "Filename: (db.dump): "
31
+ filename = gets.chomp
32
+ if filename == ""
33
+ filename = "db.dump"
32
34
  end
33
35
  host = ActiveRecord::Base.connection_db_config.host
34
36
  database = ActiveRecord::Base.connection_db_config.database
35
37
  username = ActiveRecord::Base.connection_db_config.configuration_hash[:username]
36
38
  password = ActiveRecord::Base.connection_db_config.configuration_hash[:password]
37
- cmd = "PGPASSWORD=#{password} pg_dump -Fc --no-acl --no-owner -h #{host} -U #{username} -w #{database} > #{file}"
39
+ cmd = "PGPASSWORD=#{password} pg_dump -Fc --no-acl --no-owner -h #{host} -U #{username} -w #{database} > #{filename}"
38
40
  return [
39
41
  OpenStruct.new(type: :cmd, command: cmd),
40
42
  OpenStruct.new(type: :print, command: "Exported database '#{database}'"),
41
43
  ]
42
44
  end
43
45
 
44
- def self.connect(argv)
46
+ def self.connect()
45
47
  cmd = "PGPASSWORD=#{password} psql -U #{username} -h #{host} -d #{database}"
46
48
  return [
47
49
  OpenStruct.new(type: :pty, command: cmd)
@@ -1,8 +1,7 @@
1
1
  namespace :db do
2
2
  desc "Connects to the application database"
3
3
  task connect: :environment do
4
- commands = Osmosis::Command.connect(ARGV)
5
- ARGV.clear
4
+ commands = Osmosis::Command.connect()
6
5
  Osmosis::Command.run(commands)
7
6
  end
8
7
  end
@@ -1,8 +1,7 @@
1
1
  namespace :db do
2
2
  desc "Exports a database to a backup"
3
- task import: :environment do
4
- commands = Osmosis::Command.export(ARGV)
5
- ARGV.clear
3
+ task export: :environment do
4
+ commands = Osmosis::Command.export()
6
5
  Osmosis::Command.run(commands)
7
6
  end
8
7
  end
@@ -1,8 +1,7 @@
1
1
  namespace :db do
2
2
  desc "Imports a database from a backup"
3
3
  task import: :environment do
4
- commands = Osmosis::Command.import(ARGV)
5
- ARGV.clear
4
+ commands = Osmosis::Command.import()
6
5
  Osmosis::Command.run(commands)
7
6
  end
8
7
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Osmosis
4
- VERSION = "0.1.5"
4
+ VERSION = "0.1.7"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: osmosis
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lukas_Skywalker