zander 0.1.2 → 0.1.3

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: 6aaa7c38e9278f9c8474b0c371ea89110d9a98b1
4
- data.tar.gz: 1fe1d38ba97b125b85d8cbe7c77acff4c03a954f
3
+ metadata.gz: fabb7581a9303c85870e21c1fa522444dfaea9c7
4
+ data.tar.gz: 0e190d9be3641b67d95401f354b2df8b4278ca44
5
5
  SHA512:
6
- metadata.gz: 5aaa95cc9d3ec254634c89caba8907afa4d4f1d2b5b848e08ca732f5cdea55aed7e50983635079cb1a9dede55f27a3b0bb51da30170b1dcf065f28b501ede945
7
- data.tar.gz: 09b171f1e978786c8581a613b8ca935bbe48322749a00406cc23d496c6a5cfa329dcb7e9d34d9455f457705958d72b7792b2edd40957e8b216de11853dd7eb0b
6
+ metadata.gz: 8b21e3a697ba024082fd9ff0b71fa416657d235b50fc5623ac208b4455ae49af7b9715f89b199de76456014dd56447b7d2369367821038a2e433bb5fb2ebb022
7
+ data.tar.gz: 9b40ab0106c860fbb7a8cda7054e1a4ff3306afcd518976d15ca9c45c3d8f31d1b482df36bfa1009b8a2bbf77e62897c0bd1c04d8aabe8644106b4d82c959d56
data/Gemfile CHANGED
@@ -1,6 +1,5 @@
1
1
  source 'https://rubygems.org'
2
2
  gem 'selenium-webdriver', '~> 2.43.0'
3
3
  gem 'json', '~> 1.8.1'
4
- #gem 'prawn', '~> 1.3.0'
5
4
  gem 'pdfkit', '~> 0.6.2'
6
5
  gem 'yard', '~> 0.8.7.6'
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
- `require 'zander'
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
- WEBSITES:
36
- - url: https://www.google.com/
37
- user_name: "Replace this with your username"
38
- password: "Replace this with your password"
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
- WEBSITES:
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
- source documentation [http://bit.ly/zanderdoc](http://bit.ly/zanderdoc)
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 ###
@@ -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
- require 'logger'
65
+
57
66
 
58
67
 
59
68
 
@@ -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
@@ -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 = Logger.new(LOG_FILE,10,1024000)
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 Site #{site}")
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 Site #{site}")
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
@@ -1,5 +1,6 @@
1
1
  module Zander
2
2
  #VERSION = '0.1.0' # initial release
3
3
  #VERSION = '0.1.1' # fiexed binary and added documentation
4
- VERSION = '0.1.2' # updated gemspec
4
+ #VERSION = '0.1.2' # updated gemspec
5
+ VERSION = '0.1.3' # fixed logging
5
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zander
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Spencer Carlson