ids_please 2.0.0.beta2 → 2.1.0

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: c90688ce29bb8d767bed1b76578372de08fd159e
4
- data.tar.gz: 05f2a555c749d65e856fd7f7564df5eefea1fdbd
3
+ metadata.gz: 9f6dc3bb9304d5d5333906077b71f855f49d4200
4
+ data.tar.gz: fe1e6b69b44c16e4e467ad4d2e7bfcbd034f85f7
5
5
  SHA512:
6
- metadata.gz: a9fb21b711bc75b247e91b5748473787d8ffefc27f22531c9137c0cee37960fc696f778fd3a44ed5c6cb2a8a815c4443c2ebabcfc503c25894e393b2218aa55c
7
- data.tar.gz: 7c88c109074baf10941152bfb97b82a6695d0298a57fcbadbaf4dd77535f4789ad61822f7b7204daa339da78634e488ebf481628d36e72ab18bcff5e97afac47
6
+ metadata.gz: aca6e9d7cfe116be142f6f63798f43c419c22e6d1710551638cb2f0f3ef1eaff8e547cb7650f3adfd9882ee262f20d87df3c8f09e942cce490c74482871d1900
7
+ data.tar.gz: 3231148ebbfa15562e7d428f412ee2cd4f9422e9f24a369f572bc2d4b6b4ffc1cb0e742ca69e2f4e39e8f2ecae813ba70b08c560a547f5ec9729682bb25e1e86
data/.gitignore CHANGED
@@ -1,3 +1,4 @@
1
+ .DS_Store
1
2
  *.gem
2
3
  *.rbc
3
4
  /.config
data/README.md CHANGED
@@ -75,6 +75,7 @@ Social networks supported for grabbing at the moment:
75
75
  * [Twitter](https://www.twitter.com)
76
76
  * [Instagram](http://instagram.com)
77
77
  * [Vkontakte](https://vk.com)
78
+ * [Mailru](https://my.mail.ru)
78
79
 
79
80
  ### Link parsing
80
81
 
@@ -116,6 +117,7 @@ Social networks supported at the moment:
116
117
  * [Vkontakte](http://vk.com)
117
118
  * [Odnoklassniki](http://odnoklassniki.ru)
118
119
  * [Moikrug](https://moikrug.ru)
120
+ * [Mailru](https://my.mail.ru)
119
121
 
120
122
  ## Contributors
121
123
 
@@ -0,0 +1,46 @@
1
+ require 'json'
2
+
3
+ class IdsPlease
4
+ module Grabbers
5
+ class Mailru < IdsPlease::Grabbers::Base
6
+
7
+ def grab_link
8
+ @page_source ||= open(link).read.encode('utf-8')
9
+ uid_url = "http://appsmail.ru/platform/#{link.split('/')[-2..-1].join('/')}"
10
+ @network_id = JSON.parse(open(uid_url).read)['uid']
11
+ @username, type = get_name_and_type(link)
12
+ @avatar = @page_source.scan(/profile_avatar.+\n.+image: url\(([^\(]+)/).flatten.first
13
+ @display_name = @page_source.scan(/h1.+title="([^"]+)/).flatten.first
14
+ @display_name = CGI.unescapeHTML(@display_name) if @display_name
15
+ @data = {
16
+ type: type,
17
+ description: @page_source.scan(/profile__content_mainInfo" title="([^"]+)/).flatten.first
18
+ }
19
+ @data[:description] = CGI.unescapeHTML(@data[:description]) if @data[:description]
20
+ self
21
+ rescue => e
22
+ p e
23
+ return self
24
+ end
25
+
26
+ private
27
+
28
+ def get_name_and_type(link)
29
+ ind = -1
30
+ splitted = link.split('/')
31
+ type = 'user'
32
+ splitted.each_with_index do |part, i|
33
+ if part == 'community'
34
+ ind = i + 1
35
+ type = 'group'
36
+ elsif part == 'mail'
37
+ ind = i + 1
38
+ end
39
+ end
40
+ name = splitted[ind].split('?').first.split('#').first
41
+ [name, type]
42
+ end
43
+
44
+ end
45
+ end
46
+ end
@@ -3,6 +3,7 @@ require_relative 'grabbers/facebook'
3
3
  require_relative 'grabbers/vkontakte'
4
4
  require_relative 'grabbers/instagram'
5
5
  require_relative 'grabbers/twitter'
6
+ require_relative 'grabbers/mailru'
6
7
 
7
8
  class IdsPlease
8
9
  module Grabbers
@@ -11,7 +12,8 @@ class IdsPlease
11
12
  facebook: IdsPlease::Grabbers::Facebook,
12
13
  vkontakte: IdsPlease::Grabbers::Vkontakte,
13
14
  twitter: IdsPlease::Grabbers::Twitter,
14
- instagram: IdsPlease::Grabbers::Instagram
15
+ instagram: IdsPlease::Grabbers::Instagram,
16
+ mailru: IdsPlease::Grabbers::Mailru,
15
17
  }
16
18
 
17
19
  def self.each
@@ -0,0 +1,18 @@
1
+ class IdsPlease
2
+ module Parsers
3
+ class Mailru < IdsPlease::Parsers::Base
4
+
5
+ MASK = /mail\.ru/i
6
+
7
+ class << self
8
+ private
9
+
10
+ def parse_link(link)
11
+ id = link.path.split('/')[2]
12
+ id.split('?').first.split('#').first
13
+ end
14
+ end
15
+
16
+ end
17
+ end
18
+ end
@@ -17,6 +17,7 @@ require_relative 'parsers/soundcloud'
17
17
  require_relative 'parsers/vkontakte'
18
18
  require_relative 'parsers/odnoklassniki'
19
19
  require_relative 'parsers/moikrug'
20
+ require_relative 'parsers/mailru'
20
21
 
21
22
  class IdsPlease
22
23
  module Parsers
@@ -39,7 +40,8 @@ class IdsPlease
39
40
  youtube: IdsPlease::Parsers::Youtube,
40
41
  odnoklassniki: IdsPlease::Parsers::Odnoklassniki,
41
42
  tumblr: IdsPlease::Parsers::Tumblr,
42
- moikrug: IdsPlease::Parsers::Moikrug
43
+ moikrug: IdsPlease::Parsers::Moikrug,
44
+ mailru: IdsPlease::Parsers::Mailru
43
45
  }
44
46
 
45
47
  def self.each
@@ -1,3 +1,3 @@
1
1
  class IdsPlease
2
- VERSION = '2.0.0.beta2'
2
+ VERSION = '2.1.0'
3
3
  end
@@ -30,6 +30,8 @@ describe IdsPlease do
30
30
  http://ok.ru/profile/12341234/about
31
31
  http://odnoklassniki.com/group/43214321/about?some=123
32
32
  http://moikrug-acc.moikrug.ru
33
+ https://my.mail.ru/community/test-group-102/
34
+ https://my.mail.ru/mail/gazay/
33
35
  )
34
36
 
35
37
  not_recognazible_links = %w(
@@ -133,6 +135,10 @@ describe IdsPlease do
133
135
  expect(@recognizer.recognized[:moikrug].count).to eq(1)
134
136
  end
135
137
 
138
+ it 'recognizes mailru links' do
139
+ expect(@recognizer.recognized[:mailru].count).to eq(2)
140
+ end
141
+
136
142
  end
137
143
 
138
144
  end
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: 2.0.0.beta2
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - gazay
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-25 00:00:00.000000000 Z
11
+ date: 2015-08-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -57,6 +57,7 @@ files:
57
57
  - lib/ids_please/grabbers/base.rb
58
58
  - lib/ids_please/grabbers/facebook.rb
59
59
  - lib/ids_please/grabbers/instagram.rb
60
+ - lib/ids_please/grabbers/mailru.rb
60
61
  - lib/ids_please/grabbers/twitter.rb
61
62
  - lib/ids_please/grabbers/vkontakte.rb
62
63
  - lib/ids_please/parsers.rb
@@ -69,6 +70,7 @@ files:
69
70
  - lib/ids_please/parsers/instagram.rb
70
71
  - lib/ids_please/parsers/linkedin.rb
71
72
  - lib/ids_please/parsers/livejournal.rb
73
+ - lib/ids_please/parsers/mailru.rb
72
74
  - lib/ids_please/parsers/moikrug.rb
73
75
  - lib/ids_please/parsers/odnoklassniki.rb
74
76
  - lib/ids_please/parsers/pinterest.rb
@@ -98,9 +100,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
98
100
  version: '0'
99
101
  required_rubygems_version: !ruby/object:Gem::Requirement
100
102
  requirements:
101
- - - ">"
103
+ - - ">="
102
104
  - !ruby/object:Gem::Version
103
- version: 1.3.1
105
+ version: '0'
104
106
  requirements: []
105
107
  rubyforge_project:
106
108
  rubygems_version: 2.4.5