load_remote_db 0.1.2 → 0.1.3

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
  SHA1:
3
- metadata.gz: 0359cc0a28b26e2a1fada7970f2361075efb1ea8
4
- data.tar.gz: f061f43d322ab4976c7969bdb0c693357f1eb02d
3
+ metadata.gz: b15307d40d92fd76c553d089e2960d65ce31e1cc
4
+ data.tar.gz: 5491a21958c43212756b591cf9639f3490cfe08b
5
5
  SHA512:
6
- metadata.gz: 22648d67d63c41a612b63df742592fcdaabf74889c2d52d3451e197bbf7dfe78497822ee6bfaf2baaba6482dbde5c2b298bf2a1aa655de201ad8314c42b16a4f
7
- data.tar.gz: 599bda00e0265be9f6c2beadb63e1b620996ef218ea9bd8c20893af93fac9fef956771d83066d8b9f47b233afba38959a66fce90c58d5d80b7cb26d0ba8e43c2
6
+ metadata.gz: 8e99dbedb9bcdf4140d794dace3e44681e14a9cbeb88443e00920387b493fae0ab11bda934a2014d65bf92a43fd724484f8444fe9e6aa59c349f76b697a9b545
7
+ data.tar.gz: d50d8ecd340de438c2190c5c06be4a33177cb73381d4bf1b014e64196f2a5f388dddd4e70f71cc772aa127220c8c05d6a7b971a1787a7f6e935aeab7f54f9f99
data/README.md CHANGED
@@ -1,8 +1,6 @@
1
1
  # LoadRemoteDb
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/load_remote_db`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
3
+ This gem is used to download & load the remote database into your local development environment
6
4
 
7
5
  ## Installation
8
6
 
@@ -22,18 +20,21 @@ Or install it yourself as:
22
20
 
23
21
 
24
22
 
23
+
25
24
  ## Usage
26
25
 
27
26
  Simply execute the command:
28
27
 
29
- $ [bundle exec] rake load_remote_db:run [SERVER=environment] [SYNC_FOLDER=folder]
28
+ $ [bundle exec] rake load_remote_db:run [SERVER=environment] [SYNC_FOLDER=folder] [DOWNLOAD_ONLY=true]
30
29
 
31
30
  For instance
32
31
 
33
32
  $ bundle exec rake load_remote_db:run SERVER=staging
34
33
  $ bundle exec rake load_remote_db:run SERVER=staging SYNC_FOLDER=public/system
34
+ $ bundle exec rake load_remote_db:run SERVER=staging DOWNLOAD_ONLY=true
35
35
 
36
36
 
37
+ gg
37
38
  ## Development
38
39
 
39
40
  After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -42,6 +43,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
42
43
 
43
44
 
44
45
 
46
+
45
47
  ## Contributing
46
48
 
47
49
  Bug reports and pull requests are welcome on GitHub at https://github.com/[jameshuynh]/load_remote_db.
@@ -54,3 +56,4 @@ The gem is available as open source under the terms of the [MIT License](http://
54
56
 
55
57
 
56
58
 
59
+
@@ -1,3 +1,3 @@
1
1
  module LoadRemoteDb
2
- VERSION = '0.1.2'
2
+ VERSION = '0.1.3'
3
3
  end
@@ -67,30 +67,37 @@ class RemoteDbLoader
67
67
  download_db_dump_command =
68
68
  %(scp #{@server_user}@#{@server_ip}:#{shared_path}/backup.#{bk_extension} .)
69
69
 
70
- `#{download_db_dump_command}`
70
+ system(download_db_dump_command)
71
71
 
72
72
  puts 'Deleting remote backup file...'
73
73
  delete_db_dump_command = %(ssh #{@server_user}@#{@server_ip} \
74
74
  "rm -rf #{shared_path}/backup.#{bk_extension}")
75
75
 
76
+ system(delete_db_dump_command)
77
+
76
78
  if gzip_exist
77
- `gunzip backup.sql.gz`
79
+ `gunzip -f backup.sql.gz`
78
80
  end
79
81
 
80
- if password == nil
81
- import_db_cmd =
82
- %(mysql -u #{username} #{database} < backup.sql)
82
+ if ENV['DOWNLOAD_ONLY']
83
+ puts 'backup.sql file is now stored at your Rails root folder!'
84
+ `open .`
83
85
  else
84
- import_db_cmd =
85
- %(mysql -u #{username} -p'#{password}' #{database} < backup.sql)
86
+ if password == nil
87
+ import_db_cmd =
88
+ %(mysql -u #{username} #{database} < backup.sql)
89
+ else
90
+ import_db_cmd =
91
+ %(mysql -u #{username} -p'#{password}' #{database} < backup.sql)
92
+ end
93
+
94
+ puts 'Importing database into local environment...'
95
+ `#{import_db_cmd}`
96
+
97
+ puts 'Cleaning up database backup...'
98
+ `rm backup.sql`
86
99
  end
87
100
 
88
- puts 'Importing database into local environment...'
89
- `#{import_db_cmd}`
90
-
91
- puts 'Cleaning up database backup...'
92
- `rm backup.sql`
93
-
94
101
  if to_be_rsync_folder
95
102
  puts "Synchorinizing #{to_be_rsync_folder} folder..."
96
103
  `mkdir -p 'public/#{to_be_rsync_folder.gsub('public/', '')}'`
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: load_remote_db
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Huynh