ZMediumToMarkdown 1.2.2 → 1.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/ZMediumToMarkdown +17 -7
- data/lib/Helper.rb +1 -0
- data/lib/Request.rb +6 -1
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c781fa671438a84293ba7c23ff08943ae0d9746181faab3599328b25a1b41149
|
4
|
+
data.tar.gz: '08b835966a43471b39f4eb893a1cfb65782f702ad4bbca1b2b17583ac5d80a2b'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fb5323defc4e12ab1fed8dc0ba56d67f55f8095a9bf7f7c4776491548f32e3461504238a3f38af4bea208c2cf37e49970c131d2f0e3d9f1112e9176d3f386605
|
7
|
+
data.tar.gz: b8ce667e68bdc1c84fdb9680d690d35861a82d823244e0122a85f00c0b54e35683c270d76c376e07eedff56f51ff82ea7afab20ea26379a0e6d0c22c23b22062
|
data/bin/ZMediumToMarkdown
CHANGED
@@ -12,34 +12,44 @@ 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
|
47
|
+
|
48
|
+
opts.on('-v', '--version', 'Print current ZMediumToMarkdown Version') do
|
49
|
+
puts "Version:#{Helper.getLocalVersionFromGemspec().to_string}"
|
50
|
+
end
|
39
51
|
|
40
52
|
end.parse!
|
41
|
-
|
42
|
-
Helper.logLatestRunVersion()
|
43
53
|
end
|
44
54
|
end
|
45
55
|
|
data/lib/Helper.rb
CHANGED
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.2
|
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
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 0.1.0
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rubyzip
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 2.3.2
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 2.3.2
|
55
69
|
description: ZMediumToMarkdown lets you download Medium post and convert it to markdown
|
56
70
|
format easily.
|
57
71
|
email:
|