syncevolution 0.1.5 → 0.1.6

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: e66f23c24c893a5c3f65f05bb4c01b68969e9480
4
- data.tar.gz: 72711fca4d295007d661967514962f9628435f56
3
+ metadata.gz: cb5ee760a7b2cd3658ab16b0054a9c091495a1d0
4
+ data.tar.gz: 714bcd11a734b172fe66a5506852f09afdb3e420
5
5
  SHA512:
6
- metadata.gz: 6bc97d40e0e1f7385c91e3c46c5834d7e9e17b661fa8e50af1db63516b70b26c9ff0ec4ac6548f47ecd35ed49f0910d363fee0430fcf7e16dcfdce3494933dac
7
- data.tar.gz: 77ecb22582ae6c2669bb5180fdd90848fcd072350b2e979d1ce56de1c3cb208be74c09619ac2a5c7db861566168ba6e374b329cfeab76aadb32a77e92a79d003
6
+ metadata.gz: 10b386dde8ea85515288ca74d4d2ce75633124c2a6baa1feda8d447578e14e41fe8c26198f05e304b03e602885bd85e95edb7e0d23f0efca5db1d894151f4cb2
7
+ data.tar.gz: bd0f973461089131ac7010e7e8533ed943a563cbd8600a2d5a4866485443c8889b2eed3f9212f8a155061217f3d847bdb9b5cfcdb66e08a25bb84d2dfe5a54af
data/bin/se-config CHANGED
@@ -4,6 +4,7 @@ require 'inifile'
4
4
  require 'nokogiri'
5
5
  require 'pp'
6
6
  require 'trollop'
7
+ require 'uri'
7
8
 
8
9
  module SyncEvolution
9
10
  class SyncEvolution
@@ -21,23 +22,20 @@ module SyncEvolution
21
22
  def to_gv
22
23
  gv = "digraph syncevolution {\n"
23
24
 
24
- objects = {}
25
+ gv_id = lambda{|node| id(node).split('/').collect{|n| n.gsub(/[^a-z0-9]/i, '').downcase}.join('_').gsub(/^_/, '') }
26
+
25
27
  syncs = 0
26
28
 
27
29
  @doc.xpath('//context').each{|context|
28
- objects[context['name']] ||= "o#{objects.size}"
29
- gv << " subgraph cluster_#{objects[context['name']]} {\n"
30
+ gv << " subgraph cluster_#{gv_id.call(context)} {\n"
30
31
  gv << " label = #{context['name'].inspect};\n"
31
32
 
32
33
  context.xpath('./store').each{|store|
33
- objects[context['name'] + ':' + store['name']] ||= "o#{objects.size}"
34
- gv << " #{objects[context['name'] + ':' + store['name']]} [ shape = folder, label = #{store['name'].inspect}];\n"
34
+ gv << " #{gv_id.call(store)} [ shape = folder, label = #{store['name'].inspect}];\n"
35
35
  }
36
36
 
37
37
  context.xpath('./sync').each{|sync|
38
- objects[context['name'] + ':' + sync['name']] ||= "o#{objects.size}"
39
- gv << " #{objects[context['name'] + ':' + sync['name']]} [ shape = component, label = #{sync['name'].inspect}];\n"
40
-
38
+ gv << " #{gv_id.call(sync)} [ shape = component, label = #{sync['name'].inspect}];\n"
41
39
 
42
40
  sync.xpath('./store').each{|store|
43
41
  }
@@ -48,7 +46,6 @@ module SyncEvolution
48
46
 
49
47
  @doc.xpath('//sync/store').each{|store|
50
48
  sync = store.parent
51
- context = sync.parent
52
49
 
53
50
  if sync['syncURL'] =~ /^local:\/\/@(.+)/
54
51
  targetcontext = $1.downcase
@@ -58,17 +55,17 @@ module SyncEvolution
58
55
 
59
56
  syncs += 1
60
57
 
61
- objects["#{targetcontext}:target-config"] ||= "o#{objects.size}"
62
- objects["#{targetcontext}:#{store['uri']}"] ||= "o#{objects.size}"
58
+ targetsync = @doc.at("//context[@name=#{_inspect(targetcontext)}]/sync[@name='target-config']")
59
+ targetstore = @doc.at("//context[@name=#{_inspect(targetcontext)}]/store[@name=#{_inspect(store['uri'])}]")
63
60
 
64
61
  dir = case store['sync']
65
62
  when 'two-way' then 'both'
66
63
  else throw store['sync'].inspect
67
64
  end
68
65
 
69
- gv << " #{objects[context['name'] + ':' + store['name']]} -> #{objects[context['name'] + ':' + sync['name']]} [label=\"#{syncs}\", dir=#{dir}, style=dashed];\n"
70
- gv << " #{objects[context['name'] + ':' + sync['name']]} -> #{objects["#{targetcontext}:target-config"]} [label=\"#{syncs}\", dir=#{dir}, style=dashed];\n"
71
- gv << " #{objects["#{targetcontext}:target-config"]} -> #{objects["#{targetcontext}:#{store['uri']}"]} [label=\"#{syncs}\", dir=#{dir}, style=dashed];\n"
66
+ gv << " #{gv_id.call(store)} -> #{gv_id.call(store.parent)} [label=\"#{syncs}\", dir=#{dir}, style=dashed];\n"
67
+ gv << " #{gv_id.call(store.parent)} -> #{gv_id.call(targetsync)} [label=\"#{syncs}\", dir=#{dir}, style=dashed];\n"
68
+ gv << " #{gv_id.call(targetsync)} -> #{gv_id.call(targetstore)} [label=\"#{syncs}\", dir=#{dir}, style=dashed];\n"
72
69
  }
73
70
 
74
71
  gv << "}\n"
@@ -101,7 +98,7 @@ module SyncEvolution
101
98
  }
102
99
 
103
100
  ctx_s.xpath('./sync').each{|sn_s|
104
- sn_t = @doc.at("//context[@name=#{_inspect(ctx_s['name'])}]/store[@name=#{_inspect(sn_s['name'])}]")
101
+ sn_t = @doc.at("//context[@name=#{_inspect(ctx_s['name'])}]/sync[@name=#{_inspect(sn_s['name'])}]")
105
102
  if sn_s.at('./clear') && sn_t
106
103
  sn_t.unlink
107
104
  sn_t = add(context: ctx_s['name'], sync: sn_s['name'])
@@ -122,13 +119,36 @@ module SyncEvolution
122
119
  }
123
120
  end
124
121
 
122
+ def id(node)
123
+ if node.name == 'context'
124
+ return "/#{node['name'].downcase}"
125
+ elsif node.parent.name == 'context' and ['store', 'sync'].include?(node.name)
126
+ return "/#{node.parent['name'].downcase}/#{node['name'].downcase}"
127
+ elsif node.name == 'store'
128
+ return "/#{node.parent.parent['name'].downcase}/#{node.parent['name'].downcase}/#{node['name'].downcase}"
129
+ end
130
+
131
+ throw "Unexpected node #{node.inspect}"
132
+ end
133
+
125
134
  def to_bash(indent)
126
135
  bash = ''
127
136
 
128
- params = to_params(@doc.root.attributes.reject{|k, v| k == 'name'}, indent, '')
137
+ doc = @doc.clone
138
+
139
+ doc.xpath("//*[@password='-' or @databasePassword='-']").each{|node|
140
+ ['password', 'databasePassword'].each{|attr|
141
+ next unless node[attr] == '-'
142
+ var = (id(node).gsub(/^\//, '').gsub(/\//, '__').gsub(/[^A-Z0-9]/i, '_') + '__' + attr).upcase
143
+ node[attr]="$#{var}"
144
+ bash << "#{var}=XXXXXXXXXXXXXXXX\n"
145
+ }
146
+ }
147
+
148
+ params = to_params(doc.root.attributes.reject{|k, v| k == 'name'}, indent, '')
129
149
  bash << "syncevolution --configure --template none #{params}\n" if params != ''
130
150
 
131
- @doc.xpath('//context').each{|context|
151
+ doc.xpath('//context').each{|context|
132
152
  bash << "syncevolution --remove #{escape('@' + context['name'])}\n" if context.at('./clear')
133
153
 
134
154
  params = to_params(context.attributes.reject{|k, v| k == 'name'}, indent)
@@ -260,27 +280,27 @@ module SyncEvolution
260
280
 
261
281
  def verify
262
282
  @doc.xpath("//sync[@name='target-config']/store[@sync != 'none' and @sync != 'disabled']").each{|store|
263
- puts "target-config@#{store.parent.parent['name']} has set sync of #{store['name']} to #{store['sync']}, but sync is not used in a target-config"
283
+ warn "target-config@#{store.parent.parent['name']} has set sync of #{store['name']} to #{store['sync']}, but sync is not used in a target-config"
264
284
  }
265
285
 
266
286
  @doc.xpath("//sync[@name='target-config' and @syncURL]").each{|sync|
267
- puts "target-config@#{sync.parent['name']} has set an syncURL, but syncURL is not used in a target-config"
287
+ warn "target-config@#{sync.parent['name']} has set an syncURL, but syncURL is not used in a target-config"
268
288
  }
269
289
 
270
290
  @doc.xpath("//sync").each{|sync|
271
291
  if !sync['syncURL']
272
- puts "sync-config #{sync['name']}@#{sync.parent['name']} has no syncURL" unless sync['name'] == 'target-config'
292
+ warn "sync-config #{sync['name']}@#{sync.parent['name']} has no syncURL" unless sync['name'] == 'target-config'
273
293
  else
274
294
  targetcontext = sync['syncURL'].gsub(/^local:\/\//i, '')
275
295
 
276
296
  if targetcontext != sync['syncURL'].to_s
277
- puts "sync-config #{sync['name']}@#{sync.parent['name']} set up for local sync with #{targetcontext}, which doesn't start with '@'" if targetcontext !~ /^@/
297
+ warn "sync-config #{sync['name']}@#{sync.parent['name']} set up for local sync with #{targetcontext}, which doesn't start with '@'" if targetcontext !~ /^@/
278
298
  targetcontext.sub!(/^@/, '')
279
299
  targetcontext.downcase!
280
300
  if !@doc.at("//context[@name=#{_inspect(targetcontext)}]")
281
- puts "sync-config #{sync['name']}@#{sync.parent['name']} set up for local sync with non-existent context #{targetcontext}"
301
+ warn "sync-config #{sync['name']}@#{sync.parent['name']} set up for local sync with non-existent context #{targetcontext}"
282
302
  elsif !@doc.at("//context[@name=#{_inspect(targetcontext)}]/sync[@name='target-config']")
283
- puts "sync-config #{sync['name']}@#{sync.parent['name']} set up for local sync with non-existent target-config@#{targetcontext}"
303
+ warn "sync-config #{sync['name']}@#{sync.parent['name']} set up for local sync with non-existent target-config@#{targetcontext}"
284
304
  else
285
305
  sync.xpath('./store').each{|store|
286
306
  local = @doc.at("//context[@name=#{_inspect(sync.parent['name'])}]/store[@name=#{_inspect(store['name'])}]")
@@ -289,9 +309,9 @@ module SyncEvolution
289
309
  if remote
290
310
  lbe = backend_type(local)
291
311
  rbe = backend_type(remote)
292
- puts "sync-config #{sync['name']}@#{sync.parent['name']} connects store #{local['name']}@#{sync.parent['name']} of type #{lbe} to incompatible #{remote['name']}@#{targetcontext} of type #{rbe}" if lbe != rbe
312
+ warn "sync-config #{sync['name']}@#{sync.parent['name']} connects store #{local['name']}@#{sync.parent['name']} of type #{lbe} to incompatible #{remote['name']}@#{targetcontext} of type #{rbe}" if lbe != rbe
293
313
  else
294
- puts "sync-config #{sync['name']}@#{sync.parent['name']} connects store #{store['name']}@#{sync.parent['name']} to non-existent #{store['uri']}@#{targetcontext}"
314
+ warn "sync-config #{sync['name']}@#{sync.parent['name']} connects store #{store['name']}@#{sync.parent['name']} to non-existent #{store['uri']}@#{targetcontext}"
295
315
  end
296
316
  end
297
317
  }
@@ -302,7 +322,7 @@ module SyncEvolution
302
322
 
303
323
  @doc.xpath("//sync/store").each{|store|
304
324
  if !store.parent.at(".//store[@name=#{_inspect(store['name'])}]")
305
- puts "sync-config #{store.parent['name']}@#{store.parent.parent['name']} references non-existent store #{store['name']}"
325
+ warn "sync-config #{store.parent['name']}@#{store.parent.parent['name']} references non-existent store #{store['name']}"
306
326
  end
307
327
  }
308
328
  end
@@ -1,3 +1,3 @@
1
1
  module SyncEvolution
2
- VERSION = "0.1.5"
2
+ VERSION = "0.1.6"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: syncevolution
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Emiliano Heyns