webarchive 0.1.1 → 0.1.2
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/bin/webarchive +6 -4
- data/lib/webarchive.rb +18 -9
- data/lib/webarchive/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6b8de1dbf19298def2d098e10af00c9e0f7a01b69720af1edd73622a8ecea35c
|
4
|
+
data.tar.gz: 76963d9744f2105055dda1e4b82482c6c63b78f570033c6437e1990958a6ab9b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 51c74e71a5594e9d7380b38196077af19e31687ab471dc510797c6f5399c6842c24cc700364a17112cdb60d22ce130418b812d1e3f969178ac19a327ddf0ba02
|
7
|
+
data.tar.gz: 9a9ad84a61416fc8975e3120e5ab933b33fcf1001ef725d3f71bf93081d5695d4b5bedbd7272fe2bdf3bf0d21ea7a79ba624747c2ec2d06bb7741ce78780b38f
|
data/bin/webarchive
CHANGED
@@ -7,16 +7,18 @@ require 'optparse'
|
|
7
7
|
wait = 4.0
|
8
8
|
debug = false
|
9
9
|
verbose = false
|
10
|
+
history = true
|
10
11
|
Version = WebArchive::VERSION
|
11
12
|
OptionParser.new do |opt|
|
12
13
|
opt.on('-w', '--wait=SECS', 'wait for SECS before sending a request') { |v| wait = v.to_f }
|
13
14
|
opt.on('-d', '--debug', 'add debug output, implies verbose') { debug = true }
|
15
|
+
opt.on('--[no-]history', 'record history (enabled by default)') { |v| history = v }
|
14
16
|
opt.on('--verbose') { verbose = true }
|
15
|
-
opt.on('--
|
16
|
-
puts opt
|
17
|
+
opt.on('-h', '--help', 'show help') do
|
18
|
+
puts opt
|
17
19
|
exit
|
18
|
-
|
20
|
+
end
|
19
21
|
end.parse!(ARGV)
|
20
22
|
|
21
23
|
warn "#{WebArchive} #{WebArchive::VERSION}" if verbose
|
22
|
-
WebArchive.launch(wait_secs: wait, debug: debug, verbose: verbose)
|
24
|
+
WebArchive.launch(wait_secs: wait, debug: debug, verbose: verbose, history: history)
|
data/lib/webarchive.rb
CHANGED
@@ -43,7 +43,9 @@ module WebArchive
|
|
43
43
|
begin
|
44
44
|
yield uri
|
45
45
|
rescue StandardError => e
|
46
|
-
WebArchive.warn_archive_fail(
|
46
|
+
WebArchive.warn_archive_fail(
|
47
|
+
uri, name, ([e.inspect] + e.backtrace).join("\n")
|
48
|
+
)
|
47
49
|
ensure
|
48
50
|
@in_process -= 1
|
49
51
|
break if @all_sent && self.empty?
|
@@ -124,8 +126,7 @@ module WebArchive
|
|
124
126
|
@trie.add x.strip
|
125
127
|
end
|
126
128
|
else
|
127
|
-
File.
|
128
|
-
end
|
129
|
+
File.new(@file, 'w', encoding: 'utf-8').flush
|
129
130
|
end
|
130
131
|
@lastupdate = Time.now
|
131
132
|
end
|
@@ -136,15 +137,25 @@ module WebArchive
|
|
136
137
|
@trie.children(s)
|
137
138
|
end
|
138
139
|
end
|
140
|
+
|
141
|
+
def append_to_history(str)
|
142
|
+
File.open(@file, mode: 'a', encoding: 'utf-8') do |f|
|
143
|
+
f.puts str
|
144
|
+
end
|
145
|
+
end
|
139
146
|
end
|
140
147
|
|
141
148
|
HISTORY_FILE = '~/.webarchive_history'
|
142
149
|
|
143
|
-
def self.launch(wait_secs: 1, debug: false, verbose: false, redirect: false, canonical_uri: true)
|
150
|
+
def self.launch(wait_secs: 1, debug: false, verbose: false, redirect: false, canonical_uri: true, history: true)
|
144
151
|
verbose = true if debug
|
145
152
|
Thread.abort_on_exception = true
|
146
|
-
|
147
|
-
|
153
|
+
completer = nil
|
154
|
+
if history
|
155
|
+
completer = Completer.new(HISTORY_FILE)
|
156
|
+
Readline.completion_proc = completer.to_proc
|
157
|
+
Readline.completion_append_character = ''
|
158
|
+
end
|
148
159
|
|
149
160
|
queues = []
|
150
161
|
|
@@ -223,9 +234,7 @@ module WebArchive
|
|
223
234
|
warn "skipping canonical/redirect for #{uri}: #{e.message}"
|
224
235
|
end
|
225
236
|
|
226
|
-
|
227
|
-
f.puts uri
|
228
|
-
end
|
237
|
+
completer.append_to_history(uri) if completer
|
229
238
|
end
|
230
239
|
|
231
240
|
queues.each(&:done_sending)
|
data/lib/webarchive/version.rb
CHANGED