main 2.8.3 → 2.8.4

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.
data/README CHANGED
@@ -398,6 +398,65 @@ SAMPLES
398
398
 
399
399
 
400
400
 
401
+ <========< samples/h.rb >========>
402
+
403
+ ~ > cat samples/h.rb
404
+
405
+ require 'main'
406
+
407
+ # block-defaults are instance_eval'd in the main instance and be combined with
408
+ # mixins
409
+ #
410
+ # ./h.rb #=> forty-two
411
+ # ./h.rb a #=> 42
412
+ # ./h.rb b #=> 42.0
413
+ #
414
+
415
+ Main {
416
+ fattr :default_for_foobar => 'forty-two'
417
+
418
+ option(:foobar) do
419
+ default{ default_for_foobar }
420
+ end
421
+
422
+ mixin :foo do
423
+ fattr :default_for_foobar => 42
424
+ end
425
+
426
+ mixin :bar do
427
+ fattr :default_for_foobar => 42.0
428
+ end
429
+
430
+
431
+ run{ p params[:foobar].value }
432
+
433
+ mode :a do
434
+ mixin :foo
435
+ end
436
+
437
+ mode :b do
438
+ mixin :bar
439
+ end
440
+ }
441
+
442
+ ~ > ruby samples/h.rb
443
+
444
+ "forty-two"
445
+
446
+ ~ > ruby samples/h.rb --help
447
+
448
+ NAME
449
+ h.rb
450
+
451
+ SYNOPSIS
452
+ h.rb (a|b) [options]+
453
+
454
+ PARAMETERS
455
+ --foobar
456
+ --help, -h
457
+
458
+
459
+
401
460
  DOCS
402
461
  test/main.rb
403
462
 
@@ -406,6 +465,10 @@ DOCS
406
465
  API section below
407
466
 
408
467
  HISTORY
468
+ 2.8.3
469
+ - support for block defaults
470
+
471
+
409
472
  2.8.2
410
473
  - fixes and tests for negative arity/attr arguments, options, eg
411
474
 
@@ -2,7 +2,7 @@ module Main
2
2
  #
3
3
  # top level constants
4
4
  #
5
- Main::VERSION = '2.8.3' unless
5
+ Main::VERSION = '2.8.4' unless
6
6
  defined? Main::VERSION
7
7
  def self.version() Main::VERSION end
8
8
 
@@ -346,7 +346,7 @@ module Main
346
346
 
347
347
  def setup_io_restoration
348
348
  [STDIN, STDOUT, STDERR].each do |io|
349
- dup = io.dup and @finalizers.push lambda{ io.reopen dup }
349
+ dup = io.dup and @finalizers.push lambda{ io.reopen dup rescue nil }
350
350
  end
351
351
  end
352
352
 
@@ -528,11 +528,10 @@ puts
528
528
 
529
529
  class DSL
530
530
  def self.evaluate param, &block
531
- new(param).evaluate(&block)
531
+ new(param).instance_eval(&block)
532
532
  end
533
533
 
534
534
  attr 'param'
535
- alias_method 'evaluate', 'instance_eval'
536
535
 
537
536
  def initialize param
538
537
  @param = param
@@ -1,5 +1,7 @@
1
1
  require 'main'
2
2
 
3
+ # block-defaults are instance_eval'd in the main instance and be combined with
4
+ # mixins
3
5
  #
4
6
  # ./h.rb #=> forty-two
5
7
  # ./h.rb a #=> 42
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: main
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.8.3
4
+ version: 2.8.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ara T. Howard
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-10-22 00:00:00 -06:00
12
+ date: 2009-05-18 00:00:00 -06:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -93,7 +93,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
93
93
  requirements: []
94
94
 
95
95
  rubyforge_project: codeforpeople
96
- rubygems_version: 1.2.0
96
+ rubygems_version: 1.3.1
97
97
  signing_key:
98
98
  specification_version: 2
99
99
  summary: main