yadisk 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6dad6b4c4a02ce2b8a582bded7d9828b98b568e0dfa3b67d93bb2387e6bd9441
4
- data.tar.gz: f603b1744363d545f916895aba2ca0c56814f3f549dc28af5c703a83d33d7e88
3
+ metadata.gz: 97c83d9c7b5300337ae2ce74d9074fbdeff05415547da1d8971429655d3eb9c9
4
+ data.tar.gz: 771b27f1b7f51ecf99aa6a716c53ca39340bf72a8d11406c9936cc0b68b60044
5
5
  SHA512:
6
- metadata.gz: f8f05f1e5d4b4291979983d28173b53a6c282bd17ffa6d0b3697dd7123dad3df32db2bd60031f697efe23a4e051ad61a8d270db52f87f2c11843b546a4921c02
7
- data.tar.gz: dec7fce5eaf4642de3a0bcdd6102e622b2b21bbc7eaa9092db7b277d43714eed95c68ab8eda862258df7b193296c9cde94481d8f2a95d808869774fe45d7831c
6
+ metadata.gz: 1bb0df189317862d8346b55d8529ce39a122d5f5641f89f56102827e3b26520875c31ce15a49a7adccbe7da07f5a18440d6733cf59f355a21cbe4bbf8b9c5130
7
+ data.tar.gz: 175d39680dc345592f4fc99e8a614453511ceff37c300903cea728a6ef991e81ced13c2144bcbe51df2117fb0d2f5fbe737c35779cecbeaa23239f1d581c5c1d
data/bin/yadisk CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
  # encoding: utf-8
3
3
 
4
- require 'yadisk'
4
+ require 'yadisk/main'
5
5
  require 'yadisk/check_runtime'
6
6
  require 'optparse'
7
7
 
@@ -0,0 +1,37 @@
1
+ # encoding: utf-8
2
+
3
+ require 'cgi'
4
+ require 'cgi/util'
5
+ require 'uri'
6
+ require 'io/console'
7
+ require 'json'
8
+ require 'net/http'
9
+
10
+ require 'yadisk/os'
11
+
12
+ module Yadisk
13
+ class Main
14
+ BASE_URL = 'https://cloud-api.yandex.net:443/v1/disk/public/resources/download?public_key='
15
+ def download(url, folder: ".#{File::SEPARATOR}", wget_options: nil)
16
+ enc_url = CGI::escape(url)
17
+ response = Net::HTTP.get(URI("#{BASE_URL}#{enc_url}"))
18
+ json_res = JSON.parse(response)
19
+ download_url = json_res['href']
20
+ filename = CGI::parse(URI(download_url).query)["filename"][0]
21
+ folder = folder + File::SEPARATOR if not folder.end_with?(File::SEPARATOR)
22
+ download_path = folder + filename
23
+
24
+ wget_options = (wget_options || "") + "--no-check-certificate" if Yadisk::OS.windows?
25
+ system("wget #{esc(download_url)} -O #{esc(download_path)} #{wget_options}")
26
+ end
27
+
28
+ private
29
+ def esc(str)
30
+ "#{escape_symbol}#{str}#{escape_symbol}"
31
+ end
32
+
33
+ def escape_symbol
34
+ Yadisk::OS.windows? ? '"' : "'"
35
+ end
36
+ end
37
+ end
@@ -1,3 +1,3 @@
1
1
  module Yadisk
2
- VERSION = '0.2.0'
2
+ VERSION = '0.3.0'
3
3
  end
data/lib/yadisk.rb CHANGED
@@ -1,37 +1,4 @@
1
1
  # encoding: utf-8
2
2
 
3
- require 'cgi'
4
- require 'cgi/util'
5
- require 'uri'
6
- require 'io/console'
7
- require 'json'
8
- require 'net/http'
9
-
10
- require 'yadisk/os'
11
-
12
3
  module Yadisk
13
- class Main
14
- BASE_URL = 'https://cloud-api.yandex.net:443/v1/disk/public/resources/download?public_key='
15
- def download(url, folder: ".#{File::SEPARATOR}", wget_options: nil)
16
- enc_url = CGI::escape(url)
17
- response = Net::HTTP.get(URI("#{BASE_URL}#{enc_url}"))
18
- json_res = JSON.parse(response)
19
- download_url = json_res['href']
20
- filename = CGI::parse(URI(download_url).query)["filename"][0]
21
- folder = folder + File::SEPARATOR if not folder.end_with?(File::SEPARATOR)
22
- download_path = folder + filename
23
-
24
- wget_options = (wget_options || "") + "--no-check-certificate" if Yadisk::OS.windows?
25
- system("wget #{esc(download_url)} -O #{esc(download_path)} #{wget_options}")
26
- end
27
-
28
- private
29
- def esc(str)
30
- "#{escape_symbol}#{str}#{escape_symbol}"
31
- end
32
-
33
- def escape_symbol
34
- Yadisk::OS.windows? ? '"' : "'"
35
- end
36
- end
37
4
  end
metadata CHANGED
@@ -1,11 +1,11 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yadisk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Artem Yegorov
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
  date: 2018-01-25 00:00:00.000000000 Z
@@ -16,7 +16,7 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 3.8.0
19
+ version: '3.9'
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
22
  version: '4.0'
@@ -26,7 +26,7 @@ dependencies:
26
26
  requirements:
27
27
  - - "~>"
28
28
  - !ruby/object:Gem::Version
29
- version: 3.8.0
29
+ version: '3.9'
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
32
  version: '4.0'
@@ -54,13 +54,14 @@ files:
54
54
  - bin/yadisk
55
55
  - lib/yadisk.rb
56
56
  - lib/yadisk/check_runtime.rb
57
+ - lib/yadisk/main.rb
57
58
  - lib/yadisk/os.rb
58
59
  - lib/yadisk/version.rb
59
60
  homepage: https://github.com/yegorov/yadisk
60
61
  licenses:
61
62
  - MIT
62
63
  metadata: {}
63
- post_install_message:
64
+ post_install_message:
64
65
  rdoc_options: []
65
66
  require_paths:
66
67
  - lib
@@ -75,8 +76,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
75
76
  - !ruby/object:Gem::Version
76
77
  version: '0'
77
78
  requirements: []
78
- rubygems_version: 3.0.6
79
- signing_key:
79
+ rubygems_version: 3.3.7
80
+ signing_key:
80
81
  specification_version: 4
81
82
  summary: Download file from Yandex.Disk through share link
82
83
  test_files: []