fulmar 1.7.3 → 1.7.4

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: fc973fd8341619eec3fa3f435e285409092c315f
4
- data.tar.gz: ab81cf17a631500f7ef6d1c6e547207c85adb1f4
3
+ metadata.gz: 8b224365b805643b2d4196803ff91f98391a7d09
4
+ data.tar.gz: 44926cb57c59dac055bdb5be8071ec01546c860a
5
5
  SHA512:
6
- metadata.gz: 811df6ec97e9fcae45b60c1d7b8e6a329107c72654b9d6e5b16b2da97ccf3a9de2aff5808ea114b1600163cccab60b3aac98fa2a9621ea62decfecf8ae541768
7
- data.tar.gz: 71a373b007303ab176c711f42dffcea3457b16b1c80ffc9783721d986f425061b7f725fa53ff01bf1dc82153720ac54534f948b9e642aea74be27a8ca7b8ab83
6
+ metadata.gz: 49fdb7b07030110486fca5d08555b5a357ecb1216ec29db361da21a2d3dee55a4863fc87d15a20473381904791efc29c7474beb158f0bc5d07864991ef7faf2c
7
+ data.tar.gz: 39318f26ffed3ab373de64ec1f6fb9dadef6abce1e430d0c3de1b93d8e360ea72e57ffe2d7c7ae14e5b83fd4ab17f0b2c10bab1d3d4e43a1736bbb3e8694c79f
@@ -3,19 +3,20 @@ configuration.each do |env, target, data|
3
3
  db_configs << [env, target] if data[:type] == 'maria'
4
4
  end
5
5
 
6
- def create_update_task(from_db, to_db)
7
- namespace to_db.first do
8
- desc "Update #{to_db.first} database with #{from_db.first} data" unless to_db.first.match(/^(live|prod)/) # hide sync to live
9
- task "from_#{from_db.first}" do
10
- configuration.environment = from_db.first
11
- configuration.target = from_db.last
6
+ # Expects two hashes as parameters each with { :environment, :target, :name } set
7
+ # :name is either environment:target or just the environment, if the is only one target
8
+ def create_update_task(from, to)
9
+ namespace to[:name] do
10
+ task "from_#{from[:name]}" do
11
+ configuration.environment = from[:environment]
12
+ configuration.target = from[:target]
12
13
  puts 'Getting dump...'
13
14
  sql_dump = database.download_dump
14
15
  if sql_dump == ''
15
16
  puts 'Cannot create sql dump'
16
17
  else
17
- configuration.environment = to_db.first
18
- configuration.target = to_db.last
18
+ configuration.environment = to[:environment]
19
+ configuration.target = to[:target]
19
20
  puts 'Sending dump...'
20
21
  remote_sql_dump = upload(sql_dump)
21
22
  database.load_dump(remote_sql_dump)
@@ -24,12 +25,33 @@ def create_update_task(from_db, to_db)
24
25
  end
25
26
  end
26
27
 
28
+ def name(env, target, counts)
29
+ counts[env] > 1 ? "#{env}:#{target}" : env
30
+ end
31
+
27
32
  def create_update_tasks(db_configs)
33
+ counts = {}
34
+ db_configs.each do |config|
35
+ counts[config.first] = 0 unless counts[config.first]
36
+ counts[config.first] += 1
37
+ end
38
+
28
39
  namespace :update do
29
40
  db_configs.each do |from_db|
30
41
  db_configs.each do |to_db|
31
- next if from_db == to_db
32
- create_update_task(from_db, to_db)
42
+ next if from_db == to_db # no need to sync a database to itself
43
+ next if from_db.last != to_db.last # sync only matching target names
44
+ from = {
45
+ environment: from_db.first,
46
+ target: from_db.last,
47
+ name: name(from_db.first, from_db.last, counts)
48
+ }
49
+ to = {
50
+ environment: to_db.first,
51
+ target: to_db.last,
52
+ name: name(to_db.first, to_db.last, counts)
53
+ }
54
+ create_update_task(from, to)
33
55
  end
34
56
  end
35
57
  end
@@ -1,4 +1,4 @@
1
1
  # Provides a global version number
2
2
  module Fulmar
3
- VERSION = '1.7.3'
3
+ VERSION = '1.7.4'
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fulmar
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.3
4
+ version: 1.7.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonas Siegl
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-07-02 00:00:00.000000000 Z
12
+ date: 2015-07-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler