osmosis 0.1.4 → 0.1.6

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: '033500944d7bcb9c17fb602c3381e842b060f17233096a6286884cc2bdb72c54'
4
- data.tar.gz: f05ea8a885a2560d4ec01fec4d21082fc29f665d714b30cfeeab9c7b634b299f
3
+ metadata.gz: cffa68a75573cf0f38437ec745876d6825a6e7004f5c76c3b2d29f186fda378e
4
+ data.tar.gz: e109c7e4cb9e993a8923f2e5f3065b00613848aeab47907fe3e6fcaa13122bc4
5
5
  SHA512:
6
- metadata.gz: 271e0df3804c9cc4ec4d66cd77c32f4538c09da2e9e9390bae58422715eb9c61b5ad201e51f148ddf4586fca8403a3e429a264aac6c980c0c3cb95e41bdf65cd
7
- data.tar.gz: f47ce3ddd08b8a025bf7da08267edb6e2a23edfe7ec37cd392feb3908a2fdf22e9e771d86cbc62ab2209fe2c591bd8fddeefccbbdbdf38321571f56d78099758
6
+ metadata.gz: cb4a72f4f62a9b86642ee82821731ed231b9ca53622da2f3519c1dc7124a7e34096b2a02ecba15603e94071a2b8b83baceaab060b92275dfa601e14f624a362b
7
+ data.tar.gz: 68fede9c8e52f831302750d5652637efe8a68f3a0f761577e7d539d78c384a07c1407702459bc6c804265db27a5b2fe0e6bcc60e03bab10d2ca7ef75d13fc943
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'),
@@ -26,15 +27,16 @@ module Osmosis
26
27
  end
27
28
 
28
29
  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>")]
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}'"),
@@ -1,7 +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)
4
+ commands = Osmosis::Command.connect()
5
5
  Osmosis::Command.run(commands)
6
6
  end
7
7
  end
@@ -0,0 +1,7 @@
1
+ namespace :db do
2
+ desc "Exports a database to a backup"
3
+ task import: :environment do
4
+ commands = Osmosis::Command.export()
5
+ Osmosis::Command.run(commands)
6
+ end
7
+ end
@@ -1,13 +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
- Osmosis::Command.run(commands)
6
- end
7
-
8
- desc "Exports a database to a backup"
9
- task import: :environment do
10
- commands = Osmosis::Command.export(ARGV)
4
+ commands = Osmosis::Command.import()
11
5
  Osmosis::Command.run(commands)
12
6
  end
13
7
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Osmosis
4
- VERSION = "0.1.4"
4
+ VERSION = "0.1.6"
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.4
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lukas_Skywalker
@@ -29,6 +29,7 @@ files:
29
29
  - lib/osmosis/command.rb
30
30
  - lib/osmosis/railtie.rb
31
31
  - lib/osmosis/tasks/db/connect.rake
32
+ - lib/osmosis/tasks/db/export.rake
32
33
  - lib/osmosis/tasks/db/import.rake
33
34
  - lib/osmosis/version.rb
34
35
  - sig/osmosis.rbs