osmosis 0.1.5 → 0.1.6

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: cffa68a75573cf0f38437ec745876d6825a6e7004f5c76c3b2d29f186fda378e
4
+ data.tar.gz: e109c7e4cb9e993a8923f2e5f3065b00613848aeab47907fe3e6fcaa13122bc4
5
5
  SHA512:
6
- metadata.gz: 3a6e583c73707be4c9ce5f2524515fdf2bbc02173862a8f28c2ef538a5bdd7451ab6210907587f433f754948db3ff284183b17e55d2b6a3366d84f5d22e56085
7
- data.tar.gz: 4f1e5458d0e5079ffa823f8b8bba4363033f788a646750245342561b157b294db412d9bf4a571b2721c29956ad29752ebf9666a1f4c3d92cad0ae25d311267d7
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,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
3
  task import: :environment do
4
- commands = Osmosis::Command.export(ARGV)
5
- ARGV.clear
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.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.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lukas_Skywalker