brake 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/bin/brake +1 -2
  2. data/lib/brake.rb +110 -66
  3. metadata +7 -5
data/bin/brake CHANGED
@@ -1,7 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
- require 'optparse'
2
+ # @author Ben Slaughter, Jonathan Chrisp
3
3
  #require 'brake'
4
-
5
4
  begin
6
5
  load 'Brakefile'
7
6
  rescue LoadError
data/lib/brake.rb CHANGED
@@ -1,69 +1,113 @@
1
- Cake = "\033[33m" + '''
2
- ,:/+/-
3
- /M/ .,-=;//;-
4
- .:/= ;MH/, ,=/+%$XH@MM#@:
5
- -$##@+$###@H@MMM#######H:. -/H#
6
- .,H@H@ X######@ -H#####@+- -+H###@X
7
- .,@##H; +XM##M/, =%@###@X;-
8
- X%- :M##########$. .:%M###@%:
9
- M##H, +H@@@$/-. ,;$M###@%, -
10
- M####M=,,---,.-%%H####M$: ,+@##
11
- @##################@/. :%H##@$-
12
- M###############H, ;HM##M$=
13
- #################. .=$M##M$=
14
- ################H..;XM##M$= .:+
15
- M###################@%= =+@MH%
16
- @################M/. =+H#X%=
17
- =+M##############M, -/X#X+;.
18
- .;XM##########H= ,/X#H+:,
19
- .=+HM######M+/+HM@+=.
20
- ,:/%XM####H/.
21
- ,.:=-.
22
- ''' + "\033[0m\n"
1
+ # @author Ben Slaughter, Jonathan Chrisp
2
+ require 'optparse'
23
3
 
4
+ begin
5
+ load 'Brakefile'
6
+ rescue LoadError
7
+ puts "Brakefile not present"
8
+ exit
9
+ end
24
10
 
25
- Cube = "\033[33m" + '''
26
- +@##########M/ :@#########@/
27
- ##############$;H#######@;+#############
28
- ###############M########################
29
- ##############X,-/++/+%+/,%#############
30
- ############M$: -X############
31
- ##########H;. ,--. =X##########
32
- :X######M; -$H@M##MH%: :H#######@
33
- =%#M+=, ,+@#######M###H: -=/M#%
34
- %M##@+ .X##$, ./+- ./###; +M##%
35
- %####M. /###= @##M. X###%
36
- %####M. ;M##H:. =$###X. $###%
37
- %####@. /####M$-./@#####: %###%
38
- %H#M/, /H###########@: ./M#%
39
- ;$H##@@H: .;$HM#MMMH$;, ./H@M##M$=
40
- X#########%. ..,,. .;@#########
41
- ###########H+:. ./@###########
42
- ##############/ ./%%%%+/.-M#############
43
- ##############H$@#######@@##############
44
- ##############X%########M$M#############
45
- +M##########H: .$##########X=
46
- ''' + "\033[0m\n"
11
+ if not defined?(LN_SUPPORTED)
12
+ require 'rake'
13
+ end
47
14
 
48
- Apature = "\033[33m" + '''
49
- .,-:;//;:=,
50
- . :H@@@MM@M#H/.,+%;,
51
- ,/X+ +M@@M@MM%=,-%HMMM@X/,
52
- -+@MM; $M@@MH+-,;XMMMM@MMMM@+-
53
- ;@M@@M- XM@X;. -+XXXXXHHH@M@M#@/.
54
- ,%MM@@MH ,@%= .---=-=:=,.
55
- =@#@@@MX ., -%HX$$%%%+;
56
- =-./@M@M$ .;@MMMM@MM:
57
- X@/ -$MM/ .+MM@@@M$
58
- ,@M@H: :@: . =X#@@@@-
59
- ,@@@MMX, . /H- ;@M@M=
60
- .H@@@@M@+, %MM+..%#$.
61
- /MMMM@MMH/. XM@MH; =;
62
- /%+%$XHH@$= , .H@@@@MX,
63
- .=--------. -%H.,@@@@@MX,
64
- .%MM@@@HHHXX$$$%+- .:$MMX =M@@MM%.
65
- =XMMM@MM@MM#H;,-+HMM@M+ /MMMX=
66
- =%@M@M#@$-.=$@MM@@@M; %M%=
67
- ,:+$+-,/H#MMMMMMM@= =,
68
- =++%%%%+/:-.
69
- ''' + "\033[0m\n"
15
+ # @author Ben Slaughter
16
+ class Brake
17
+ # starts the Brake Class
18
+ def genesis
19
+ arguments = self.parse_command_line_options
20
+ p '---------------- debug --------------'
21
+ p ARGV
22
+ p '-------------------------------------'
23
+ self.run_rake_task( arguments, task)
24
+ end
25
+
26
+ # Parses the options from the command line
27
+ # converts the information into a Hash that is returned
28
+ # @return [hash] arguemnts a hash containg the parsed and data
29
+ def parse_command_line_options
30
+ options = []
31
+
32
+ # parses the options from the command line
33
+ OptionParser.new do |opts|
34
+ opts.banner = "\nBrake, The Brandwatch Rake wrapper for cucumber, Give Rake a Brake.\nUsage: brake <task> [options]"
35
+ opts.separator ""
36
+ opts.separator "Global options:"
37
+ opts.on("-e", "--enviroment release", String, "String: The enviroment to run the tests against eg Release" ) { |o| options.push([:env, o]) }
38
+ opts.on("-p", "--platform brandwatchWeb", String, "String: The platform to run the tests on eg brandwatchWeb" ) { |o| options.push([:platform, o]) }
39
+ opts.on("-t", "--tags @high,@login", Array, "Array: A list of all tagged test to be run" ) { |o| options.push([:tags, o]) }
40
+ opts.on("-l", "--log_level debug", String, "String: The log output level debug|info" ) { |o| options.push([:log_level, o]) }
41
+ opts.separator "Browser options:"
42
+ opts.on("-H", "--[no-]highlight", "Bool: To turn off the highlight of elements" ) { |o| options.push([:highlight, o]) }
43
+ opts.separator ""
44
+ opts.separator "BrandwatchWeb options:"
45
+ opts.on("-b", "--browser chrome", String, "String: The type of browser to run" ) { |o| options.push([:browser, o]) }
46
+ opts.on("-s", "--screen 1280,1024", Array, "Array: The width,hight of the browser window" ) { |o| options.push([:screen, o]) }
47
+ opts.on("--pos", "--position 0,0", Array, "Array: The x,y coords of the browser 0,0 top left" ) { |o| options.push([:position, o]) }
48
+ opts.separator ""
49
+ opts.separator "API options:"
50
+ opts.on("-v", "--version 00", String, "String: API Version number" ) { |o| options.push([:version, o]) }
51
+ opts.separator ""
52
+ opts.separator "For furthur assistance please contact Ben Slaughter"
53
+ opts.on_tail("-h", "--help", "Show this message") do
54
+ puts opts
55
+ exit
56
+ end
57
+ end.parse!
58
+
59
+ # creates the default arguments
60
+ # --require features Ensures that all features are included
61
+ # -P Disables profiles, we no longer need it as all data is given at command line
62
+ arguments = { :req => "--require features -P" }
63
+
64
+ # takes the parsed options and turns them into meaningful data
65
+ # the data is later read by the automation code
66
+ options.each do | value |
67
+ case value[0]
68
+ when :platform
69
+ arguments[:platform] = "PLATFORM=#{value[1].downcase}"
70
+ when :env
71
+ arguments[:env] = "ENVIRONMENT=#{value[1].downcase}"
72
+ when :tags
73
+ arguments[:tags] ||= []
74
+ arguments[:tags].push( "--tags #{value[1].join(',')}" )
75
+ when :log_level
76
+ arguments[:log_level] = "LOGLEVEL=#{value[1].downcase}"
77
+ when :highlight
78
+ arguments[:highlight] = "HIGHLIGHT=true"
79
+ when :browser
80
+ arguments[:browser] = "BROWSERNAME=#{value[1].downcase}"
81
+ when :screen
82
+ arguments.push( "SCREENWIDTH=#{value[1][0].downcase} SCREENHEIGHT=#{value[1][1].downcase}" )
83
+ when :position
84
+ arguments.push( "XPOSITION=#{value[1][0].downcase} YPOSITION=#{value[1][1].downcase}" )
85
+ when :version
86
+ arguments.push( "VERSION=#{value[1].downcase}" )
87
+ end
88
+ end
89
+ return arguments
90
+ end
91
+
92
+ # Runs the given rake task with the given arguments
93
+ # @param [hash] arguments a hash containing the arguments to be passed to the task
94
+ # @param [string] task This is the name of the rake task to be invoked
95
+ def run_rake_task( arguments, task = 'default' )
96
+ puts "running task: " + task
97
+ case task.downcase
98
+ when 'default'
99
+ puts "WARNING: No Defaults set for default task"
100
+ Rake::Task[:default].invoke( arguments.values.join( ' ' ) )
101
+ when 'brandwatchweb', 'bw'
102
+ arguments = arguments.merge({ :platform => "PLATFORM=brandwatchweb", :env => 'ENVIRONMENT=release', :browser => 'BROWSERNAME=chrome' })
103
+ Rake::Task[:brandwatchWeb].invoke( arguments.values.join( ' ' ) )
104
+ when 'brandwatchapi', 'api'
105
+ arguments = arguments.merge({ :platform => "PLATFORM=brandwatchapi", :env => 'ENVIRONMENT=int', :version => 'VERSION=1' })
106
+ Rake::Task[:brandwatchAPI].invoke( arguments.values.join( ' ' ) )
107
+ else
108
+ puts "WARNING: No Defaults set for custom task"
109
+ Rake::Task[task].invoke( arguments.values.join( ' ' ) )
110
+ end
111
+ end
112
+
113
+ end
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.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,9 +10,9 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-08-16 00:00:00.000000000 Z
13
+ date: 2012-09-06 00:00:00.000000000 Z
14
14
  dependencies: []
15
- description: Brandwatch Rake opts parser wrapper
15
+ description: A Brandwatch made, options parser wrapper for Rake, No Brake for Rake.
16
16
  email: bens@brandwatch.com
17
17
  executables:
18
18
  - brake
@@ -24,7 +24,9 @@ files:
24
24
  homepage: http://rubygems.org/gems/brake
25
25
  licenses:
26
26
  - GPL-2
27
- post_install_message: Thanks for installing brake!
27
+ post_install_message: ! 'Thanks for installing brake!
28
+
29
+ No Brake for Rake.'
28
30
  rdoc_options: []
29
31
  require_paths:
30
32
  - lib
@@ -45,6 +47,6 @@ rubyforge_project:
45
47
  rubygems_version: 1.8.24
46
48
  signing_key:
47
49
  specification_version: 3
48
- summary: And on the eighth day, god created Break
50
+ summary: A Brandwatch wrapper for rake, No Brake for Rake.
49
51
  test_files: []
50
52
  has_rdoc: