omnibrowser 0.0.6 → 0.0.7

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: ca9faf3378bff0064d5fae7ac9b352554da8ab8b
4
- data.tar.gz: d2c9f47c1fcccbfd44257493f828f5d005c71d38
3
+ metadata.gz: 4549c62b32e8df4e719f492362a4be13ec5ac06f
4
+ data.tar.gz: 14a1152ec1a2fc05bc1ac57278079355225aa3a3
5
5
  SHA512:
6
- metadata.gz: ed326265040e4343e09fbb226dc825c420761df2314f09bcd09878d4791a09bdfbd5a7e9104a0668ea5128e005d9f185f0902097a1e1e202cca406626b0a0084
7
- data.tar.gz: 5683cf5a548f957debf2061e7e1529f0e0da8394c404e24773a4e755f969a34ca5d4babc49629f898915f3ddb87e6f41e8b3dddcbee9f000586434880a8a610e
6
+ metadata.gz: fc49d1acefc932f0c82d77726ad11ada77bb4aeff700c359d71fadb90597131c77dcb6d09c1b74bbe0a48958f5794b9f39eb3ec9d857aab2d104f307d43f01ab
7
+ data.tar.gz: ed61f9aa7f753ca37056450aad446042475603855d26ec2fd77502766cd43ea387501e04d34d08620085717c004716d36568e132fd12a906e5827a4456da68af
@@ -0,0 +1,75 @@
1
+ require 'flex_core'
2
+
3
+ class BasicBrowser
4
+
5
+ FIREFOX_41 = 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.1'
6
+
7
+ CHROME = 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36'
8
+
9
+ def initialize (*configs)
10
+
11
+ @profile = Selenium::WebDriver::Firefox::Profile.new
12
+ @profile['javascript.enabled'] = false if configs.include?(:no_java)
13
+ @profile['general.useragent.override'] =
14
+ case
15
+ when configs.include?(:firefox_41)
16
+ FIREFOX_41
17
+ else
18
+ CHROME
19
+ end
20
+
21
+ @browser = Watir::Browser.new(:firefox, profile: @profile)
22
+
23
+ end
24
+
25
+ def resize (width, height = nil)
26
+ height = width if height.nil?
27
+ @browser.window.resize_to(width, height)
28
+ end
29
+
30
+ def move (x, y)
31
+ @browser.window.move_to(x, y)
32
+ end
33
+
34
+ def zoom_out (times)
35
+ times.times do
36
+ @browser.send_keys([:command, :subtract])
37
+ end
38
+ end
39
+
40
+ def position
41
+ @browser.windows.first.position.to_a
42
+ end
43
+
44
+ def size
45
+ @browser.windows.first.size.to_a
46
+ end
47
+
48
+ def method_missing (method, *args)
49
+
50
+ nav_methods = [:goto, :refresh, :back]
51
+
52
+ begin
53
+ result = @browser.send(method, *args)
54
+ rescue Timeout::Error => _
55
+ sputs 'page timed out'
56
+ @browser.stop
57
+ @browser.refresh
58
+ end
59
+
60
+ sleep(0.88)
61
+ lprint '.' if method.is_in?(nav_methods)
62
+
63
+ result
64
+ end
65
+
66
+ def save_html (path)
67
+ path = path
68
+ path << '.html' unless path =~ /.+\.html\z/
69
+
70
+ file = File.open(path, 'w')
71
+ file.puts @browser.html
72
+ file.close
73
+ end
74
+
75
+ end
@@ -6,11 +6,13 @@ require 'omni_browser/website'
6
6
  require 'watir-webdriver'
7
7
  require 'watir-webdriver/extensions/alerts'
8
8
 
9
- class OmniBrowser
9
+ require_relative 'basic_browser'
10
10
 
11
- FIREFOX_41 = 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.1'
11
+ class BasicBrowser
12
12
 
13
- CHROME = 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36'
13
+ end
14
+
15
+ class OmniBrowser < BasicBrowser
14
16
 
15
17
  attr_reader :database, :config, :logging_db, :domains_db, :ip_db
16
18
  attr_accessor :tunnel, :allowance, :my_ip
@@ -59,29 +61,6 @@ class OmniBrowser
59
61
  @dom_id = nil
60
62
  end
61
63
 
62
- def resize (width, height = nil)
63
- height = width if height.nil?
64
- @browser.window.resize_to(width, height)
65
- end
66
-
67
- def move (x, y)
68
- @browser.window.move_to(x, y)
69
- end
70
-
71
- def zoom_out (times)
72
- times.times do
73
- @browser.send_keys([:command, :subtract])
74
- end
75
- end
76
-
77
- def position
78
- @browser.windows.first.position.to_a
79
- end
80
-
81
- def size
82
- @browser.windows.first.size.to_a
83
- end
84
-
85
64
  def method_missing (method, *args)
86
65
  if [:goto, :refresh, :back].include?(method)
87
66
  save_domain
@@ -143,13 +122,4 @@ class OmniBrowser
143
122
  @browser.url.scan(/[^\/]+/)[1].strip
144
123
  end
145
124
 
146
- def save_html (path)
147
- path = path
148
- path << '.html' unless path =~ /.+\.html\z/
149
-
150
- file = File.open(path, 'w')
151
- file.puts @browser.html
152
- file.close
153
- end
154
-
155
125
  end
@@ -2,7 +2,11 @@ require 'flex_config'
2
2
  require 'flex_pg'
3
3
  require 'open-uri'
4
4
 
5
- class OmniBrowser
5
+ class BasicBrowser
6
+
7
+ end
8
+
9
+ class OmniBrowser < BasicBrowser
6
10
 
7
11
  def get_my_ip
8
12
  puts 'Getting IP'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omnibrowser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eugene Lai
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-05 00:00:00.000000000 Z
11
+ date: 2016-03-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: flex_pg
@@ -58,6 +58,7 @@ executables: []
58
58
  extensions: []
59
59
  extra_rdoc_files: []
60
60
  files:
61
+ - lib/basic_browser.rb
61
62
  - lib/omni_browser.rb
62
63
  - lib/omni_browser/action_logging.rb
63
64
  - lib/omni_browser/action_logging/watir_mods.rb
@@ -82,7 +83,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
82
83
  version: '0'
83
84
  requirements: []
84
85
  rubyforge_project:
85
- rubygems_version: 2.5.2
86
+ rubygems_version: 2.6.1
86
87
  signing_key:
87
88
  specification_version: 4
88
89
  summary: A powerful automated browser