jofh22 0.1.0 → 0.2.0

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
  SHA256:
3
- metadata.gz: 7dcdc2521319123e2c811fcf7a3cbb43c1ab4e003277e43d3cfb0cc15c0df09d
4
- data.tar.gz: b384667c9c65ba2a6f36a00a84a78c2a8a81f7451b2c3d021df37365bbca8562
3
+ metadata.gz: 2f081a0a933c94d6c67de08abf988681217546e858ee9ed801454d3c3f4da16d
4
+ data.tar.gz: 1d7c5d78ad06fb948a1754d8eb29a954d1fcd9300d4380c4b66c86e415ff762b
5
5
  SHA512:
6
- metadata.gz: 3721a5cfd7dac65d6c49c5dce0473f79a6c74b105145c50a6a35768543ce9566419a46e102c59528ff048d5d925a12e34fc29986f50a6e9f7c3fd9a374159807
7
- data.tar.gz: 42749c78d3ec47283c6bdec4170dcabcdc8853198227e5aef4e96fa57de464ac71c388441d1058ff94690837471d0a6648f0107818560251ab133bdcea17300c
6
+ metadata.gz: cf5f21b6687f9963339a59c6bb17af7638da7d1fbfcaf84f69575c6b5dd9b4efba7846f243d8092172bc009200e6276636d8e1d7ee2199355f89df6b8cbfaf0a
7
+ data.tar.gz: 380f2f64f445bf1a51661751a24b9426d8da3fe144aec42981abe5e0852251065335c0a5302559b93a518025a49dc4c06ed34372c1033a78898d57c6c99554c8
checksums.yaml.gz.sig CHANGED
Binary file
@@ -0,0 +1,37 @@
1
+ ---
2
+ :title:
3
+ - :select
4
+ - //div[select/@name="cmdTitle"]
5
+ :first_name:
6
+ - :input
7
+ - //input[@name="txtForename"]
8
+ :last_name:
9
+ - :input
10
+ - //input[@name="txtSurname"]
11
+ :postcode:
12
+ - :input
13
+ - //input[@name="txtHomePostcode"]
14
+ :home_telephone:
15
+ - :input
16
+ - //input[@name="txtHomeTelephone"]
17
+ :utamr:
18
+ - :click
19
+ - //input[@name="recoveryOption"]
20
+ :email_address:
21
+ - :input
22
+ - //input[@name="txtHomeEmail"]
23
+ :password:
24
+ - :input
25
+ - //input[@name="txtPassword"]
26
+ :retype_password:
27
+ - :input
28
+ - //input[@name="txtPassword2"]
29
+ :ayceb:
30
+ - :select
31
+ - //div[select/@name="cmbEmployed"]
32
+ :ictih:
33
+ - :click
34
+ - //input[@name="Termscheckbox"]
35
+ :register:
36
+ - :click
37
+ - //button[@type="submit"]
data/lib/jofh22.rb CHANGED
@@ -6,14 +6,13 @@
6
6
 
7
7
  require 'yaml'
8
8
  require 'ferrumwizard'
9
- require 'nokorexi'
10
9
 
11
10
 
12
11
  module Jofh22
13
12
 
14
13
  class NHSScot
15
14
 
16
- attr_reader :browser, :h, :doc
15
+ attr_reader :browser
17
16
 
18
17
  # notes:
19
18
  #
@@ -21,122 +20,61 @@ module Jofh22
21
20
  # read a cookie file
22
21
  # * the *yml* parameter refeference the YAML file containing the inputs
23
22
  #
24
- def initialize(yml='/tmp/tmp.yaml', cookies: nil, debug: false)
23
+ def initialize(yml='/tmp/tmp.yaml', ofh22_filepath=nil,
24
+ cookies: nil, debug: false)
25
25
 
26
- @debug = debug
26
+ @cookies, @debug = cookies, debug
27
+ ofh22_filepath ||= File.join(File.dirname(__FILE__), '..', 'data',
28
+ 'nhs_scot.yaml')
27
29
  url = 'https://apply.jobs.scot.nhs.uk/register.aspx'
30
+ cookies2 = cookies if File.exists? cookies
28
31
  @browser = browser = FerrumWizard.new(url, headless: false,
29
- cookies: cookies)
30
- sleep 1
31
- @doc = Nokorexi.new(browser.body).to_doc
32
+ cookies: cookies2)
32
33
  sleep 1
33
34
 
34
35
  filepath = yml
35
36
  @h = YAML.load(File.read(filepath))
36
37
 
38
+ if not @h['home_telephone'].to_s[0] == '+' then
39
+ @h['home_telephone'] = '+' + @h['home_telephone'].to_s
40
+ end
41
+
42
+ @ofh22 = YAML.load(File.read(ofh22_filepath))
43
+
37
44
  end
38
45
 
39
- def populate_form()
40
-
41
- h, browser = @h, @browser
42
- r = browser.at_xpath('//select[@name="cmdTitle"]')
43
-
44
- # Title
45
- # options: , Councillor, Doctor, Father, Friar, Lady, Lord, Major,
46
- # Miss, Mr., Mrs., Ms., Mx., Professor, Reverend, Sir
47
- title = h['title']
48
- titles = %w( Councillor Doctor Father Friar Lady Lord Major Miss Mr.) +
49
- %w(Mrs. Ms. Mx. Professor Reverend Sir)
50
- r = titles.grep /#{title}/i
51
- n = titles.index(r.first) + 1
52
- r = browser.at_xpath('//div[select/@name="cmdTitle"]')
53
- r.focus
54
- n.times { r.type(:down); sleep 0.4}
55
- r.click
56
- sleep 0.5
57
-
58
- r = browser.at_xpath('//input[@name="txtForename"]')
59
-
60
- # First name
61
- first_name = h['first_name']
62
- r.focus.type first_name
63
- sleep 0.5
64
-
65
- r = browser.at_xpath('//input[@name="txtSurname"]')
66
-
67
- # Last name
68
- last_name = h['last_name']
69
- r.focus.type last_name
70
- sleep 0.5
71
-
72
- r = browser.at_xpath('//input[@name="txtHomePostcode"]')
73
-
74
- # Postcode
75
- postcode = h['postcode']
76
- r.focus.type postcode
77
- sleep 0.5
78
-
79
- r = browser.at_xpath('//input[@name="txtHomeTelephone"]')
80
-
81
- # Home Telephone
82
- home_telephone = h['home_telephone']
83
- r.focus.type '+' + home_telephone.to_s.sub(/^\+/,'')
84
- sleep 0.5
85
-
86
- r = browser.at_xpath('//input[@name="recoveryOption"]')
87
- r.focus.click
88
-
89
- r = browser.at_xpath('//input[@name="txtHomeEmail"]')
90
-
91
- # Email address
92
- email_address = h['email_address']
93
- r.focus.type email_address
94
- sleep 0.5
95
-
96
- r = browser.at_xpath('//input[@name="txtPassword"]')
97
-
98
- # Password
99
- password = h['password']
100
- r.focus.type password
101
- sleep 0.5
102
-
103
- r = browser.at_xpath('//input[@name="txtPassword2"]')
104
-
105
- # Re-type password
106
- retype_password = h['retype_password']
107
- r.focus.type retype_password
108
- sleep 0.5
109
-
110
- r = browser.at_xpath('//select[@name="cmbEmployed"]')
111
- sleep 0.5
112
- # Are you currently employed by NHS Scotland?
113
- # options: Please select, Yes, No
114
- ayceb = h['ayceb']
115
- titles = ['Please select', 'Yes', 'No']
116
- puts 'ayceb: ' + ayceb.inspect if @debug
117
- puts 'titles: ' + titles.inspect if @debug
118
-
119
- r2 = titles.grep /#{ayceb}/i
120
- puts 'r2: ' + r2.inspect if @debug
121
- n = titles.index(r2.first) + 1
122
- r = browser.at_xpath('//div[select/@name="cmbEmployed"]')
123
- r.focus
124
- n.times { r.type(:down); sleep 0.4}
125
- r.click
126
- sleep 0.5
127
-
128
- r = browser.at_xpath('//input[@name="Termscheckbox"]')
129
- r.focus.click
130
-
131
- r = browser.at_xpath('//button[@type="submit"]')
132
- r.focus.click
133
-
134
- #r.focus.type(:enter)
135
- sleep 2
136
- browser.save_cookies(cookie_filepath)
46
+ # used for the registration process for new applicants
47
+ #
48
+ def populate_form(cookie_filepath=@cookies)
49
+
50
+ @ofh22.each do |key, x|
51
+
52
+ if @debug then
53
+ puts 'key: ' + key.inspect
54
+ puts 'x: ' + x.inspect
55
+ end
56
+
57
+ type, xpath = x
58
+
59
+ if type == :input or type == :select then
60
+ @browser.method(type).call(xpath, @h[key.to_s])
61
+ elsif type == :click
62
+ @browser.method(type).call(xpath)
63
+ end
64
+
65
+ end
66
+
67
+ @browser.save_cookies(cookie_filepath)
137
68
  puts 'cookies saved to ' + cookie_filepath
138
69
 
70
+ end
71
+
72
+ def to_h()
73
+ @h
74
+ end
139
75
 
76
+ def to_ofh22()
77
+ @ofh22
140
78
  end
141
79
 
142
80
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jofh22
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -35,7 +35,7 @@ cert_chain:
35
35
  cf1DJMYHlnirwc8n9E70PSbNohM3s47lbjLfbQRTb18TFrHi4OHXv7M9xaYxVQhQ
36
36
  /FCeM970TfCe+6ZwjFwlykWw
37
37
  -----END CERTIFICATE-----
38
- date: 2022-05-29 00:00:00.000000000 Z
38
+ date: 2022-06-01 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: ferrumwizard
@@ -46,7 +46,7 @@ dependencies:
46
46
  version: '0.3'
47
47
  - - ">="
48
48
  - !ruby/object:Gem::Version
49
- version: 0.3.3
49
+ version: 0.3.4
50
50
  type: :runtime
51
51
  prerelease: false
52
52
  version_requirements: !ruby/object:Gem::Requirement
@@ -56,33 +56,14 @@ dependencies:
56
56
  version: '0.3'
57
57
  - - ">="
58
58
  - !ruby/object:Gem::Version
59
- version: 0.3.3
60
- - !ruby/object:Gem::Dependency
61
- name: nokorexi
62
- requirement: !ruby/object:Gem::Requirement
63
- requirements:
64
- - - "~>"
65
- - !ruby/object:Gem::Version
66
- version: '0.7'
67
- - - ">="
68
- - !ruby/object:Gem::Version
69
- version: 0.7.0
70
- type: :runtime
71
- prerelease: false
72
- version_requirements: !ruby/object:Gem::Requirement
73
- requirements:
74
- - - "~>"
75
- - !ruby/object:Gem::Version
76
- version: '0.7'
77
- - - ">="
78
- - !ruby/object:Gem::Version
79
- version: 0.7.0
59
+ version: 0.3.4
80
60
  description:
81
61
  email: digital.robertson@gmail.com
82
62
  executables: []
83
63
  extensions: []
84
64
  extra_rdoc_files: []
85
65
  files:
66
+ - data/nhs_scot.yaml
86
67
  - lib/jofh22.rb
87
68
  homepage: https://github.com/jrobertson/jofh22
88
69
  licenses:
metadata.gz.sig CHANGED
Binary file