db-sync 0.0.7 → 0.0.8

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: f4e51a666d06cee39c43fdc16efd0c570824b4d1
4
- data.tar.gz: 21a0a4cf59e600a774d0f5b181d1efde9a084c38
3
+ metadata.gz: 38e721c9ca210dda67876ca18cf22ccc2e6bd69c
4
+ data.tar.gz: 799f09fec87874a887df51b9400665f2834c4915
5
5
  SHA512:
6
- metadata.gz: af31b45d32fc1d539140c9574816bdc23cb95673ab52e8cca919e6f5a08d3ab060425d094e542fa0592bc2441c0db071f59871d0c09befa4d6aa59978ab62d88
7
- data.tar.gz: e7f1093a52f6899fb8b2b74c1df8c22acbe69fc67aac7857862941f06d565be2607569d0fac8f700f88c75abe8fb900a99376690358e6e97958c827082784334
6
+ metadata.gz: 228fde22d5a7965b51fac83115402b30070b0af53d2575d98e7fc54b8905bbd0b28ed782ba5cbef49c7356588e6e8cd54644dd78ec2806da6f8490e27c7ce3e5
7
+ data.tar.gz: b03fe23c607614c419bc37d85901dbfa754ccb4baa383e4bc11fbc77e29b4b125da758d2962bf1d2069268b5f4eb07969db82bcf0814093e248d8466b490e004
@@ -9,6 +9,12 @@ module Db
9
9
  class Sync
10
10
  include ActiveSupport::Configurable
11
11
 
12
+ attr_accessor :sync_dir
13
+
14
+ def initialize(sync_dir = nil)
15
+ self.sync_dir = sync_dir || 'data'
16
+ end
17
+
12
18
  def log
13
19
  @log ||= []
14
20
  end
@@ -116,7 +122,7 @@ module Db
116
122
 
117
123
  def table_filename(table)
118
124
  # TODO: change data with custom dir
119
- File.join(Rails.root || '.', 'db', 'data', "#{table}.yml")
125
+ File.join(Rails.root || '.', 'db', sync_dir, "#{table}.yml")
120
126
  end
121
127
 
122
128
  def configure
@@ -1,5 +1,5 @@
1
1
  module Db
2
2
  class Sync
3
- VERSION = '0.0.7'.freeze
3
+ VERSION = '0.0.8'.freeze
4
4
  end
5
5
  end
@@ -2,15 +2,15 @@ namespace :db do
2
2
  namespace :sync do
3
3
  desc 'Download data from the databse into files.'
4
4
  task down: :environment do
5
- synchronizer = Db::Sync.new
5
+ synchronizer = Db::Sync.new(sync_dir)
6
6
  synchronizer.sync_down
7
7
  end
8
8
 
9
9
  desc 'Upload data from the files into the database.'
10
10
  task up: :environment do
11
11
  commit = ENV['commit'].present? ? ENV['commit'] == 'true' : nil
12
- synchronizer = Db::Sync.new
13
- sync_up_and_print(synchronizer, commit)
12
+ synchronizer = Db::Sync.new(sync_dir)
13
+ sync_up_and_print(synchronizer, sync_dir, commit)
14
14
  if commit.nil? && synchronizer.log.present?
15
15
  print "Commit Changes? [y/n]\n"
16
16
  sync_up_and_print(synchronizer, true) if STDIN.gets.chomp == 'y'
@@ -23,3 +23,7 @@ def self.sync_up_and_print(synchronizer, commit)
23
23
  synchronizer.sync_up(commit)
24
24
  print synchronizer.log.join("\n") + "\n"
25
25
  end
26
+
27
+ def self.sync_dir
28
+ ENV['dir']
29
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: db-sync
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vasil Joskov