brake 0.2.4 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README +30 -16
- data/bin/brake +2 -1
- data/lib/brake.rb +108 -91
- metadata +6 -5
data/README
CHANGED
@@ -2,33 +2,40 @@ README
|
|
2
2
|
A Brandwatch rake wrapper, Brake
|
3
3
|
|
4
4
|
Simply this is a wrapper disigned to give the end user some control by being able to pass command line options
|
5
|
-
but still having the conviniance of rake tasks
|
6
|
-
Primarly used to aid in the brandwatch automation tasting hence brake for brandwatch rake
|
7
|
-
The tool has now evolved and if used cleverly could be used by anyome
|
5
|
+
but still having the conviniance and structure of rake tasks
|
8
6
|
|
9
|
-
Brake Version:0.2.
|
7
|
+
Brake Version:0.2.5
|
10
8
|
|
11
|
-
Brake,
|
9
|
+
Brake, A Cucumber options parser wrapper for Rake, because, cake was already taken!, Give Rake a Brake.
|
12
10
|
Usage: brake <task> [options]
|
13
11
|
|
12
|
+
Cucmber options:
|
13
|
+
-t, --tags @high,@login Array: A list of all tagged test to be run
|
14
|
+
-d, --dry-run Bool: turns on the selenium dry run feature
|
15
|
+
-v, --verbose Bool: Show the files and features loaded
|
16
|
+
-f, --format String: How to format the features (Default: pretty)
|
17
|
+
|
14
18
|
Global options:
|
15
19
|
-e, --enviroment release String: The enviroment to run the tests against eg Release
|
16
|
-
-t, --tags @high,@login Array: A list of all tagged test to be run
|
17
20
|
-l, --log_level debug String: The log output level debug|info
|
18
|
-
|
19
|
-
BrandwatchWeb options:
|
20
21
|
-c, --controller chrome String: The type of controller to run (API, Chrome, Safari)
|
22
|
+
--[no-]headless Bool: To turn on/off headless mode (only works on Linux!)
|
23
|
+
--[no-]cleanup Bool: To turn on/off setup cleanup
|
24
|
+
--retries 3 String: The number of retries to perform on element methods
|
25
|
+
--timeouts 10 String: The length of the timeouts on element methods
|
26
|
+
|
27
|
+
Web options:
|
21
28
|
-s, --screen 1280,1024 Array: The width,hight of the browser window
|
22
29
|
--pos, --position 0,0 Array: The x,y coords of the browser 0,0 top left
|
23
30
|
|
24
|
-
API options:
|
25
|
-
-v, --version 00 String: API Version number
|
26
|
-
|
27
31
|
Browser options:
|
28
|
-
-H, --[no-]highlight Bool: To turn off the highlight of elements
|
32
|
+
-H, --[no-]highlight Bool: To turn on/off the highlight of elements
|
33
|
+
Brake options:
|
34
|
+
|
35
|
+
-I, --iterate Int: Number of times to run the task
|
36
|
+
-U, --[no-]untangle Bool: Turns Debug on/off
|
37
|
+
-h, --help You're Looking at it
|
29
38
|
|
30
|
-
-u, --[no-]untangle Bool: Turns Debug on/off
|
31
|
-
-h, --help You're looking at it
|
32
39
|
For furthur assistance please contact Ben Slaughter or Jonathan Chrisp
|
33
40
|
bens@brandwatch.com or jonathan@brandwatch.com
|
34
41
|
|
@@ -55,12 +62,19 @@ Ben - Added -s as default (removes source)
|
|
55
62
|
0.2.2
|
56
63
|
Jon - Updated API task to run release as default
|
57
64
|
|
58
|
-
|
65
|
+
0.2.3
|
59
66
|
Ben - Removed '--require features' from the default args so now only -P disable profiles and -s disable source code line numbers
|
60
67
|
Ben - Removed platform, this is no longer required
|
61
68
|
|
62
|
-
|
69
|
+
0.2.4
|
63
70
|
Ben - Some typos in comments and improved readme and code comments for yard docs
|
64
71
|
Jon - Added headless, retries, highlight and cleanup options
|
65
72
|
|
73
|
+
0.3.0
|
74
|
+
Ben - Improved code, Cleaned up options parser, now a single block of code
|
75
|
+
Ben - There are no more pre included tasks, it is either default or user entered
|
76
|
+
Ben - Error checking on screen and position
|
77
|
+
Ben - Brake passes a hash of arguments to the rake task
|
78
|
+
Ben - Cucumber options added and task iterations
|
79
|
+
|
66
80
|
END
|
data/bin/brake
CHANGED
data/lib/brake.rb
CHANGED
@@ -5,7 +5,8 @@ require 'optparse'
|
|
5
5
|
begin
|
6
6
|
load 'Brakefile'
|
7
7
|
rescue LoadError
|
8
|
-
puts "Brakefile
|
8
|
+
puts "Brakefile load error"
|
9
|
+
puts "please check your brake file"
|
9
10
|
exit
|
10
11
|
end
|
11
12
|
|
@@ -13,24 +14,44 @@ end
|
|
13
14
|
# class brake the heart and soul of brake
|
14
15
|
# simply this is a wrapper disigned to give the end user some control by being able to pass command line options
|
15
16
|
# but still having the conviniance of rake tasks
|
16
|
-
#
|
17
|
-
# The tool has now evolved and if used cleverly could be used by anyome
|
17
|
+
# The tool has now evolved and if used cleverly could be used by anyone
|
18
18
|
class Brake
|
19
19
|
# Starts the Brake Class
|
20
20
|
# Outputs the brake version at runtime
|
21
21
|
# If there is no information given to brake it will rin the 'default task'
|
22
22
|
def genesis
|
23
23
|
puts "Brake Version:" + Gem.loaded_specs["brake"].version.to_s
|
24
|
-
@arguments = self.parse_command_line_options
|
25
|
-
self.debug( ARGV )
|
26
24
|
|
25
|
+
# creates the default arguments
|
26
|
+
# -P Disables profiles, we no longer need it as all data is given at command line
|
27
|
+
# -s removes the extra source code line no note displayed in the command line
|
28
|
+
@arguments = { :req => "-P -s" }
|
29
|
+
# Untangle is false untill the options parser has run
|
30
|
+
@untangle = false
|
31
|
+
# Brake can run Its task several times
|
32
|
+
@taskIterations = 1
|
33
|
+
|
34
|
+
# Runs the options parser, Arguments and Untangle are now inst variables
|
35
|
+
self.parse_command_line_options
|
36
|
+
|
37
|
+
self.debug( ARGV )
|
38
|
+
# Default is assigned to the ARGV if there is no task given
|
27
39
|
ARGV.push('default') if ARGV == []
|
28
|
-
|
29
|
-
|
30
|
-
self.run_rake_task(
|
40
|
+
# Brake only runs one task at a time
|
41
|
+
@taskIterations.times do
|
42
|
+
self.run_rake_task( ARGV[0] )
|
31
43
|
end
|
44
|
+
|
45
|
+
# This code is commented out to keep things simple
|
46
|
+
# Brake will execute the first task and then drop everything else
|
47
|
+
# This stops incorrect options causing problems
|
48
|
+
# ARGV.each do | task |
|
49
|
+
# self.debug( task )
|
50
|
+
# self.run_rake_task( task )
|
51
|
+
# end
|
32
52
|
end
|
33
53
|
|
54
|
+
# prints out the passed message if debug/untangle is on
|
34
55
|
def debug( message )
|
35
56
|
if @untangle
|
36
57
|
puts message.to_s
|
@@ -42,116 +63,112 @@ class Brake
|
|
42
63
|
# The Hash is then returned
|
43
64
|
# @return [hash] arguemnts a hash containg the parsed and data
|
44
65
|
def parse_command_line_options
|
45
|
-
options = []
|
46
|
-
@untangle = false
|
47
|
-
|
48
66
|
begin
|
49
67
|
# parses the options from the command line
|
50
68
|
OptionParser.new do |opts|
|
51
|
-
opts.banner = "\nBrake,
|
69
|
+
opts.banner = "\nBrake, A Cucumber options parser wrapper for Rake, because, cake was already taken!, Give Rake a Brake.\nUsage: brake <task> [options]"
|
52
70
|
opts.separator ""
|
53
|
-
opts.separator "
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
opts.on("-
|
59
|
-
|
60
|
-
|
61
|
-
opts.on("
|
62
|
-
|
71
|
+
opts.separator "Cucmber options:"
|
72
|
+
opts.on("-t", "--tags @high,@login", Array, "Array: A list of all tagged test to be run" ) do |opt|
|
73
|
+
@arguments[:tags] ||= []
|
74
|
+
@arguments[:tags].push( "--tags #{opt.join(',')}" )
|
75
|
+
end
|
76
|
+
opts.on("-d", "--dry-run", "Bool: turns on the selenium dry run feature" ) do |opt|
|
77
|
+
@arguments[:dry_run] = "--dry-run"
|
78
|
+
end
|
79
|
+
opts.on("-v", "--verbose", "Bool: Show the files and features loaded" ) do |opt|
|
80
|
+
@arguments[:verbose] = "--verbose"
|
81
|
+
end
|
82
|
+
opts.on("-f", "--format", String, "String: How to format the features (Default: pretty)" ) do |opt|
|
83
|
+
@arguments[:format] = "--format #{opt}"
|
84
|
+
end
|
85
|
+
|
86
|
+
opts.separator ""
|
87
|
+
opts.separator "Global options:"
|
88
|
+
opts.on("-e", "--enviroment release", String, "String: The enviroment to run the tests against eg Release" ) do |opt|
|
89
|
+
@arguments[:env] = "ENVIRONMENT=#{opt.downcase}"
|
90
|
+
end
|
91
|
+
opts.on("-l", "--log_level debug", String, "String: The log output level debug|info" ) do |opt|
|
92
|
+
@arguments[:log_level] = "LOGLEVEL=#{opt.downcase}"
|
93
|
+
end
|
94
|
+
opts.on("-c", "--controller chrome", String, "String: The type of controller to run (API, Chrome, Safari)" ) do |opt|
|
95
|
+
@arguments[:controller] = "CONTROLLER=#{opt.downcase}"
|
96
|
+
end
|
97
|
+
opts.on("--[no-]headless", "Bool: To turn on/off headless mode (only works on Linux!)" ) do |opt|
|
98
|
+
@arguments[:headless] = "HEADLESS=#{opt.to_s}"
|
99
|
+
end
|
100
|
+
opts.on("--[no-]cleanup", "Bool: To turn on/off setup cleanup" ) do |opt|
|
101
|
+
@arguments[:cleanup] = "CLEANUP=#{opt.to_s}"
|
102
|
+
end
|
103
|
+
opts.on("--retries 3", String, "String: The number of retries to perform on element methods" ) do |opt|
|
104
|
+
@arguments[:retries] = "RETRIES=#{opt.downcase}"
|
105
|
+
end
|
106
|
+
opts.on("--timeouts 10", String, "String: The length of the timeouts on element methods" ) do |opt|
|
107
|
+
@arguments[:timeouts] = "TIMEOUTS=#{opt.downcase}"
|
108
|
+
end
|
109
|
+
|
63
110
|
opts.separator ""
|
64
|
-
opts.separator "
|
65
|
-
opts.on("-s", "--screen 1280,1024", Array, "Array: The width,hight of the browser window" )
|
66
|
-
|
111
|
+
opts.separator "Web options:"
|
112
|
+
opts.on("-s", "--screen 1280,1024", Array, "Array: The width,hight of the browser window" ) do |opt|
|
113
|
+
if opt.length != 2
|
114
|
+
puts "Incorrect number of args for screen: " + opt.to_s
|
115
|
+
exit
|
116
|
+
end
|
117
|
+
@arguments[:screen] = "SCREENWIDTH=#{opt[0].downcase} SCREENHEIGHT=#{opt[1].downcase}"
|
118
|
+
end
|
119
|
+
opts.on("--pos", "--position 0,0", Array, "Array: The x,y coords of the browser 0,0 top left" ) do |opt|
|
120
|
+
if opt.length > 2
|
121
|
+
puts "Incorrect number of args for position: " + opt.to_s
|
122
|
+
exit
|
123
|
+
end
|
124
|
+
@arguments[:position] = "XPOSITION=#{opt[0].downcase} YPOSITION=#{opt[1].downcase}"
|
125
|
+
end
|
126
|
+
|
67
127
|
opts.separator ""
|
68
128
|
opts.separator "Browser options:"
|
69
|
-
opts.on("-H", "--[no-]highlight", "Bool: To turn on/off the highlight of elements" )
|
70
|
-
|
71
|
-
|
72
|
-
|
129
|
+
opts.on("-H", "--[no-]highlight", "Bool: To turn on/off the highlight of elements" ) do |opt|
|
130
|
+
@arguments[:highlight] = "HIGHLIGHT=#{opt.to_s}"
|
131
|
+
end
|
132
|
+
|
133
|
+
opts.separator "Brake options:"
|
73
134
|
opts.separator ""
|
74
|
-
opts.on("-
|
135
|
+
opts.on("-I", "--iterate", String, "Int: Number of times to run the task" ) do |opt|
|
136
|
+
@taskIterations = opt.to_i
|
137
|
+
end
|
138
|
+
opts.on("-U", "--[no-]untangle", "Bool: Turns Debug on/off" ) do |opt|
|
139
|
+
@untangle = opt
|
140
|
+
end
|
75
141
|
opts.on_tail("-h", "--help", "You're Looking at it") do
|
76
142
|
puts opts
|
77
|
-
puts "
|
143
|
+
puts "\nFor furthur assistance please contact Ben Slaughter or Jonathan Chrisp"
|
78
144
|
puts "bens@brandwatch.com or jonathan@brandwatch.com"
|
79
145
|
exit
|
80
146
|
end
|
81
|
-
end.parse!
|
147
|
+
end.parse! # options parser
|
82
148
|
rescue OptionParser::InvalidOption => e
|
83
149
|
puts e.message
|
84
150
|
self.debug( e.backtrace.to_s )
|
85
151
|
exit
|
86
|
-
end
|
87
|
-
|
88
|
-
# creates the default arguments
|
89
|
-
# -P Disables profiles, we no longer need it as all data is given at command line
|
90
|
-
# -s removes the extra source code line no note displayed in the command line
|
91
|
-
arguments = { :req => "-P -s" }
|
92
|
-
|
93
|
-
# takes the parsed options and turns them into meaningful data
|
94
|
-
# the data is later read by the automation code
|
95
|
-
options.each do | value |
|
96
|
-
case value[0]
|
97
|
-
when :env
|
98
|
-
arguments[:env] = "ENVIRONMENT=#{value[1].downcase}"
|
99
|
-
when :tags
|
100
|
-
arguments[:tags] ||= []
|
101
|
-
arguments[:tags].push( "--tags #{value[1].join(',')}" )
|
102
|
-
when :log_level
|
103
|
-
arguments[:log_level] = "LOGLEVEL=#{value[1].downcase}"
|
104
|
-
when :dry_run
|
105
|
-
arguments[:dry_run] = "--dry-run"
|
106
|
-
when :headless
|
107
|
-
arguments[:headless] = "HEADLESS=#{value[1].to_s}"
|
108
|
-
when :cleanup
|
109
|
-
arguments[:cleanup] = "CLEANUP=#{value[1].to_s}"
|
110
|
-
when :retries
|
111
|
-
arguments[:retries] = "RETRIES=#{value[1].downcase}"
|
112
|
-
when :timeouts
|
113
|
-
arguments[:timeouts] = "TIMEOUTS=#{value[1].downcase}"
|
114
|
-
when :highlight
|
115
|
-
arguments[:highlight] = "HIGHLIGHT=true"
|
116
|
-
when :controller
|
117
|
-
arguments[:controller] = "CONTROLLER=#{value[1].downcase}"
|
118
|
-
when :screen
|
119
|
-
arguments.push( "SCREENWIDTH=#{value[1][0].downcase} SCREENHEIGHT=#{value[1][1].downcase}" )
|
120
|
-
when :position
|
121
|
-
arguments.push( "XPOSITION=#{value[1][0].downcase} YPOSITION=#{value[1][1].downcase}" )
|
122
|
-
when :version
|
123
|
-
arguments.push( "VERSION=#{value[1].downcase}" )
|
124
|
-
end
|
125
|
-
end
|
126
|
-
return arguments
|
127
|
-
end
|
152
|
+
end # begin
|
153
|
+
end # def
|
128
154
|
|
129
155
|
# Runs the given rake task with the given arguments
|
130
156
|
# @param [string] task This is the name of the rake task to be invoked
|
131
157
|
# @param [hash] arguments a hash containing the arguments to be passed to the task
|
132
158
|
# @note There are 2 pre built tasks bw/brandwatchWeb and api/brandwatchapi
|
133
|
-
def run_rake_task( task
|
159
|
+
def run_rake_task( task )
|
134
160
|
puts "running task: " + task
|
135
|
-
self.debug( arguments )
|
161
|
+
self.debug( @arguments )
|
136
162
|
begin
|
137
|
-
|
138
|
-
|
139
|
-
puts "WARNING: No Defaults set for default task"
|
140
|
-
Rake::Task['default'].execute( arguments.values.join( ' ' ) )
|
141
|
-
when 'brandwatchweb', 'bw'
|
142
|
-
arguments = { :env => 'ENVIRONMENT=release', :controller => 'CONTROLLER=chrome' }.merge(arguments)
|
143
|
-
Rake::Task['brandwatchweb'].execute( arguments.values.join( ' ' ) )
|
144
|
-
when 'brandwatchapi', 'api'
|
145
|
-
arguments = { :env => 'ENVIRONMENT=release', :controller => 'CONTROLLER=api', :version => 'VERSION=1' }.merge(arguments)
|
146
|
-
Rake::Task['brandwatchapi'].execute( arguments.values.join( ' ' ) )
|
163
|
+
if task.downcase == 'default'
|
164
|
+
Rake::Task['default'].execute( @arguments )
|
147
165
|
else
|
148
|
-
|
149
|
-
|
150
|
-
end # case
|
166
|
+
Rake::Task[task].execute( @arguments )
|
167
|
+
end # if
|
151
168
|
|
152
|
-
# This
|
169
|
+
# This caused me some problems while running tasks
|
153
170
|
# There is no raise as several tasks may be run
|
154
|
-
# and due to
|
171
|
+
# and due to the design requierments of the wrapper I do not want the code to quit
|
155
172
|
rescue RuntimeError => e
|
156
173
|
puts "Brake Aborted!"
|
157
174
|
puts e.message
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: brake
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-10-
|
13
|
+
date: 2012-10-19 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rake
|
@@ -28,7 +28,8 @@ dependencies:
|
|
28
28
|
- - '='
|
29
29
|
- !ruby/object:Gem::Version
|
30
30
|
version: 0.9.2.2
|
31
|
-
description: A
|
31
|
+
description: A Cucumber options parser wrapper for Rake, because, cake was already
|
32
|
+
taken!
|
32
33
|
email: bens@brandwatch.com
|
33
34
|
executables:
|
34
35
|
- brake
|
@@ -41,7 +42,7 @@ files:
|
|
41
42
|
homepage: http://rubygems.org/gems/brake
|
42
43
|
licenses:
|
43
44
|
- GPL-2
|
44
|
-
post_install_message:
|
45
|
+
post_install_message:
|
45
46
|
rdoc_options: []
|
46
47
|
require_paths:
|
47
48
|
- lib
|
@@ -62,6 +63,6 @@ rubyforge_project:
|
|
62
63
|
rubygems_version: 1.8.24
|
63
64
|
signing_key:
|
64
65
|
specification_version: 3
|
65
|
-
summary: A
|
66
|
+
summary: A Cucumber options parser wrapper for Rake.
|
66
67
|
test_files: []
|
67
68
|
has_rdoc:
|