followers_number 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/followers_number/parser.rb +14 -0
- data/lib/followers_number/parsers/twitter.rb +10 -0
- data/lib/followers_number/request.rb +7 -0
- data/lib/followers_number/validator.rb +15 -0
- data/lib/followers_number/version.rb +12 -0
- data/lib/followers_number.rb +18 -0
- metadata +96 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 73d7619b12e30e16394c86dd9844092c8f677360f9d39e85796241dd31dcf36d
|
4
|
+
data.tar.gz: fce06805d58f83f19a0d9b4f3a8c75e022b67cf93220ce2375969c704032e827
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d05b513038c3a3f58fa445cb0c2439b45ba01af7199204c04faa0196f89d6c54aa8c739380b29f5d659693a1c6980398ec048b204a487e3472d8eb8a5cec5760
|
7
|
+
data.tar.gz: bd65b81adf091b3ff3c41ce32b365d241a64d3f2f91545f4fd81676c3a0f5ff17c75d74b734600e116778dde60cd6b03243ecfb7befa299dc588510875ed4aba
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module FollowersNumber
|
2
|
+
class Parser
|
3
|
+
MAPPING = {
|
4
|
+
'twitter.com' => FollowersNumber::Parsers::Twitter
|
5
|
+
}
|
6
|
+
|
7
|
+
def self.call(profile_url, response)
|
8
|
+
html = ::Nokogiri::HTML(response.body)
|
9
|
+
mapper = MAPPING[URI.parse(profile_url).host]
|
10
|
+
|
11
|
+
mapper.parse(html)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module FollowersNumber
|
2
|
+
class Validator
|
3
|
+
class InvalidProfileURL < StandardError; end
|
4
|
+
|
5
|
+
NETWORKS = %w[twitter.com]
|
6
|
+
|
7
|
+
def self.validate!(profile_url)
|
8
|
+
unless NETWORKS.include?(URI.parse(profile_url.to_s.downcase).host)
|
9
|
+
raise InvalidProfileURL, profile_url
|
10
|
+
end
|
11
|
+
|
12
|
+
true
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require_relative 'followers_number/parsers/twitter'
|
2
|
+
require_relative 'followers_number/request'
|
3
|
+
require_relative 'followers_number/validator'
|
4
|
+
require_relative 'followers_number/parser'
|
5
|
+
|
6
|
+
require 'rest-client'
|
7
|
+
require 'nokogiri'
|
8
|
+
|
9
|
+
module FollowersNumber
|
10
|
+
class << self
|
11
|
+
def for(profile_url)
|
12
|
+
::FollowersNumber::Validator.validate!(profile_url)
|
13
|
+
|
14
|
+
response = ::FollowersNumber::Request.get(profile_url)
|
15
|
+
::FollowersNumber::Parser.call(profile_url, response)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
metadata
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: followers_number
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Paweł Dąbrowski
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-04-08 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rspec
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.7'
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 3.7.0
|
23
|
+
type: :development
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '3.7'
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 3.7.0
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: rest-client
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
type: :runtime
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: nokogiri
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
61
|
+
description: Get the followers number for the given social media profile
|
62
|
+
email: dziamber@gmail.com
|
63
|
+
executables: []
|
64
|
+
extensions: []
|
65
|
+
extra_rdoc_files: []
|
66
|
+
files:
|
67
|
+
- lib/followers_number.rb
|
68
|
+
- lib/followers_number/parser.rb
|
69
|
+
- lib/followers_number/parsers/twitter.rb
|
70
|
+
- lib/followers_number/request.rb
|
71
|
+
- lib/followers_number/validator.rb
|
72
|
+
- lib/followers_number/version.rb
|
73
|
+
homepage:
|
74
|
+
licenses: []
|
75
|
+
metadata: {}
|
76
|
+
post_install_message:
|
77
|
+
rdoc_options: []
|
78
|
+
require_paths:
|
79
|
+
- lib
|
80
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
85
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
requirements: []
|
91
|
+
rubyforge_project:
|
92
|
+
rubygems_version: 2.7.6
|
93
|
+
signing_key:
|
94
|
+
specification_version: 4
|
95
|
+
summary: Get the followers number for the given social media profile
|
96
|
+
test_files: []
|