twitter-text 1.6.1 → 1.6.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/twitter-text/autolink.rb +3 -3
- data/lib/twitter-text/hash_helper.rb +21 -0
- data/lib/twitter-text/regex.rb +2 -2
- data/twitter-text.gemspec +3 -2
- metadata +42 -63
- data/lib/twitter-text/core_ext/hash.rb +0 -21
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 595273c391784101eaebd3ca2ddea9b9d0555e7d
|
4
|
+
data.tar.gz: 843c50a9cd7e5b3b2ae9db70ca30100b6885e4b5
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 30deea59f90ff972f3ac61a10ecad0a5f3bef0992b79198528ecf840f2b22f0e562040737d5d1e14334e58f6ffd507951c1c5c1be04bcab990e719b7b155b18f
|
7
|
+
data.tar.gz: 52400f3fbf97d3e829e3699d5e3d3bba43f69a3691b665115db00227f3d53ada93783f6842f40dcfb1bcc569adc82c518e82ae4cf7b83d8854543895fc1a5c87
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
3
|
require 'set'
|
4
|
-
require 'twitter-text/
|
4
|
+
require 'twitter-text/hash_helper'
|
5
5
|
|
6
6
|
module Twitter
|
7
7
|
# A module for including Tweet auto-linking in a class. The primary use of this is for helpers/views so they can auto-link
|
@@ -48,7 +48,7 @@ module Twitter
|
|
48
48
|
|
49
49
|
# map JSON entity to twitter-text entity
|
50
50
|
entities.each do |entity|
|
51
|
-
|
51
|
+
HashHelper.symbolize_keys!(entity)
|
52
52
|
# hashtag
|
53
53
|
entity[:hashtag] = entity[:text] if entity[:text]
|
54
54
|
end
|
@@ -227,7 +227,7 @@ module Twitter
|
|
227
227
|
|
228
228
|
def url_entities_hash(url_entities)
|
229
229
|
(url_entities || {}).inject({}) do |entities, entity|
|
230
|
-
|
230
|
+
HashHelper.symbolize_keys!(entity)
|
231
231
|
entities[entity[:url]] = entity
|
232
232
|
entities
|
233
233
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Twitter
|
2
|
+
module HashHelper
|
3
|
+
# Return a new hash with all keys converted to symbols, as long as
|
4
|
+
# they respond to +to_sym+.
|
5
|
+
#
|
6
|
+
# { 'name' => 'Rob', 'years' => '28' }.symbolize_keys
|
7
|
+
# #=> { :name => "Rob", :years => "28" }
|
8
|
+
def self.symbolize_keys(hash)
|
9
|
+
hash.dup.symbolize_keys!
|
10
|
+
end
|
11
|
+
|
12
|
+
# Destructively convert all keys to symbols, as long as they respond
|
13
|
+
# to +to_sym+. Same as +symbolize_keys+, but modifies +self+.
|
14
|
+
def self.symbolize_keys!(hash)
|
15
|
+
hash.keys.each do |key|
|
16
|
+
hash[(key.to_sym rescue key) || key] = hash.delete(key)
|
17
|
+
end
|
18
|
+
hash
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/twitter-text/regex.rb
CHANGED
@@ -194,8 +194,8 @@ module Twitter
|
|
194
194
|
ci|ck|cl|cm|cn|co|cr|cs|cu|cv|cx|cy|cz|dd|de|dj|dk|dm|do|dz|ec|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gg|gh|gi|gl|gm|
|
195
195
|
gn|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|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|
|
196
196
|
lk|lr|ls|lt|lu|lv|ly|ma|mc|md|me|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|
|
197
|
-
pf|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|sy|sz|tc|td|tf|tg|
|
198
|
-
tj|tk|tl|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|za|zm|zw
|
197
|
+
pf|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|sx|sy|sz|tc|td|tf|tg|
|
198
|
+
th|tj|tk|tl|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|za|zm|zw)
|
199
199
|
(?=[^0-9a-z]|$)
|
200
200
|
)
|
201
201
|
}ix
|
data/twitter-text.gemspec
CHANGED
@@ -2,13 +2,14 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = "twitter-text"
|
5
|
-
s.version = "1.6.
|
5
|
+
s.version = "1.6.2"
|
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",
|
9
9
|
"raffi@twitter.com", "jcummins@twitter.com", "niw@niw.at", "keita@twitter.com", "jkoval@twitter.com"]
|
10
10
|
s.homepage = "http://twitter.com"
|
11
11
|
s.description = s.summary = "A gem that provides text handling for Twitter"
|
12
|
+
s.license = "Apache 2.0"
|
12
13
|
|
13
14
|
s.platform = Gem::Platform::RUBY
|
14
15
|
s.has_rdoc = true
|
@@ -20,7 +21,7 @@ Gem::Specification.new do |s|
|
|
20
21
|
s.add_development_dependency "rdoc"
|
21
22
|
s.add_development_dependency "rspec"
|
22
23
|
s.add_development_dependency "simplecov"
|
23
|
-
s.add_runtime_dependency "unf", "~> 0.0
|
24
|
+
s.add_runtime_dependency "unf", "~> 0.1.0"
|
24
25
|
|
25
26
|
s.files = `git ls-files`.split("\n")
|
26
27
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
metadata
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: twitter-text
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
version: 1.6.1
|
4
|
+
version: 1.6.2
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Matt Sanford
|
@@ -17,120 +16,106 @@ authors:
|
|
17
16
|
autorequire:
|
18
17
|
bindir: bin
|
19
18
|
cert_chain: []
|
20
|
-
date: 2013-
|
19
|
+
date: 2013-09-16 00:00:00.000000000 Z
|
21
20
|
dependencies:
|
22
21
|
- !ruby/object:Gem::Dependency
|
23
|
-
version_requirements: !ruby/object:Gem::Requirement
|
24
|
-
requirements:
|
25
|
-
- - ~>
|
26
|
-
- !ruby/object:Gem::Version
|
27
|
-
version: '1.3'
|
28
|
-
none: false
|
29
|
-
prerelease: false
|
30
22
|
name: multi_json
|
31
23
|
requirement: !ruby/object:Gem::Requirement
|
32
24
|
requirements:
|
33
25
|
- - ~>
|
34
26
|
- !ruby/object:Gem::Version
|
35
27
|
version: '1.3'
|
36
|
-
none: false
|
37
28
|
type: :development
|
38
|
-
|
29
|
+
prerelease: false
|
39
30
|
version_requirements: !ruby/object:Gem::Requirement
|
40
31
|
requirements:
|
41
|
-
- -
|
32
|
+
- - ~>
|
42
33
|
- !ruby/object:Gem::Version
|
43
|
-
version: '
|
44
|
-
|
45
|
-
prerelease: false
|
34
|
+
version: '1.3'
|
35
|
+
- !ruby/object:Gem::Dependency
|
46
36
|
name: nokogiri
|
47
37
|
requirement: !ruby/object:Gem::Requirement
|
48
38
|
requirements:
|
49
|
-
- -
|
39
|
+
- - '>='
|
50
40
|
- !ruby/object:Gem::Version
|
51
41
|
version: '0'
|
52
|
-
none: false
|
53
42
|
type: :development
|
54
|
-
|
43
|
+
prerelease: false
|
55
44
|
version_requirements: !ruby/object:Gem::Requirement
|
56
45
|
requirements:
|
57
|
-
- -
|
46
|
+
- - '>='
|
58
47
|
- !ruby/object:Gem::Version
|
59
48
|
version: '0'
|
60
|
-
|
61
|
-
prerelease: false
|
49
|
+
- !ruby/object:Gem::Dependency
|
62
50
|
name: rake
|
63
51
|
requirement: !ruby/object:Gem::Requirement
|
64
52
|
requirements:
|
65
|
-
- -
|
53
|
+
- - '>='
|
66
54
|
- !ruby/object:Gem::Version
|
67
55
|
version: '0'
|
68
|
-
none: false
|
69
56
|
type: :development
|
70
|
-
|
57
|
+
prerelease: false
|
71
58
|
version_requirements: !ruby/object:Gem::Requirement
|
72
59
|
requirements:
|
73
|
-
- -
|
60
|
+
- - '>='
|
74
61
|
- !ruby/object:Gem::Version
|
75
62
|
version: '0'
|
76
|
-
|
77
|
-
prerelease: false
|
63
|
+
- !ruby/object:Gem::Dependency
|
78
64
|
name: rdoc
|
79
65
|
requirement: !ruby/object:Gem::Requirement
|
80
66
|
requirements:
|
81
|
-
- -
|
67
|
+
- - '>='
|
82
68
|
- !ruby/object:Gem::Version
|
83
69
|
version: '0'
|
84
|
-
none: false
|
85
70
|
type: :development
|
86
|
-
|
71
|
+
prerelease: false
|
87
72
|
version_requirements: !ruby/object:Gem::Requirement
|
88
73
|
requirements:
|
89
|
-
- -
|
74
|
+
- - '>='
|
90
75
|
- !ruby/object:Gem::Version
|
91
76
|
version: '0'
|
92
|
-
|
93
|
-
prerelease: false
|
77
|
+
- !ruby/object:Gem::Dependency
|
94
78
|
name: rspec
|
95
79
|
requirement: !ruby/object:Gem::Requirement
|
96
80
|
requirements:
|
97
|
-
- -
|
81
|
+
- - '>='
|
98
82
|
- !ruby/object:Gem::Version
|
99
83
|
version: '0'
|
100
|
-
none: false
|
101
84
|
type: :development
|
102
|
-
|
85
|
+
prerelease: false
|
103
86
|
version_requirements: !ruby/object:Gem::Requirement
|
104
87
|
requirements:
|
105
|
-
- -
|
88
|
+
- - '>='
|
106
89
|
- !ruby/object:Gem::Version
|
107
90
|
version: '0'
|
108
|
-
|
109
|
-
prerelease: false
|
91
|
+
- !ruby/object:Gem::Dependency
|
110
92
|
name: simplecov
|
111
93
|
requirement: !ruby/object:Gem::Requirement
|
112
94
|
requirements:
|
113
|
-
- -
|
95
|
+
- - '>='
|
114
96
|
- !ruby/object:Gem::Version
|
115
97
|
version: '0'
|
116
|
-
none: false
|
117
98
|
type: :development
|
118
|
-
|
99
|
+
prerelease: false
|
119
100
|
version_requirements: !ruby/object:Gem::Requirement
|
120
101
|
requirements:
|
121
|
-
- -
|
102
|
+
- - '>='
|
122
103
|
- !ruby/object:Gem::Version
|
123
|
-
version: 0
|
124
|
-
|
125
|
-
prerelease: false
|
104
|
+
version: '0'
|
105
|
+
- !ruby/object:Gem::Dependency
|
126
106
|
name: unf
|
127
107
|
requirement: !ruby/object:Gem::Requirement
|
128
108
|
requirements:
|
129
109
|
- - ~>
|
130
110
|
- !ruby/object:Gem::Version
|
131
|
-
version: 0.0
|
132
|
-
none: false
|
111
|
+
version: 0.1.0
|
133
112
|
type: :runtime
|
113
|
+
prerelease: false
|
114
|
+
version_requirements: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - ~>
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: 0.1.0
|
134
119
|
description: A gem that provides text handling for Twitter
|
135
120
|
email:
|
136
121
|
- matt@twitter.com
|
@@ -157,9 +142,9 @@ files:
|
|
157
142
|
- Rakefile
|
158
143
|
- lib/twitter-text.rb
|
159
144
|
- lib/twitter-text/autolink.rb
|
160
|
-
- lib/twitter-text/core_ext/hash.rb
|
161
145
|
- lib/twitter-text/deprecation.rb
|
162
146
|
- lib/twitter-text/extractor.rb
|
147
|
+
- lib/twitter-text/hash_helper.rb
|
163
148
|
- lib/twitter-text/hit_highlighter.rb
|
164
149
|
- lib/twitter-text/regex.rb
|
165
150
|
- lib/twitter-text/rewriter.rb
|
@@ -180,34 +165,28 @@ files:
|
|
180
165
|
- test/conformance_test.rb
|
181
166
|
- twitter-text.gemspec
|
182
167
|
homepage: http://twitter.com
|
183
|
-
licenses:
|
168
|
+
licenses:
|
169
|
+
- Apache 2.0
|
170
|
+
metadata: {}
|
184
171
|
post_install_message:
|
185
172
|
rdoc_options: []
|
186
173
|
require_paths:
|
187
174
|
- lib
|
188
175
|
required_ruby_version: !ruby/object:Gem::Requirement
|
189
176
|
requirements:
|
190
|
-
- -
|
177
|
+
- - '>='
|
191
178
|
- !ruby/object:Gem::Version
|
192
179
|
version: '0'
|
193
|
-
segments:
|
194
|
-
- 0
|
195
|
-
hash: -209443876529914673
|
196
|
-
none: false
|
197
180
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
198
181
|
requirements:
|
199
|
-
- -
|
182
|
+
- - '>='
|
200
183
|
- !ruby/object:Gem::Version
|
201
184
|
version: '0'
|
202
|
-
segments:
|
203
|
-
- 0
|
204
|
-
hash: -209443876529914673
|
205
|
-
none: false
|
206
185
|
requirements: []
|
207
186
|
rubyforge_project:
|
208
|
-
rubygems_version:
|
187
|
+
rubygems_version: 2.0.3
|
209
188
|
signing_key:
|
210
|
-
specification_version:
|
189
|
+
specification_version: 4
|
211
190
|
summary: Twitter text handling library
|
212
191
|
test_files:
|
213
192
|
- spec/autolinking_spec.rb
|
@@ -1,21 +0,0 @@
|
|
1
|
-
class Hash
|
2
|
-
|
3
|
-
# Return a new hash with all keys converted to symbols, as long as
|
4
|
-
# they respond to +to_sym+.
|
5
|
-
#
|
6
|
-
# { 'name' => 'Rob', 'years' => '28' }.symbolize_keys
|
7
|
-
# #=> { :name => "Rob", :years => "28" }
|
8
|
-
def symbolize_keys
|
9
|
-
dup.symbolize_keys!
|
10
|
-
end
|
11
|
-
|
12
|
-
# Destructively convert all keys to symbols, as long as they respond
|
13
|
-
# to +to_sym+. Same as +symbolize_keys+, but modifies +self+.
|
14
|
-
def symbolize_keys!
|
15
|
-
keys.each do |key|
|
16
|
-
self[(key.to_sym rescue key) || key] = delete(key)
|
17
|
-
end
|
18
|
-
self
|
19
|
-
end
|
20
|
-
|
21
|
-
end
|