whos_using_what 0.0.5 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/whos_using_what/config_module.rb +10 -0
- data/lib/whos_using_what/linkedin_client.rb +49 -7
- data/lib/whos_using_what.rb +3 -1
- metadata +18 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
require 'oauth'
|
|
2
2
|
require 'json'
|
|
3
|
+
require_relative 'config_module'
|
|
3
4
|
|
|
4
5
|
class LinkedinClient
|
|
5
6
|
|
|
@@ -7,18 +8,21 @@ class LinkedinClient
|
|
|
7
8
|
attr :access_token, true
|
|
8
9
|
attr :companyUrls
|
|
9
10
|
|
|
11
|
+
include ConfigModule
|
|
12
|
+
|
|
10
13
|
|
|
11
14
|
def initialize(api_key, api_secret, user_token, user_secret, url)
|
|
15
|
+
super()
|
|
12
16
|
|
|
13
|
-
@industryCodes = "4,132,6,96,113";
|
|
14
17
|
@numberResults = "5"
|
|
15
18
|
@start = "15"
|
|
16
|
-
@companyUrls = Hash.new
|
|
17
19
|
|
|
18
20
|
consumer = OAuth::Consumer.new(api_key, api_secret, {:site => url})
|
|
19
21
|
|
|
20
22
|
@access_token = OAuth::AccessToken.new(consumer, user_token, user_secret)
|
|
21
23
|
|
|
24
|
+
#this appears to be the most that linkedin will give back per request
|
|
25
|
+
@max_results = 20
|
|
22
26
|
|
|
23
27
|
end
|
|
24
28
|
|
|
@@ -30,18 +34,20 @@ class LinkedinClient
|
|
|
30
34
|
end
|
|
31
35
|
end
|
|
32
36
|
|
|
33
|
-
|
|
37
|
+
|
|
38
|
+
def parseCompanyResults(result)
|
|
39
|
+
results = Hash.new
|
|
34
40
|
result['companies']['values'].each do |company|
|
|
35
|
-
|
|
41
|
+
results[company['universalName']] = company['websiteUrl']
|
|
36
42
|
end
|
|
37
|
-
|
|
43
|
+
return results
|
|
38
44
|
end
|
|
39
45
|
|
|
40
46
|
|
|
47
|
+
#test method, remove eventually
|
|
41
48
|
def apiCallLinkedin
|
|
42
|
-
#url = "http://api.linkedin.com/v1/people-search:(people:(headline,first-name,last-name,positions,location:(name)),num-results)?title=software¤t-title=true&facet=location%2Cus%3A84&format=json&count=500"
|
|
43
49
|
url = "http://api.linkedin.com/v1/company-search:(companies:(universal-name,website-url,locations:(address:(city,state))),facets,num-results)?facet=location,us:84&facet=industry," <<
|
|
44
|
-
@
|
|
50
|
+
@linkedin_tech_industry_codes <<
|
|
45
51
|
"&format=json" <<
|
|
46
52
|
"&start=" << @start <<
|
|
47
53
|
"&count=" << @numberResults
|
|
@@ -53,4 +59,40 @@ class LinkedinClient
|
|
|
53
59
|
end
|
|
54
60
|
|
|
55
61
|
|
|
62
|
+
def gather_company_data(start, number_to_collect, industry_codes)
|
|
63
|
+
|
|
64
|
+
request_num = number_to_collect
|
|
65
|
+
cnt = 0
|
|
66
|
+
div = number_to_collect / @max_results
|
|
67
|
+
if (div <1)
|
|
68
|
+
div = 1
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
results = Hash.new
|
|
72
|
+
|
|
73
|
+
if (industry_codes == nil)
|
|
74
|
+
industry_codes = @linkedin_tech_industry_codes
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
while cnt < div do
|
|
78
|
+
url = "http://api.linkedin.com/v1/company-search:(companies:(universal-name,website-url,locations:(address:(city,state))),facets,num-results)?facet=location,us:84&facet=industry," <<
|
|
79
|
+
industry_codes <<
|
|
80
|
+
"&format=json" <<
|
|
81
|
+
"&start=" << (cnt * @max_results + 1).to_s <<
|
|
82
|
+
"&count=" << @max_results.to_s
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
json = @access_token.get(url)
|
|
86
|
+
|
|
87
|
+
tmp_results = parseCompanyResults(JSON.parse(json.body))
|
|
88
|
+
|
|
89
|
+
tmp_results.each do |key, value|
|
|
90
|
+
results[key] = value
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
cnt = cnt + 1
|
|
94
|
+
end
|
|
95
|
+
results
|
|
96
|
+
end
|
|
97
|
+
|
|
56
98
|
end
|
data/lib/whos_using_what.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: whos_using_what
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.6
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -59,6 +59,22 @@ dependencies:
|
|
|
59
59
|
- - ! '>='
|
|
60
60
|
- !ruby/object:Gem::Version
|
|
61
61
|
version: '0'
|
|
62
|
+
- !ruby/object:Gem::Dependency
|
|
63
|
+
name: yaml
|
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
|
65
|
+
none: false
|
|
66
|
+
requirements:
|
|
67
|
+
- - ! '>='
|
|
68
|
+
- !ruby/object:Gem::Version
|
|
69
|
+
version: '0'
|
|
70
|
+
type: :runtime
|
|
71
|
+
prerelease: false
|
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
73
|
+
none: false
|
|
74
|
+
requirements:
|
|
75
|
+
- - ! '>='
|
|
76
|
+
- !ruby/object:Gem::Version
|
|
77
|
+
version: '0'
|
|
62
78
|
description: What companies are using what technologies
|
|
63
79
|
email: r.dane1010@gmail.com
|
|
64
80
|
executables: []
|
|
@@ -67,6 +83,7 @@ extra_rdoc_files: []
|
|
|
67
83
|
files:
|
|
68
84
|
- lib/whos_using_what/search_client.rb
|
|
69
85
|
- lib/whos_using_what/linkedin_client.rb
|
|
86
|
+
- lib/whos_using_what/config_module.rb
|
|
70
87
|
- lib/whos_using_what.rb
|
|
71
88
|
homepage: http://rubygems.org/gems/whos_using_what
|
|
72
89
|
licenses: []
|