{"action":"created","comment":{"url":"https://api.github.com/repos/gottfrois/image_info/pulls/comments/36718748","id":36718748,"diff_hunk":"@@ -3,15 +3,15 @@\n module ImageInfo\n   class Parser\n \n-    attr_reader :image, :bytes, :parser\n+    attr_reader :image\n \n     def initialize(image, data)\n-      @image  = image\n-      @bytes  = data.bytes\n-      @parser = ::ImageSize.new(data)\n+      @image = image\n+      @data = data","path":"lib/image_info/parser.rb","position":12,"original_position":12,"commit_id":"025f154fc5fccaaaf0719e18511e4496e5cdafd2","original_commit_id":"025f154fc5fccaaaf0719e18511e4496e5cdafd2","user":{"login":"gottfrois","id":943784,"avatar_url":"https://avatars.githubusercontent.com/u/943784?v=3","gravatar_id":"","url":"https://api.github.com/users/gottfrois","html_url":"https://github.com/gottfrois","followers_url":"https://api.github.com/users/gottfrois/followers","following_url":"https://api.github.com/users/gottfrois/following{/other_user}","gists_url":"https://api.github.com/users/gottfrois/gists{/gist_id}","starred_url":"https://api.github.com/users/gottfrois/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gottfrois/subscriptions","organizations_url":"https://api.github.com/users/gottfrois/orgs","repos_url":"https://api.github.com/users/gottfrois/repos","events_url":"https://api.github.com/users/gottfrois/events{/privacy}","received_events_url":"https://api.github.com/users/gottfrois/received_events","type":"User","site_admin":false},"body":"please make that a `attr_reader` and use `data` instead of `@data` in the class directly","created_at":"2015-08-11T07:40:51Z","updated_at":"2015-08-11T07:40:51Z","html_url":"https://github.com/gottfrois/image_info/pull/4#discussion_r36718748","pull_request_url":"https://api.github.com/repos/gottfrois/image_info/pulls/4","_links":{"self":{"href":"https://api.github.com/repos/gottfrois/image_info/pulls/comments/36718748"},"html":{"href":"https://github.com/gottfrois/image_info/pull/4#discussion_r36718748"},"pull_request":{"href":"https://api.github.com/repos/gottfrois/image_info/pulls/4"}}},"pull_request":{"url":"https://api.github.com/repos/gottfrois/image_info/pulls/4","id":42015040,"html_url":"https://github.com/gottfrois/image_info/pull/4","diff_url":"https://github.com/gottfrois/image_info/pull/4.diff","patch_url":"https://github.com/gottfrois/image_info/pull/4.patch","issue_url":"https://api.github.com/repos/gottfrois/image_info/issues/4","number":4,"state":"open","locked":false,"title":"Download just enough data","user":{"login":"vdaubry","id":498298,"avatar_url":"https://avatars.githubusercontent.com/u/498298?v=3","gravatar_id":"","url":"https://api.github.com/users/vdaubry","html_url":"https://github.com/vdaubry","followers_url":"https://api.github.com/users/vdaubry/followers","following_url":"https://api.github.com/users/vdaubry/following{/other_user}","gists_url":"https://api.github.com/users/vdaubry/gists{/gist_id}","starred_url":"https://api.github.com/users/vdaubry/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vdaubry/subscriptions","organizations_url":"https://api.github.com/users/vdaubry/orgs","repos_url":"https://api.github.com/users/vdaubry/repos","events_url":"https://api.github.com/users/vdaubry/events{/privacy}","received_events_url":"https://api.github.com/users/vdaubry/received_events","type":"User","site_admin":false},"body":"This PR streams requests from typhoeus and abort them as soon as enough data as been downloaded to get the type and size of image. Solves #1 \r\n\r\nThe speed improvement is huge for large image or connection to slow hosts :\r\n\r\nBefore :\r\n``` \r\n2.2.2 :003 > puts Benchmark.measure { ImageInfo.from(\"http://imgsv.imaging.nikon.com/lineup/dslr/d600/img/sample01/img_04_l.jpg\") }\r\n  1.520000   0.550000   2.070000 (122.197889)\r\n```\r\nAfter :\r\n``` \r\n2.2.2 :005 > puts Benchmark.measure { ImageInfo.from(\"http://imgsv.imaging.nikon.com/lineup/dslr/d600/img/sample01/img_04_l.jpg\") }\r\n  0.060000   0.020000   0.080000 ( 2.359798)\r\n```\r\n\r\nBut when downloading lots of small images there isn't any real difference. Ex: find size for all images of [unimpressedcats](http://unimpressedcats.tumblr.com/)\r\n\r\nBefore :\r\n``` \r\n2.2.2 :003 > puts Benchmark.measure { ImageInfo.from([\"http://hit-counter.info/hit.php?id=614340&counter=11\", \"http://i50.tinypic.com/oft2ky.gif\",\"http://41.media.tumblr.com/80d7139b2fef7f415b89836679a69ea7/tumblr_nrsc81iHo71ri5cmio1_500.jpg\", \"http://36.media.tumblr.com/60db7d23c38fc2e5ca23935c00518d13/tumblr_nlms7jr0Ca1qi17eeo1_500.jpg\", \"http://40.media.tumblr.com/013f06f3e3f44ac1fc6ebc50f8750393/tumblr_n7f6usGHGX1tqbr7ro1_500.jpg\"]) }\r\n  0.020000   0.010000   0.030000 (  0.426701)\r\n```\r\nAfter :\r\n``` \r\n2.2.2 :005 > puts Benchmark.measure { ImageInfo.from([\"http://hit-counter.info/hit.php?id=614340&counter=11\", \"http://i50.tinypic.com/oft2ky.gif\",\"http://41.media.tumblr.com/80d7139b2fef7f415b89836679a69ea7/tumblr_nrsc81iHo71ri5cmio1_500.jpg\", \"http://36.media.tumblr.com/60db7d23c38fc2e5ca23935c00518d13/tumblr_nlms7jr0Ca1qi17eeo1_500.jpg\", \"http://40.media.tumblr.com/013f06f3e3f44ac1fc6ebc50f8750393/tumblr_n7f6usGHGX1tqbr7ro1_500.jpg\"]) }\r\n  0.020000   0.010000   0.030000 (  0.416174)\r\n```","created_at":"2015-08-10T12:34:54Z","updated_at":"2015-08-11T07:40:51Z","closed_at":null,"merged_at":null,"merge_commit_sha":"52ba8add2c564a9aa4abdd5c6f9ef475343e48fe","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/gottfrois/image_info/pulls/4/commits","review_comments_url":"https://api.github.com/repos/gottfrois/image_info/pulls/4/comments","review_comment_url":"https://api.github.com/repos/gottfrois/image_info/pulls/comments{/number}","comments_url":"https://api.github.com/repos/gottfrois/image_info/issues/4/comments","statuses_url":"https://api.github.com/repos/gottfrois/image_info/statuses/025f154fc5fccaaaf0719e18511e4496e5cdafd2","head":{"label":"vdaubry:downlad_just_enough_data","ref":"downlad_just_enough_data","sha":"025f154fc5fccaaaf0719e18511e4496e5cdafd2","user":{"login":"vdaubry","id":498298,"avatar_url":"https://avatars.githubusercontent.com/u/498298?v=3","gravatar_id":"","url":"https://api.github.com/users/vdaubry","html_url":"https://github.com/vdaubry","followers_url":"https://api.github.com/users/vdaubry/followers","following_url":"https://api.github.com/users/vdaubry/following{/other_user}","gists_url":"https://api.github.com/users/vdaubry/gists{/gist_id}","starred_url":"https://api.github.com/users/vdaubry/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vdaubry/subscriptions","organizations_url":"https://api.github.com/users/vdaubry/orgs","repos_url":"https://api.github.com/users/vdaubry/repos","events_url":"https://api.github.com/users/vdaubry/events{/privacy}","received_events_url":"https://api.github.com/users/vdaubry/received_events","type":"User","site_admin":false},"repo":{"id":40474709,"name":"image_info","full_name":"vdaubry/image_info","owner":{"login":"vdaubry","id":498298,"avatar_url":"https://avatars.githubusercontent.com/u/498298?v=3","gravatar_id":"","url":"https://api.github.com/users/vdaubry","html_url":"https://github.com/vdaubry","followers_url":"https://api.github.com/users/vdaubry/followers","following_url":"https://api.github.com/users/vdaubry/following{/other_user}","gists_url":"https://api.github.com/users/vdaubry/gists{/gist_id}","starred_url":"https://api.github.com/users/vdaubry/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vdaubry/subscriptions","organizations_url":"https://api.github.com/users/vdaubry/orgs","repos_url":"https://api.github.com/users/vdaubry/repos","events_url":"https://api.github.com/users/vdaubry/events{/privacy}","received_events_url":"https://api.github.com/users/vdaubry/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/vdaubry/image_info","description":"ImageInfo finds the size and type of a single or multiple images from the web by fetching as little as needed in batches.","fork":true,"url":"https://api.github.com/repos/vdaubry/image_info","forks_url":"https://api.github.com/repos/vdaubry/image_info/forks","keys_url":"https://api.github.com/repos/vdaubry/image_info/keys{/key_id}","collaborators_url":"https://api.github.com/repos/vdaubry/image_info/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/vdaubry/image_info/teams","hooks_url":"https://api.github.com/repos/vdaubry/image_info/hooks","issue_events_url":"https://api.github.com/repos/vdaubry/image_info/issues/events{/number}","events_url":"https://api.github.com/repos/vdaubry/image_info/events","assignees_url":"https://api.github.com/repos/vdaubry/image_info/assignees{/user}","branches_url":"https://api.github.com/repos/vdaubry/image_info/branches{/branch}","tags_url":"https://api.github.com/repos/vdaubry/image_info/tags","blobs_url":"https://api.github.com/repos/vdaubry/image_info/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/vdaubry/image_info/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/vdaubry/image_info/git/refs{/sha}","trees_url":"https://api.github.com/repos/vdaubry/image_info/git/trees{/sha}","statuses_url":"https://api.github.com/repos/vdaubry/image_info/statuses/{sha}","languages_url":"https://api.github.com/repos/vdaubry/image_info/languages","stargazers_url":"https://api.github.com/repos/vdaubry/image_info/stargazers","contributors_url":"https://api.github.com/repos/vdaubry/image_info/contributors","subscribers_url":"https://api.github.com/repos/vdaubry/image_info/subscribers","subscription_url":"https://api.github.com/repos/vdaubry/image_info/subscription","commits_url":"https://api.github.com/repos/vdaubry/image_info/commits{/sha}","git_commits_url":"https://api.github.com/repos/vdaubry/image_info/git/commits{/sha}","comments_url":"https://api.github.com/repos/vdaubry/image_info/comments{/number}","issue_comment_url":"https://api.github.com/repos/vdaubry/image_info/issues/comments{/number}","contents_url":"https://api.github.com/repos/vdaubry/image_info/contents/{+path}","compare_url":"https://api.github.com/repos/vdaubry/image_info/compare/{base}...{head}","merges_url":"https://api.github.com/repos/vdaubry/image_info/merges","archive_url":"https://api.github.com/repos/vdaubry/image_info/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/vdaubry/image_info/downloads","issues_url":"https://api.github.com/repos/vdaubry/image_info/issues{/number}","pulls_url":"https://api.github.com/repos/vdaubry/image_info/pulls{/number}","milestones_url":"https://api.github.com/repos/vdaubry/image_info/milestones{/number}","notifications_url":"https://api.github.com/repos/vdaubry/image_info/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/vdaubry/image_info/labels{/name}","releases_url":"https://api.github.com/repos/vdaubry/image_info/releases{/id}","created_at":"2015-08-10T09:35:09Z","updated_at":"2015-08-10T09:35:09Z","pushed_at":"2015-08-10T12:14:20Z","git_url":"git://github.com/vdaubry/image_info.git","ssh_url":"git@github.com:vdaubry/image_info.git","clone_url":"https://github.com/vdaubry/image_info.git","svn_url":"https://github.com/vdaubry/image_info","homepage":null,"size":434,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"gottfrois:master","ref":"master","sha":"1491a769dd6e0bfd0825ac81d7c9c54079b95ae3","user":{"login":"gottfrois","id":943784,"avatar_url":"https://avatars.githubusercontent.com/u/943784?v=3","gravatar_id":"","url":"https://api.github.com/users/gottfrois","html_url":"https://github.com/gottfrois","followers_url":"https://api.github.com/users/gottfrois/followers","following_url":"https://api.github.com/users/gottfrois/following{/other_user}","gists_url":"https://api.github.com/users/gottfrois/gists{/gist_id}","starred_url":"https://api.github.com/users/gottfrois/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gottfrois/subscriptions","organizations_url":"https://api.github.com/users/gottfrois/orgs","repos_url":"https://api.github.com/users/gottfrois/repos","events_url":"https://api.github.com/users/gottfrois/events{/privacy}","received_events_url":"https://api.github.com/users/gottfrois/received_events","type":"User","site_admin":false},"repo":{"id":38487872,"name":"image_info","full_name":"gottfrois/image_info","owner":{"login":"gottfrois","id":943784,"avatar_url":"https://avatars.githubusercontent.com/u/943784?v=3","gravatar_id":"","url":"https://api.github.com/users/gottfrois","html_url":"https://github.com/gottfrois","followers_url":"https://api.github.com/users/gottfrois/followers","following_url":"https://api.github.com/users/gottfrois/following{/other_user}","gists_url":"https://api.github.com/users/gottfrois/gists{/gist_id}","starred_url":"https://api.github.com/users/gottfrois/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gottfrois/subscriptions","organizations_url":"https://api.github.com/users/gottfrois/orgs","repos_url":"https://api.github.com/users/gottfrois/repos","events_url":"https://api.github.com/users/gottfrois/events{/privacy}","received_events_url":"https://api.github.com/users/gottfrois/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/gottfrois/image_info","description":"ImageInfo finds the size and type of a single or multiple images from the web by fetching as little as needed in batches.","fork":false,"url":"https://api.github.com/repos/gottfrois/image_info","forks_url":"https://api.github.com/repos/gottfrois/image_info/forks","keys_url":"https://api.github.com/repos/gottfrois/image_info/keys{/key_id}","collaborators_url":"https://api.github.com/repos/gottfrois/image_info/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/gottfrois/image_info/teams","hooks_url":"https://api.github.com/repos/gottfrois/image_info/hooks","issue_events_url":"https://api.github.com/repos/gottfrois/image_info/issues/events{/number}","events_url":"https://api.github.com/repos/gottfrois/image_info/events","assignees_url":"https://api.github.com/repos/gottfrois/image_info/assignees{/user}","branches_url":"https://api.github.com/repos/gottfrois/image_info/branches{/branch}","tags_url":"https://api.github.com/repos/gottfrois/image_info/tags","blobs_url":"https://api.github.com/repos/gottfrois/image_info/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/gottfrois/image_info/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/gottfrois/image_info/git/refs{/sha}","trees_url":"https://api.github.com/repos/gottfrois/image_info/git/trees{/sha}","statuses_url":"https://api.github.com/repos/gottfrois/image_info/statuses/{sha}","languages_url":"https://api.github.com/repos/gottfrois/image_info/languages","stargazers_url":"https://api.github.com/repos/gottfrois/image_info/stargazers","contributors_url":"https://api.github.com/repos/gottfrois/image_info/contributors","subscribers_url":"https://api.github.com/repos/gottfrois/image_info/subscribers","subscription_url":"https://api.github.com/repos/gottfrois/image_info/subscription","commits_url":"https://api.github.com/repos/gottfrois/image_info/commits{/sha}","git_commits_url":"https://api.github.com/repos/gottfrois/image_info/git/commits{/sha}","comments_url":"https://api.github.com/repos/gottfrois/image_info/comments{/number}","issue_comment_url":"https://api.github.com/repos/gottfrois/image_info/issues/comments{/number}","contents_url":"https://api.github.com/repos/gottfrois/image_info/contents/{+path}","compare_url":"https://api.github.com/repos/gottfrois/image_info/compare/{base}...{head}","merges_url":"https://api.github.com/repos/gottfrois/image_info/merges","archive_url":"https://api.github.com/repos/gottfrois/image_info/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/gottfrois/image_info/downloads","issues_url":"https://api.github.com/repos/gottfrois/image_info/issues{/number}","pulls_url":"https://api.github.com/repos/gottfrois/image_info/pulls{/number}","milestones_url":"https://api.github.com/repos/gottfrois/image_info/milestones{/number}","notifications_url":"https://api.github.com/repos/gottfrois/image_info/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/gottfrois/image_info/labels{/name}","releases_url":"https://api.github.com/repos/gottfrois/image_info/releases{/id}","created_at":"2015-07-03T10:46:11Z","updated_at":"2015-08-06T08:41:49Z","pushed_at":"2015-08-10T12:34:55Z","git_url":"git://github.com/gottfrois/image_info.git","ssh_url":"git@github.com:gottfrois/image_info.git","clone_url":"https://github.com/gottfrois/image_info.git","svn_url":"https://github.com/gottfrois/image_info","homepage":null,"size":497,"stargazers_count":43,"watchers_count":43,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4,"mirror_url":null,"open_issues_count":2,"forks":4,"open_issues":2,"watchers":43,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/gottfrois/image_info/pulls/4"},"html":{"href":"https://github.com/gottfrois/image_info/pull/4"},"issue":{"href":"https://api.github.com/repos/gottfrois/image_info/issues/4"},"comments":{"href":"https://api.github.com/repos/gottfrois/image_info/issues/4/comments"},"review_comments":{"href":"https://api.github.com/repos/gottfrois/image_info/pulls/4/comments"},"review_comment":{"href":"https://api.github.com/repos/gottfrois/image_info/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/gottfrois/image_info/pulls/4/commits"},"statuses":{"href":"https://api.github.com/repos/gottfrois/image_info/statuses/025f154fc5fccaaaf0719e18511e4496e5cdafd2"}}}}