zander 0.1.2 → 0.1.3
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.
- checksums.yaml +4 -4
- data/Gemfile +0 -1
- data/README.md +17 -9
- data/bin/zander +1 -1
- data/lib/zander.rb +15 -6
- data/lib/zander/site.rb +12 -2
- data/lib/zander/sites.rb +4 -10
- data/lib/zander/version.rb +2 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fabb7581a9303c85870e21c1fa522444dfaea9c7
|
4
|
+
data.tar.gz: 0e190d9be3641b67d95401f354b2df8b4278ca44
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8b21e3a697ba024082fd9ff0b71fa416657d235b50fc5623ac208b4455ae49af7b9715f89b199de76456014dd56447b7d2369367821038a2e433bb5fb2ebb022
|
7
|
+
data.tar.gz: 9b40ab0106c860fbb7a8cda7054e1a4ff3306afcd518976d15ca9c45c3d8f31d1b482df36bfa1009b8a2bbf77e62897c0bd1c04d8aabe8644106b4d82c959d56
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -28,18 +28,20 @@ Usage
|
|
28
28
|
cut -d '(' -f 2 | sed 's/)//g')/bin/zander"
|
29
29
|
|
30
30
|
#### Custom Input Example
|
31
|
-
|
32
|
-
Zander.run(sites: "sites.yaml", actions: "actions.yaml")
|
31
|
+
require 'zander'
|
32
|
+
Zander.run(sites: "sites.yaml", actions: "actions.yaml")
|
33
33
|
|
34
34
|
sites.yaml
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
35
|
+
|
36
|
+
WEBSITES:
|
37
|
+
- url: https://www.google.com/
|
38
|
+
user_name: "Replace this with your username"
|
39
|
+
password: "Replace this with your password"
|
39
40
|
|
40
41
|
|
41
42
|
actions.yaml
|
42
|
-
|
43
|
+
|
44
|
+
WEBSITES:
|
43
45
|
- URL: https://www.google.com/
|
44
46
|
ACTIONS:
|
45
47
|
- action:
|
@@ -67,7 +69,13 @@ actions.yaml
|
|
67
69
|
- manual:
|
68
70
|
- action:
|
69
71
|
action_type: done
|
70
|
-
|
72
|
+
|
73
|
+
Notice: variable names and their values are defined by you in `sites.yaml`.
|
74
|
+
variables can then be used in `actions.yaml`. i.e. You could change `user_name:`
|
75
|
+
to `email:` or any other value that you prefer and as long as you also
|
76
|
+
update `user_name` to 'email' in the `actions.yaml` it will still work.
|
77
|
+
|
71
78
|
Documentation
|
72
79
|
---
|
73
|
-
|
80
|
+
* `actions.yaml` documentation [docs](http://)
|
81
|
+
* source documentation [http://bit.ly/zanderdoc](http://bit.ly/zanderdoc)
|
data/bin/zander
CHANGED
@@ -27,7 +27,7 @@
|
|
27
27
|
# a full example is shown at the bottom #
|
28
28
|
# #
|
29
29
|
#######################################################################################################
|
30
|
-
require 'zander'
|
30
|
+
require 'zander' #
|
31
31
|
#######################################################################################################
|
32
32
|
### 1.) Demo - Uses share/sites.yaml and shre/actions.yaml ###
|
33
33
|
Zander.run ###
|
data/lib/zander.rb
CHANGED
@@ -21,26 +21,35 @@ lib = File.expand_path('../../lib/', __FILE__)
|
|
21
21
|
$:.unshift lib unless $:.include?(lib)
|
22
22
|
# p $:.dup
|
23
23
|
|
24
|
+
require 'logger'
|
25
|
+
|
24
26
|
module Zander
|
27
|
+
@@log_level = nil
|
28
|
+
LOG_FILE = STDOUT # 'log.txt'
|
29
|
+
LOG = ::Logger.new(LOG_FILE,10,1024000)
|
30
|
+
|
25
31
|
def self.run(sites: nil, actions: nil, steps: nil)
|
26
|
-
|
32
|
+
LOG.level = Logger::INFO
|
33
|
+
LOG.level = @@log_level unless @@log_level == nil
|
34
|
+
|
27
35
|
if steps == nil
|
28
36
|
steps = ARGV[0].split(',').map(&:to_i) unless ARGV[0] == nil
|
29
37
|
end
|
30
38
|
|
31
39
|
if (sites != nil && actions != nil)
|
32
|
-
zander = Sites.new(sites,steps)
|
40
|
+
zander = Sites.new(sites,steps, LOG)
|
33
41
|
zander.add_actions(actions)
|
34
42
|
else
|
35
|
-
zander = Sites.new(Util.get_path('share/sites.yaml'),steps)
|
43
|
+
zander = Sites.new(Util.get_path('share/sites.yaml'),steps, LOG)
|
36
44
|
zander.add_actions(Util.get_path('share/actions.yaml'))
|
37
45
|
end
|
38
|
-
|
39
|
-
zander.set_log_level Logger::DEBUG
|
40
46
|
zander.sites.each do |site|
|
41
47
|
site.drive
|
42
48
|
end
|
49
|
+
end
|
43
50
|
|
51
|
+
def self.log_level(level)
|
52
|
+
@@log_level = level
|
44
53
|
end
|
45
54
|
end
|
46
55
|
require 'zander/cmd_mapper'
|
@@ -53,7 +62,7 @@ require 'zander/ht'
|
|
53
62
|
|
54
63
|
require 'selenium-webdriver'
|
55
64
|
require 'yaml'
|
56
|
-
|
65
|
+
|
57
66
|
|
58
67
|
|
59
68
|
|
data/lib/zander/site.rb
CHANGED
@@ -19,7 +19,6 @@ module Zander
|
|
19
19
|
def add_actions(actions)
|
20
20
|
actions.each do |action|
|
21
21
|
# convert keys in action hash to symbols
|
22
|
-
puts "Action Hash::: #{action}"
|
23
22
|
action = action.keys_to_sym
|
24
23
|
@log.debug("Create action #{action}")
|
25
24
|
obj = CommandMapper.map(self, @driver, @log, action)
|
@@ -67,8 +66,10 @@ module Zander
|
|
67
66
|
@actions.each do |action|
|
68
67
|
vars << action.to_s
|
69
68
|
end
|
69
|
+
elsif key.to_s == "@password"
|
70
|
+
vars << "#{key}=\"#{mask(value)}\""
|
70
71
|
elsif index == vh.size - 1
|
71
|
-
vars << "#{key}=\"#{value}\""
|
72
|
+
vars << "#{key}=\"#{value}\""
|
72
73
|
else
|
73
74
|
"#{key}=\"#{value}\", "
|
74
75
|
end
|
@@ -76,6 +77,15 @@ module Zander
|
|
76
77
|
vars
|
77
78
|
end
|
78
79
|
|
80
|
+
def mask(var)
|
81
|
+
clear = 3 #keep last 3 in clear text
|
82
|
+
masked = var[0];
|
83
|
+
(var.length-(clear+1)).times do
|
84
|
+
masked << '*'
|
85
|
+
end
|
86
|
+
masked << var[(var.length-clear)...var.length]
|
87
|
+
end
|
88
|
+
|
79
89
|
def inspect
|
80
90
|
to_s
|
81
91
|
end
|
data/lib/zander/sites.rb
CHANGED
@@ -3,14 +3,12 @@ module Zander
|
|
3
3
|
IMPLICIT_WAIT = 10
|
4
4
|
YAML_URL = 'URL'
|
5
5
|
YAML_ACTIONS = 'ACTIONS'
|
6
|
-
LOG_FILE = STDOUT # 'log.txt'
|
7
6
|
|
8
7
|
attr_reader :sites
|
9
8
|
|
10
|
-
def initialize(yaml_file, steps = nil)
|
9
|
+
def initialize(yaml_file, steps = nil, log)
|
11
10
|
@sites_yaml_file = yaml_file
|
12
|
-
@log =
|
13
|
-
@log.level = Logger::DEBUG
|
11
|
+
@log = log
|
14
12
|
@sites = Array.new
|
15
13
|
### FIREFOX PROFILE
|
16
14
|
profile = Selenium::WebDriver::Firefox::Profile.new
|
@@ -36,11 +34,11 @@ module Zander
|
|
36
34
|
if yaml.has_key? 'WEBSITES'
|
37
35
|
yaml['WEBSITES'].each_with_index do |site, index|
|
38
36
|
if steps == nil
|
39
|
-
@log.debug("Create
|
37
|
+
@log.debug("Create site object for #{site['url']}")
|
40
38
|
@sites.push(Site.new(parent: self, hash: site, driver: @driver, log: @log))
|
41
39
|
else
|
42
40
|
if steps.include?(index)
|
43
|
-
@log.debug("Create
|
41
|
+
@log.debug("Create site object for #{site['url']}")
|
44
42
|
@sites.push(Site.new(parent: self, hash: site, driver: @driver, log: @log))
|
45
43
|
end
|
46
44
|
end
|
@@ -49,10 +47,6 @@ module Zander
|
|
49
47
|
end
|
50
48
|
end
|
51
49
|
|
52
|
-
def set_log_level(level)
|
53
|
-
@log.level = level
|
54
|
-
end
|
55
|
-
|
56
50
|
def get_site(url)
|
57
51
|
@sites.each do |site|
|
58
52
|
return site if site.url == url
|
data/lib/zander/version.rb
CHANGED