ids_please 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -4
- data/lib/ids_please/facebook.rb +4 -3
- data/lib/ids_please/google_plus.rb +4 -5
- data/lib/ids_please.rb +1 -1
- data/spec/ids_please/basic_spec.rb +2 -1
- 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: 8fc61f2173fb750fec7df4b629a7ade28ea6ead0
|
4
|
+
data.tar.gz: a502e562bcf87f2aa198f3a0553e6fd3f07850f5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1a42ed0c14b29bae3cd13206b9e0baab7181f37d312cd6ce12d6e61e899b25c7c98f1716e718fd61da99a597ed16ddcb7bde30f7768a6d9e63064b1e66ce469a
|
7
|
+
data.tar.gz: 4d83ac5bac217e9f57cc4f273e37af05757e47d702f8809114eedcc0d253b28783c8ba74c37432dc6b3aa763ac6688fe7871fd067a238ca8b2e3ee99b8caf937
|
data/README.md
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
Get social network IDs or screen names from links to social network accounts.
|
4
4
|
|
5
5
|
Sometimes you need to get a social network account name from a link —
|
6
|
-
to store a screen name in
|
6
|
+
to store a screen name in your database instead of parsing the link every time,
|
7
7
|
or maybe to work with these accounts using social network APIs (as I do).
|
8
8
|
Would be easier to have a library that extracts this kind of information
|
9
9
|
from all known social networks for your pleasure.
|
@@ -29,8 +29,8 @@ This is how you get social IDs from from links:
|
|
29
29
|
```ruby
|
30
30
|
ids = IdsPlease.new('https://twitter.com/gazay', 'http://facebook.com/alexey.gaziev')
|
31
31
|
ids.parse
|
32
|
-
puts ids.parsed[
|
33
|
-
puts ids.parsed[
|
32
|
+
puts ids.parsed[:twitter] # => ["gazay"]
|
33
|
+
puts ids.parsed[:facebook] # => ["alexey.gaziev"]
|
34
34
|
|
35
35
|
puts ids.original # => ["https://twitter.com/gazay", "http://facebook.com/alexey.gaziev"]
|
36
36
|
```
|
@@ -40,7 +40,7 @@ Or you can just check that the link is for a known social network:
|
|
40
40
|
```ruby
|
41
41
|
ids = IdsPlease.new('https://twitter.com/gazay', 'http://some-unknown-network.com/gazay')
|
42
42
|
ids.recognize
|
43
|
-
puts ids.recognized # => {
|
43
|
+
puts ids.recognized # => {:twitter=>[#<URI::HTTP:0x007fea3bba7e30 URL:http://twitter.com/gazay>]}
|
44
44
|
puts ids.unrecognized # => ["http://some-unknown-network.com/gazay"]
|
45
45
|
```
|
46
46
|
|
data/lib/ids_please/facebook.rb
CHANGED
@@ -4,9 +4,10 @@ class IdsPlease
|
|
4
4
|
MASK = /fb\.me|fb\.com|facebook/i
|
5
5
|
|
6
6
|
def self.parse_link(link)
|
7
|
-
if link.query && !link.query.empty?
|
8
|
-
|
9
|
-
|
7
|
+
query = CGI.parse(link.query) if link.query && !link.query.empty?
|
8
|
+
|
9
|
+
if query && query['id']
|
10
|
+
query['id'].first
|
10
11
|
elsif link.path =~ /\/pages\//
|
11
12
|
link.path.split('/').last
|
12
13
|
else
|
@@ -14,11 +14,10 @@ class IdsPlease
|
|
14
14
|
private
|
15
15
|
|
16
16
|
def self.parse_link(link)
|
17
|
-
if
|
18
|
-
|
19
|
-
|
20
|
-
matched
|
21
|
-
matched[1] if matched
|
17
|
+
if matched = link.path.match(/\/\+(\w+)/)
|
18
|
+
matched[1]
|
19
|
+
elsif matched = link.path.match(/\/(\d{2,})/)
|
20
|
+
matched[1]
|
22
21
|
end
|
23
22
|
end
|
24
23
|
|
data/lib/ids_please.rb
CHANGED
@@ -10,6 +10,7 @@ describe IdsPlease do
|
|
10
10
|
https://twitter.com/twi_acc
|
11
11
|
https://vimeo.com/vimeo_acc
|
12
12
|
https://plus.google.com/12341234
|
13
|
+
https://plus.google.com/+VladimirBokov
|
13
14
|
https://soundcloud.com/sc_acc
|
14
15
|
https://youtube.com/channels/yb_acc
|
15
16
|
http://tumblr-acc.tumblr.com
|
@@ -57,7 +58,7 @@ describe IdsPlease do
|
|
57
58
|
end
|
58
59
|
|
59
60
|
it 'get right id from google+ link' do
|
60
|
-
expect(@recognizer.parsed[:google_plus]
|
61
|
+
expect(@recognizer.parsed[:google_plus]).to eq(['12341234', 'VladimirBokov'])
|
61
62
|
end
|
62
63
|
|
63
64
|
it 'get right id from soundcloud 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.0.
|
4
|
+
version: 1.0.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-04-
|
11
|
+
date: 2014-04-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|