imagize 0.5.1 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -0
- data/VERSION +1 -1
- data/imagize.gemspec +23 -27
- data/lib/imagize.rb +33 -6
- data/spec/imagize_spec.rb +4 -1
- metadata +31 -14
- data/.gitignore +0 -21
data/Rakefile
CHANGED
@@ -11,6 +11,7 @@ begin
|
|
11
11
|
gem.homepage = "http://github.com/dongelen/imagize"
|
12
12
|
gem.authors = ["Raymond van Dongelen"]
|
13
13
|
gem.add_development_dependency "rspec", ">= 1.2.9"
|
14
|
+
gem.add_dependency "cloudapp_api"
|
14
15
|
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
15
16
|
end
|
16
17
|
Jeweler::GemcutterTasks.new
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.6.0
|
data/imagize.gemspec
CHANGED
@@ -1,55 +1,51 @@
|
|
1
1
|
# Generated by jeweler
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
|
-
s.name =
|
8
|
-
s.version = "0.
|
7
|
+
s.name = "imagize"
|
8
|
+
s.version = "0.6.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Raymond van Dongelen"]
|
12
|
-
s.date =
|
13
|
-
s.description =
|
14
|
-
s.email =
|
12
|
+
s.date = "2011-09-05"
|
13
|
+
s.description = "Retrieve images from a tweet"
|
14
|
+
s.email = "dongelen@nhl.nl"
|
15
15
|
s.extra_rdoc_files = [
|
16
16
|
"LICENSE",
|
17
|
-
|
17
|
+
"README.rdoc"
|
18
18
|
]
|
19
19
|
s.files = [
|
20
20
|
".document",
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
"lib/imagize.rb",
|
28
|
-
"spec/imagize_spec.rb",
|
29
|
-
"spec/spec.opts",
|
30
|
-
"spec/spec_helper.rb"
|
31
|
-
]
|
32
|
-
s.homepage = %q{http://github.com/dongelen/imagize}
|
33
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
34
|
-
s.require_paths = ["lib"]
|
35
|
-
s.rubygems_version = %q{1.3.6}
|
36
|
-
s.summary = %q{Retrieve images from a tweet}
|
37
|
-
s.test_files = [
|
21
|
+
"LICENSE",
|
22
|
+
"README.rdoc",
|
23
|
+
"Rakefile",
|
24
|
+
"VERSION",
|
25
|
+
"imagize.gemspec",
|
26
|
+
"lib/imagize.rb",
|
38
27
|
"spec/imagize_spec.rb",
|
39
|
-
|
28
|
+
"spec/spec.opts",
|
29
|
+
"spec/spec_helper.rb"
|
40
30
|
]
|
31
|
+
s.homepage = "http://github.com/dongelen/imagize"
|
32
|
+
s.require_paths = ["lib"]
|
33
|
+
s.rubygems_version = "1.8.10"
|
34
|
+
s.summary = "Retrieve images from a tweet"
|
41
35
|
|
42
36
|
if s.respond_to? :specification_version then
|
43
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
44
37
|
s.specification_version = 3
|
45
38
|
|
46
|
-
if Gem::Version.new(Gem::
|
39
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
47
40
|
s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
|
41
|
+
s.add_runtime_dependency(%q<cloudapp_api>, [">= 0"])
|
48
42
|
else
|
49
43
|
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
44
|
+
s.add_dependency(%q<cloudapp_api>, [">= 0"])
|
50
45
|
end
|
51
46
|
else
|
52
47
|
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
48
|
+
s.add_dependency(%q<cloudapp_api>, [">= 0"])
|
53
49
|
end
|
54
50
|
end
|
55
51
|
|
data/lib/imagize.rb
CHANGED
@@ -1,9 +1,11 @@
|
|
1
|
+
require "rubygems"
|
1
2
|
require "net/http"
|
2
3
|
require "uri"
|
4
|
+
require 'cloudapp_api'
|
3
5
|
|
4
|
-
module Imagize
|
5
6
|
|
6
|
-
|
7
|
+
module Imagize
|
8
|
+
|
7
9
|
URL_DEFINITIONS = {
|
8
10
|
:twitpic => {
|
9
11
|
:url => "http://twitpic.com/",
|
@@ -82,6 +84,8 @@ module Imagize
|
|
82
84
|
YOUTUBE_LONG_URL="www.youtube.com/watch"
|
83
85
|
YOUTUBE_LONG_CONVERT_URL="http://img.youtube.com/vi/§ID§/0.jpg"
|
84
86
|
|
87
|
+
CLOUD_APP = "http://cl.ly/"
|
88
|
+
|
85
89
|
class Imagizer
|
86
90
|
|
87
91
|
def imagize(message, extract_shorteners=false)
|
@@ -94,7 +98,7 @@ module Imagize
|
|
94
98
|
SHORTENERS.each do |service, details|
|
95
99
|
currentService = details[:url]
|
96
100
|
tweet.scan /#{currentService}\w*/ do |current|
|
97
|
-
tweet = tweet.sub
|
101
|
+
tweet = tweet.sub(current, extract_shortener(current))
|
98
102
|
end
|
99
103
|
end
|
100
104
|
end
|
@@ -104,9 +108,25 @@ module Imagize
|
|
104
108
|
currentService = details[:url]
|
105
109
|
tweet.scan /#{currentService}\w*/ do |current|
|
106
110
|
code = current.sub(currentService, "")
|
107
|
-
images << make_url
|
111
|
+
images << make_url(service, code)
|
108
112
|
end
|
109
|
-
end
|
113
|
+
end
|
114
|
+
|
115
|
+
|
116
|
+
#Find cl.ly
|
117
|
+
tweet.scan /#{CLOUD_APP}\w*/ do |current|
|
118
|
+
p "Current is " + current
|
119
|
+
code = current.sub(CLOUD_APP, "")
|
120
|
+
p code
|
121
|
+
|
122
|
+
add_cloud_app_image images, code
|
123
|
+
|
124
|
+
|
125
|
+
end
|
126
|
+
|
127
|
+
#Find shorteners that use cl.ly
|
128
|
+
# Resolv.getaddress "dirk.si"
|
129
|
+
|
110
130
|
|
111
131
|
# long youtube
|
112
132
|
tweet.scan /#{YOUTUBE_LONG_URL}\?v=\w*/ do |current|
|
@@ -114,7 +134,7 @@ module Imagize
|
|
114
134
|
code = current.sub(YOUTUBE_LONG_URL+"?v=", "")
|
115
135
|
p code
|
116
136
|
|
117
|
-
images << make_youtube_url
|
137
|
+
images << make_youtube_url(code)
|
118
138
|
|
119
139
|
end
|
120
140
|
|
@@ -143,5 +163,12 @@ module Imagize
|
|
143
163
|
def make_youtube_url (code)
|
144
164
|
YOUTUBE_LONG_CONVERT_URL.gsub "§ID§", code
|
145
165
|
end
|
166
|
+
|
167
|
+
def add_cloud_app_image(images, code)
|
168
|
+
drop = CloudApp::Drop.find code
|
169
|
+
if drop.image?
|
170
|
+
images << drop.remote_url
|
171
|
+
end
|
172
|
+
end
|
146
173
|
end
|
147
174
|
end
|
data/spec/imagize_spec.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
2
|
include Imagize
|
3
|
-
|
4
3
|
describe "Imagize" do
|
5
4
|
before (:all) do
|
6
5
|
@imagizer = Imagize::Imagizer.new
|
@@ -139,5 +138,9 @@ describe "Imagize" do
|
|
139
138
|
@imagizer.imagize("This is some message http://is.gd/bSD5l but shortened", true).should include "http://www.hi.com/1/2/3/x.gif"
|
140
139
|
end
|
141
140
|
|
141
|
+
it "shoud recognize cloud app url" do
|
142
|
+
@imagizer.imagize("This is some message http://cl.ly/2wr4").should include "http://f.cl.ly/items/7c7aea1395c3db0aee18/CloudApp%20Logo.png"
|
143
|
+
|
144
|
+
end
|
142
145
|
|
143
146
|
end
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: imagize
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
hash: 7
|
5
|
+
prerelease:
|
5
6
|
segments:
|
6
7
|
- 0
|
7
|
-
-
|
8
|
-
-
|
9
|
-
version: 0.
|
8
|
+
- 6
|
9
|
+
- 0
|
10
|
+
version: 0.6.0
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Raymond van Dongelen
|
@@ -14,16 +15,17 @@ autorequire:
|
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
17
|
|
17
|
-
date: 2011-
|
18
|
-
default_executable:
|
18
|
+
date: 2011-09-05 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: rspec
|
22
22
|
prerelease: false
|
23
23
|
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
24
25
|
requirements:
|
25
26
|
- - ">="
|
26
27
|
- !ruby/object:Gem::Version
|
28
|
+
hash: 13
|
27
29
|
segments:
|
28
30
|
- 1
|
29
31
|
- 2
|
@@ -31,6 +33,20 @@ dependencies:
|
|
31
33
|
version: 1.2.9
|
32
34
|
type: :development
|
33
35
|
version_requirements: *id001
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: cloudapp_api
|
38
|
+
prerelease: false
|
39
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
41
|
+
requirements:
|
42
|
+
- - ">="
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
hash: 3
|
45
|
+
segments:
|
46
|
+
- 0
|
47
|
+
version: "0"
|
48
|
+
type: :runtime
|
49
|
+
version_requirements: *id002
|
34
50
|
description: Retrieve images from a tweet
|
35
51
|
email: dongelen@nhl.nl
|
36
52
|
executables: []
|
@@ -42,7 +58,6 @@ extra_rdoc_files:
|
|
42
58
|
- README.rdoc
|
43
59
|
files:
|
44
60
|
- .document
|
45
|
-
- .gitignore
|
46
61
|
- LICENSE
|
47
62
|
- README.rdoc
|
48
63
|
- Rakefile
|
@@ -52,36 +67,38 @@ files:
|
|
52
67
|
- spec/imagize_spec.rb
|
53
68
|
- spec/spec.opts
|
54
69
|
- spec/spec_helper.rb
|
55
|
-
has_rdoc: true
|
56
70
|
homepage: http://github.com/dongelen/imagize
|
57
71
|
licenses: []
|
58
72
|
|
59
73
|
post_install_message:
|
60
|
-
rdoc_options:
|
61
|
-
|
74
|
+
rdoc_options: []
|
75
|
+
|
62
76
|
require_paths:
|
63
77
|
- lib
|
64
78
|
required_ruby_version: !ruby/object:Gem::Requirement
|
79
|
+
none: false
|
65
80
|
requirements:
|
66
81
|
- - ">="
|
67
82
|
- !ruby/object:Gem::Version
|
83
|
+
hash: 3
|
68
84
|
segments:
|
69
85
|
- 0
|
70
86
|
version: "0"
|
71
87
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
88
|
+
none: false
|
72
89
|
requirements:
|
73
90
|
- - ">="
|
74
91
|
- !ruby/object:Gem::Version
|
92
|
+
hash: 3
|
75
93
|
segments:
|
76
94
|
- 0
|
77
95
|
version: "0"
|
78
96
|
requirements: []
|
79
97
|
|
80
98
|
rubyforge_project:
|
81
|
-
rubygems_version: 1.
|
99
|
+
rubygems_version: 1.8.10
|
82
100
|
signing_key:
|
83
101
|
specification_version: 3
|
84
102
|
summary: Retrieve images from a tweet
|
85
|
-
test_files:
|
86
|
-
|
87
|
-
- spec/spec_helper.rb
|
103
|
+
test_files: []
|
104
|
+
|