hardcode 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 +4 -4
- data/lib/hardcode/cli.rb +22 -23
- data/lib/hardcode/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6b1497ae5b8a4b28c4a50507e2686f49520ab41d
|
|
4
|
+
data.tar.gz: 08d25649e9543b9d728089c785c395e1bebaac9b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9044f1c141dbc03f3e092f873e4c8e26eb219adfccaa7cfe981ae5df46273efbc85de7e940fe6ea351ecd8de5d7b0f390182334bbf9d5b22567db0a9aa9562d5
|
|
7
|
+
data.tar.gz: dee8d5bf23d8bcea741163676d8f8c15d1f1bfa57de8c5d8f925ffc00b16b7f0b71ca27fddc4caa517998be9f6e71b6f23635a930b51df2dc1c2f6bbc48cfba9
|
data/lib/hardcode/cli.rb
CHANGED
|
@@ -103,32 +103,31 @@ module Hardcode
|
|
|
103
103
|
aliases: '-t',
|
|
104
104
|
default: '/tmp'
|
|
105
105
|
def watch(source_dir)
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
end
|
|
118
|
-
FileUtils.mv(source_file, options[:tmp_dir], verbose: true)
|
|
119
|
-
ch.default_exchange.publish(
|
|
120
|
-
{
|
|
121
|
-
source: File.join(options[:tmp_dir], File.basename(source_file)),
|
|
122
|
-
dest_dir: options[:destination]
|
|
123
|
-
}.to_json,
|
|
124
|
-
routing_key: q.name,
|
|
125
|
-
persistent: true
|
|
126
|
-
)
|
|
106
|
+
FileUtils.touch LOCK_FILE
|
|
107
|
+
conn = Bunny.new
|
|
108
|
+
conn.start
|
|
109
|
+
ch = conn.create_channel
|
|
110
|
+
q = ch.queue('stack_encode', durable: true)
|
|
111
|
+
listener = Listen.to(source_dir) do |modified, added, removed|
|
|
112
|
+
unless added.empty?
|
|
113
|
+
source_file = added.first
|
|
114
|
+
# wait until the file is fully written and not uploaded anymore
|
|
115
|
+
while system %Q[lsof '#{source_file}']
|
|
116
|
+
sleep 1
|
|
127
117
|
end
|
|
118
|
+
FileUtils.mv(source_file, options[:tmp_dir], verbose: true)
|
|
119
|
+
ch.default_exchange.publish(
|
|
120
|
+
{
|
|
121
|
+
source: File.join(options[:tmp_dir], File.basename(source_file)),
|
|
122
|
+
dest_dir: options[:destination]
|
|
123
|
+
}.to_json,
|
|
124
|
+
routing_key: q.name,
|
|
125
|
+
persistent: true
|
|
126
|
+
)
|
|
128
127
|
end
|
|
129
|
-
listener.start
|
|
130
|
-
sleep
|
|
131
128
|
end
|
|
129
|
+
listener.start
|
|
130
|
+
sleep
|
|
132
131
|
end
|
|
133
132
|
|
|
134
133
|
end # class
|
data/lib/hardcode/version.rb
CHANGED