twitter-text 1.8.0 → 1.9.0
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.
- checksums.yaml +4 -4
- data/lib/twitter-text/autolink.rb +3 -1
- data/lib/twitter-text/regex.rb +22 -14
- data/spec/autolinking_spec.rb +10 -0
- data/spec/test_urls.rb +4 -1
- data/test/conformance_test.rb +2 -1
- data/twitter-text.gemspec +1 -1
- metadata +24 -24
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d032fd2fa1300bbc000a2e7a8f718fc5a7b33e12
|
4
|
+
data.tar.gz: ac18985474a651ee6ca291e9cdb5fc7116f2d346
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7f2c3e340d6768091cc0cfca016f0fbb292deae6f02b6aa4045ce353aadd0e538195b5ed71abb285a82eae40fbdf7c9751271430ea1874f8087b1f1e7b5ed3a5
|
7
|
+
data.tar.gz: d5ab53a8920d232b2b1c6cdf03e6d5a723d12923d2da461329181af0ceb166cac8c034a3f4f715061cf6d007b00aadb745a97817d47984b6f770a86ddb6a8ba6
|
@@ -63,6 +63,7 @@ module Twitter
|
|
63
63
|
options = DEFAULT_OPTIONS.merge(options)
|
64
64
|
options[:html_attrs] = extract_html_attrs_from_options!(options)
|
65
65
|
options[:html_attrs][:rel] ||= "nofollow" unless options[:suppress_no_follow]
|
66
|
+
options[:html_attrs][:target] = "_blank" if options[:target_blank] == true
|
66
67
|
|
67
68
|
Twitter::Rewriter.rewrite_entities(text.dup, entities) do |entity, chars|
|
68
69
|
if entity[:url]
|
@@ -98,6 +99,7 @@ module Twitter
|
|
98
99
|
# <tt>:symbol_tag</tt>:: tag to apply around symbol (@, #, $) in username / hashtag / cashtag links
|
99
100
|
# <tt>:text_with_symbol_tag</tt>:: tag to apply around text part in username / hashtag / cashtag links
|
100
101
|
# <tt>:url_target</tt>:: the value for <tt>target</tt> attribute on URL links.
|
102
|
+
# <tt>:target_blank</tt>:: adds <tt>target="_blank"</tt> to all auto_linked items username / hashtag / cashtag links / urls
|
101
103
|
# <tt>:link_attribute_block</tt>:: function to modify the attributes of a link based on the entity. called with |entity, attributes| params, and should modify the attributes hash.
|
102
104
|
# <tt>:link_text_block</tt>:: function to modify the text of a link based on the entity. called with |entity, text| params, and should return a modified text.
|
103
105
|
def auto_link(text, options = {}, &block)
|
@@ -210,7 +212,7 @@ module Twitter
|
|
210
212
|
:username_url_base, :list_url_base, :hashtag_url_base, :cashtag_url_base,
|
211
213
|
:username_url_block, :list_url_block, :hashtag_url_block, :cashtag_url_block, :link_url_block,
|
212
214
|
:username_include_symbol, :suppress_lists, :suppress_no_follow, :url_entities,
|
213
|
-
:invisible_tag_attrs, :symbol_tag, :text_with_symbol_tag, :url_target,
|
215
|
+
:invisible_tag_attrs, :symbol_tag, :text_with_symbol_tag, :url_target, :target_blank,
|
214
216
|
:link_attribute_block, :link_text_block
|
215
217
|
]).freeze
|
216
218
|
|
data/lib/twitter-text/regex.rb
CHANGED
@@ -189,26 +189,34 @@ module Twitter
|
|
189
189
|
|
190
190
|
REGEXEN[:valid_gTLD] = %r{
|
191
191
|
(?:
|
192
|
-
(?:academy|aero|agency|arpa|asia|bargains|berlin|bike|biz|blue|boutique|build|builders|
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
192
|
+
(?:academy|actor|aero|agency|arpa|asia|bar|bargains|berlin|best|bid|bike|biz|blue|boutique|build|builders|
|
193
|
+
buzz|cab|camera|camp|cards|careers|cat|catering|center|ceo|cheap|christmas|cleaning|clothing|club|codes|
|
194
|
+
coffee|com|community|company|computer|construction|contractors|cool|coop|cruises|dance|dating|democrat|
|
195
|
+
diamonds|directory|domains|edu|education|email|enterprises|equipment|estate|events|expert|exposed|farm|fish|
|
196
|
+
flights|florist|foundation|futbol|gallery|gift|glass|gov|graphics|guitars|guru|holdings|holiday|house|
|
197
|
+
immobilien|industries|info|institute|int|international|jobs|kaufen|kim|kitchen|kiwi|koeln|kred|land|lighting|
|
198
|
+
limo|link|luxury|management|mango|marketing|menu|mil|mobi|moda|monash|museum|nagoya|name|net|neustar|ninja|
|
199
|
+
okinawa|onl|org|partners|parts|photo|photography|photos|pics|pink|plumbing|post|pro|productions|properties|
|
200
|
+
pub|qpon|recipes|red|rentals|repair|report|reviews|rich|ruhr|sexy|shiksha|shoes|singles|social|solar|
|
201
|
+
solutions|supplies|supply|support|systems|tattoo|technology|tel|tienda|tips|today|tokyo|tools|training|
|
202
|
+
travel|uno|vacations|ventures|viajes|villas|vision|vote|voting|voto|voyage|wang|watch|wed|wien|wiki|works|
|
203
|
+
xxx|xyz|zone|дети|онлайн|орг|сайт|بازار|شبكة|みんな|中信|中文网|公司|公益|在线|我爱你|政务|游戏|移动|网络|集团|삼성)
|
200
204
|
(?=[^0-9a-z@]|$)
|
201
205
|
)
|
202
206
|
}ix
|
203
207
|
|
204
208
|
REGEXEN[:valid_ccTLD] = %r{
|
205
209
|
(?:
|
206
|
-
(?:ac|ad|ae|af|ag|ai|al|am|an|ao|aq|ar|as|at|au|aw|ax|az|ba|bb|bd|be|bf|bg|bh|bi|bj|bm|bn|bo|br|bs|
|
207
|
-
ci|ck|cl|cm|cn|co|cr|
|
208
|
-
gn|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|
|
209
|
-
|
210
|
-
|
211
|
-
|
210
|
+
(?:ac|ad|ae|af|ag|ai|al|am|an|ao|aq|ar|as|at|au|aw|ax|az|ba|bb|bd|be|bf|bg|bh|bi|bj|bl|bm|bn|bo|bq|br|bs|
|
211
|
+
bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|cr|cu|cv|cw|cx|cy|cz|de|dj|dk|dm|do|dz|ec|ee|eg|eh|er|es|
|
212
|
+
et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gg|gh|gi|gl|gm|gn|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|
|
213
|
+
im|in|io|iq|ir|is|it|je|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|
|
214
|
+
me|mf|mg|mh|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|mv|mw|mx|my|mz|na|nc|ne|nf|ng|ni|nl|no|np|nr|nu|nz|om|pa|pe|pf|
|
215
|
+
pg|ph|pk|pl|pm|pn|pr|ps|pt|pw|py|qa|re|ro|rs|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|ss|st|su|sv|
|
216
|
+
sx|sy|sz|tc|td|tf|tg|th|tj|tk|tl|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|
|
217
|
+
ye|yt|za|zm|zw|мон|рф|срб|укр|қаз|الاردن|الجزائر|السعودية|المغرب|امارات|ایران|بھارت|تونس|سودان|سورية|عمان|فلسطين|قطر|مصر|مليسيا|پاکستان|
|
218
|
+
भारत|বাংলা|ভারত|ਭਾਰਤ|ભારત|இந்தியா|இலங்கை|சிங்கப்பூர்|భారత్|ලංකා|ไทย|გე|中国|中國|台湾|台灣|新加坡|
|
219
|
+
香港|한국)
|
212
220
|
(?=[^0-9a-z@]|$)
|
213
221
|
)
|
214
222
|
}ix
|
data/spec/autolinking_spec.rb
CHANGED
@@ -742,6 +742,16 @@ describe Twitter::Autolink do
|
|
742
742
|
auto_linked.should_not match(/<a[^>]+username[^>]+target[^>]+>/)
|
743
743
|
auto_linked.should match(/<a[^>]+test.com[^>]+target=\"_blank\"[^>]*>/)
|
744
744
|
end
|
745
|
+
|
746
|
+
it "should apply target='_blank' only to auto-linked URLs when :target_blank is set to true" do
|
747
|
+
auto_linked = @linker.auto_link("#hashtag @mention http://test.com/", {:target_blank => true})
|
748
|
+
auto_linked.should have_autolinked_hashtag('#hashtag')
|
749
|
+
auto_linked.should link_to_screen_name('mention')
|
750
|
+
auto_linked.should have_autolinked_url('http://test.com/')
|
751
|
+
auto_linked.should match(/<a[^>]+hashtag[^>]+target=\"_blank\"[^>]*>/)
|
752
|
+
auto_linked.should match(/<a[^>]+username[^>]+target=\"_blank\"[^>]*>/)
|
753
|
+
auto_linked.should match(/<a[^>]+test.com[^>]+target=\"_blank\"[^>]*>/)
|
754
|
+
end
|
745
755
|
end
|
746
756
|
|
747
757
|
describe "link_url_with_entity" do
|
data/spec/test_urls.rb
CHANGED
data/test/conformance_test.rb
CHANGED
@@ -11,7 +11,8 @@ if OLD_RUBY
|
|
11
11
|
$KCODE='u'
|
12
12
|
end
|
13
13
|
|
14
|
-
|
14
|
+
$:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
|
15
|
+
require 'twitter-text'
|
15
16
|
|
16
17
|
class ConformanceTest < Test::Unit::TestCase
|
17
18
|
include Twitter::Extractor
|
data/twitter-text.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = "twitter-text"
|
5
|
-
s.version = "1.
|
5
|
+
s.version = "1.9.0"
|
6
6
|
s.authors = ["Matt Sanford", "Patrick Ewing", "Ben Cherry", "Britt Selvitelle",
|
7
7
|
"Raffi Krikorian", "J.P. Cummins", "Yoshimasa Niwa", "Keita Fujii", "James Koval"]
|
8
8
|
s.email = ["matt@twitter.com", "patrick.henry.ewing@gmail.com", "bcherry@gmail.com", "bs@brittspace.com",
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: twitter-text
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Sanford
|
@@ -16,104 +16,104 @@ authors:
|
|
16
16
|
autorequire:
|
17
17
|
bindir: bin
|
18
18
|
cert_chain: []
|
19
|
-
date: 2014-
|
19
|
+
date: 2014-03-18 00:00:00.000000000 Z
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
22
|
name: multi_json
|
23
23
|
requirement: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
|
-
- - ~>
|
25
|
+
- - "~>"
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: '1.3'
|
28
28
|
type: :development
|
29
29
|
prerelease: false
|
30
30
|
version_requirements: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
|
-
- - ~>
|
32
|
+
- - "~>"
|
33
33
|
- !ruby/object:Gem::Version
|
34
34
|
version: '1.3'
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
36
|
name: nokogiri
|
37
37
|
requirement: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
|
-
- - ~>
|
39
|
+
- - "~>"
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: 1.5.10
|
42
42
|
type: :development
|
43
43
|
prerelease: false
|
44
44
|
version_requirements: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
|
-
- - ~>
|
46
|
+
- - "~>"
|
47
47
|
- !ruby/object:Gem::Version
|
48
48
|
version: 1.5.10
|
49
49
|
- !ruby/object:Gem::Dependency
|
50
50
|
name: rake
|
51
51
|
requirement: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
|
-
- -
|
53
|
+
- - ">="
|
54
54
|
- !ruby/object:Gem::Version
|
55
55
|
version: '0'
|
56
56
|
type: :development
|
57
57
|
prerelease: false
|
58
58
|
version_requirements: !ruby/object:Gem::Requirement
|
59
59
|
requirements:
|
60
|
-
- -
|
60
|
+
- - ">="
|
61
61
|
- !ruby/object:Gem::Version
|
62
62
|
version: '0'
|
63
63
|
- !ruby/object:Gem::Dependency
|
64
64
|
name: rdoc
|
65
65
|
requirement: !ruby/object:Gem::Requirement
|
66
66
|
requirements:
|
67
|
-
- -
|
67
|
+
- - ">="
|
68
68
|
- !ruby/object:Gem::Version
|
69
69
|
version: '0'
|
70
70
|
type: :development
|
71
71
|
prerelease: false
|
72
72
|
version_requirements: !ruby/object:Gem::Requirement
|
73
73
|
requirements:
|
74
|
-
- -
|
74
|
+
- - ">="
|
75
75
|
- !ruby/object:Gem::Version
|
76
76
|
version: '0'
|
77
77
|
- !ruby/object:Gem::Dependency
|
78
78
|
name: rspec
|
79
79
|
requirement: !ruby/object:Gem::Requirement
|
80
80
|
requirements:
|
81
|
-
- -
|
81
|
+
- - ">="
|
82
82
|
- !ruby/object:Gem::Version
|
83
83
|
version: '0'
|
84
84
|
type: :development
|
85
85
|
prerelease: false
|
86
86
|
version_requirements: !ruby/object:Gem::Requirement
|
87
87
|
requirements:
|
88
|
-
- -
|
88
|
+
- - ">="
|
89
89
|
- !ruby/object:Gem::Version
|
90
90
|
version: '0'
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: simplecov
|
93
93
|
requirement: !ruby/object:Gem::Requirement
|
94
94
|
requirements:
|
95
|
-
- -
|
95
|
+
- - ">="
|
96
96
|
- !ruby/object:Gem::Version
|
97
97
|
version: '0'
|
98
98
|
type: :development
|
99
99
|
prerelease: false
|
100
100
|
version_requirements: !ruby/object:Gem::Requirement
|
101
101
|
requirements:
|
102
|
-
- -
|
102
|
+
- - ">="
|
103
103
|
- !ruby/object:Gem::Version
|
104
104
|
version: '0'
|
105
105
|
- !ruby/object:Gem::Dependency
|
106
106
|
name: unf
|
107
107
|
requirement: !ruby/object:Gem::Requirement
|
108
108
|
requirements:
|
109
|
-
- - ~>
|
109
|
+
- - "~>"
|
110
110
|
- !ruby/object:Gem::Version
|
111
111
|
version: 0.1.0
|
112
112
|
type: :runtime
|
113
113
|
prerelease: false
|
114
114
|
version_requirements: !ruby/object:Gem::Requirement
|
115
115
|
requirements:
|
116
|
-
- - ~>
|
116
|
+
- - "~>"
|
117
117
|
- !ruby/object:Gem::Version
|
118
118
|
version: 0.1.0
|
119
119
|
description: A gem that provides text handling for Twitter
|
@@ -131,11 +131,11 @@ executables: []
|
|
131
131
|
extensions: []
|
132
132
|
extra_rdoc_files: []
|
133
133
|
files:
|
134
|
-
- .gemtest
|
135
|
-
- .gitignore
|
136
|
-
- .gitmodules
|
137
|
-
- .rspec
|
138
|
-
- .travis.yml
|
134
|
+
- ".gemtest"
|
135
|
+
- ".gitignore"
|
136
|
+
- ".gitmodules"
|
137
|
+
- ".rspec"
|
138
|
+
- ".travis.yml"
|
139
139
|
- Gemfile
|
140
140
|
- LICENSE
|
141
141
|
- README.rdoc
|
@@ -174,17 +174,17 @@ require_paths:
|
|
174
174
|
- lib
|
175
175
|
required_ruby_version: !ruby/object:Gem::Requirement
|
176
176
|
requirements:
|
177
|
-
- -
|
177
|
+
- - ">="
|
178
178
|
- !ruby/object:Gem::Version
|
179
179
|
version: '0'
|
180
180
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
181
181
|
requirements:
|
182
|
-
- -
|
182
|
+
- - ">="
|
183
183
|
- !ruby/object:Gem::Version
|
184
184
|
version: '0'
|
185
185
|
requirements: []
|
186
186
|
rubyforge_project:
|
187
|
-
rubygems_version: 2.
|
187
|
+
rubygems_version: 2.2.2
|
188
188
|
signing_key:
|
189
189
|
specification_version: 4
|
190
190
|
summary: Twitter text handling library
|