ZMediumToMarkdown 1.3.9 → 1.4.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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/Helper.rb +37 -31
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 40d6f0e842faa414ceb2a9e08eab389e56e10e3636d6d21a5853c5fb0dad17b5
4
- data.tar.gz: 767d52380374c45fe7f1f698425204ca22ac88c97dc5859de1e9020e1bcbbbc3
3
+ metadata.gz: a55fc9a63d9ad7bed70ee69309d5e28587549a17414aca83b2699755cb50d87d
4
+ data.tar.gz: fa6f4de0f2783e47e7aae43a30b57ae478e4a250f5045a9f061558422882285c
5
5
  SHA512:
6
- metadata.gz: e80de85129ca95baf8a187ef286722fe64a35e862c42a03f1dde3c092ba9a812ea897fe10a9db973187e85a7d76a754eee08dbf1e14d7a5e7b6f3c28d3b691b9
7
- data.tar.gz: 36fa0ef2f103274d07c2ad12dc1c0ab8da5ac3fc51b9c34e121de9a6808c42abdc13c5eda54ad72d58887a491511b2b0219d8c85a383f26ca6e346066ccccdfc
6
+ metadata.gz: d370856e9155669e2fc4d836dd1aab4c238003bbfe7403a533acf2c3e7985d09185aba634d3e363c414f3f24c231950635ceb12c5c02cdccb201f5eca71a2865
7
+ data.tar.gz: 0c99a6c98bd62a427ee2baa71345d8edf9575415b99f395052520149febd8fbbf5580d9800506d1f7316f5d741832fa6e3ee9427bf0a49c2415fa06d9f97cf7c
data/lib/Helper.rb CHANGED
@@ -46,42 +46,48 @@ class Helper
46
46
  end
47
47
 
48
48
  def self.downloadLatestVersion()
49
- apiPath = 'https://api.github.com/repos/ZhgChgLi/ZMediumToMarkdown/releases'
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
- zipFilePath = version["zipball_url"]
64
- puts "Downloading latest version from github..."
65
- open('latest.zip', 'wb') do |fo|
66
- fo.print open(zipFilePath).read
67
- end
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
- puts "Unzip..."
70
- Zip::File.open("latest.zip") do |zipfile|
71
- zipfile.each do |file|
72
- fileNames = file.name.split("/")
73
- fileNames.shift
74
- filePath = fileNames.join("/")
75
- if filePath != ''
76
- puts "Unzinp...#{filePath}"
77
- zipfile.extract(file, filePath) { true }
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
- end
81
- File.delete("latest.zip")
84
+ File.delete("latest.zip")
82
85
 
83
- tagName = version["tag_name"]
84
- puts "Update to version #{tagName} successfully!"
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)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ZMediumToMarkdown
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.9
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ZhgChgLi