whos_using_what 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -12,6 +12,9 @@ class SearchClient
12
12
 
13
13
  @positiveMatchUrlPatterns = Array.new.push("http")
14
14
 
15
+ @technologiesToSearchFor = Array.new.push("ruby").push("java").push("javascript").push("python").push("c++").push("c#")
16
+
17
+ @jobPageTokens = Array.new.push("job", "hiring", "career")
15
18
 
16
19
  @results = Hash.new
17
20
 
@@ -45,20 +48,56 @@ class SearchClient
45
48
  if (add)
46
49
  acceptedUrls.push(url)
47
50
  end
51
+ end
52
+ acceptedUrls
53
+ end
48
54
 
49
55
 
56
+ def arraySearch(array, rawHtml)
57
+
58
+ rawHtml = rawHtml.downcase
59
+ array.each do |token|
60
+ if (rawHtml.index(token) != nil)
61
+ return true
62
+ end
50
63
  end
64
+ return false
65
+ end
66
+
67
+
68
+ def determineIfUsesTechnology(technology, rawHtml)
69
+
70
+ isJobPage = arraySearch(@jobPageTokens, rawHtml)
71
+
72
+ return isJobPage
51
73
 
52
74
  end
53
75
 
76
+
54
77
  def search(site, query)
55
78
 
56
79
  url = "https://www.google.com/search?hl=en&as_q=" << query << "&as_epq=&as_oq=&as_eq=&as_nlo=&as_nhi=&lr=&cr=&as_qdr=all&as_sitesearch=" << site << "&as_occt=any&safe=off&tbs=&as_filetype=&as_rights="
57
80
 
58
81
  rawHtml = RestClient.get(url)
59
82
 
60
- extractUrls(rawHtml, site)
83
+ urls = extractUrls(rawHtml, site)
84
+
85
+ isMatch = false
86
+
87
+ urls.each do |url|
88
+ if (determineIfUsesTechnology(query, RestClient.get(url)))
89
+ isMatch = true
90
+ break
91
+ end
92
+ end
93
+
94
+ if (isMatch)
95
+ puts site << " uses " << query
96
+ else
97
+ puts site << " does not use " << query
98
+ end
61
99
 
62
100
  end
63
101
 
64
- end
102
+ end
103
+
@@ -5,7 +5,7 @@ class WhosUsingWhat
5
5
  if __FILE__ == $PROGRAM_NAME
6
6
 
7
7
  client = SearchClient.new()
8
- client.search( "37signals.com", "ruby")
8
+ client.search( "ebay.com", "ruby")
9
9
 
10
10
  end
11
11
 
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.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: