agent_q 0.0.16 → 0.0.17
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/agent_q +20 -8
- data/lib/{agent_q.rb → check_case.rb} +13 -8
- data/lib/run_queries.rb +64 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aed3c3ba07adf20d25faad701cf7602f555222261e85964a10a2e9a203684854
|
4
|
+
data.tar.gz: 56cecb1453e333cfca334b557a699a94bf00898173f1d51ac8c125e3f58b0fa2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cc6190c61c8609c5617dbaba1d1537b624b58096d9234ec0584c2e8f36ac02129d2e471cdfdb2537f7f0920d181e148c7f7853ba99b4bced8b28c836a97e5842
|
7
|
+
data.tar.gz: b6dc6764d7094cc891bcd711849a2c749eb47d6355f28e9197e208396b6f1e7d84d01aa41d7d6b358dbdf4a99c3f6aef0e7bc86c02502e75b588301e72c88d92
|
data/bin/agent_q
CHANGED
@@ -1,13 +1,25 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
require 'rubygems'
|
3
|
-
require_relative '../lib/
|
3
|
+
require_relative '../lib/check_case'
|
4
|
+
require_relative '../lib/run_queries'
|
4
5
|
|
5
|
-
|
6
|
-
threshold_score = ARGV[1]
|
7
|
-
username = ARGV[2]
|
8
|
-
password = ARGV[3]
|
9
|
-
quepid_url = ARGV[4]
|
6
|
+
subcommand = ARGV[0]
|
10
7
|
|
8
|
+
if subcommand == 'check-case'
|
9
|
+
quepid_case = ARGV[1]
|
10
|
+
threshold_score = ARGV[2]
|
11
|
+
username = ARGV[3]
|
12
|
+
password = ARGV[4]
|
13
|
+
quepid_url = ARGV[5]
|
14
|
+
|
15
|
+
CheckCase.new(quepid_case, threshold_score, username, password, quepid_url).run
|
16
|
+
end
|
11
17
|
|
12
|
-
|
13
|
-
|
18
|
+
if subcommand == 'run-queries'
|
19
|
+
quepid_case = ARGV[1]
|
20
|
+
username = ARGV[2]
|
21
|
+
password = ARGV[3]
|
22
|
+
quepid_url = ARGV[4]
|
23
|
+
|
24
|
+
RunQueries.new(quepid_case, username, password, quepid_url).run
|
25
|
+
end
|
@@ -5,7 +5,7 @@ require 'capybara/dsl'
|
|
5
5
|
require 'capybara/cuprite'
|
6
6
|
require 'json'
|
7
7
|
|
8
|
-
class
|
8
|
+
class CheckCase
|
9
9
|
include Capybara::DSL
|
10
10
|
|
11
11
|
|
@@ -15,8 +15,13 @@ class AgentQ
|
|
15
15
|
@username = username
|
16
16
|
@password = password
|
17
17
|
@quepid_url = quepid_url
|
18
|
+
|
19
|
+
Capybara.register_driver :cuprite do |app|
|
20
|
+
Capybara::Cuprite::Driver.new(app, timeout: 30) # Increase timeout to 30 seconds
|
21
|
+
end
|
18
22
|
|
19
23
|
Capybara.default_driver = :cuprite
|
24
|
+
Capybara.default_max_wait_time = 30 # Increase timeout to 30 seconds
|
20
25
|
#Capybara.app_host = @quepid_url
|
21
26
|
end
|
22
27
|
|
@@ -32,17 +37,17 @@ class AgentQ
|
|
32
37
|
|
33
38
|
click_button('Sign in')
|
34
39
|
end
|
35
|
-
|
36
|
-
#within(:xpath, "/html/body/div[3]/div/div/div[1]/div[1]/div/form") do
|
37
|
-
# fill_in('Password', with: @password)
|
38
|
-
#end
|
39
40
|
#save_screenshot('quepid_login.png')
|
40
41
|
|
42
|
+
visit("#{@quepid_url}/case/#{@quepid_case}")
|
41
43
|
|
44
|
+
page.has_css?('.search-feedback', visible: true, wait: Capybara.default_max_wait_time)
|
45
|
+
|
46
|
+
#save_screenshot('quepid_case_queries2.png')
|
42
47
|
|
43
|
-
|
44
|
-
|
45
|
-
#save_screenshot('
|
48
|
+
page.has_no_css?('.search-feedback', wait: Capybara.default_max_wait_time)
|
49
|
+
|
50
|
+
#save_screenshot('quepid_case.png')
|
46
51
|
|
47
52
|
visit "#{@quepid_url}/api/cases/#{@quepid_case}/scores/all.json"
|
48
53
|
html = page.html
|
data/lib/run_queries.rb
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
# Inspired by http://ngauthier.com/2014/06/scraping-the-web-with-ruby.html
|
2
|
+
|
3
|
+
require 'capybara'
|
4
|
+
require 'capybara/dsl'
|
5
|
+
require 'capybara/cuprite'
|
6
|
+
require 'json'
|
7
|
+
|
8
|
+
class RunQueries
|
9
|
+
include Capybara::DSL
|
10
|
+
|
11
|
+
|
12
|
+
def initialize(quepid_case, username, password, quepid_url)
|
13
|
+
@quepid_case = quepid_case
|
14
|
+
@username = username
|
15
|
+
@password = password
|
16
|
+
@quepid_url = quepid_url
|
17
|
+
|
18
|
+
Capybara.register_driver :cuprite do |app|
|
19
|
+
Capybara::Cuprite::Driver.new(app, timeout: 30) # Increase timeout to 30 seconds
|
20
|
+
end
|
21
|
+
|
22
|
+
Capybara.default_driver = :cuprite
|
23
|
+
Capybara.default_max_wait_time = 30 # Increase timeout to 30 seconds
|
24
|
+
# Capybara.app_host = @quepid_url
|
25
|
+
end
|
26
|
+
|
27
|
+
def run
|
28
|
+
|
29
|
+
# we go direct to the case, which then prompts the login process. That way we only
|
30
|
+
# score the requested case
|
31
|
+
visit("#{@quepid_url}/case/#{@quepid_case}/query/0")
|
32
|
+
save_screenshot('quepid.png')
|
33
|
+
within('#login') do
|
34
|
+
fill_in('user_email', with: @username)
|
35
|
+
fill_in('user_password', with: @password)
|
36
|
+
|
37
|
+
click_button('Sign in')
|
38
|
+
end
|
39
|
+
save_screenshot('quepid_login.png')
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
visit("#{@quepid_url}/case/#{@quepid_case}/query/0")
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
save_screenshot('quepid_case_queries.png')
|
48
|
+
|
49
|
+
page.has_css?('.search-feedback', visible: true, wait: 60)
|
50
|
+
|
51
|
+
save_screenshot('quepid_case_queries2.png')
|
52
|
+
|
53
|
+
page.has_no_css?('.search-feedback', wait: 60)
|
54
|
+
|
55
|
+
save_screenshot('quepid_case_queries3.png')
|
56
|
+
|
57
|
+
content = find('.snapshot-payload').text
|
58
|
+
|
59
|
+
puts content
|
60
|
+
|
61
|
+
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: agent_q
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.17
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Pugh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-03-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capybara
|
@@ -80,7 +80,8 @@ extensions: []
|
|
80
80
|
extra_rdoc_files: []
|
81
81
|
files:
|
82
82
|
- bin/agent_q
|
83
|
-
- lib/
|
83
|
+
- lib/check_case.rb
|
84
|
+
- lib/run_queries.rb
|
84
85
|
homepage: http://rubygems.org/gems/agent_q
|
85
86
|
licenses:
|
86
87
|
- MIT
|