imgur_url 0.2 → 0.3

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
@@ -25,8 +25,9 @@ i.permalink_url
25
25
 
26
26
  #### Supported `url` sizes
27
27
  - `:original` (default)
28
- - `:huge`
29
- - `:large`
30
- - `:medium`
31
- - `:thumb`
32
- - `:small`
28
+ - `:huge` (1024px in largest dimension)
29
+ - `:large` (640px in largest dimension)
30
+ - `:medium` (320px in largest dimension)
31
+ - `:box` (160px/160px center-cropped)
32
+ - `:thumb` (160px in largest dimension)
33
+ - `:small` (90px/90px center-cropped)
@@ -3,6 +3,7 @@ module ImgurUrl
3
3
  SIZES = {
4
4
  :small => 's',
5
5
  :thumb => 't',
6
+ :box => 'b',
6
7
  :medium => 'm',
7
8
  :large => 'l',
8
9
  :huge => 'h',
@@ -14,6 +15,10 @@ module ImgurUrl
14
15
  removalrequest
15
16
  ]
16
17
 
18
+ def self.from_id(id)
19
+ self.new("http://imgur.com/#{id}")
20
+ end
21
+
17
22
  def initialize(url)
18
23
  @original_url = url
19
24
  raise InvalidUrl unless id.present? && !IGNORE_PATHS.include?(id)
@@ -1,3 +1,3 @@
1
1
  module ImgurUrl
2
- VERSION = "0.2"
2
+ VERSION = "0.3"
3
3
  end
@@ -3,8 +3,6 @@ require 'spec_helper'
3
3
  module ImgurUrl
4
4
  describe Image do
5
5
  shared_examples "with a valid imgur image URL" do
6
- subject { described_class.new(url) }
7
-
8
6
  its(:id) { should == "dhuY8" }
9
7
  its(:permalink_url) { should == "http://imgur.com/dhuY8" }
10
8
  its(:download_url) { should == "http://imgur.com/download/dhuY8" }
@@ -16,6 +14,7 @@ module ImgurUrl
16
14
  subject.url(:huge).should == "http://i.imgur.com/dhuY8h.jpg"
17
15
  subject.url(:large).should == "http://i.imgur.com/dhuY8l.jpg"
18
16
  subject.url(:medium).should == "http://i.imgur.com/dhuY8m.jpg"
17
+ subject.url(:box).should == "http://i.imgur.com/dhuY8b.jpg"
19
18
  subject.url(:thumb).should == "http://i.imgur.com/dhuY8t.jpg"
20
19
  subject.url(:small).should == "http://i.imgur.com/dhuY8s.jpg"
21
20
  end
@@ -29,22 +28,27 @@ module ImgurUrl
29
28
  end
30
29
 
31
30
  context "a default permalink URL" do
32
- let(:url) { "http://imgur.com/dhuY8" }
31
+ subject { described_class.new("http://imgur.com/dhuY8") }
33
32
  it_behaves_like "with a valid imgur image URL"
34
33
  end
35
34
 
36
35
  context "a default permalink URL with query params" do
37
- let(:url) { "http://imgur.com/dhuY8?tags" }
36
+ subject { described_class.new("http://imgur.com/dhuY8?tags") }
38
37
  it_behaves_like "with a valid imgur image URL"
39
38
  end
40
39
 
41
40
  context "a direct URL" do
42
- let(:url) { "http://i.imgur.com/dhuY8.jpg" }
41
+ subject { described_class.new("http://i.imgur.com/dhuY8.jpg") }
43
42
  it_behaves_like "with a valid imgur image URL"
44
43
  end
45
44
 
46
45
  context "a download URL" do
47
- let(:url) { "http://imgur.com/download/dhuY8" }
46
+ subject { described_class.new("http://imgur.com/download/dhuY8") }
47
+ it_behaves_like "with a valid imgur image URL"
48
+ end
49
+
50
+ describe ".from_id" do
51
+ subject { described_class.from_id('dhuY8') }
48
52
  it_behaves_like "with a valid imgur image URL"
49
53
  end
50
54
 
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.2'
4
+ version: '0.3'
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-15 00:00:00.000000000 Z
12
+ date: 2013-06-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: andand