directlink 0.0.4.2 → 0.0.4.3

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
  SHA1:
3
- metadata.gz: 95b60e38f85cce3fe9c3cf915a4ae95cf76a1a33
4
- data.tar.gz: c2a6dfdd49aa4b9ab22bf9dbaad5d594f1307454
3
+ metadata.gz: 57cb3f9cecd52d2a4ac93edb8dd372398b0a54fa
4
+ data.tar.gz: 4dc3b43d8f661432207c6481eac1d3246377a003
5
5
  SHA512:
6
- metadata.gz: dbca7e2c709fc76d04deb83c77b2742cb9ccd8b842d8f366a36c938f4baa709cd4748d09a8c503d78811364cacbd014c724dd8f78caa641225a89ff3dee9af89
7
- data.tar.gz: e7ed956ca117b8e2d4a281cab5f314e553d375181381a80fc3a882bf9f6cec19fe360d1bbbe5ec3b4f6aa38a9516fcb140ed57c91329e8062af43d548714bfe7
6
+ metadata.gz: f1199f9b98636f09e58676764e1c943ef792fe24271f1d127bbbb8d7b8355544924d13cf19be91ff06ed468e885dbd98def0c5189ce351d28daacda35a9c12e1
7
+ data.tar.gz: 0c5e5720f11a60aa8548f8598b36d2395e1fd08a2bea654c2fe288916e85399d3897e8843aa2a90fb91e02e813b38859754362cb97373307e09b6bb92d139086
data/README.md CHANGED
@@ -85,7 +85,9 @@ When an image hosting with known API is recognized, it will try to use the API t
85
85
  ```
86
86
  $ export IMGUR_CLIENT_ID=0f99cd781...
87
87
  $ export FLICKR_API_KEY=dc2bfd348b...
88
+ $ export REDDIT_SECRETS=secrets.yaml
88
89
  ```
90
+ (check the format of reddit secrets file in the [reddit_bot gem dependency README](https://github.com/Nakilon/reddit_bot/#usage))
89
91
 
90
92
  #### the "don't give up mode"
91
93
 
@@ -100,6 +102,7 @@ $ directlink https://github.com/Nakilon/dhash-vips
100
102
  => https://camo.githubusercontent.com/5456cc20ae9b20c06792ddd19b533ae36404d8c1/68747470733a2f2f73746f726167652e676f6f676c65617069732e636f6d2f64686173682d766970732e6e616b696c6f6e2e70726f2f6964686173685f6578616d706c655f6f75742e706e67
101
103
  png 1610x800
102
104
  ```
105
+ It can even find images in the Markdown body of a Reddit self post! (new feature, needs more testing)
103
106
 
104
107
  ### As a library
105
108
 
@@ -161,5 +164,5 @@ SocketError: Failed to open TCP connection to minus.com:80 (getaddrinfo: nodenam
161
164
  * 500px.com has discontinued API in June 2018 -- the tool now uses undocumented methods
162
165
  * `DirectLink()` can return an Array of Structs for 1) Imgur 2) Reddit unless `giveup = true` is set
163
166
 
164
- TODO: maybe make all these web service specific methods private and discourage to use them since they all return very different things and sometimes don't raise exceptions while the `DirectLink()` does
167
+ TODO: maybe make all these web service specific methods private and discourage to use them since they all return very different things and sometimes don't raise exceptions while the `DirectLink()` does
165
168
  TODO: what should `--json` print if exception was thrown?
data/bin/directlink CHANGED
@@ -40,7 +40,7 @@ if github
40
40
  # FileUtils.rm_rf dir
41
41
  end
42
42
  else
43
- require "directlink"
43
+ require_relative "../lib/directlink"
44
44
  end
45
45
  NetHTTPUtils.logger.level = debug ? Logger::INFO : Logger::FATAL
46
46
  # TODO --timeout=
data/directlink.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "directlink"
3
- spec.version = "0.0.4.2"
3
+ spec.version = "0.0.4.3"
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"
@@ -13,6 +13,7 @@ Gem::Specification.new do |spec|
13
13
  spec.add_dependency "nokogiri"
14
14
  spec.add_dependency "reddit_bot", "~>1.6.7"
15
15
  spec.add_dependency "kramdown"
16
+ spec.add_dependency "addressable"
16
17
  spec.add_development_dependency "minitest"
17
18
 
18
19
  spec.require_path = "lib"
data/lib/directlink.rb CHANGED
@@ -238,7 +238,8 @@ def DirectLink link, max_redirect_resolving_retry_delay = nil, giveup = false
238
238
  begin
239
239
  URI link
240
240
  rescue URI::InvalidURIError
241
- link = URI.escape link
241
+ require "addressable"
242
+ link = Addressable::URI.escape link
242
243
  end
243
244
  raise DirectLink::ErrorBadLink.new link, true unless URI(link).host
244
245
 
data/test.rb CHANGED
@@ -397,6 +397,15 @@ describe DirectLink do
397
397
 
398
398
  describe "DirectLink()" do
399
399
 
400
+ # thanks to gem addressable
401
+ it "does not throw URI::InvalidURIError if there are brackets" do
402
+ assert_equal 404, (
403
+ assert_raises NetHTTPUtils::Error do
404
+ DirectLink "https://www.flickr.com/photos/leogaggl/28488925847/%20[2048x1152]"
405
+ end.code
406
+ )
407
+ end
408
+
400
409
  it "throws ErrorBadLink if link is invalid" do
401
410
  assert_equal "test".inspect, (
402
411
  assert_raises DirectLink::ErrorBadLink do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: directlink
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4.2
4
+ version: 0.0.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Victor Maslov aka Nakilon
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-08-22 00:00:00.000000000 Z
11
+ date: 2018-08-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fastimage
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: addressable
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: minitest
71
85
  requirement: !ruby/object:Gem::Requirement