directlink 0.0.1.1 → 0.0.1.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 +4 -4
- data/bin/directlink +8 -2
- data/directlink.gemspec +2 -1
- data/test.rb +15 -8
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9a8470c30310de349800459f325c2d244075fba2
|
4
|
+
data.tar.gz: fe0a118c8bb52d675325ce8d3356bb8fa7ca936f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 60db6a81f31ba3a0425db1bf74d6719e852a6710fb716a081817ae9eaa8482f923b1ec1a5cb5f9dbf1d265e3599807c090a0e949e53ab568def36af7c6ffb53f
|
7
|
+
data.tar.gz: 693fab788a1c312f3cf42843e5029d4f40db50127da55034160ff9a607ac4002a57371632df3b24e0aa82f4ce1aaf4d5f00e83cd0589ff6f573ced8fab28b7c1
|
data/bin/directlink
CHANGED
@@ -31,7 +31,7 @@ if github
|
|
31
31
|
dir = Dir.mktmpdir "directlink"
|
32
32
|
src = File.join dir, "directlink.rb"
|
33
33
|
puts "downloaded directlink.rb from GitHub (#{
|
34
|
-
File.write src, NetHTTPUtils.request_data("https://
|
34
|
+
File.write src, NetHTTPUtils.request_data("https://raw.githubusercontent.com/nakilon/directlink/master/lib/directlink.rb", form: {raw: true})
|
35
35
|
} bytes)"
|
36
36
|
require_relative src
|
37
37
|
ensure
|
@@ -43,7 +43,13 @@ else
|
|
43
43
|
require "directlink"
|
44
44
|
end
|
45
45
|
DirectLink.silent = !debug
|
46
|
-
abort "usage: directlink [--debug] [--json] <link1> <link2> <link3>
|
46
|
+
abort "usage: directlink [--debug] [--json] <link1> <link2> <link3> ...\n#{
|
47
|
+
if github
|
48
|
+
"impossible to tell version for sure from raw.githubusercontent.com"
|
49
|
+
else
|
50
|
+
"directlink version #{Gem.loaded_specs["directlink"].version} (#{Gem.loaded_specs["directlink"].metadata["source_code_uri"]})"
|
51
|
+
end
|
52
|
+
}" if [nil, "-h", "--help", "-v", "--version"].include? ARGV.first
|
47
53
|
|
48
54
|
begin
|
49
55
|
if json
|
data/directlink.gemspec
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
Gem::Specification.new do |spec|
|
2
2
|
spec.name = "directlink"
|
3
|
-
spec.version = "0.0.1.
|
3
|
+
spec.version = "0.0.1.2"
|
4
4
|
spec.summary = "converts any kind of image hyperlink to direct link, type of image and its resolution"
|
5
5
|
|
6
6
|
spec.author = "Victor Maslov aka Nakilon"
|
7
7
|
spec.email = "nakilon@gmail.com"
|
8
8
|
spec.license = "MIT"
|
9
9
|
spec.homepage = "https://github.com/nakilon/directlink"
|
10
|
+
spec.metadata = {"source_code_uri" => "https://github.com/nakilon/directlink"}
|
10
11
|
|
11
12
|
spec.add_dependency "nethttputils", "~>0.2.2.0"
|
12
13
|
spec.add_dependency "fastimage", "~>2.1.3"
|
data/test.rb
CHANGED
@@ -304,17 +304,24 @@ describe DirectLink do
|
|
304
304
|
|
305
305
|
describe "shows usage help if misused" do
|
306
306
|
[
|
307
|
-
[
|
308
|
-
[
|
309
|
-
[
|
307
|
+
[/\Ausage: directlink \[--debug\] \[--json\] <link1> <link2> <link3> \.\.\.\ndirectlink version \d\.\d\.\d\.\d \(https:\/\/github\.com\/nakilon\/directlink\)\n\z/, nil],
|
308
|
+
[/\Ausage: directlink \[--debug\] \[--json\] <link1> <link2> <link3> \.\.\.\ndirectlink version \d\.\d\.\d\.\d \(https:\/\/github\.com\/nakilon\/directlink\)\n\z/, "-h"],
|
309
|
+
[/\Ausage: directlink \[--debug\] \[--json\] <link1> <link2> <link3> \.\.\.\ndirectlink version \d\.\d\.\d\.\d \(https:\/\/github\.com\/nakilon\/directlink\)\n\z/, "--help"],
|
310
|
+
[/\Ausage: directlink \[--debug\] \[--json\] <link1> <link2> <link3> \.\.\.\ndirectlink version \d\.\d\.\d\.\d \(https:\/\/github\.com\/nakilon\/directlink\)\n\z/, "-v"],
|
311
|
+
[/\Ausage: directlink \[--debug\] \[--json\] <link1> <link2> <link3> \.\.\.\ndirectlink version \d\.\d\.\d\.\d \(https:\/\/github\.com\/nakilon\/directlink\)\n\z/, "--version"],
|
310
312
|
["DirectLink::ErrorBadLink: \"--\"\n", "--"],
|
311
313
|
["DirectLink::ErrorBadLink: \"-\"\n", "-"],
|
312
314
|
["DirectLink::ErrorBadLink: \"-\"\n", "- -"],
|
313
315
|
["DirectLink::ErrorBadLink: \"asd\"\n", "asd"],
|
314
|
-
].each_with_index do |(
|
316
|
+
].each_with_index do |(expectation, param), i|
|
315
317
|
it "##{i + 1}" do
|
316
|
-
string, status = Open3.capture2e "ruby
|
317
|
-
|
318
|
+
string, status = Open3.capture2e "bundle exec ruby bin/directlink #{param}"
|
319
|
+
if expectation.is_a? String
|
320
|
+
assert_equal expectation, string
|
321
|
+
else
|
322
|
+
assert_match expectation, string
|
323
|
+
end
|
324
|
+
assert_equal 1, status.exitstatus
|
318
325
|
end
|
319
326
|
end
|
320
327
|
end
|
@@ -332,7 +339,7 @@ describe DirectLink do
|
|
332
339
|
[1, "https://imgur.com/a/badlinkpattern", "NetHTTPUtils::Error: HTTP error #404 "],
|
333
340
|
].each_with_index do |(expected_exit_code, link, expected_output, unset), i|
|
334
341
|
it "##{i + 1}" do
|
335
|
-
string, status = Open3.capture2e "export #{File.read("api_tokens_for_travis.sh").gsub(/\n?export/, ?\s).strip}#{unset} && ruby
|
342
|
+
string, status = Open3.capture2e "export #{File.read("api_tokens_for_travis.sh").gsub(/\n?export/, ?\s).strip}#{unset} && bundle exec ruby bin/directlink #{link}"
|
336
343
|
assert_equal [expected_exit_code, "#{expected_output}\n"], [status.exitstatus, string], "for #{link}"
|
337
344
|
end
|
338
345
|
end
|
@@ -375,7 +382,7 @@ describe DirectLink do
|
|
375
382
|
'.gsub(/^ {8}/, ""), "json"],
|
376
383
|
].each do |expected_output, param|
|
377
384
|
it "#{param || "default"} succeeds" do
|
378
|
-
string, status = Open3.capture2e "export #{File.read("api_tokens_for_travis.sh").gsub(/\n?export/, ?\s).strip} && ruby
|
385
|
+
string, status = Open3.capture2e "export #{File.read("api_tokens_for_travis.sh").gsub(/\n?export/, ?\s).strip} && bundle exec ruby bin/directlink#{" --#{param}" if param} #{valid_imgur_image_url1} #{valid_imgur_image_url2}"
|
379
386
|
assert_equal [0, expected_output], [status.exitstatus, string]
|
380
387
|
end
|
381
388
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: directlink
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.1.
|
4
|
+
version: 0.0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Victor Maslov aka Nakilon
|
@@ -73,7 +73,8 @@ files:
|
|
73
73
|
homepage: https://github.com/nakilon/directlink
|
74
74
|
licenses:
|
75
75
|
- MIT
|
76
|
-
metadata:
|
76
|
+
metadata:
|
77
|
+
source_code_uri: https://github.com/nakilon/directlink
|
77
78
|
post_install_message:
|
78
79
|
rdoc_options: []
|
79
80
|
require_paths:
|