ids_please 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ids_please/base_parser.rb +18 -16
- data/lib/ids_please/facebook.rb +11 -9
- data/lib/ids_please/google_plus.rb +14 -12
- data/lib/ids_please/hi5.rb +9 -7
- data/lib/ids_please/linkedin.rb +9 -8
- data/lib/ids_please/livejournal.rb +8 -6
- data/lib/ids_please/moikrug.rb +11 -9
- data/lib/ids_please/odnoklassniki.rb +11 -9
- data/lib/ids_please/reddit.rb +5 -3
- data/lib/ids_please/tumblr.rb +6 -4
- data/lib/ids_please/twitter.rb +9 -7
- data/lib/ids_please/vkontakte.rb +12 -10
- data/lib/ids_please/youtube.rb +8 -6
- data/lib/ids_please.rb +1 -1
- data/spec/ids_please/basic_spec.rb +3 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 26c46bd87c6161d008f9f271aa4e784e701be728
|
4
|
+
data.tar.gz: f8c670dc5783dd145189c2c8b1ef0fd7cb2825e1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7f4a8d777e9d1c8c8270e9d48a596e0bee359a53b7f78b6cce90a138b8e71260d2ce20bfda2ab7a0b192eeca364be881c5cf947bb547303da92ffee16db36789
|
7
|
+
data.tar.gz: 57712f6e90931fc6489f81728e9d20dc667d58a5d2a0a624c291771f1447e2a28804dee8310c3db3bd98f352a0a68464379b0b05fb707e23ffd805d87c17cf62
|
@@ -1,26 +1,28 @@
|
|
1
1
|
class IdsPlease
|
2
2
|
class BaseParser
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
class << self
|
5
|
+
def to_sym
|
6
|
+
self.name.split('::').last.downcase.to_sym
|
7
|
+
end
|
7
8
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
9
|
+
def parse(links)
|
10
|
+
links.map do |l|
|
11
|
+
id = parse_link(l)
|
12
|
+
matched_id = id.match(valid_id_regex) if id
|
13
|
+
matched_id[1] if matched_id
|
14
|
+
end.compact
|
15
|
+
end
|
15
16
|
|
16
|
-
|
17
|
+
private
|
17
18
|
|
18
|
-
|
19
|
-
|
20
|
-
|
19
|
+
def parse_link(link)
|
20
|
+
link.path.split('/')[1]
|
21
|
+
end
|
21
22
|
|
22
|
-
|
23
|
-
|
23
|
+
def valid_id_regex
|
24
|
+
/\A([\w\.\+-]{2,})/
|
25
|
+
end
|
24
26
|
end
|
25
27
|
|
26
28
|
end
|
data/lib/ids_please/facebook.rb
CHANGED
@@ -3,17 +3,19 @@ class IdsPlease
|
|
3
3
|
|
4
4
|
MASK = /fb\.me|fb\.com|facebook/i
|
5
5
|
|
6
|
-
|
6
|
+
class << self
|
7
|
+
private
|
7
8
|
|
8
|
-
|
9
|
-
|
9
|
+
def parse_link(link)
|
10
|
+
query = CGI.parse(link.query) if link.query && !link.query.empty?
|
10
11
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
12
|
+
if query && !query['id'].empty?
|
13
|
+
query['id'].first
|
14
|
+
elsif link.path =~ /\/pages\//
|
15
|
+
link.path.split('/').last
|
16
|
+
else
|
17
|
+
link.path.split('/')[1]
|
18
|
+
end
|
17
19
|
end
|
18
20
|
end
|
19
21
|
|
@@ -3,21 +3,23 @@ class IdsPlease
|
|
3
3
|
|
4
4
|
MASK = /google/i
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
class << self
|
7
|
+
def to_sym
|
8
|
+
:google_plus
|
9
|
+
end
|
9
10
|
|
10
|
-
|
11
|
-
|
12
|
-
|
11
|
+
def parse(links)
|
12
|
+
links.map { |l| parse_link(l) }.compact
|
13
|
+
end
|
13
14
|
|
14
|
-
|
15
|
+
private
|
15
16
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
17
|
+
def parse_link(link)
|
18
|
+
if matched = link.path.match(/\/(\+\w+)/)
|
19
|
+
matched[1]
|
20
|
+
elsif matched = link.path.match(/\/(\d{2,})/)
|
21
|
+
matched[1]
|
22
|
+
end
|
21
23
|
end
|
22
24
|
end
|
23
25
|
|
data/lib/ids_please/hi5.rb
CHANGED
@@ -3,15 +3,17 @@ class IdsPlease
|
|
3
3
|
|
4
4
|
MASK = /hi5/i
|
5
5
|
|
6
|
-
|
6
|
+
class << self
|
7
|
+
private
|
7
8
|
|
8
|
-
|
9
|
-
|
9
|
+
def parse_link(link)
|
10
|
+
query = CGI.parse(link.query) if link.query && !link.query.empty?
|
10
11
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
12
|
+
if query && !query['uid'].empty?
|
13
|
+
query['uid'].first
|
14
|
+
else
|
15
|
+
link.path.split('/')[1]
|
16
|
+
end
|
15
17
|
end
|
16
18
|
end
|
17
19
|
|
data/lib/ids_please/linkedin.rb
CHANGED
@@ -3,18 +3,19 @@ class IdsPlease
|
|
3
3
|
|
4
4
|
MASK = /linkedin/i
|
5
5
|
|
6
|
-
|
6
|
+
class << self
|
7
|
+
private
|
7
8
|
|
8
|
-
|
9
|
-
|
9
|
+
def parse_link(link)
|
10
|
+
query = CGI.parse(link.query) if link.query && !link.query.empty?
|
10
11
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
12
|
+
if query && !query['id'].empty?
|
13
|
+
query['id'].first
|
14
|
+
elsif link.path =~ /\/pub\//
|
15
|
+
link.path.split('/')[2]
|
16
|
+
end
|
15
17
|
end
|
16
18
|
end
|
17
19
|
|
18
|
-
|
19
20
|
end
|
20
21
|
end
|
@@ -3,13 +3,15 @@ class IdsPlease
|
|
3
3
|
|
4
4
|
MASK = /livejournal/i
|
5
5
|
|
6
|
-
|
6
|
+
class << self
|
7
|
+
private
|
7
8
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
9
|
+
def parse_link(link)
|
10
|
+
parsed = link.host.sub('.livejournal.com', '')
|
11
|
+
parsed = link.host.split('.livejournal').first if parsed == link.host
|
12
|
+
return if parsed == link.host
|
13
|
+
parsed
|
14
|
+
end
|
13
15
|
end
|
14
16
|
|
15
17
|
end
|
data/lib/ids_please/moikrug.rb
CHANGED
@@ -3,17 +3,19 @@ class IdsPlease
|
|
3
3
|
|
4
4
|
MASK = /moikrug/i
|
5
5
|
|
6
|
-
|
7
|
-
links
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
6
|
+
class << self
|
7
|
+
def parse(links)
|
8
|
+
links.map do |link|
|
9
|
+
next if link.host.sub('.moikrug.ru', '') == link.host
|
10
|
+
parse_link(link)
|
11
|
+
end.compact
|
12
|
+
end
|
12
13
|
|
13
|
-
|
14
|
+
private
|
14
15
|
|
15
|
-
|
16
|
-
|
16
|
+
def parse_link(link)
|
17
|
+
link.host.sub('.moikrug.ru', '')
|
18
|
+
end
|
17
19
|
end
|
18
20
|
|
19
21
|
end
|
@@ -1,17 +1,19 @@
|
|
1
1
|
class IdsPlease
|
2
2
|
class Odnoklassniki < IdsPlease::BaseParser
|
3
3
|
|
4
|
-
MASK = /odnoklassniki/i
|
4
|
+
MASK = /odnoklassniki|ok\.ru/i
|
5
5
|
|
6
|
-
|
6
|
+
class << self
|
7
|
+
private
|
7
8
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
9
|
+
def parse_link(link)
|
10
|
+
if matched = link.path.match(/\/(\d{2,})/)
|
11
|
+
matched[1]
|
12
|
+
elsif link.path =~ /\/about\//
|
13
|
+
link.path.split('/')[-2]
|
14
|
+
elsif link.path.split('/').size >= 3
|
15
|
+
link.path.split('/')[2]
|
16
|
+
end
|
15
17
|
end
|
16
18
|
end
|
17
19
|
|
data/lib/ids_please/reddit.rb
CHANGED
data/lib/ids_please/tumblr.rb
CHANGED
@@ -3,11 +3,13 @@ class IdsPlease
|
|
3
3
|
|
4
4
|
MASK = /tumblr/i
|
5
5
|
|
6
|
-
|
6
|
+
class << self
|
7
|
+
private
|
7
8
|
|
8
|
-
|
9
|
-
|
10
|
-
|
9
|
+
def parse_link(link)
|
10
|
+
return if link.host.sub('.tumblr.com', '') == link.host
|
11
|
+
link.host.sub('.tumblr.com', '')
|
12
|
+
end
|
11
13
|
end
|
12
14
|
|
13
15
|
end
|
data/lib/ids_please/twitter.rb
CHANGED
@@ -3,14 +3,16 @@ class IdsPlease
|
|
3
3
|
|
4
4
|
MASK = /twitter/i
|
5
5
|
|
6
|
-
|
6
|
+
class << self
|
7
|
+
private
|
7
8
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
9
|
+
def parse_link(link)
|
10
|
+
if link.path =~ /%23!/
|
11
|
+
id = link.path.sub(/\A\/%23!\//, '')
|
12
|
+
id.split(/[\/\?#]/).first
|
13
|
+
else
|
14
|
+
link.path.split('/')[1]
|
15
|
+
end
|
14
16
|
end
|
15
17
|
end
|
16
18
|
|
data/lib/ids_please/vkontakte.rb
CHANGED
@@ -3,18 +3,20 @@ class IdsPlease
|
|
3
3
|
|
4
4
|
MASK = /vk\.com|vkontakte/i
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
class << self
|
7
|
+
def parse(links)
|
8
|
+
links.map { |l| parse_link(l) }.compact
|
9
|
+
end
|
9
10
|
|
10
|
-
|
11
|
+
private
|
11
12
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
13
|
+
def parse_link(link)
|
14
|
+
if link.path =~ /id|club/
|
15
|
+
id = link.path.sub(/\A\/id|\A\/club/, '')
|
16
|
+
id.split(/[\/\?#]/).first
|
17
|
+
else
|
18
|
+
link.path.split('/')[1]
|
19
|
+
end
|
18
20
|
end
|
19
21
|
end
|
20
22
|
|
data/lib/ids_please/youtube.rb
CHANGED
@@ -3,13 +3,15 @@ class IdsPlease
|
|
3
3
|
|
4
4
|
MASK = /youtu\.be|youtube/i
|
5
5
|
|
6
|
-
|
6
|
+
class << self
|
7
|
+
private
|
7
8
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
9
|
+
def parse_link(link)
|
10
|
+
if link.path =~ /channels|user/
|
11
|
+
link.path.split('/')[2]
|
12
|
+
else
|
13
|
+
link.path.split('/')[1]
|
14
|
+
end
|
13
15
|
end
|
14
16
|
end
|
15
17
|
|
data/lib/ids_please.rb
CHANGED
@@ -26,6 +26,7 @@ describe IdsPlease do
|
|
26
26
|
https://youtube.com/channels/yb_acc
|
27
27
|
http://tumblr-acc.tumblr.com
|
28
28
|
http://odnoklassniki.com/profile/12341234/about
|
29
|
+
http://ok.ru/profile/12341234/about
|
29
30
|
http://odnoklassniki.com/group/43214321/about?some=123
|
30
31
|
http://moikrug-acc.moikrug.ru
|
31
32
|
)
|
@@ -124,7 +125,7 @@ describe IdsPlease do
|
|
124
125
|
end
|
125
126
|
|
126
127
|
it 'recognizes odnoklassniki link' do
|
127
|
-
expect(@recognizer.recognized[:odnoklassniki].count).to eq(
|
128
|
+
expect(@recognizer.recognized[:odnoklassniki].count).to eq(3)
|
128
129
|
end
|
129
130
|
|
130
131
|
it 'recognizes moikrug link' do
|
@@ -226,7 +227,7 @@ describe IdsPlease do
|
|
226
227
|
end
|
227
228
|
|
228
229
|
it 'get right id from odnoklassniki link' do
|
229
|
-
expect(@recognizer.parsed[:odnoklassniki]).to eq(['12341234', '43214321'])
|
230
|
+
expect(@recognizer.parsed[:odnoklassniki].sort).to eq(['12341234', '43214321', '12341234'].sort)
|
230
231
|
end
|
231
232
|
|
232
233
|
it 'get right id from moikrug link' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ids_please
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- gazay
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-07-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|