ZMediumToMarkdown 1.2.2 → 1.3.0
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/ZMediumToMarkdown +13 -7
- data/lib/Request.rb +6 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 478b02a8d17067e64ef3c402640961cc75c91a560b0370e598be80ee17b27296
|
4
|
+
data.tar.gz: 2b01dcc7f9950271bcb0f4e59f10c2c6a1015cd1d013df796e62a4b2138ba69e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3dbf24729dae8e94881fa876ef9cb2119ee1370b45160c3aa6974ee84cb6522ae85ff5380c600db2420df32ec5ec50ac00350f7e56cf41177cc56ed186845ac1
|
7
|
+
data.tar.gz: c62b15539cd70a2d6523f3d89ded3a88ac5220ca72896d7a163d557cc2d1ccbcfec94b548ed78920b74fbe05ef52d18c0b8f4fe57cf832a7f17e2d7f72dd2224
|
data/bin/ZMediumToMarkdown
CHANGED
@@ -12,34 +12,40 @@ class Main
|
|
12
12
|
def initialize
|
13
13
|
fetcher = ZMediumFetcher.new
|
14
14
|
ARGV << '-h' if ARGV.empty?
|
15
|
+
|
16
|
+
filePath = File.expand_path File.dirname(__FILE__)
|
17
|
+
outputFilePath = PathPolicy.new(filePath, "Output")
|
18
|
+
|
15
19
|
OptionParser.new do |opts|
|
16
20
|
opts.banner = "Usage: ZMediumFetcher [options]"
|
17
21
|
|
18
22
|
opts.on('-uUSERNAME', '--username=USERNAME', 'Downloading all posts from user') do |username|
|
19
|
-
|
20
|
-
fetcher.downloadPostsByUsername(username, pathPolicy)
|
23
|
+
fetcher.downloadPostsByUsername(username, outputFilePath)
|
21
24
|
|
22
25
|
Helper.printNewVersionMessageIfExists()
|
23
26
|
end
|
24
27
|
|
25
28
|
opts.on('-pPOST_URL', '--postURL=POST_URL', 'Downloading single post') do |postURL|
|
26
|
-
|
27
|
-
fetcher.downloadPost(postURL, pathPolicy)
|
29
|
+
fetcher.downloadPost(postURL, outputFilePath)
|
28
30
|
|
29
31
|
Helper.printNewVersionMessageIfExists()
|
30
32
|
end
|
31
33
|
|
32
|
-
opts.on('-n', '--new', 'Update to latest version') do
|
34
|
+
opts.on('-n', '--new', 'Update to latest version') do
|
33
35
|
if Helper.compareVersion(Helper.getRemoteVersionFromGithub(), Helper.getLocalVersionFromGemspec())
|
34
36
|
Helper.downloadLatestVersion()
|
35
37
|
else
|
36
38
|
puts "You're using the latest version :)"
|
37
39
|
end
|
38
40
|
end
|
41
|
+
|
42
|
+
opts.on('-c', '--clean', 'Remove all downloaded posts data') do
|
43
|
+
FileUtils.rm_rf(Dir[outputFilePath.getAbsolutePath(nil)])
|
44
|
+
|
45
|
+
Helper.printNewVersionMessageIfExists()
|
46
|
+
end
|
39
47
|
|
40
48
|
end.parse!
|
41
|
-
|
42
|
-
Helper.logLatestRunVersion()
|
43
49
|
end
|
44
50
|
end
|
45
51
|
|
data/lib/Request.rb
CHANGED
@@ -23,12 +23,17 @@ class Request
|
|
23
23
|
end
|
24
24
|
|
25
25
|
response = https.request(request)
|
26
|
+
|
26
27
|
# 3XX Redirect
|
27
28
|
if response.code.to_i >= 300 && response.code.to_i <= 399 && !response['location'].nil? && response['location'] != ''
|
28
29
|
if retryCount >= 10
|
29
30
|
raise "Error: Retry limit reached. path: #{url}"
|
30
31
|
else
|
31
|
-
|
32
|
+
location = response['location']
|
33
|
+
if !location.match? /^(http)/
|
34
|
+
location = "#{uri.scheme}://#{uri.host}#{location}"
|
35
|
+
end
|
36
|
+
response = self.URL(location, method, data)
|
32
37
|
end
|
33
38
|
end
|
34
39
|
response
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ZMediumToMarkdown
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ZhgChgLi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-06-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|