whaly 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +7 -0
  2. data/lib/whaly/whalys.rb +219 -0
  3. data/lib/whaly.rb +2 -0
  4. metadata +51 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 4ff8fe6f76d97a3f8f62ab7ad9be8cc35333f9734b90220adeedb78939bfe093
4
+ data.tar.gz: 99afe906cfbff69cecaca1221176453599ed6d23db7fae0cf80413daf2697b14
5
+ SHA512:
6
+ metadata.gz: e259517fdfced8ae304179f20ff921c11d3f6d7ae8910b480ce40edb032b4b220dc3284ab9e11d95dc8a4ab4707054e627f2a4fb671d2fafb6c7d4902a0ba17d
7
+ data.tar.gz: 8b48a8443167212f85c59606c9e17fcc11167f5c05301218c255c73afe94d96ae555f9e145262a60ca1c0685b1712fae2a44acbcab47fd9aa52ac69f36250566
@@ -0,0 +1,219 @@
1
+ class Whaly
2
+
3
+ def whaly_s(names)
4
+ whalys_runs = Whaly.new()
5
+ whalys_runs.whalyrun(names)
6
+ end
7
+
8
+ def whalyrun(fiz)
9
+ while true
10
+ lz = []
11
+ def fileopener(filename)
12
+ File.open(filename) do |thename|
13
+ return thename.readlines
14
+ end
15
+ end
16
+
17
+
18
+ lz.push(fileopener(fiz))
19
+
20
+ votes = []
21
+ count = 0
22
+
23
+ fileopener(fiz).each do |line|
24
+ name = line.chomp
25
+ votes.push(name)
26
+ end
27
+
28
+ values = []
29
+ counter = 0
30
+ votes.each do |thehow|
31
+ spts = thehow
32
+ values << spts.to_s.split("is")[1]
33
+ end
34
+
35
+ path = []
36
+ counter = 0
37
+ votes.each do |thehow|
38
+ spts = thehow
39
+ x = spts.to_s.split("find ")[1]
40
+ xx = x.to_s.split("is")
41
+ path << xx[0]
42
+ end
43
+
44
+
45
+ pzath = []
46
+ counter = 0
47
+ votes.each do |thehow|
48
+ spts = thehow
49
+ x = spts.to_s.split("is")[1]
50
+ xx = x.to_s.split(".")
51
+ pzath << xx[1]
52
+ end
53
+
54
+
55
+ storeit = []
56
+ counter = 0
57
+ votes.each do |thehow|
58
+ spts = thehow
59
+ x = spts.to_s.split(" ")
60
+ storeit << x
61
+ end
62
+
63
+
64
+ ppp = []
65
+
66
+ fileopener(fiz).each do |plm|
67
+ ppp << plm.split("\n")
68
+ end
69
+
70
+ plm = 0
71
+ sz = []
72
+ ppp.each do |how|
73
+ sz.push(how.to_s.split(" "))
74
+ plm += 1
75
+ end
76
+
77
+ z = storeit.length
78
+
79
+ counter = 0
80
+ st = 0
81
+ game = []
82
+ # lkm = {}
83
+ # z = []
84
+ while counter < z
85
+ ps = storeit[counter]
86
+ history = { '<--' => 'driver.navigate.back', '-->' => 'driver.navigate.forward', 'refresh' => 'driver.navigate.refresh'}
87
+ if storeit[counter][ps.find_index("@import").to_i + 1] == "-"
88
+ valz = {'whaly-engine' => 'selenium-webdriver',
89
+ 'whaly-gems' => 'rubygems'}
90
+ game << format("require '%s'",valz[storeit[counter][2]])
91
+ elsif storeit[counter][ps.find_index("start-whaly-engine").to_i + 1] == 'c' || storeit[counter][ps.find_index("start-whaly-engine").to_i + 1] == 'f' || storeit[counter][ps.find_index("start-whaly-engine").to_i + 1] == 'i'
92
+ engine_values = {
93
+ 'c' => 'chrome',
94
+ 'f' => 'firefox',
95
+ 'i' => 'ie'
96
+ }
97
+ engine = storeit[counter][ps.find_index("start-whaly-engine").to_i + 1]
98
+ game << format("driver = Selenium::WebDriver.for(:%s)",engine_values[engine])
99
+ elsif storeit[counter].find_index("<--")
100
+ game << history['<--']
101
+ elsif storeit[counter].find_index("-->")
102
+ game << history['-->']
103
+ elsif storeit[counter].find_index("refresh!!")
104
+ game << history['refresh']
105
+ elsif sz[counter].find_index("keyboard") || sz[counter].find_index("mouse")
106
+ pppp = []
107
+ pppp << sz[counter].to_s.sub("[","").sub("]","")
108
+
109
+ rejectwords = pppp.to_s.split("\n").to_s.chars
110
+ removeit = rejectwords.reject { |lop| lop.include?("[") || lop.include?("]") || lop.include?("\"") || lop.include?("\\") || lop.include?(", ")}
111
+
112
+ zu = []
113
+
114
+ removeit.join("").split("I/O") do |lll|
115
+ if lll
116
+ zu << "driver.action." + lll.to_s.sub(" mouse,","").sub(" keyboard,","").sub(", ","").sub(", =>, "," => ").sub(", "," ").sub(", "," ").sub(", "," ")
117
+ end
118
+ end
119
+
120
+ rej = zu.reject { |llkm| llkm if llkm == "driver.action."}
121
+
122
+ rej.each do |lolo|
123
+ game << lolo
124
+ end
125
+ elsif storeit[counter][ps.find_index("stop-whaly-engine").to_i + 1] == '-quit'
126
+ engine = storeit[counter][ps.find_index("stop-whaly-engine").to_i + 1]
127
+ engine_values = {
128
+ '-quit' => 'quit'
129
+ }
130
+ game << format("driver.%s",engine_values[engine])
131
+ elsif storeit[counter][ps.find_index("imp-wait").to_i + 1] == "++"
132
+ game << format("driver.manage.timeouts.implicit_wait = %s",storeit[counter].last)
133
+ elsif storeit[counter][ps.find_index("imp-wait").to_i + 1] == "--"
134
+ game << format("driver.manage.timeouts.implicit_wait = %s",0)
135
+ elsif storeit[counter][ps.find_index("go").to_i + 3] == "url"
136
+ l = storeit[counter][ps.find_index("url").to_i + 1]
137
+ game << format("driver.navigate.to(%s)",l.split("\"]")[0])
138
+ elsif storeit[counter][ps.find_index("find").to_i + 2] == "is"
139
+ a = storeit[counter][ps.find_index("find").to_i + 1]
140
+ rej = storeit[counter].reject { |ll| ll.include?("is")}
141
+ rejj = rej.reject { |ll| ll.include?("find")}
142
+ rejjj = rejj.reject { |llz| llz.include?(rejj[0])}
143
+ first = values[counter]
144
+ if pzath[counter]
145
+ game << format("driver.find_element(:%s,%s).%s",a,values[counter].to_s.split(".")[0],pzath[counter])
146
+ else
147
+ game << format("driver.find_element(:%s,%s)",a,values[counter])
148
+ end
149
+ elsif storeit[counter][ps.find_index("and").to_i + 1] == "select-by"
150
+ b = storeit[counter][ps.find_index("isz").to_i - 1]
151
+ a = values[counter].to_s.split("and")[0].split("z")[1]
152
+ s = values[counter].to_s.split("select-by")[1].split("-")[1]
153
+ m = values[counter].to_s.split("select-by")[1].split("-")[2]
154
+ game << format("Selenium::WebDriver::Support::Select.new(driver.find_element(:%s, %s)).select_by(%s,%s)",b,a,s,m)
155
+ elsif storeit[counter][ps.find_index("and").to_i + 1] == "deselect-by"
156
+ b = storeit[counter][ps.find_index("isz").to_i - 1]
157
+ a = values[counter].to_s.split("and")[0].split("z")[1]
158
+ s = values[counter].to_s.split("deselect-by")[1].split("-")[1]
159
+ m = values[counter].to_s.split("deselect-by")[1].split("-")[2]
160
+ game << format("Selenium::WebDriver::Support::Select.new(driver.find_element(:%s, %s)).deselect_by(%s,%s)",b,a,s,m)
161
+ elsif storeit[counter][ps.find_index("add-cookies").to_i + 1] == "{"
162
+ chk = {}
163
+ lzz = 0
164
+ storeit[counter].each do |ll|
165
+ chk[lzz] = ll
166
+ lzz += 1
167
+ end
168
+ zd = chk.values.to_s.split(",").reject { |ll| ll.include?(",") || ll.include?(" ") || ll.include?("add-cookies")}
169
+ py = zd.to_s.split("").reject { |lkjn| lkjn.include?("\"") || lkjn.include?("add-cookies") || lkjn.include?("]") || lkjn.include?("[") || lkjn.include?("\\") || lkjn.include?("{")}
170
+ pkj = []
171
+ py.each do |lkjj|
172
+ pkj << lkjj.sub(",","")
173
+ end
174
+ polm = pkj.join("").sub(" ","")
175
+ pjk = []
176
+ polm.to_s.split(" ") do |plkjm|
177
+ pjk.push(plkjm + ',')
178
+ end
179
+ singleline = ''
180
+ pjk.each do |plkj|
181
+ singleline += plkj
182
+ end
183
+ game << "driver.manage.add_cookie(#{singleline.sub("},","")})"
184
+ elsif storeit[counter][ps.find_index("show").to_i + 1] == "l-all-cookies"
185
+ game << "driver.manage.all_cookies"
186
+ elsif storeit[counter][ps.find_index("del").to_i + 1] == "d-all-cookies"
187
+ game << "driver.manage.delete_all_cookies"
188
+ elsif storeit[counter][ps.find_index("show").to_i + 1] == "-Scookies"
189
+ ik = storeit[counter].reject { |lzp| lzp.include?("-") || lzp.include?("show")}
190
+ game << format("driver.manage.cookie_named(%s)",ik[0])
191
+ elsif storeit[counter][ps.find_index("show").to_i + 1] == "-Dcookies"
192
+ ik = storeit[counter].reject { |lzp| lzp.include?("-") || lzp.include?("del")}
193
+ game << format("driver.manage.delete_all_cookies(%s)",ik[0])
194
+ elsif storeit[counter].length < 2
195
+ game << "\n"
196
+ elsif storeit[counter][ps.find_index("delay-for").to_i]
197
+ if storeit[counter][ps.find_index("delay-for").to_i]
198
+ game << format("sleep %s", storeit[counter][1])
199
+ else
200
+ game << format("%s", storeit[counter][1])
201
+ end
202
+ end
203
+ counter += 1
204
+ end
205
+ sleep 0.5
206
+ File.open("whalytest_" + fiz + ".rb",'w') do |file|
207
+ game.map do |ll|
208
+ file.write(ll + "\n")
209
+ end
210
+ end
211
+ puts "whaly engine is running until you press ctrl + c to stop"
212
+ end
213
+
214
+
215
+ end
216
+
217
+ end
218
+
219
+
data/lib/whaly.rb ADDED
@@ -0,0 +1,2 @@
1
+
2
+ require "whaly/whalys"
metadata ADDED
@@ -0,0 +1,51 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: whaly
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.4
5
+ platform: ruby
6
+ authors:
7
+ - suresh pandiyan
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2022-10-28 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Whaly is the easy way to write a browser-based selenium scripts for ruby
14
+ users.It's fully focused on the words, because words better than codes.it's written
15
+ in ruby language.it's only compatible for ruby language (not for another programming
16
+ language)
17
+ email: suresh.pandiyan1@outlook.com
18
+ executables: []
19
+ extensions: []
20
+ extra_rdoc_files: []
21
+ files:
22
+ - lib/whaly.rb
23
+ - lib/whaly/whalys.rb
24
+ homepage: https://github.com/sureshpandiyan1/whaly
25
+ licenses:
26
+ - MIT
27
+ metadata:
28
+ homepage_uri: https://github.com/sureshpandiyan1/whaly
29
+ source_code_uri: https://github.com/sureshpandiyan1/whaly
30
+ changelog_uri: https://github.com/sureshpandiyan1/whaly
31
+ funding_uri: https://ko-fi.com/sureshp
32
+ post_install_message:
33
+ rdoc_options: []
34
+ require_paths:
35
+ - lib
36
+ required_ruby_version: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 2.5.0
41
+ required_rubygems_version: !ruby/object:Gem::Requirement
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ requirements: []
47
+ rubygems_version: 3.3.23
48
+ signing_key:
49
+ specification_version: 4
50
+ summary: Whaly - easy way to write a text-based automation for selenium
51
+ test_files: []