db_stager 0.2.1 → 1.0.0

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
  SHA1:
3
- metadata.gz: 7144864a030786eac584c002945d972aebf2c2f9
4
- data.tar.gz: 5322fb8b234927617f4696ae6d4d5dfbcd3c5fa1
3
+ metadata.gz: afc0778cda3b7cf0e73f56f748a14f6fa0adc6ae
4
+ data.tar.gz: c195aec4e4d0ad80d47bae96f64218880b57a723
5
5
  SHA512:
6
- metadata.gz: 3102262cec9d51155b1e83cfd56649b552e700c872ab2f5a23fe70f8cf641d14ec35b77ca5d1df351dc8d07f535cdb83e7fa027cf53654e179d1ab6289577bef
7
- data.tar.gz: fe5e70470b372f04ed99a6cd2ba0d3a77f6fd285805dfa5c7619160e0ff7254ce71f89c9724a83129c95b375dc29c1b2334a037e89af2d89ab4394567c406511
6
+ metadata.gz: c7d89ea1be63280715cde99ce4a19d0770526cf0daea4023f7265bf32d37c7dda365dfcffb9ed12f6342a1644be7045ef15bf4983a630fdc68a39c40d0b48e3f
7
+ data.tar.gz: 39cdf412e03565a8b5bd23e5007569f011ca7d8d87ac546a4214cb76e6d8b390f501e7adf3d8c98a2d2072f8cda116cd329c60449ad46c75cfb9fce98c244efd
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- db_stager (0.2.1)
4
+ db_stager (1.0.0)
5
5
  dotenv (~> 2.2)
6
6
  faker (~> 1.9)
7
7
  hashie (~> 3.5)
data/README.md CHANGED
@@ -1,6 +1,5 @@
1
- # DbStager
1
+ # This gem has been renamed to stage_hand. Find it at [Rubygems.org](https://rubygems.org/gems/stage_hand) or [Gitlab](https://gitlab.com/notch8/stage_hand)
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/db_stager`. To experiment with that code, run `bin/console` for an interactive prompt.
4
3
 
5
4
  Perform backups and restores of databases, scrubbing records along the way. This allows taking limited snapshots of large databases and keeps customer info out of your staging site.
6
5
 
@@ -9,7 +8,7 @@ Perform backups and restores of databases, scrubbing records along the way. This
9
8
  Add this line to your application's Gemfile:
10
9
 
11
10
  ```ruby
12
- gem 'db_stager'
11
+ gem 'db_stager', require: false
13
12
  ```
14
13
 
15
14
  And then execute:
@@ -22,7 +21,50 @@ Or install it yourself as:
22
21
 
23
22
  ## Usage
24
23
 
25
- TODO: Write usage instructions here
24
+ Generate an example config file
25
+
26
+ `db_stager install`
27
+
28
+ Create a new, modified copy of the production database
29
+
30
+ `db_stager capture -e production`
31
+
32
+ Load the current database file, currently just does `rake db:structure:load` but may be exapnded in the future
33
+
34
+ `db_stager load -e staging`
35
+
36
+ ## Configuration
37
+
38
+ DbStager uses a configuration file found in config/stage_hand.yml. There are two sections of this file.
39
+
40
+ ### excluded_tables
41
+
42
+ This is a list of all the tables to exclude. These tables are skipped by data insertion, but they are reset to the current schema currently. schema_migrations is always in the excluded list, though the structure load will set the values of that table to the most recent migration.
43
+
44
+ ```yaml
45
+ excluded_tables:
46
+ - sites
47
+ - secrets
48
+ ```
49
+
50
+ ### fields
51
+
52
+ Here is where the real magic happens. You can specify fields to either be set to blank (by using nil or false) or by evaluating code. [Faker](https://github.com/stympy/faker) is included to make doing so easy. There is also a special variable called `existing_value` which contains the value before any changes. These fields will be changed in flight to the sql file and thus sensitive data can be removed from the production data dump.
53
+
54
+ ```yaml
55
+ fields:
56
+ users:
57
+ email: "existing_value.match('notch8.com') ? existing_value : Faker::Internet.unique.email"
58
+ zip: false
59
+ action_items:
60
+ name: "Faker::Name.unique.name"
61
+ ```
62
+
63
+ ## TODO
64
+
65
+ -[ ] File upload
66
+ -[ ] File Download
67
+ -[ ] Ability to limit the number of rows to insert per table
26
68
 
27
69
  ## Development
28
70
 
@@ -32,7 +74,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
32
74
 
33
75
  ## Contributing
34
76
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/db_stager. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
77
+ Bug reports and pull requests are welcome on GitHub at https://gitlab.com/notch8/db_stager. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
36
78
 
37
79
  ## License
38
80
 
data/db_stager.gemspec CHANGED
@@ -10,8 +10,8 @@ Gem::Specification.new do |spec|
10
10
  spec.email = ["rob@notch8.com"]
11
11
 
12
12
  spec.summary = %q{DB Stager backups and restores databases for staging. Allows scrubbing of records.}
13
- spec.description = %q{Perform backups and restores of databases, scrubbing records along the way. This allows taking limited snapshots of large databases and keeps customer info out of your staging site.}
14
- spec.homepage = "https://gitlab.com/notch8/db_stager"
13
+ spec.description = %q{This gem has been renamed to stage_hand. Find it at [Rubygems.org](https://rubygems.org/gems/stage_hand) or [Gitlab](https://gitlab.com/notch8/stage_hand)}
14
+ spec.homepage = "https://gitlab.com/notch8/stage_hand"
15
15
  spec.license = "MIT"
16
16
 
17
17
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
data/lib/db_stager/cli.rb CHANGED
@@ -34,7 +34,8 @@ module DbStager
34
34
  if fields[table_name]
35
35
  fields[table_name].each do |field_name, task|
36
36
  if task
37
- item[field_name.to_sym] = send(task)
37
+ existing_value = item[field_name.to_sym]
38
+ item[field_name.to_sym] = eval(task)
38
39
  else
39
40
  item[field_name.to_sym] = nil
40
41
  end
@@ -74,7 +75,7 @@ module DbStager
74
75
  return @config_file if @config_file
75
76
  config_file_path = File.join(Dir.pwd, 'config', 'stage_hand.yml')
76
77
  if File.exists?(config_file_path)
77
- @config_file = Hashie::Mash.load(ERB.new(File.read(config_file_path)))
78
+ @config_file = Hashie::Mash.load(config_file_path)
78
79
  else
79
80
  @config_file = {}
80
81
  end
@@ -1,3 +1,3 @@
1
1
  module DbStager
2
- VERSION = "0.2.1"
2
+ VERSION = "1.0.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: db_stager
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rob Kaufman
@@ -136,9 +136,8 @@ dependencies:
136
136
  - - "~>"
137
137
  - !ruby/object:Gem::Version
138
138
  version: '1.9'
139
- description: Perform backups and restores of databases, scrubbing records along the
140
- way. This allows taking limited snapshots of large databases and keeps customer
141
- info out of your staging site.
139
+ description: This gem has been renamed to stage_hand. Find it at [Rubygems.org](https://rubygems.org/gems/stage_hand)
140
+ or [Gitlab](https://gitlab.com/notch8/stage_hand)
142
141
  email:
143
142
  - rob@notch8.com
144
143
  executables:
@@ -162,7 +161,7 @@ files:
162
161
  - lib/db_stager.rb
163
162
  - lib/db_stager/cli.rb
164
163
  - lib/db_stager/version.rb
165
- homepage: https://gitlab.com/notch8/db_stager
164
+ homepage: https://gitlab.com/notch8/stage_hand
166
165
  licenses:
167
166
  - MIT
168
167
  metadata: {}