imgur_url 0.1 → 0.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.
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- Ruby gem for dealing with [imgur](http://imgur.com) image URLs.
1
+ Ruby gem for dealing with [imgur](http://imgur.com) image URLs. Install with `gem install imgur_url`
2
2
 
3
3
  [![Build Status](https://secure.travis-ci.org/6/imgur_url.png?branch=master)](http://travis-ci.org/6/imgur_url)
4
4
 
@@ -22,7 +22,6 @@ i.permalink_url
22
22
  - `http://imgur.com/{image_id}`
23
23
  - `http://i.imgur.com/{image_id}.jpg`
24
24
  - `http://imgur.com/download/{image_id}`
25
- - `http://imgur.com/gallery/{image_id}`
26
25
 
27
26
  #### Supported `url` sizes
28
27
  - `:original` (default)
@@ -9,17 +9,18 @@ module ImgurUrl
9
9
  :original => '',
10
10
  }
11
11
 
12
- ALBUM_PATH = "a"
12
+ IGNORE_PATHS = %w[
13
+ gallery
14
+ removalrequest
15
+ ]
13
16
 
14
17
  def initialize(url)
15
18
  @original_url = url
16
- unless id.present? && id != ALBUM_PATH
17
- raise InvalidUrl
18
- end
19
+ raise InvalidUrl unless id.present? && !IGNORE_PATHS.include?(id)
19
20
  end
20
21
 
21
22
  def id
22
- @id ||= @original_url.match(%r{imgur\.com/(?:(?:gallery|download)/)?([^.#?/]+)}).andand[1]
23
+ @id ||= @original_url.match(%r{^http://(?:i\.)?imgur\.com/(?:download/)?([^.#?/]{5,})}).andand[1]
23
24
  end
24
25
 
25
26
  def url(size = :original)
@@ -1,3 +1,3 @@
1
1
  module ImgurUrl
2
- VERSION = "0.1"
2
+ VERSION = "0.2"
3
3
  end
@@ -43,11 +43,6 @@ module ImgurUrl
43
43
  it_behaves_like "with a valid imgur image URL"
44
44
  end
45
45
 
46
- context "a gallery URL" do
47
- let(:url) { "http://imgur.com/gallery/dhuY8" }
48
- it_behaves_like "with a valid imgur image URL"
49
- end
50
-
51
46
  context "a download URL" do
52
47
  let(:url) { "http://imgur.com/download/dhuY8" }
53
48
  it_behaves_like "with a valid imgur image URL"
@@ -59,9 +54,20 @@ module ImgurUrl
59
54
  end
60
55
  end
61
56
 
62
- context "with an imgur album URL" do
63
- let(:url) { "http://imgur.com/a/CrSqu" }
64
- it_behaves_like "with an invalid URL"
57
+ %w[
58
+ http://imgur.com/a/CrSqu
59
+ http://imgur.com/blog
60
+ http://imgur.com/blog/2013/06/11/tech-tuesday-real-time-messaging/
61
+ http://imgur.com/user/alan
62
+ http://imgur.com/new/time
63
+ http://imgur.com/removalrequest
64
+ http://imgur.com/gallery
65
+ https://imgur.com/signin
66
+ ].each do |url|
67
+ context "with the non-image imgur url: #{url}" do
68
+ let(:url) { url }
69
+ it_behaves_like "with an invalid URL"
70
+ end
65
71
  end
66
72
 
67
73
  context "with a non-imgur URL" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: imgur_url
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.1'
4
+ version: '0.2'
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-06-14 00:00:00.000000000 Z
12
+ date: 2013-06-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: andand