db-sync 0.0.12 → 0.0.13

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: e1c6f12f9c1c53f368a683fbb2c3886fe7ef3e46
4
- data.tar.gz: 1021509bf29560e7e07ae70ea4c9e81adc36702f
3
+ metadata.gz: db44699a815ff0d136105d6523fb2a72dce02571
4
+ data.tar.gz: 9500152b296e6499793244837821b2a68109f0a7
5
5
  SHA512:
6
- metadata.gz: 1458e96183699e5230511ca67292e2134c32134b8453abb0d46587aaf3fbefaf28a33f6f2c68dcc9da4ba4b7f31f848849c403741dcd93251a273244e86b772c
7
- data.tar.gz: 89616a301c200affb19571f3b450d95b3c86c4770db1e797be7de26f6f5bc066e185403c0914d27047905a7276f1ec344b6508c80b614bf4b676736024d93c05
6
+ metadata.gz: e9bea85c109bc4d70d6c3cf99a4f49a372873a25e96a07e6f12879cadc16f0dabaa938949ab26ea46cfadec0fdf2c3306271584318df849644763225ac225a59
7
+ data.tar.gz: 1c7638c0f837d435c39e3349d1aad33e53e1a3f3ce545a1941beaeacf053d9c4b6876cec17b29ed0b086af38beedc0ad587b90de7aca39616e3da63bfbba054a
data/lib/db/sync.rb CHANGED
@@ -9,10 +9,11 @@ module Db
9
9
  class Sync
10
10
  include ActiveSupport::Configurable
11
11
 
12
- attr_accessor :sync_dir
12
+ attr_accessor :sync_dir, :custom_tables
13
13
 
14
- def initialize(sync_dir = nil)
14
+ def initialize(sync_dir = nil, tables = nil)
15
15
  self.sync_dir = File.join((Rails.root || '.'), 'db', (sync_dir || 'data'))
16
+ self.custom_tables = tables
16
17
  end
17
18
 
18
19
  def log
@@ -34,6 +35,7 @@ module Db
34
35
  delete_records(table, diff.deletes, commit)
35
36
  update_records(table, diff.updates, commit)
36
37
  insert_records(table, diff.inserts, commit)
38
+ # TODO: fix auto increments
37
39
  end
38
40
  end
39
41
 
@@ -112,7 +114,7 @@ module Db
112
114
  end
113
115
 
114
116
  def working_tables
115
- config.tables || all_tables
117
+ custom_tables || config.tables || all_tables
116
118
  end
117
119
 
118
120
  def all_tables
@@ -1,5 +1,5 @@
1
1
  module Db
2
2
  class Sync
3
- VERSION = '0.0.12'.freeze
3
+ VERSION = '0.0.13'.freeze
4
4
  end
5
5
  end
data/lib/tasks/db.rake CHANGED
@@ -1,15 +1,17 @@
1
1
  namespace :db do
2
2
  namespace :sync do
3
- desc 'Download data from the databse into files.'
3
+ desc 'Download data from the databse into files. [commit=true/false tables=table1,table2]'
4
4
  task down: :environment do
5
- synchronizer = Db::Sync.new(sync_dir)
5
+ tables = ENV['tables'].present? ? ENV['tables'].split(',') : nil
6
+ synchronizer = Db::Sync.new(sync_dir, tables)
6
7
  synchronizer.sync_down
7
8
  end
8
9
 
9
- desc 'Upload data from the files into the database.'
10
+ desc 'Upload data from the files into the database. [commit=true/false tables=table1,table2]'
10
11
  task up: :environment do
12
+ tables = ENV['tables'].present? ? ENV['tables'].split(',') : nil
11
13
  commit = ENV['commit'].present? ? ENV['commit'] == 'true' : nil
12
- synchronizer = Db::Sync.new(sync_dir)
14
+ synchronizer = Db::Sync.new(sync_dir, tables)
13
15
  sync_up_and_print(synchronizer, commit)
14
16
  if commit.nil? && synchronizer.log.present?
15
17
  print "Commit Changes? [y/n]\n"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: db-sync
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.12
4
+ version: 0.0.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vasil Joskov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-04-27 00:00:00.000000000 Z
11
+ date: 2016-07-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -178,7 +178,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
178
178
  version: '0'
179
179
  requirements: []
180
180
  rubyforge_project:
181
- rubygems_version: 2.4.5.1
181
+ rubygems_version: 2.5.1
182
182
  signing_key:
183
183
  specification_version: 4
184
184
  summary: Database Synchronization Tool