sps_filesync 0.1.0 → 0.1.1

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
  SHA256:
3
- metadata.gz: 711e11ca97636d5d844135fce4536cd3fc1bfa9eba3e99e19a0fd81a13cf0f36
4
- data.tar.gz: f9a384de79ee25dad945a87c6204de9a4c1898895e95851a0f408db4e6e98b6e
3
+ metadata.gz: 4ee9f212b84cfa40ec03c474550ec036e5c3280f75b72a6fbf0919213cf0a25d
4
+ data.tar.gz: b78039bd833d337375022039304b56eb4c2909b70fc7acfa57188ece382e19d5
5
5
  SHA512:
6
- metadata.gz: 784b3e141adfbd001a083074b68ff4a1285f6edcb2008f34213e82864f5e435d9e17440e96e1728b72d24f0c84e20df677534f4aaa3a94bc7586e2914fa14f06
7
- data.tar.gz: 539bd2abcb92bc9216bf22d42e6f73c5128fa2f191436ff783b3c50f2a2b3438ddd7ed6d6b8c1e881b6416c3f4928b7ce78de2270828ae314938f649839d6880
6
+ metadata.gz: 363a79b215ce9f7179a7b49c2b27d7ec2f187aa6f77dbf51083a652781e5033964ca29b2718987b2511ec5a350e68a1bc26224955f4af13c17111859c210484a
7
+ data.tar.gz: 7d453c72a738ea15263bf6fa3d8eaa42ee07ce14639fcff0c6a3860ef54fdb13c216ab3b219d71e50c635cbc28d97ec89a88749e305b2d8ae2b72d021f35fda9
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -20,76 +20,84 @@ class SpsFileSync < SPSSub
20
20
 
21
21
  def subscribe(topic: 'file/*')
22
22
 
23
- super(topic: topic) do |msg, topic|
24
-
25
-
26
- if @debug then
27
- puts 'topic: ' + topic.inspect
28
- puts 'msg: ' + msg.inspect
29
- end
30
-
31
- action = topic.split('/').last.to_sym
32
-
33
- @master_address , path = msg.match(/^dfs:\/\/([^\/]+)(.*)/).captures
34
-
35
- case action
36
- when :cp
37
-
38
- src, dest = msg.split(/ +/,2)
23
+ super(topic: topic + ' or nodes or nodes/*') do |msg, topic|
39
24
 
40
- file_op do |f, node|
41
- src_path = "dfs://%s%s" % [node, src[/^dfs:\/\/[^\/]+(.*)/]]
42
- target_path = "dfs://%s%s" % [node, dest[/^dfs:\/\/[^\/]+(.*)/]]
43
- f.cp src_path, target_path
25
+ if msg =~ /^dfs:\/\// then
26
+
27
+ if @debug then
28
+ puts 'topic: ' + topic.inspect
29
+ puts 'msg: ' + msg.inspect
44
30
  end
45
31
 
46
- when :mkdir
47
-
48
- file_op {|f, node| f.mkdir "dfs://%s%s" % [node, path] }
32
+ action = topic.split('/').last.to_sym
49
33
 
50
- when :mkdir_p
51
-
52
- file_op {|f, node| f.mkdir_p "dfs://%s%s" % [node, path] }
53
-
54
- when :mv
34
+ @master_address , path = msg.match(/^dfs:\/\/([^\/]+)(.*)/).captures
55
35
 
56
- src, dest = msg.split(/ +/,2)
36
+ case action
37
+ when :cp
57
38
 
58
- file_op do |f, node|
59
- src_path = "dfs://%s/%s" % [node, src[/^dfs:\/\/[^\/]+(.*)/]]
60
- target_path = "dfs://%s/%s" % [node, dest[/^dfs:\/\/[^\/]+(.*)/]]
61
- f.mv src_path, target_path
62
- end
63
-
64
- when :write
39
+ src, dest = msg.split(/ +/,2)
65
40
 
66
- master_path = msg
41
+ file_op do |f, node|
42
+ src_path = "dfs://%s%s" % [node, src[/^dfs:\/\/[^\/]+(.*)/]]
43
+ target_path = "dfs://%s%s" % [node, dest[/^dfs:\/\/[^\/]+(.*)/]]
44
+ f.cp src_path, target_path
45
+ end
46
+
47
+ when :mkdir
48
+
49
+ file_op {|f, node| f.mkdir "dfs://%s%s" % [node, path] }
67
50
 
68
- file_op do |f, node|
69
- target_path = "dfs://%s%s" % [node, path]
51
+ when :mkdir_p
70
52
 
71
- if @debug then
72
- puts 'master_path: ' + master_path.inspect
73
- puts 'target_path: ' + target_path.inspect
74
- end
75
-
76
- DfsFile.cp master_path, target_path
53
+ file_op {|f, node| f.mkdir_p "dfs://%s%s" % [node, path] }
54
+
55
+ when :mv
56
+
57
+ src, dest = msg.split(/ +/,2)
58
+
59
+ file_op do |f, node|
60
+ src_path = "dfs://%s/%s" % [node, src[/^dfs:\/\/[^\/]+(.*)/]]
61
+ target_path = "dfs://%s/%s" % [node, dest[/^dfs:\/\/[^\/]+(.*)/]]
62
+ f.mv src_path, target_path
63
+ end
64
+
65
+ when :write
66
+
67
+ master_path = msg
68
+
69
+ file_op do |f, node|
70
+ target_path = "dfs://%s%s" % [node, path]
71
+
72
+ if @debug then
73
+ puts 'master_path: ' + master_path.inspect
74
+ puts 'target_path: ' + target_path.inspect
75
+ end
76
+
77
+ DfsFile.cp master_path, target_path
77
78
 
78
- end
79
-
80
- when :rm
79
+ end
80
+
81
+ when :rm
82
+
83
+ file_op {|f, node| f.rm "dfs://%s%s" % [node, path] }
81
84
 
82
- file_op {|f, node| f.rm "dfs://%s%s" % [node, path] }
83
-
84
- when :zip
85
+ when :zip
85
86
 
86
- master_path = msg
87
+ master_path = msg
87
88
 
88
- file_op do |f, node|
89
- target_path = "dfs://%s%s" % [node, path]
90
- f.cp master_path, target_path
91
- end
92
-
89
+ file_op do |f, node|
90
+ target_path = "dfs://%s%s" % [node, path]
91
+ f.cp master_path, target_path
92
+ end
93
+
94
+ end
95
+
96
+ elsif topic == 'nodes/set'
97
+ @nodes = msg.split(/ +/)
98
+ elsif topic == 'nodes' and msg == 'get'
99
+
100
+ notice 'nodes/listed: ' + @nodes.join(' ')
93
101
  end
94
102
  end
95
103
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sps_filesync
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -35,7 +35,7 @@ cert_chain:
35
35
  feUGIGfnNt45GzAXotThqQumr3i8r7QA6adlEdEvfEuB4QJ2sjZ+1mneJVJOWXuQ
36
36
  0EhbgFKdvj2b8zaB8UqvKK0Q
37
37
  -----END CERTIFICATE-----
38
- date: 2018-08-23 00:00:00.000000000 Z
38
+ date: 2018-08-24 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: sps-sub
metadata.gz.sig CHANGED
Binary file