ZMediumToMarkdown 1.2.1 → 1.2.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 +6 -6
- data/lib/Helper.rb +1 -22
- data/lib/ZMediumFetcher.rb +1 -4
- 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: f4927555e3c7d6f021e1c989a83e03a095f613d28fc482d3f08599d16229dbc0
|
4
|
+
data.tar.gz: 77753af16833d4927574a3a170b3d046f35688c1a7146b85a857ca6fcad35851
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 55d662074d29bae6267a7982f3f03c61264b6a5628f2ca15aa9b06a70d3d8d329505f5c833700b8580743719885afe99fb090e3d50ea7a720c5848d56a557e6f
|
7
|
+
data.tar.gz: 5a3ac99f7b8ea47bc24f8f2f48b8f5147fa86d2f8bba920be4592be08ae6f2b7434a545ec353fc879f65ca4ac34dc5285273c17f97f58a66d345072db678863b
|
data/bin/ZMediumToMarkdown
CHANGED
@@ -15,18 +15,18 @@ class Main
|
|
15
15
|
OptionParser.new do |opts|
|
16
16
|
opts.banner = "Usage: ZMediumFetcher [options]"
|
17
17
|
|
18
|
-
opts.on('-uUSERNAME', '--username=USERNAME', '
|
19
|
-
Helper.checkNewVersion()
|
20
|
-
|
18
|
+
opts.on('-uUSERNAME', '--username=USERNAME', 'Downloading all posts from user') do |username|
|
21
19
|
pathPolicy = PathPolicy.new("#{File.expand_path('../', File.dirname(__FILE__))}", "Output")
|
22
20
|
fetcher.downloadPostsByUsername(username, pathPolicy)
|
21
|
+
|
22
|
+
Helper.printNewVersionMessageIfExists()
|
23
23
|
end
|
24
24
|
|
25
|
-
opts.on('-pPOST_URL', '--postURL=POST_URL', '
|
26
|
-
Helper.checkNewVersion()
|
27
|
-
|
25
|
+
opts.on('-pPOST_URL', '--postURL=POST_URL', 'Downloading single post') do |postURL|
|
28
26
|
pathPolicy = PathPolicy.new("#{File.expand_path('../', File.dirname(__FILE__))}", "Output")
|
29
27
|
fetcher.downloadPost(postURL, pathPolicy)
|
28
|
+
|
29
|
+
Helper.printNewVersionMessageIfExists()
|
30
30
|
end
|
31
31
|
|
32
32
|
opts.on('-n', '--new', 'Update to latest version') do |postURL|
|
data/lib/Helper.rb
CHANGED
@@ -96,7 +96,7 @@ class Helper
|
|
96
96
|
result
|
97
97
|
end
|
98
98
|
|
99
|
-
def self.
|
99
|
+
def self.printNewVersionMessageIfExists()
|
100
100
|
if Helper.compareVersion(Helper.getRemoteVersionFromGithub(), Helper.getLocalVersionFromGemspec())
|
101
101
|
puts "##########################################################"
|
102
102
|
puts "##### New Version Available!!! #####"
|
@@ -118,27 +118,6 @@ class Helper
|
|
118
118
|
end
|
119
119
|
end
|
120
120
|
|
121
|
-
def self.logLatestRunVersion()
|
122
|
-
version = Helper.getLocalVersionFromGemspec()
|
123
|
-
rootPath = File.expand_path('../', File.dirname(__FILE__))
|
124
|
-
|
125
|
-
File.open("#{rootPath}/.latestRunVersion" , 'w+') do |file|
|
126
|
-
file.puts(version.to_string())
|
127
|
-
end
|
128
|
-
end
|
129
|
-
|
130
|
-
def self.getLocalVersionFromFile()
|
131
|
-
rootPath = File.expand_path('../', File.dirname(__FILE__))
|
132
|
-
result = File.read("#{rootPath}/.latestRunVersion")
|
133
|
-
|
134
|
-
if !result.nil?
|
135
|
-
versions = result.split(".")
|
136
|
-
Version.new(versions[0],versions[1],versions[2])
|
137
|
-
else
|
138
|
-
nil
|
139
|
-
end
|
140
|
-
end
|
141
|
-
|
142
121
|
def self.getRemoteVersionFromGithub()
|
143
122
|
apiPath = 'https://api.github.com/repos/ZhgChgLi/ZMediumToMarkdown/releases'
|
144
123
|
versions = JSON.parse(Request.URL(apiPath).body).sort { |a,b| b["id"] <=> a["id"] }
|
data/lib/ZMediumFetcher.rb
CHANGED
@@ -212,12 +212,9 @@ class ZMediumFetcher
|
|
212
212
|
progress.printLog()
|
213
213
|
|
214
214
|
absolutePath = postPathPolicy.getAbsolutePath("#{postPath}.md")
|
215
|
-
|
216
|
-
# if user latest use's version is < latest local version than force download (don't skip, make sure bug fixed can be influenced)
|
217
|
-
forceDownload = Helper.compareVersion(Helper.getLocalVersionFromGemspec(), Helper.getLocalVersionFromFile())
|
218
215
|
|
219
216
|
# if markdown file is exists and last modification time is >= latestPublishedAt(last update post time on medium)
|
220
|
-
if
|
217
|
+
if File.file?(absolutePath) && File.mtime(absolutePath) >= postInfo.latestPublishedAt
|
221
218
|
# Already downloaded and nothing has changed!, Skip!
|
222
219
|
progress.currentPostParagraphIndex = paragraphs.length
|
223
220
|
progress.message = "Skip, Post already downloaded and nothing has changed!"
|