twitter-text 1.7.0 → 1.8.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/.travis.yml +4 -0
- data/README.rdoc +1 -1
- data/Rakefile +1 -1
- data/lib/twitter-text/autolink.rb +4 -4
- data/lib/twitter-text/regex.rb +14 -1
- data/spec/autolinking_spec.rb +8 -0
- data/spec/spec_helper.rb +1 -1
- data/test/conformance_test.rb +20 -4
- 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: 5f1bec22f1774f73007ab1490af65c1a5ad75786
|
4
|
+
data.tar.gz: bf7463dedb6b11bdc70146d6076132c4d181ba98
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7756ea6edc3d0a818cc5c4f112c42fcea8d79ff52655e0b15207ed29467c09476d36e0a707e6324d8afef04bf35760199c6363043197d32bfff80ad78a5d71f7
|
7
|
+
data.tar.gz: 0a8b3ad25d09d4dee903b1579d1a549dade610863bd1e19cd0258f76415462de838a0fd9c3ce7633db1e59229a71f1d7d28a33cef374abdee3e807e0eb8ec7a1
|
data/.travis.yml
CHANGED
data/README.rdoc
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
== twitter-text {<img src="https://secure.travis-ci.org/twitter/twitter-text-rb.png" />}[http://travis-ci.org/twitter/twitter-text-rb] {<img src="https://codeclimate.com/badge.png" />}[https://codeclimate.com/github/twitter/twitter-text-rb]
|
1
|
+
== twitter-text {<img src="https://secure.travis-ci.org/twitter/twitter-text-rb.png?branch=master" />}[http://travis-ci.org/twitter/twitter-text-rb] {<img src="https://codeclimate.com/badge.png" />}[https://codeclimate.com/github/twitter/twitter-text-rb]
|
2
2
|
|
3
3
|
A gem that provides text processing routines for Twitter Tweets. The major
|
4
4
|
reason for this is to unify the various auto-linking and extraction of
|
data/Rakefile
CHANGED
@@ -64,7 +64,7 @@ module Twitter
|
|
64
64
|
options[:html_attrs] = extract_html_attrs_from_options!(options)
|
65
65
|
options[:html_attrs][:rel] ||= "nofollow" unless options[:suppress_no_follow]
|
66
66
|
|
67
|
-
Twitter::Rewriter.rewrite_entities(text, entities) do |entity, chars|
|
67
|
+
Twitter::Rewriter.rewrite_entities(text.dup, entities) do |entity, chars|
|
68
68
|
if entity[:url]
|
69
69
|
link_to_url(entity, chars, options, &block)
|
70
70
|
elsif entity[:hashtag]
|
@@ -370,9 +370,9 @@ module Twitter
|
|
370
370
|
|
371
371
|
def link_to_screen_name(entity, chars, options = {})
|
372
372
|
name = "#{entity[:screen_name]}#{entity[:list_slug]}"
|
373
|
-
|
374
|
-
chunk =
|
375
|
-
|
373
|
+
|
374
|
+
chunk = name.dup
|
375
|
+
chunk = yield(chunk) if block_given?
|
376
376
|
|
377
377
|
at = chars[entity[:indices].first]
|
378
378
|
|
data/lib/twitter-text/regex.rb
CHANGED
@@ -187,7 +187,20 @@ module Twitter
|
|
187
187
|
REGEXEN[:valid_subdomain] = /(?:(?:#{DOMAIN_VALID_CHARS}(?:[_-]|#{DOMAIN_VALID_CHARS})*)?#{DOMAIN_VALID_CHARS}\.)/io
|
188
188
|
REGEXEN[:valid_domain_name] = /(?:(?:#{DOMAIN_VALID_CHARS}(?:[-]|#{DOMAIN_VALID_CHARS})*)?#{DOMAIN_VALID_CHARS}\.)/io
|
189
189
|
|
190
|
-
REGEXEN[:valid_gTLD] =
|
190
|
+
REGEXEN[:valid_gTLD] = %r{
|
191
|
+
(?:
|
192
|
+
(?:academy|aero|agency|arpa|asia|bargains|berlin|bike|biz|blue|boutique|build|builders|buzz|cab|camera|camp|careers|cat|catering|
|
193
|
+
center|ceo|cheap|cleaning|clothing|club|codes|coffee|com|community|company|computer|construction|contractors|cool|coop|cruises|
|
194
|
+
dance|dating|democrat|diamonds|directory|domains|edu|education|email|enterprises|equipment|estate|events|expert|exposed|farm|
|
195
|
+
flights|florist|gallery|gift|glass|gov|graphics|guitars|guru|holdings|holiday|house|immobilien|info|institute|int|international|
|
196
|
+
jobs|kaufen|kim|kitchen|kiwi|land|lighting|limo|link|luxury|management|marketing|menu|mil|mobi|moda|monash|museum|nagoya|name|net|
|
197
|
+
ninja|onl|org|partners|photo|photography|photos|pics|pink|plumbing|post|pro|properties|recipes|red|rentals|repair|report|rich|ruhr|
|
198
|
+
sexy|shiksha|shoes|singles|social|solar|solutions|support|systems|tattoo|technology|tel|tienda|tips|today|tokyo|tools|training|
|
199
|
+
travel|uno|ventures|viajes|voting|voyage|wang|watch|wed|wien|works|xxx|zone)
|
200
|
+
(?=[^0-9a-z@]|$)
|
201
|
+
)
|
202
|
+
}ix
|
203
|
+
|
191
204
|
REGEXEN[:valid_ccTLD] = %r{
|
192
205
|
(?:
|
193
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|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|
|
data/spec/autolinking_spec.rb
CHANGED
@@ -23,6 +23,14 @@ describe Twitter::Autolink do
|
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
|
+
context "username in camelCase" do
|
27
|
+
def original_text() "@jaCob iS cOoL" end
|
28
|
+
|
29
|
+
it "should be linked" do
|
30
|
+
@autolinked_text.should link_to_screen_name('jaCob')
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
26
34
|
context "username at beginning of line" do
|
27
35
|
def original_text; "@jacob you're cool"; end
|
28
36
|
|
data/spec/spec_helper.rb
CHANGED
@@ -59,7 +59,7 @@ RSpec::Matchers.define :link_to_screen_name do |screen_name, inner_text|
|
|
59
59
|
@link = Nokogiri::HTML(text).search("a.username")
|
60
60
|
@link &&
|
61
61
|
@link.inner_text == expected &&
|
62
|
-
"https://twitter.com/#{screen_name}".
|
62
|
+
"https://twitter.com/#{screen_name}".should == @link.first['href']
|
63
63
|
end
|
64
64
|
|
65
65
|
failure_message_for_should do |text|
|
data/test/conformance_test.rb
CHANGED
@@ -3,9 +3,11 @@ require 'nokogiri'
|
|
3
3
|
require 'test/unit'
|
4
4
|
require 'yaml'
|
5
5
|
|
6
|
-
# Ruby 1.8 encoding
|
6
|
+
# Detect Ruby 1.8 and older to apply necessary encoding fixes
|
7
7
|
major, minor, patch = RUBY_VERSION.split('.')
|
8
|
-
|
8
|
+
OLD_RUBY = major.to_i == 1 && minor.to_i < 9
|
9
|
+
|
10
|
+
if OLD_RUBY
|
9
11
|
$KCODE='u'
|
10
12
|
end
|
11
13
|
|
@@ -19,12 +21,24 @@ class ConformanceTest < Test::Unit::TestCase
|
|
19
21
|
|
20
22
|
private
|
21
23
|
|
22
|
-
%w(description expected
|
24
|
+
%w(description expected json hits).each do |key|
|
23
25
|
define_method key.to_sym do
|
24
26
|
@test_info[key]
|
25
27
|
end
|
26
28
|
end
|
27
29
|
|
30
|
+
if OLD_RUBY
|
31
|
+
def text
|
32
|
+
@test_info['text'].gsub(/\\u([0-9a-f]{8})/i) do
|
33
|
+
[$1.to_i(16)].pack('U*')
|
34
|
+
end
|
35
|
+
end
|
36
|
+
else
|
37
|
+
def text
|
38
|
+
@test_info['text']
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
28
42
|
def assert_equal_without_attribute_order(expected, actual, failure_message = nil)
|
29
43
|
assert_block(build_message(failure_message, "<?> expected but was\n<?>", expected, actual)) do
|
30
44
|
equal_nodes?(Nokogiri::HTML(expected).root, Nokogiri::HTML(actual).root)
|
@@ -53,8 +67,10 @@ class ConformanceTest < Test::Unit::TestCase
|
|
53
67
|
yaml = YAML.load_file(File.join(CONFORMANCE_DIR, file))
|
54
68
|
raise "No such test suite: #{test_type.to_s}" unless yaml["tests"][test_type.to_s]
|
55
69
|
|
70
|
+
file_name = file.split('.').first
|
71
|
+
|
56
72
|
yaml["tests"][test_type.to_s].each do |test_info|
|
57
|
-
name = :"test_#{test_type} #{test_info['description']}"
|
73
|
+
name = :"test_#{file_name}_#{test_type} #{test_info['description']}"
|
58
74
|
define_method name do
|
59
75
|
@test_info = test_info
|
60
76
|
instance_eval(&block)
|
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.8.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.8.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:
|
19
|
+
date: 2014-02-25 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
|
-
-
|
135
|
-
-
|
136
|
-
-
|
137
|
-
-
|
138
|
-
-
|
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.1.11
|
188
188
|
signing_key:
|
189
189
|
specification_version: 4
|
190
190
|
summary: Twitter text handling library
|