ZMediumToMarkdown 1.2.2 → 1.3.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f4927555e3c7d6f021e1c989a83e03a095f613d28fc482d3f08599d16229dbc0
4
- data.tar.gz: 77753af16833d4927574a3a170b3d046f35688c1a7146b85a857ca6fcad35851
3
+ metadata.gz: c781fa671438a84293ba7c23ff08943ae0d9746181faab3599328b25a1b41149
4
+ data.tar.gz: '08b835966a43471b39f4eb893a1cfb65782f702ad4bbca1b2b17583ac5d80a2b'
5
5
  SHA512:
6
- metadata.gz: 55d662074d29bae6267a7982f3f03c61264b6a5628f2ca15aa9b06a70d3d8d329505f5c833700b8580743719885afe99fb090e3d50ea7a720c5848d56a557e6f
7
- data.tar.gz: 5a3ac99f7b8ea47bc24f8f2f48b8f5147fa86d2f8bba920be4592be08ae6f2b7434a545ec353fc879f65ca4ac34dc5285273c17f97f58a66d345072db678863b
6
+ metadata.gz: fb5323defc4e12ab1fed8dc0ba56d67f55f8095a9bf7f7c4776491548f32e3461504238a3f38af4bea208c2cf37e49970c131d2f0e3d9f1112e9176d3f386605
7
+ data.tar.gz: b8ce667e68bdc1c84fdb9680d690d35861a82d823244e0122a85f00c0b54e35683c270d76c376e07eedff56f51ff82ea7afab20ea26379a0e6d0c22c23b22062
@@ -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
- pathPolicy = PathPolicy.new("#{File.expand_path('../', File.dirname(__FILE__))}", "Output")
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
- pathPolicy = PathPolicy.new("#{File.expand_path('../', File.dirname(__FILE__))}", "Output")
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 |postURL|
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
@@ -8,6 +8,7 @@ require "Request"
8
8
  require 'json'
9
9
  require 'open-uri'
10
10
  require 'zip'
11
+ require 'rubygems'
11
12
 
12
13
  class Helper
13
14
 
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
- response = self.URL(response['location'], method, data)
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.2.2
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-05-30 00:00:00.000000000 Z
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: