smeargle 0.1.2 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -11,3 +11,7 @@
11
11
  ## v0.1.2
12
12
  * Added error handling to image_details
13
13
  * Added better image link support
14
+
15
+ ## v1.0.0
16
+ * Added a license to gemspec
17
+ * Stable release
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Smeargle [![BuildStatus](https://secure.travis-ci.org/mockra/smeargle.png)](http://travis-ci.org/mockra/smeargle)
1
+ # Smeargle [![BuildStatus](https://secure.travis-ci.org/mockra/smeargle.png)](http://travis-ci.org/mockra/smeargle) [![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/mockra/smeargle)
2
2
 
3
3
  Smeargle is an image collection tool that will return an object
4
4
  containing images from a given URL. Smeargle was designed to be
@@ -54,7 +54,7 @@ to run. You may want to have it run in the background.
54
54
 
55
55
  # returns an array filtered by provided options
56
56
  s.images
57
-
57
+
58
58
  s.images.each do |img|
59
59
  img[:url]
60
60
  img[:width]
@@ -14,22 +14,17 @@ module Smeargle
14
14
  end
15
15
 
16
16
  def formatted_images
17
- formatted_images = []
18
- image_collection.each do |img|
19
- formatted_images << image_format(img)
20
- end
21
- formatted_images
17
+ formatted_images ||=
18
+ image_collection.reject{ |i| corrupt? i }.
19
+ map { |i| format_image_url i }
22
20
  end
23
21
 
24
22
  def detailed_images
25
- detailed_images = []
26
- formatted_images.each do |img|
27
- detailed_images << image_details(img)
28
- end
29
- detailed_images
23
+ detailed_images ||=
24
+ formatted_images.map { |i| image_details i }
30
25
  end
31
26
 
32
- def image_format img
27
+ def format_image_url img
33
28
  if URI(img).relative?
34
29
  self.clean_url + img
35
30
  else
@@ -58,5 +53,9 @@ module Smeargle
58
53
  @simple_images ||= formatted_images
59
54
  end
60
55
 
56
+ def corrupt? img
57
+ img =~ /\;/
58
+ end
59
+
61
60
  end
62
61
  end
@@ -16,8 +16,9 @@ module Smeargle
16
16
  parsed_url = URI.parse url
17
17
  if !parsed_url.scheme
18
18
  @safe_url ||= 'http://' + url
19
+ else
20
+ @safe_url ||= url
19
21
  end
20
- @safe_url ||= url
21
22
  end
22
23
 
23
24
  def response_body
@@ -1,3 +1,3 @@
1
1
  module Smeargle
2
- VERSION = "0.1.2"
2
+ VERSION = "1.0.0"
3
3
  end
data/smeargle.gemspec CHANGED
@@ -17,6 +17,8 @@ Gem::Specification.new do |gem|
17
17
  gem.require_paths = ["lib"]
18
18
  gem.version = Smeargle::VERSION
19
19
 
20
+ gem.license = 'MIT'
21
+
20
22
  gem.add_development_dependency 'rake'
21
23
  gem.add_development_dependency 'rspec'
22
24
  gem.add_development_dependency 'fakeweb'
@@ -9,7 +9,8 @@ describe Smeargle::Image do
9
9
  { url: 'test.png', height: 10, width: 10 })
10
10
 
11
11
  FakeWeb.register_uri :get, 'http://google.com',
12
- body: "Google <img src='/test.png' /> <img src='/test.png' />"
12
+ body: "Google <img src='/test.png' /> <img src='/test.png' />
13
+ <img src='/test.png;script' />"
13
14
  end
14
15
 
15
16
  describe 'images' do
@@ -26,14 +27,14 @@ describe Smeargle::Image do
26
27
  end
27
28
  end
28
29
 
29
- describe 'image_format' do
30
+ describe 'format_image_url' do
30
31
  it 'should format relative paths' do
31
- e = smeargle.image_format '/test.png'
32
+ e = smeargle.format_image_url '/test.png'
32
33
  e.should == 'http://google.com/test.png'
33
34
  end
34
35
 
35
36
  it 'should not format absolute paths' do
36
- e = smeargle.image_format 'http://google.com/test.png'
37
+ e = smeargle.format_image_url 'http://google.com/test.png'
37
38
  e.should == 'http://google.com/test.png'
38
39
  end
39
40
  end
@@ -43,6 +44,11 @@ describe Smeargle::Image do
43
44
  e = smeargle.formatted_images
44
45
  e.first.should == 'http://google.com/test.png'
45
46
  end
47
+
48
+ it 'should exclude corrupted images' do
49
+ e = smeargle.formatted_images
50
+ e.count.should == 1
51
+ end
46
52
  end
47
53
 
48
54
  describe 'detailed_images' do
@@ -54,7 +60,7 @@ describe Smeargle::Image do
54
60
 
55
61
  describe 'image_collection' do
56
62
  it 'should not contain duplicates' do
57
- smeargle.image_collection.count.should == 1
63
+ smeargle.image_collection.count.should == 2
58
64
  end
59
65
  end
60
66
 
@@ -74,4 +80,11 @@ describe Smeargle::Image do
74
80
  end
75
81
  end
76
82
 
83
+ describe 'corrupt?' do
84
+ it 'should return true for corrupt url' do
85
+ e = smeargle.corrupt? 'http:/google.com/test;test.png'
86
+ e.should be_true
87
+ end
88
+ end
89
+
77
90
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smeargle
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 1.0.0
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: 2012-09-09 00:00:00.000000000 Z
12
+ date: 2012-11-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -115,7 +115,8 @@ files:
115
115
  - spec/smeargle_spec.rb
116
116
  - spec/spec_helper.rb
117
117
  homepage: http://mockra.com
118
- licenses: []
118
+ licenses:
119
+ - MIT
119
120
  post_install_message:
120
121
  rdoc_options: []
121
122
  require_paths:
@@ -128,7 +129,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
128
129
  version: '0'
129
130
  segments:
130
131
  - 0
131
- hash: -3610093232473006616
132
+ hash: 2203931265859465904
132
133
  required_rubygems_version: !ruby/object:Gem::Requirement
133
134
  none: false
134
135
  requirements:
@@ -137,7 +138,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
137
138
  version: '0'
138
139
  segments:
139
140
  - 0
140
- hash: -3610093232473006616
141
+ hash: 2203931265859465904
141
142
  requirements: []
142
143
  rubyforge_project:
143
144
  rubygems_version: 1.8.23