brake 0.0.3 → 0.1.0

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 +2 -103
  2. data/lib/brake.rb +8 -7
  3. metadata +2 -2
data/bin/brake CHANGED
@@ -1,105 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
- # @author Ben Slaughter, Jonathan Chrisp
3
- #require 'brake'
4
- begin
5
- load 'Brakefile'
6
- rescue LoadError
7
- puts "Brake file not present"
8
- exit
9
- end
10
-
11
- if not defined?(LN_SUPPORTED)
12
- require 'rake'
13
- end
14
-
15
- options = []
16
-
17
- # parses the options from the command line
18
- OptionParser.new do |opts|
19
- opts.banner = "\nBrake, The Brandwatch Rake wrapper for cucumber, And on the eighth day, god created Brake.\nUsage: brake <task> [options]"
20
-
21
- opts.separator ""
22
- opts.separator "Defaulted options:"
23
- opts.on("-e", "--enviroment release", String, "String: The enviroment to run the tests against eg Release" ) { |o| options.push([:env, o]) }
24
- opts.on("-p", "--platform brandwatchWeb", String, "String: The platform to run the tests on eg brandwatchWeb" ) { |o| options.push([:platform, o]) }
25
-
26
- opts.separator ""
27
- opts.separator "Global options:"
28
- opts.on("-t", "--tags @high,@login", Array, "Array: A list of all tagged test to be run" ) { |o| options.push([:tags, o]) }
29
- opts.on("-l", "--log_level debug", String, "String: The log output level debug|info" ) { |o| options.push([:log_level, o]) }
30
-
31
- opts.separator "Browser options:"
32
- opts.on("-H", "--[no-]highlight", "Bool: To turn off the highlight of elements" ) { |o| options.push([:highlight, o]) }
33
-
34
- opts.separator ""
35
- opts.separator "BrandwatchWeb options:"
36
- opts.on("-b", "--browser chrome", String, "String: The type of browser to run" ) { |o| options.push([:browser, o]) }
37
- opts.on("-s", "--screen 1280,1024", Array, "Array: The width,hight of the browser window" ) { |o| options.push([:screen, o]) }
38
- opts.on("--pos", "--position 0,0", Array, "Array: The x,y coords of the browser 0,0 top left" ) { |o| options.push([:position, o]) }
39
-
40
- opts.separator ""
41
- opts.separator "API options:"
42
- opts.on("-v", "--version 00", String, "String: API Version number" ) { |o| options.push([:version, o]) }
43
-
44
- opts.separator ""
45
- opts.separator "For furthur assistance please contact Ben Slaughter"
46
- opts.on_tail("-h", "--help", "Show this message") do
47
- puts opts
48
- exit
49
- end
50
-
51
- end.parse!
52
-
53
- if ARGV.length > 1
54
- raise "incorrect arguments"
55
- end
56
-
57
- arguments = { :req => "--require features -P" }
58
- options.each do | value |
59
- case value[0]
60
- when :platform
61
- arguments[:platform] = "PLATFORM=#{value[1].downcase}"
62
- when :env
63
- arguments[:env] = "ENVIRONMENT=#{value[1].downcase}"
64
- when :tags
65
- arguments[:tags] ||= []
66
- arguments[:tags].push( "--tags #{value[1].join(',')}" )
67
- when :log_level
68
- arguments[:log_level] = "LOGLEVEL=#{value[1].downcase}"
69
- when :highlight
70
- arguments[:highlight] = "HIGHLIGHT=true"
71
- when :browser
72
- arguments[:browser] = "BROWSERNAME=#{value[1].downcase}"
73
- when :screen
74
- arguments.push( "SCREENWIDTH=#{value[1][0].downcase} SCREENHEIGHT=#{value[1][1].downcase}" )
75
- when :position
76
- arguments.push( "XPOSITION=#{value[1][0].downcase} YPOSITION=#{value[1][1].downcase}" )
77
- when :version
78
- arguments.push( "VERSION=#{value[1].downcase}" )
79
- end
80
- end
81
-
82
- if ARGV[0] == nil
83
- puts "running task: default"
84
- puts "WARNING: No Defaults set for default task"
85
- Rake::Task[:default].invoke( arguments.values.join( ' ' ) )
86
- else
87
- ARGV.each do | task |
88
- puts "running task: " + task
89
- case task.downcase
90
- when 'brandwatchweb', 'bw'
91
- arguments = arguments.merge({ :platform => "PLATFORM=brandwatchweb", :env => 'ENVIRONMENT=release', :browser => 'BROWSERNAME=chrome' })
92
- Rake::Task[:brandwatchWeb].invoke( arguments.values.join( ' ' ) )
93
- when 'brandwatchapi', 'api'
94
- arguments = arguments.merge({ :platform => "PLATFORM=brandwatchapi", :env => 'ENVIRONMENT=int', :version => 'VERSION=1' })
95
- Rake::Task[:brandwatchAPI].invoke( arguments.values.join( ' ' ) )
96
- else
97
- Rake::Task[task].invoke( arguments.values.join( ' ' ) )
98
- end
99
- end
100
- end
101
-
102
-
103
-
104
-
2
+ require 'brake'
105
3
 
4
+ Brake.new.genesis
data/lib/brake.rb CHANGED
@@ -14,13 +14,12 @@ end
14
14
 
15
15
  # @author Ben Slaughter
16
16
  class Brake
17
- # starts the Brake Class
17
+ # Starts the Brake Class
18
18
  def genesis
19
19
  arguments = self.parse_command_line_options
20
- p '---------------- debug --------------'
21
- p ARGV
22
- p '-------------------------------------'
23
- self.run_rake_task( arguments, task)
20
+ ARGV.each do | task |
21
+ self.run_rake_task( task, arguments)
22
+ end
24
23
  end
25
24
 
26
25
  # Parses the options from the command line
@@ -38,6 +37,7 @@ class Brake
38
37
  opts.on("-p", "--platform brandwatchWeb", String, "String: The platform to run the tests on eg brandwatchWeb" ) { |o| options.push([:platform, o]) }
39
38
  opts.on("-t", "--tags @high,@login", Array, "Array: A list of all tagged test to be run" ) { |o| options.push([:tags, o]) }
40
39
  opts.on("-l", "--log_level debug", String, "String: The log output level debug|info" ) { |o| options.push([:log_level, o]) }
40
+ opts.separator ""
41
41
  opts.separator "Browser options:"
42
42
  opts.on("-H", "--[no-]highlight", "Bool: To turn off the highlight of elements" ) { |o| options.push([:highlight, o]) }
43
43
  opts.separator ""
@@ -90,9 +90,10 @@ class Brake
90
90
  end
91
91
 
92
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
93
  # @param [string] task This is the name of the rake task to be invoked
95
- def run_rake_task( arguments, task = 'default' )
94
+ # @param [hash] arguments a hash containing the arguments to be passed to the task
95
+ def run_rake_task( task, arguments )
96
+ task = 'default' if task == nil
96
97
  puts "running task: " + task
97
98
  case task.downcase
98
99
  when 'default'
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.3
4
+ version: 0.1.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-09-06 00:00:00.000000000 Z
13
+ date: 2012-09-07 00:00:00.000000000 Z
14
14
  dependencies: []
15
15
  description: A Brandwatch made, options parser wrapper for Rake, No Brake for Rake.
16
16
  email: bens@brandwatch.com