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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7779235b8c59f4d9358aa29c286841278d15bf5d
4
- data.tar.gz: 7295b6fcadf9aac2394dbd938df565b22078dcab
3
+ metadata.gz: 8fc61f2173fb750fec7df4b629a7ade28ea6ead0
4
+ data.tar.gz: a502e562bcf87f2aa198f3a0553e6fd3f07850f5
5
5
  SHA512:
6
- metadata.gz: 1211b6e2d5f4c70b5d8ddf96d7cf9e94bafe85c01ee5ebd8416b4c03eca139401dc262c955ee43a5cdee9df373726ebb9b8eac40e97ab851a2dc5e352b3dce06
7
- data.tar.gz: 890bbc710aabcfefaa89fb3674896f2c024c9bce2e0cc9ef57cb0a0dd9f1e8e9ec8971e271baf09dfe87cf87031a41e332235120ad15fbf8357750ebb7b28312
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 yor database instead of parsing the link every time,
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['Twitter'] # => ["gazay"]
33
- puts ids.parsed['Facebook'] # => ["alexey.gaziev"]
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 # => {"Twitter"=>[#<URI::HTTP:0x007fea3bba7e30 URL:http://twitter.com/gazay>]}
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
 
@@ -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
- query = CGI.parse(link.query)
9
- query['id'].first if query.keys.include?('id')
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 link.host == 'google.com'
18
- link.path.split('/')[1]
19
- else
20
- matched = link.path.match(/\/(\d{2,})/)
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
@@ -14,7 +14,7 @@ require_relative 'ids_please/odnoklassniki'
14
14
 
15
15
  class IdsPlease
16
16
 
17
- VERSION = '1.0.0'
17
+ VERSION = '1.0.1'
18
18
 
19
19
  attr_accessor :original, :recognized, :unrecognized, :parsed
20
20
 
@@ -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].first).to eq('12341234')
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.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-22 00:00:00.000000000 Z
11
+ date: 2014-04-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake