bee 0.5.1 → 0.5.2

Sign up to get free protection for your applications and to get access to all the features.
data/README CHANGED
@@ -25,4 +25,4 @@ or go to URL http://www.apache.org/licenses/LICENSE-2.0).
25
25
 
26
26
  = Copyright
27
27
 
28
- bee version 0.5.1 (C) Michel Casabianca & Contributors - 2006-2009
28
+ bee version 0.5.2 (C) Michel Casabianca & Contributors - 2006-2010
data/bin/bee CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- # Copyright 2006-2009 Michel Casabianca <michel.casabianca@gmail.com>
3
+ # Copyright 2006-2010 Michel Casabianca <michel.casabianca@gmail.com>
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
6
6
  # you may not use this file except in compliance with the License.
@@ -19,4 +19,4 @@
19
19
  $:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
20
20
  require 'bee_console'
21
21
 
22
- Bee::Console.start_command_line
22
+ Bee::Console.start_command_line(ARGV)
@@ -7,7 +7,7 @@ goto endofruby
7
7
  goto endofruby
8
8
  #!/usr/bin/env ruby
9
9
 
10
- # Copyright 2006-2009 Michel Casabianca <michel.casabianca@gmail.com>
10
+ # Copyright 2006-2010 Michel Casabianca <michel.casabianca@gmail.com>
11
11
  #
12
12
  # Licensed under the Apache License, Version 2.0 (the "License");
13
13
  # you may not use this file except in compliance with the License.
@@ -26,7 +26,7 @@ goto endofruby
26
26
  $:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
27
27
  require 'bee_console'
28
28
 
29
- Bee::Console.start_command_line
29
+ Bee::Console.start_command_line(ARGV)
30
30
 
31
31
  __END__
32
32
  :endofruby
@@ -1,4 +1,4 @@
1
- # Copyright 2006-2009 Michel Casabianca <michel.casabianca@gmail.com>
1
+ # Copyright 2006-2010 Michel Casabianca <michel.casabianca@gmail.com>
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright 2006-2009 Michel Casabianca <michel.casabianca@gmail.com>
1
+ # Copyright 2006-2010 Michel Casabianca <michel.casabianca@gmail.com>
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- # Copyright 2006-2009 Michel Casabianca <michel.casabianca@gmail.com>
3
+ # Copyright 2006-2010 Michel Casabianca <michel.casabianca@gmail.com>
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
6
6
  # you may not use this file except in compliance with the License.
data/lib/bee.rb CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright 2006-2009 Michel Casabianca <michel.casabianca@gmail.com>
1
+ # Copyright 2006-2010 Michel Casabianca <michel.casabianca@gmail.com>
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -401,7 +401,7 @@ module Bee
401
401
  # Extend parent targets.
402
402
  # - parent: parent targets.
403
403
  def extend(parent)
404
- # set appropriate targets
404
+ # set appropriate targets for targets of parent
405
405
  for targets in parent.hash.values
406
406
  for target in targets
407
407
  target.targets = self
@@ -411,16 +411,22 @@ module Bee
411
411
  for name in parent.hash.keys
412
412
  if @hash[name]
413
413
  @hash[name] = parent.hash[name] + @hash[name]
414
+ # clean dependencies for redefined targets
415
+ for target in parent.hash[name]
416
+ target.depends.clear
417
+ end
418
+ # copy documentation of parent if target not documented
419
+ if not @hash[name].last.description
420
+ description = nil
421
+ for target in parent.hash[name]
422
+ description = target.description || description
423
+ end
424
+ @hash[name].last.description = description
425
+ end
414
426
  else
415
427
  @hash[name] = parent.hash[name]
416
428
  end
417
429
  end
418
- # remove dependencies of the parent
419
- for targets in parent.hash.values
420
- for target in targets
421
- target.depends.clear
422
- end
423
- end
424
430
  # set default default target to parent one if none was set
425
431
  @default = @default || parent.default
426
432
  end
@@ -504,7 +510,7 @@ module Bee
504
510
  # Target dependencies.
505
511
  attr_accessor :depends
506
512
  # Target description.
507
- attr_reader :description
513
+ attr_accessor :description
508
514
  # Script that run in the target.
509
515
  attr_reader :script
510
516
 
@@ -1,4 +1,4 @@
1
- # Copyright 2006-2009 Michel Casabianca <michel.casabianca@gmail.com>
1
+ # Copyright 2006-2010 Michel Casabianca <michel.casabianca@gmail.com>
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -37,6 +37,8 @@ module Bee
37
37
  -t egg Run a given egg to generate a template project.
38
38
  -v Enable verbose mode.
39
39
  -s style Define style for output (see documentation).
40
+ -c Use color scheme for output (if running in color terminal).
41
+ -w Use black and white output (default).
40
42
  -f file Build file to run (defaults to "build.yml").
41
43
  -r Look for build file recursively up in file system.
42
44
  -l Print bee logo on console.
@@ -53,16 +55,18 @@ targets Targets to run (default target if omitted).'
53
55
  BEE_OPT_ENV = 'BEEOPT'
54
56
  # Bee text logo (generated with http://www.network-science.de/ascii/)
55
57
  BEE_LOGO = <<'EOF'
56
- _
57
- | |__ ___ ___
58
- _____ | '_ \ / _ \/ _ \ _____ _____ _____ _____ _____ _____ _____ _____
59
- |_____| | |_) | __/ __/ |_____|_____|_____|_____|_____|_____|_____|_____|
60
- |_.__/ \___|\___| 0.5.0 http://bee.rubyforge.org
58
+ _
59
+ | |__ ___ ___
60
+ ____ | '_ \ / _ \/ _ \ _____ _____ _____ _____ _____ _____ _____ _____ _____
61
+ |____| | |_) | __/ __/ |_____|_____|_____|_____|_____|_____|_____|_____|_____|
62
+ |_.__/ \___|\___| 0.5.2 http://bee.rubyforge.org
61
63
 
62
64
  EOF
63
65
 
64
66
  # Parse command line and return parsed arguments.
65
- def self.parse_command_line
67
+ # - arguments: command line arguments.
68
+ def self.parse_command_line(arguments)
69
+ arguments = arguments.clone
66
70
  version = false
67
71
  help = false
68
72
  help_build = false
@@ -74,15 +78,18 @@ EOF
74
78
  template = nil
75
79
  verbose = false
76
80
  style = nil
81
+ color = false
77
82
  file = DEFAULT_BUILD_FILE
78
83
  recursive = false
79
84
  logo = false
80
85
  targets = []
81
86
  # read options in BEEOPT environment variable
82
87
  options = ENV[BEE_OPT_ENV]
83
- options.split(' ').reverse.each { |option| ARGV.unshift(option) } if
88
+ options.split(' ').reverse.each { |option| arguments.unshift(option) } if
84
89
  options
85
90
  # parse command line arguments
91
+ old_argv = ARGV
92
+ ARGV.replace(arguments)
86
93
  opts = GetoptLong.new(['--version', '-V', GetoptLong::NO_ARGUMENT],
87
94
  ['--help', '-h', GetoptLong::NO_ARGUMENT],
88
95
  ['--help-build', '-b', GetoptLong::NO_ARGUMENT],
@@ -93,6 +100,8 @@ EOF
93
100
  ['--template', '-t', GetoptLong::REQUIRED_ARGUMENT],
94
101
  ['--verbose', '-v', GetoptLong::NO_ARGUMENT],
95
102
  ['--style', '-s', GetoptLong::REQUIRED_ARGUMENT],
103
+ ['--color', '-c', GetoptLong::NO_ARGUMENT],
104
+ ['--black-and-white', '-w', GetoptLong::NO_ARGUMENT],
96
105
  ['--file', '-f', GetoptLong::REQUIRED_ARGUMENT],
97
106
  ['--recursive', '-r', GetoptLong::NO_ARGUMENT],
98
107
  ['--logo', '-l', GetoptLong::NO_ARGUMENT])
@@ -122,6 +131,10 @@ EOF
122
131
  verbose = true
123
132
  when '--style'
124
133
  style = arg
134
+ when '--color'
135
+ color = true
136
+ when '--black-and-white'
137
+ color = false
125
138
  when '--file'
126
139
  file = arg
127
140
  when '--recursive'
@@ -131,9 +144,10 @@ EOF
131
144
  end
132
145
  end
133
146
  targets = Array.new(ARGV)
147
+ ARGV.replace(old_argv)
134
148
  return [version, help, help_build, help_task, help_template, task,
135
- properties, dry_run, template, verbose, style, file, recursive,
136
- logo, targets]
149
+ properties, dry_run, template, verbose, style, color, file,
150
+ recursive, logo, targets]
137
151
  end
138
152
 
139
153
  # Parse a command line property.
@@ -152,17 +166,18 @@ EOF
152
166
  end
153
167
 
154
168
  # Start build from command line.
155
- def self.start_command_line
169
+ # - arguments: command line arguments.
170
+ def self.start_command_line(arguments)
156
171
  STDOUT.sync = true
157
172
  begin
158
173
  version, help, help_build, help_task, help_template, task,
159
- properties, dry_run, template, verbose, style, file, recursive,
160
- logo, targets = parse_command_line
174
+ properties, dry_run, template, verbose, style, color, file,
175
+ recursive, logo, targets = parse_command_line(arguments)
161
176
  rescue
162
177
  puts "ERROR: parsing command line (type 'bee -h' for help)"
163
178
  exit(EXIT_PARSING_CMDLINE)
164
179
  end
165
- formatter = Formatter.new(style)
180
+ formatter = Formatter.new(style, color)
166
181
  begin
167
182
  if logo
168
183
  puts BEE_LOGO
@@ -247,6 +262,16 @@ EOF
247
262
  DEFAULT_STYLE = {
248
263
  :line_character => '-'
249
264
  }
265
+ # Color style (supposed to work on color terminals).
266
+ COLOR_STYLE = {
267
+ :line_character => '-',
268
+ :target_foreground => :yellow,
269
+ :task_foreground => :blue,
270
+ :success_style => :bright,
271
+ :success_foreground => :green,
272
+ :error_style => :bright,
273
+ :error_foreground => :red
274
+ }
250
275
  # Short style keys for command line
251
276
  SHORT_STYLE_KEYS = {
252
277
  'lc' => 'line_character',
@@ -267,14 +292,19 @@ EOF
267
292
 
268
293
  # Constructor.
269
294
  # - style: style as a Hash or a String.
270
- def initialize(style)
295
+ # - color: a boolean telling if we use default color scheme.
296
+ def initialize(style, color=false)
297
+ # set default or color style
298
+ if color
299
+ @style = COLOR_STYLE.clone
300
+ else
301
+ @style = DEFAULT_STYLE.clone
302
+ end
271
303
  # if style is a String, this is command line argument
272
- style = parse_style_from_command_line(style) if style.kind_of?(String)
273
- # if style is nil, set default style
274
- @style = style || DEFAULT_STYLE
275
- # set default values for keys if nil
276
- for key in DEFAULT_STYLE.keys
277
- @style[key] = @style[key] || DEFAULT_STYLE[key]
304
+ if style.kind_of?(String)
305
+ @style.merge!(parse_style_from_command_line(style))
306
+ elsif style.kind_of?(Hash)
307
+ @style.merge!(style)
278
308
  end
279
309
  end
280
310
 
@@ -332,32 +362,32 @@ EOF
332
362
  help = ''
333
363
  # print build name and description
334
364
  if build.name
335
- help << "- Build: #{build.name}\n"
365
+ help << "build: #{build.name}\n"
336
366
  end
337
367
  if build.extends
338
- help << " Extends: #{build.extends}\n"
368
+ help << "extends: #{build.extends}\n"
339
369
  end
340
370
  if build.description
341
- help << format_description('Description', build.description, 2, false)
371
+ help << format_description('description', build.description, 0, false)
342
372
  end
343
373
  # print build properties
344
374
  if build.context.properties.length > 0
345
- help << "- Properties:\n"
375
+ help << "properties:\n"
346
376
  for property in build.context.properties.sort
347
- help << " - #{property}: " +
377
+ help << "- #{property}: " +
348
378
  "#{build.context.get_property(property, true).inspect}\n"
349
379
  end
350
380
  end
351
381
  # print build targets
352
382
  description = build.targets.description
353
383
  if description.length > 0
354
- help << "- Targets:\n"
384
+ help << "targets:\n"
355
385
  for name in description.keys.sort
356
- help << format_description(name, description[name], 2)
386
+ help << format_description(name, description[name], 0)
357
387
  end
358
388
  end
359
389
  # print default target
360
- help << "- Default: #{build.default}\n"
390
+ help << "default: #{build.default}\n"
361
391
  return help.strip
362
392
  end
363
393
 
@@ -1,4 +1,4 @@
1
- # Copyright 2006-2009 Michel Casabianca <michel.casabianca@gmail.com>
1
+ # Copyright 2006-2010 Michel Casabianca <michel.casabianca@gmail.com>
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -83,10 +83,10 @@ module Bee
83
83
  end
84
84
  params[param.to_sym] = params[param.to_s]
85
85
  else
86
- params[param.to_sym] = description[param][:default] if
87
- description[param][:default]
88
- params[param.to_s] = description[param][:default] if
89
- description[param][:default]
86
+ if description[param][:default]
87
+ params[param.to_sym] = description[param][:default]
88
+ params[param.to_s] = description[param][:default]
89
+ end
90
90
  end
91
91
  end
92
92
  for param in params.keys
@@ -1,4 +1,4 @@
1
- # Copyright 2006-2009 Michel Casabianca <michel.casabianca@gmail.com>
1
+ # Copyright 2006-2010 Michel Casabianca <michel.casabianca@gmail.com>
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -454,6 +454,9 @@ module Bee
454
454
  # false.
455
455
  # - flatten: tells if included files should be copied in destination
456
456
  # directory, ignoring their subdirectory. Optional, defaults to false.
457
+ # - lenient: tells if copy is lenient, which will silently succeed on
458
+ # errors (for instance if root or destination directory don't exist).
459
+ # Optional, defaults to false.
457
460
  #
458
461
  # Example:
459
462
  #
@@ -476,7 +479,8 @@ module Bee
476
479
  :excludes => { :mandatory => false, :type => :string_or_array },
477
480
  :dest => { :mandatory => true, :type => :string },
478
481
  :flatten => { :mandatory => false, :type => :boolean, :default => false },
479
- :dotmatch => { :mandatory => false, :type => :boolean, :default => false }
482
+ :dotmatch => { :mandatory => false, :type => :boolean, :default => false },
483
+ :lenient => { :mandatory => false, :type => :boolean, :default => false }
480
484
  }
481
485
  check_parameters(params, params_desc)
482
486
  root = params[:root]
@@ -485,10 +489,22 @@ module Bee
485
489
  dest = params[:dest]
486
490
  flatten = params[:flatten]
487
491
  dotmatch = params[:dotmatch]
488
- error "copy 'root' parameter must be an existing directory" unless
489
- File.exists?(root) and File.directory?(root)
490
- error "copy 'dest' parameter must be an existing directory" unless
491
- File.exists?(dest) and File.directory?(dest)
492
+ lenient = params[:lenient]
493
+ # check that root and dest are existing directories
494
+ if not (File.exists?(root) and File.directory?(root))
495
+ if lenient
496
+ return
497
+ else
498
+ error "copy 'root' parameter must be an existing directory"
499
+ end
500
+ end
501
+ if not (File.exists?(dest) and File.directory?(dest))
502
+ if lenient
503
+ return
504
+ else
505
+ error "copy 'dest' parameter must be an existing directory"
506
+ end
507
+ end
492
508
  # select files and copy
493
509
  files = filter_files(includes, excludes, root, dotmatch)
494
510
  puts "Copying #{files.length} file(s) to '#{dest}'"
@@ -517,6 +533,9 @@ module Bee
517
533
  # directory, ignoring their subdirectory. Optional, defaults to false.
518
534
  # - dotmatch: tells if joker matches dot files. Optional, defaults to
519
535
  # false.
536
+ # - lenient: tells if move is lenient, which will silently succeed on
537
+ # errors (for instance if root or destination directory don't exist).
538
+ # Optional, defaults to false.
520
539
  #
521
540
  # Example:
522
541
  #
@@ -540,7 +559,8 @@ module Bee
540
559
  :excludes => { :mandatory => false, :type => :string_or_array },
541
560
  :dest => { :mandatory => true, :type => :string },
542
561
  :flatten => { :mandatory => false, :type => :boolean, :default => false },
543
- :dotmatch => { :mandatory => false, :type => :boolean, :default => false }
562
+ :dotmatch => { :mandatory => false, :type => :boolean, :default => false },
563
+ :lenient => { :mandatory => false, :type => :boolean, :default => false }
544
564
  }
545
565
  check_parameters(params, params_desc)
546
566
  root = params[:root]
@@ -549,10 +569,22 @@ module Bee
549
569
  dest = params[:dest]
550
570
  flatten = params[:flatten]
551
571
  dotmatch = params[:dotmatch]
552
- error "move 'root' parameter must be an existing directory" unless
553
- File.exists?(root) and File.directory?(root)
554
- error "move 'dest' parameter must be an existing directory" unless
555
- File.exists?(dest) and File.directory?(dest)
572
+ lenient = params[:lenient]
573
+ # check that root and dest are existing directories
574
+ if not (File.exists?(root) and File.directory?(root))
575
+ if lenient
576
+ return
577
+ else
578
+ error "move 'root' parameter must be an existing directory"
579
+ end
580
+ end
581
+ if not (File.exists?(dest) and File.directory?(dest))
582
+ if lenient
583
+ return
584
+ else
585
+ error "move 'dest' parameter must be an existing directory"
586
+ end
587
+ end
556
588
  # select files and make move
557
589
  files = filter_files(includes, excludes, root, dotmatch)
558
590
  puts "Moving #{files.length} file(s) to '#{dest}'"
@@ -779,16 +811,25 @@ module Bee
779
811
  excludes = params[:excludes]
780
812
  dotmatch = params[:dotmatch]
781
813
  dir = params[:dir]
814
+ error "Test directory '#{dir}' not found" if
815
+ not (File.exists?(dir) and File.directory?(dir))
782
816
  files = filter_files(includes, excludes, root, dotmatch)
783
817
  for file in files
784
- load file
818
+ load File.join(root || '.', file)
785
819
  end
786
820
  size = (files.kind_of?(Array) ? files.size : 1)
787
821
  puts "Running #{size} unit test(s)"
788
- ok = Test::Unit::AutoRunner.run(false, dir)
789
- error "Tests failed" if not ok
822
+ old_dir = Dir.pwd
823
+ begin
824
+ Dir.chdir(dir)
825
+ runner = Test::Unit::AutoRunner.new(false)
826
+ ok = runner.run
827
+ error "Test failure" if not ok
828
+ ensure
829
+ Dir.chdir(old_dir)
830
+ end
790
831
  end
791
-
832
+
792
833
  # Run an ERB file or source in bee context and store result in a file or
793
834
  # property. Parameter is a Hash with following entries:
794
835
  #
@@ -1,4 +1,4 @@
1
- # Copyright 2006-2009 Michel Casabianca <michel.casabianca@gmail.com>
1
+ # Copyright 2006-2010 Michel Casabianca <michel.casabianca@gmail.com>
2
2
  # 2006 Avi Bryant
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -30,7 +30,7 @@ module Bee
30
30
  # Expanded pattern for resource
31
31
  EXPANDED_PATTERN = /^ruby:\/\/(.*?)(:(.*?))?\/(.*)$/
32
32
  # Default terminal width
33
- DEFAULT_TERM_WIDTH = 80
33
+ DEFAULT_TERM_WIDTH = (RUBY_PLATFORM =~ /win32/ ? 79 : 80)
34
34
 
35
35
  # Get line length calling IOCTL. Return DEFAULT_TERM_WIDTH if call failed.
36
36
  def self.term_width
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bee
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michel Casabianca & Contributors
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-01-20 00:00:00 +01:00
12
+ date: 2010-01-13 00:00:00 +01:00
13
13
  default_executable: bee
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -42,33 +42,34 @@ extra_rdoc_files:
42
42
  - README
43
43
  - LICENSE
44
44
  files:
45
- - bin/bee
46
45
  - bin/bee.bat
47
- - lib/bee.rb
46
+ - bin/bee
48
47
  - lib/bee_console.rb
49
48
  - lib/bee_task.rb
50
49
  - lib/bee_task_default.rb
51
50
  - lib/bee_util.rb
52
- - egg/package
53
- - egg/package/bee_task.erb
51
+ - lib/bee.rb
52
+ - egg/package.yml
53
+ - egg/package/test.erb
54
+ - egg/package/test_suite.rb
55
+ - egg/package/gem_spec.erb
54
56
  - egg/package/build.erb
55
- - egg/package/egg.yml
56
- - egg/package/egg_build.erb
57
- - egg/package/egg_launcher.erb
58
57
  - egg/package/egg_script.rb
59
- - egg/package/gem_spec.erb
60
58
  - egg/package/license
59
+ - egg/package/egg_launcher.erb
61
60
  - egg/package/readme.erb
62
- - egg/package/test.erb
61
+ - egg/package/bee_task.erb
62
+ - egg/package/egg.yml
63
63
  - egg/package/test_build.erb
64
- - egg/package/test_build.rb
64
+ - egg/package/egg_build.erb
65
65
  - egg/package/test_build_listener.rb
66
- - egg/package/test_suite.rb
67
- - egg/package.yml
66
+ - egg/package/test_build.rb
68
67
  - README
69
68
  - LICENSE
70
69
  has_rdoc: true
71
70
  homepage: http://bee.rubyforge.org
71
+ licenses: []
72
+
72
73
  post_install_message: Enjoy bee!
73
74
  rdoc_options: []
74
75
 
@@ -89,9 +90,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
89
90
  requirements: []
90
91
 
91
92
  rubyforge_project: bee
92
- rubygems_version: 1.3.0
93
+ rubygems_version: 1.3.5
93
94
  signing_key:
94
- specification_version: 2
95
+ specification_version: 3
95
96
  summary: bee is a build tool
96
97
  test_files: []
97
98