ZMediumToMarkdown 1.3.7 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/ZMediumToMarkdown +1 -1
- data/lib/Helper.rb +37 -31
- 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: a55fc9a63d9ad7bed70ee69309d5e28587549a17414aca83b2699755cb50d87d
|
4
|
+
data.tar.gz: fa6f4de0f2783e47e7aae43a30b57ae478e4a250f5045a9f061558422882285c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d370856e9155669e2fc4d836dd1aab4c238003bbfe7403a533acf2c3e7985d09185aba634d3e363c414f3f24c231950635ceb12c5c02cdccb201f5eca71a2865
|
7
|
+
data.tar.gz: 0c99a6c98bd62a427ee2baa71345d8edf9575415b99f395052520149febd8fbbf5580d9800506d1f7316f5d741832fa6e3ee9427bf0a49c2415fa06d9f97cf7c
|
data/bin/ZMediumToMarkdown
CHANGED
data/lib/Helper.rb
CHANGED
@@ -46,42 +46,48 @@ class Helper
|
|
46
46
|
end
|
47
47
|
|
48
48
|
def self.downloadLatestVersion()
|
49
|
-
|
50
|
-
versions = JSON.parse(Request.URL(apiPath).body).sort { |a,b| b["id"] <=> a["id"] }
|
51
|
-
|
52
|
-
version = nil
|
53
|
-
index = 0
|
54
|
-
while version == nil do
|
55
|
-
thisVersion = versions[index]
|
56
|
-
if thisVersion["prerelease"] == false
|
57
|
-
version = thisVersion
|
58
|
-
next
|
59
|
-
end
|
60
|
-
index += 1
|
61
|
-
end
|
49
|
+
rootPath = File.expand_path('../', File.dirname(__FILE__))
|
62
50
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
51
|
+
if File.file?("#{rootPath}/ZMediumToMarkdown.gemspec")
|
52
|
+
apiPath = 'https://api.github.com/repos/ZhgChgLi/ZMediumToMarkdown/releases'
|
53
|
+
versions = JSON.parse(Request.URL(apiPath).body).sort { |a,b| b["id"] <=> a["id"] }
|
54
|
+
|
55
|
+
version = nil
|
56
|
+
index = 0
|
57
|
+
while version == nil do
|
58
|
+
thisVersion = versions[index]
|
59
|
+
if thisVersion["prerelease"] == false
|
60
|
+
version = thisVersion
|
61
|
+
next
|
62
|
+
end
|
63
|
+
index += 1
|
64
|
+
end
|
65
|
+
|
66
|
+
zipFilePath = version["zipball_url"]
|
67
|
+
puts "Downloading latest version from github..."
|
68
|
+
open('latest.zip', 'wb') do |fo|
|
69
|
+
fo.print open(zipFilePath).read
|
70
|
+
end
|
68
71
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
72
|
+
puts "Unzip..."
|
73
|
+
Zip::File.open("latest.zip") do |zipfile|
|
74
|
+
zipfile.each do |file|
|
75
|
+
fileNames = file.name.split("/")
|
76
|
+
fileNames.shift
|
77
|
+
filePath = fileNames.join("/")
|
78
|
+
if filePath != ''
|
79
|
+
puts "Unzinp...#{filePath}"
|
80
|
+
zipfile.extract(file, filePath) { true }
|
81
|
+
end
|
78
82
|
end
|
79
83
|
end
|
80
|
-
|
81
|
-
File.delete("latest.zip")
|
84
|
+
File.delete("latest.zip")
|
82
85
|
|
83
|
-
|
84
|
-
|
86
|
+
tagName = version["tag_name"]
|
87
|
+
puts "Update to version #{tagName} successfully!"
|
88
|
+
else
|
89
|
+
system("gem update ZMediumToMarkdown")
|
90
|
+
end
|
85
91
|
end
|
86
92
|
|
87
93
|
def self.createPostInfo(postInfo)
|