FreedomCoder-esearchy 0.0.14 → 0.0.15
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/README.rdoc +1 -1
- data/lib/esearchy.rb +21 -12
- data/lib/esearchy/bing.rb +3 -3
- data/lib/esearchy/google.rb +3 -3
- data/lib/esearchy/linkedin.rb +2 -2
- data/lib/esearchy/pgp.rb +12 -4
- data/lib/esearchy/searchy.rb +8 -3
- data/lib/esearchy/yahoo.rb +3 -3
- metadata +1 -1
data/README.rdoc
CHANGED
@@ -43,7 +43,7 @@ For thouse who want to integrate this to their application you can use it in "th
|
|
43
43
|
|
44
44
|
or in the more classic way in which you can create an Esearchy objetc and work on it
|
45
45
|
|
46
|
-
domain = Esearchy.new :query => "domain.com", :maxhits => 500
|
46
|
+
domain = Esearchy.new :query => "domain.com", :maxhits => 500, :engines => [:Google,:Yahoo]
|
47
47
|
domain.search
|
48
48
|
domain.save_to_file "~/emails.txt"
|
49
49
|
|
data/lib/esearchy.rb
CHANGED
@@ -15,14 +15,23 @@ class ESearchy
|
|
15
15
|
ESearchy::LOG.file = value
|
16
16
|
end
|
17
17
|
|
18
|
-
|
19
|
-
|
18
|
+
def eng(arr)
|
19
|
+
hsh = {}; arr.each {|e| hsh[e] = instance_eval "#{e}"}; hsh
|
20
|
+
end
|
21
|
+
|
22
|
+
DEFAULT_ENGINES = [:Google, :Bing, :Yahoo, :PGP, :LinkedIn]
|
20
23
|
|
21
24
|
def initialize(options={}, &block)
|
22
25
|
@query = options[:query]
|
23
26
|
@depth_search = options[:depth] || true
|
24
|
-
@maxhits = options[:maxhits]
|
25
|
-
@engines = options[:engines]
|
27
|
+
@maxhits = options[:maxhits] || 0
|
28
|
+
@engines = options[:engines] ? eng(options[:engines]) :
|
29
|
+
{ :Google => Google,
|
30
|
+
:Bing => Bing,
|
31
|
+
:Yahoo => Yahoo,
|
32
|
+
:PGP => PGP,
|
33
|
+
:LinkedIn => LinkedIn }
|
34
|
+
|
26
35
|
@engines.each {|n,e| @engines[n] = e.new(@maxhits)}
|
27
36
|
@threads = Array.new
|
28
37
|
block.call(self) if block_given?
|
@@ -60,32 +69,32 @@ class ESearchy
|
|
60
69
|
end
|
61
70
|
|
62
71
|
def yahoo_key=(value)
|
63
|
-
@engines[
|
72
|
+
@engines[:Yahoo].appid = value
|
64
73
|
end
|
65
74
|
|
66
75
|
def bing_key=(value)
|
67
|
-
@engines[
|
76
|
+
@engines[:Bing].appid = value
|
68
77
|
end
|
69
78
|
|
70
79
|
def linkedin_credentials(user, pass)
|
71
|
-
@engines[
|
72
|
-
@engines[
|
80
|
+
@engines[:LinkedIn].username = user
|
81
|
+
@engines[:LinkedIn].password = pass
|
73
82
|
end
|
74
83
|
alias_method :linkedin_credentials=, :linkedin_credentials
|
75
84
|
|
76
85
|
def company_name(company)
|
77
|
-
@engines[
|
86
|
+
@engines[:LinkedIn].company_name = company
|
78
87
|
end
|
79
88
|
alias_method :company_name=, :company_name
|
80
89
|
|
81
90
|
def search_engine(key, value)
|
82
91
|
if [:Google, :Bing, :Yahoo, :PGP, :LinkedIn, :GoogleGroups].include?(key)
|
83
92
|
if value == true
|
84
|
-
unless @engines[key
|
85
|
-
@engines[key
|
93
|
+
unless @engines[key]
|
94
|
+
@engines[key] = instance_eval "#{key}.new(@maxhits)"
|
86
95
|
end
|
87
96
|
elsif value == false
|
88
|
-
@engines.delete(key
|
97
|
+
@engines.delete(key)
|
89
98
|
end
|
90
99
|
else
|
91
100
|
raise(ArgumentError, "No plugin with that Key")
|
data/lib/esearchy/bing.rb
CHANGED
@@ -5,12 +5,12 @@ local_path = "#{File.dirname(__FILE__)}/"
|
|
5
5
|
class Bing
|
6
6
|
include Searchy
|
7
7
|
|
8
|
-
def initialize(maxhits
|
8
|
+
def initialize(maxhits=0, appid=nil, start=0)
|
9
9
|
@appid = appid || Keys::BING_APP_KEY
|
10
|
-
@start = start
|
10
|
+
@start = start
|
11
11
|
@emails = []
|
12
12
|
@threads = []
|
13
|
-
@totalhits = maxhits
|
13
|
+
@totalhits = maxhits
|
14
14
|
@r_urls = Queue.new
|
15
15
|
@r_docs = Queue.new
|
16
16
|
@r_pdfs = Queue.new
|
data/lib/esearchy/google.rb
CHANGED
@@ -5,9 +5,9 @@ local_path = "#{File.dirname(__FILE__)}/"
|
|
5
5
|
class Google
|
6
6
|
include Searchy
|
7
7
|
|
8
|
-
def initialize(maxhits =
|
9
|
-
@start = start
|
10
|
-
@totalhits = maxhits
|
8
|
+
def initialize(maxhits = 0, start = 0)
|
9
|
+
@start = start
|
10
|
+
@totalhits = maxhits
|
11
11
|
@emails = []
|
12
12
|
@r_urls = Queue.new
|
13
13
|
@r_docs = Queue.new
|
data/lib/esearchy/linkedin.rb
CHANGED
data/lib/esearchy/pgp.rb
CHANGED
@@ -1,12 +1,11 @@
|
|
1
1
|
class PGP
|
2
2
|
include Searchy
|
3
3
|
|
4
|
-
def initialize(maxhits=
|
4
|
+
def initialize(maxhits=0)
|
5
|
+
@totalhits = maxhits
|
5
6
|
@emails = []
|
6
|
-
@lock = Mutex.new
|
7
|
-
@threads = []
|
8
7
|
end
|
9
|
-
|
8
|
+
|
10
9
|
def search(query)
|
11
10
|
@query = query
|
12
11
|
http = Net::HTTP.new("pgp.mit.edu",11371)
|
@@ -26,4 +25,13 @@ class PGP
|
|
26
25
|
ESearchy::LOG.puts "Error: Something went wrong with the HTTP request"
|
27
26
|
end
|
28
27
|
end
|
28
|
+
|
29
|
+
def emails
|
30
|
+
maxhits == 0 ? emails : emails[0..@totalhits]
|
31
|
+
end
|
32
|
+
|
33
|
+
def emails=(value)
|
34
|
+
emails = value
|
35
|
+
end
|
36
|
+
|
29
37
|
end
|
data/lib/esearchy/searchy.rb
CHANGED
@@ -105,8 +105,10 @@ module Searchy
|
|
105
105
|
if File.exists?("C:\\antiword\\antiword.exe")
|
106
106
|
search_emails(`C:\\antiword\\antiword.exe "#{name}" -f -s`)
|
107
107
|
else
|
108
|
-
|
109
|
-
|
108
|
+
# This G h e t t o but, for now it works on emails
|
109
|
+
# that do not contain Capital letters:)
|
110
|
+
ESearchy::LOG.puts "M$ Word|Antiword are not installed. Using the Ghetto way."
|
111
|
+
search_emails( File.open(name).readlines[0..19].to_s )
|
110
112
|
end
|
111
113
|
end
|
112
114
|
elsif RUBY_PLATFORM =~ /linux|darwin/
|
@@ -116,7 +118,10 @@ module Searchy
|
|
116
118
|
File.exists?("/opt/local/bin/antiword")
|
117
119
|
search_emails(`antiword "#{name}" -f -s`)
|
118
120
|
else
|
119
|
-
|
121
|
+
# This G h e t t o but, for now it works on emails
|
122
|
+
# that do not contain Capital letters:)
|
123
|
+
ESearchy::LOG.puts "Antiword is not installed. Using the Ghetto way."
|
124
|
+
search_emails( File.open(name).readlines[0..19].to_s )
|
120
125
|
end
|
121
126
|
rescue
|
122
127
|
ESearchy::LOG.puts "Something went wrong parsing the .doc\n"
|
data/lib/esearchy/yahoo.rb
CHANGED
@@ -5,10 +5,10 @@ local_path = "#{File.dirname(__FILE__)}/"
|
|
5
5
|
class Yahoo
|
6
6
|
include Searchy
|
7
7
|
|
8
|
-
def initialize(maxhits
|
8
|
+
def initialize(maxhits=0, appid = nil, start=0)
|
9
9
|
@appid = appid || Keys::YAHOO_APP_KEY
|
10
|
-
@start = start
|
11
|
-
@totalhits = maxhits
|
10
|
+
@start = start
|
11
|
+
@totalhits = maxhits
|
12
12
|
@emails = []
|
13
13
|
@r_urls = Queue.new
|
14
14
|
@r_docs = Queue.new
|