ruby-quilt 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.
- data/lib/quilt.rb +21 -3
- metadata +1 -1
data/lib/quilt.rb
CHANGED
@@ -11,6 +11,7 @@ class Quilt
|
|
11
11
|
FOOTER_KEY = "footer"
|
12
12
|
PREFIX_KEY = "prefix"
|
13
13
|
DEBUG_PREFIX_KEY = "debug_prefix"
|
14
|
+
ARCHIVE_SUFFIX = ".tgz"
|
14
15
|
|
15
16
|
def initialize(config, log = Logger.new(STDOUT))
|
16
17
|
@config = config;
|
@@ -185,11 +186,11 @@ class Quilt
|
|
185
186
|
end
|
186
187
|
port = @config[:remote_port] ? @config[:remote_port].to_i : 80
|
187
188
|
# Fetch the version
|
188
|
-
filename = "#{name}
|
189
|
+
filename = "#{name}#{ARCHIVE_SUFFIX}"
|
189
190
|
version_dir = File.join(@config[:local_path], name)
|
190
191
|
begin
|
191
192
|
res = Net::HTTP.get_response(@config[:remote_host].to_s,
|
192
|
-
File.join(@config[:remote_path].to_s,
|
193
|
+
File.join(@config[:remote_path].to_s, filename), port)
|
193
194
|
if (res.code != "200")
|
194
195
|
log_error("no version fetched : #{res.code}")
|
195
196
|
return nil
|
@@ -260,7 +261,7 @@ class Quilt
|
|
260
261
|
''}"
|
261
262
|
end
|
262
263
|
|
263
|
-
def
|
264
|
+
def health
|
264
265
|
# return true if no remote info
|
265
266
|
return [true, nil] if !@config[:remote_host] || !@config[:remote_path]
|
266
267
|
# fetch health_check.txt from remote URL
|
@@ -277,4 +278,21 @@ class Quilt
|
|
277
278
|
end
|
278
279
|
[true, nil]
|
279
280
|
end
|
281
|
+
|
282
|
+
def status
|
283
|
+
remote_url = "Remote URL: none"
|
284
|
+
if (@config[:remote_host] && @config[:remote_path])
|
285
|
+
host = @config[:remote_host].to_s
|
286
|
+
port = @config[:remote_port] ? @config[:remote_port].to_i : 80
|
287
|
+
path = File.join(@config[:remote_path].to_s, "<version>#{ARCHIVE_SUFFIX}")
|
288
|
+
remote_url = "Remote URL: http://#{host}:#{port}#{path}"
|
289
|
+
end
|
290
|
+
body = <<EOS
|
291
|
+
-- Quilt Status --
|
292
|
+
#{remote_url}
|
293
|
+
Locally Available Versions:
|
294
|
+
#{@versions.keys.join("\n ")}
|
295
|
+
EOS
|
296
|
+
body
|
297
|
+
end
|
280
298
|
end
|