brake 0.1.6 → 0.2.0

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.
Files changed (3) hide show
  1. data/README +47 -0
  2. data/lib/brake.rb +40 -28
  3. metadata +4 -5
data/README ADDED
@@ -0,0 +1,47 @@
1
+ README
2
+ A Brandwatch rake wrapper, Brake
3
+
4
+ Brake Version:0.2.0
5
+
6
+ Brake, The Brandwatch Rake wrapper for cucumber, Give Rake a Brake.
7
+ Usage: brake <task> [options]
8
+
9
+ Global options:
10
+ -e, --enviroment release String: The enviroment to run the tests against eg Release
11
+ -p, --platform brandwatchWeb String: The platform to run the tests on eg brandwatchWeb
12
+ -t, --tags @high,@login Array: A list of all tagged test to be run
13
+ -l, --log_level debug String: The log output level debug|info
14
+
15
+ BrandwatchWeb options:
16
+ -c, --controller chrome String: The type of controller to run (API, Chrome, Safari)
17
+ -s, --screen 1280,1024 Array: The width,hight of the browser window
18
+ --pos, --position 0,0 Array: The x,y coords of the browser 0,0 top left
19
+
20
+ API options:
21
+ -v, --version 00 String: API Version number
22
+
23
+ Browser options:
24
+ -H, --[no-]highlight Bool: To turn off the highlight of elements
25
+
26
+ -u, --[no-]untangle Bool: Turns Debug on/off
27
+ -h, --help Show this message
28
+ For furthur assistance please contact Ben Slaughter or Jonathan Chrisp
29
+ bens@brandwatch.com or jonathan@brandwatch.com
30
+
31
+ Release Notes:
32
+ 0.1.0
33
+ Class structure created
34
+
35
+ 0.1.6
36
+ Code cleanup
37
+ Changed the names so that all the task names are strings rather than half symbol and half strings
38
+
39
+ 0.2.0
40
+ Added this readme file
41
+ Cleaned up the debug code
42
+ Added the Version output to display the current version number
43
+ Added the debug method so that the code looks cleaner and easier to understand
44
+ Added the RuntimeError handling to mimic the same rake functionality
45
+ Moved rake requier to be called before the Brakefile load
46
+
47
+ END
data/lib/brake.rb CHANGED
@@ -13,15 +13,20 @@ end
13
13
  class Brake
14
14
  # Starts the Brake Class
15
15
  def genesis
16
- arguments, untangle = self.parse_command_line_options
17
-
18
- # puts out the command line arguments if untangle is true
19
- p ARGV if untangle
16
+ puts "Brake Version:" + Gem.loaded_specs["brake"].version.to_s
17
+ @arguments = self.parse_command_line_options
18
+ self.debug( ARGV )
20
19
 
21
20
  ARGV.push('default') if ARGV == []
22
21
  ARGV.each do | task |
23
- p task if untangle
24
- self.run_rake_task( task, arguments )
22
+ self.debug( task )
23
+ self.run_rake_task( task, @arguments )
24
+ end
25
+ end
26
+
27
+ def debug( message )
28
+ if @untangle
29
+ puts message.to_s
25
30
  end
26
31
  end
27
32
 
@@ -30,7 +35,7 @@ class Brake
30
35
  # @return [hash] arguemnts a hash containg the parsed and data
31
36
  def parse_command_line_options
32
37
  options = []
33
- untangle = false
38
+ @untangle = false
34
39
 
35
40
  begin
36
41
  # parses the options from the command line
@@ -54,7 +59,7 @@ class Brake
54
59
  opts.separator "Browser options:"
55
60
  opts.on("-H", "--[no-]highlight", "Bool: To turn off the highlight of elements" ) { |o| options.push([:highlight, o]) }
56
61
  opts.separator ""
57
- opts.on("-u", "--[no-]untangle", "Bool: Turns Debug on/off" ) { |o| untangle = o }
62
+ opts.on("-u", "--[no-]untangle", "Bool: Turns Debug on/off" ) { |o| @untangle = o }
58
63
  opts.on_tail("-h", "--help", "Show this message") do
59
64
  puts opts
60
65
  puts "For furthur assistance please contact Ben Slaughter or Jonathan Chrisp"
@@ -64,14 +69,14 @@ class Brake
64
69
  end.parse!
65
70
  rescue OptionParser::InvalidOption => e
66
71
  puts e.message
67
- # puts e.backtrace[0].to_s
72
+ self.debug( e.backtrace.to_s )
68
73
  exit
69
74
  end
70
75
 
71
76
  # creates the default arguments
72
77
  # --require features Ensures that all features are included
73
78
  # -P Disables profiles, we no longer need it as all data is given at command line
74
- arguments = { :req => "--require features -P" }
79
+ arguments = { :req => "--require features" }
75
80
 
76
81
  # takes the parsed options and turns them into meaningful data
77
82
  # the data is later read by the automation code
@@ -98,7 +103,7 @@ class Brake
98
103
  arguments.push( "VERSION=#{value[1].downcase}" )
99
104
  end
100
105
  end
101
- return arguments, untangle
106
+ return arguments
102
107
  end
103
108
 
104
109
  # Runs the given rake task with the given arguments
@@ -106,20 +111,27 @@ class Brake
106
111
  # @param [hash] arguments a hash containing the arguments to be passed to the task
107
112
  def run_rake_task( task, arguments )
108
113
  puts "running task: " + task
109
- case task.downcase
110
- when 'default'
111
- puts "WARNING: No Defaults set for default task"
112
- Rake::Task['default'].invoke( arguments.values.join( ' ' ) )
113
- when 'brandwatchweb', 'bw'
114
- arguments = { :platform => "PLATFORM=brandwatchweb", :env => 'ENVIRONMENT=release', :controller => 'CONTROLLER=chrome' }.merge(arguments)
115
- Rake::Task['brandwatchweb'].invoke( arguments.values.join( ' ' ) )
116
- when 'brandwatchapi', 'api'
117
- arguments = { :platform => "PLATFORM=brandwatchapi", :env => 'ENVIRONMENT=int', :controller => 'CONTROLLER=api', :version => 'VERSION=1' }.merge(arguments)
118
- Rake::Task['brandwatchapi'].invoke( arguments.values.join( ' ' ) )
119
- else
120
- puts "WARNING: No Defaults set for custom task"
121
- Rake::Task[task].invoke( arguments.values.join( ' ' ) )
122
- end
123
- end
124
-
125
- end
114
+ self.debug( arguments )
115
+ begin
116
+ case task.downcase
117
+ when 'default'
118
+ puts "WARNING: No Defaults set for default task"
119
+ Rake::Task['default'].execute( arguments.values.join( ' ' ) )
120
+ when 'brandwatchweb', 'bw'
121
+ arguments = { :platform => "PLATFORM=brandwatchweb", :env => 'ENVIRONMENT=release', :controller => 'CONTROLLER=chrome' }.merge(arguments)
122
+ Rake::Task['brandwatchweb'].execute( arguments.values.join( ' ' ) )
123
+ when 'brandwatchapi', 'api'
124
+ arguments = { :platform => "PLATFORM=brandwatchapi", :env => 'ENVIRONMENT=int', :controller => 'CONTROLLER=api', :version => 'VERSION=1' }.merge(arguments)
125
+ Rake::Task['brandwatchapi'].execute( arguments.values.join( ' ' ) )
126
+ else
127
+ puts "WARNING: No Defaults set for custom task"
128
+ Rake::Task[task].execute( arguments.values.join( ' ' ) )
129
+ end # case
130
+ rescue RuntimeError => e
131
+ puts "Brake Aborted!"
132
+ puts e.message
133
+ puts "( For full backtrace run again with --untangle )"
134
+ self.debug( e.backtrace )
135
+ end # begin
136
+ end # def
137
+ end # class
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.1.6
4
+ version: 0.2.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-20 00:00:00.000000000 Z
13
+ date: 2012-09-25 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rake
@@ -37,12 +37,11 @@ extra_rdoc_files: []
37
37
  files:
38
38
  - bin/brake
39
39
  - lib/brake.rb
40
+ - README
40
41
  homepage: http://rubygems.org/gems/brake
41
42
  licenses:
42
43
  - GPL-2
43
- post_install_message: ! 'Thanks for installing brake!
44
-
45
- No Brake for Rake.'
44
+ post_install_message: Thanks for installing brake!
46
45
  rdoc_options: []
47
46
  require_paths:
48
47
  - lib