brice 0.2.3 → 0.2.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
@@ -2,17 +2,18 @@
2
2
 
3
3
  == VERSION
4
4
 
5
- This documentation refers to brice version 0.2.3
5
+ This documentation refers to brice version 0.2.4
6
6
 
7
7
 
8
8
  == DESCRIPTION
9
9
 
10
- Enhances your IRb experience by adding new functionality and by providing
11
- a framework that you can utilize to add your own extensions. It comes with
12
- a set of pre-selected features (see the files in {lib/rc}[link:../lib/rc]),
13
- but is highly configurable in that regard.
10
+ Enhances your IRb experience by adding new functionality and by
11
+ providing a framework that you can utilize to add your own extensions.
12
+ It comes with a set of pre-selected features (see the files in
13
+ {lib/brice/rc}[link:../lib/brice/rc]), but is highly configurable
14
+ in that regard.
14
15
 
15
- Add this to your <tt>.irbrc</tt> and receive the default goodness:
16
+ Add this to your <tt>~/.irbrc</tt> and receive the default goodness:
16
17
 
17
18
  require 'rubygems'
18
19
  require 'brice/init' # equivalent to: require 'brice'; Brice.init
@@ -35,6 +36,32 @@ Please note that further changes to the configuration for brice can't be
35
36
  guaranteed to have any effect after <tt>Brice.init</tt> has been called.
36
37
 
37
38
 
39
+ == DEFAULT FEATURES
40
+
41
+ +added_methods+:: Loads AddedMethods[http://blackwinter.github.com/added_methods]
42
+ if one (or both) of the following environment variables has
43
+ been set:
44
+
45
+ +WATCH_FOR_ADDED_METHODS+:: Regular expression or +true+
46
+ +WATCH_FOR_ADDED_METHODS_IN+:: Space- or comma-delimited list of class names
47
+ +libs+:: Loads libraries, either a set of default ones or those you
48
+ configure with <tt>config.libs = %w[...]</tt>.
49
+ +history+:: Configures IRb history support. See Brice::History for more
50
+ information.
51
+ +colours+:: Configures IRb colour support. See Brice::Colours for more
52
+ information.
53
+ +shortcuts+:: Includes convenient shortcut methods. See Brice::Shortcuts
54
+ and Brice::Shortcuts::ObjectShortcuts for more information.
55
+ +init+:: Does some basic initialization for IRb.
56
+ +prompt+:: Configures the IRb prompt, providing <tt>:BRICE_SIMPLE</tt>
57
+ and <tt>:BRICE_VERBOSE</tt> prompt modes.
58
+ +rails+:: Provides some Rails settings, such as adding the
59
+ <tt>:BRICE_RAILS</tt> prompt mode, setting the Rails logger
60
+ to +STDOUT+, and defining convenience accessors for your
61
+ models.
62
+ +devel+:: Provides some useful settings when developing Ruby libraries.
63
+
64
+
38
65
  == LINKS
39
66
 
40
67
  <b></b>
@@ -50,7 +77,7 @@ RubyForge project:: http://rubyforge.org/projects/prometheus
50
77
 
51
78
  == LICENSE AND COPYRIGHT
52
79
 
53
- Copyright (C) 2008-2011 Jens Wille
80
+ Copyright (C) 2008-2012 Jens Wille
54
81
 
55
82
  brice is free software: you can redistribute it and/or modify it under the
56
83
  terms of the GNU Affero General Public License as published by the Free
data/lib/brice/colours.rb CHANGED
@@ -3,7 +3,7 @@
3
3
  # #
4
4
  # A component of brice, the extra cool IRb goodness donator #
5
5
  # #
6
- # Copyright (C) 2008-2011 Jens Wille #
6
+ # Copyright (C) 2008-2012 Jens Wille #
7
7
  # #
8
8
  # Authors: #
9
9
  # Jens Wille <jens.wille@uni-koeln.de> #
@@ -29,6 +29,10 @@ require 'brice'
29
29
  module Brice
30
30
 
31
31
  # Add colour support to IRb.
32
+ #
33
+ # Set your own colours with <tt>config.colours.opt = { :colours => { ... } }</tt>
34
+ # or modify the default scheme (DEFAULT_COLOURS) with <tt>config.colours.opt =
35
+ # { :colours => Brice::Colours::DEFAULT_COLOURS.merge(...) }</tt>.
32
36
 
33
37
  module Colours
34
38
 
data/lib/brice/dsl.rb CHANGED
@@ -3,7 +3,7 @@
3
3
  # #
4
4
  # A component of brice, the extra cool IRb goodness donator #
5
5
  # #
6
- # Copyright (C) 2008-2011 Jens Wille #
6
+ # Copyright (C) 2008-2012 Jens Wille #
7
7
  # #
8
8
  # Authors: #
9
9
  # Jens Wille <jens.wille@uni-koeln.de> #
@@ -62,21 +62,22 @@ module Brice
62
62
  alias_method :define_irb_method, :irb_def
63
63
 
64
64
  # call-seq:
65
- # brice_rescue(what, args = [], error = Exception)
65
+ # brice_rescue(what[, args[, error[, quiet]]])
66
66
  #
67
67
  # Call +what+ with +args+ and rescue potential +error+, optionally
68
68
  # executing block in case of success. Gives a nicer error location
69
- # instead of the full backtrace.
69
+ # instead of the full backtrace. Doesn't warn about any errors when
70
+ # +quiet+ is +true+.
70
71
  #
71
72
  # Returns either the result of the executed method or of the block.
72
- def brice_rescue(what, args = [], error = Exception)
73
+ def brice_rescue(what, args = [], error = Exception, quiet = Brice.quiet)
73
74
  res = send(what, *args)
74
75
 
75
76
  block_given? ? yield : res
76
77
  rescue Exception => err
77
78
  raise unless err.is_a?(error)
78
79
 
79
- unless Brice.quiet
80
+ unless quiet
80
81
  # FIXME: ideally, we'd want the __FILE__ and __LINE__ of the
81
82
  # rc file where the error occurred.
82
83
  location = caller.find { |c| c !~ %r{(?:\A|/)lib/brice[/.]} }
@@ -89,25 +90,29 @@ module Brice
89
90
  end
90
91
 
91
92
  # call-seq:
92
- # brice_require(string)
93
+ # brice_require(string[, quiet])
94
+ # brice_require(string[, quiet]) { ... }
93
95
  #
94
96
  # Kernel#require the library named +string+ and optionally execute
95
- # block in case of success.
97
+ # the block in case of success. Doesn't warn about load errors when
98
+ # +quiet+ is +true+.
96
99
  #
97
100
  # Returns either the result of the executed method or of the block.
98
- def brice_require(string, &block)
99
- brice_rescue(:require, [string], LoadError, &block)
101
+ def brice_require(string, quiet = Brice.quiet, &block)
102
+ brice_rescue(:require, [string], LoadError, quiet, &block)
100
103
  end
101
104
 
102
105
  # call-seq:
103
- # brice_load(filename, wrap = false)
106
+ # brice_load(filename[, wrap[, quiet]])
107
+ # brice_load(filename[, wrap[, quiet]]) { ... }
104
108
  #
105
- # Kernel#load the file named +filename+ and optionally execute
106
- # block in case of success.
109
+ # Kernel#load the file named +filename+ with argument +wrap+ and
110
+ # optionally execute the block in case of success. Doesn't warn
111
+ # about load errors when +quiet+ is +true+.
107
112
  #
108
113
  # Returns either the result of the executed method or of the block.
109
- def brice_load(filename, wrap = false, &block)
110
- brice_rescue(:load, [filename, wrap], &block)
114
+ def brice_load(filename, wrap = false, quiet = Brice.quiet, &block)
115
+ brice_rescue(:load, [filename, wrap], Exception, quiet, &block)
111
116
  end
112
117
 
113
118
  # call-seq:
data/lib/brice/history.rb CHANGED
@@ -3,7 +3,7 @@
3
3
  # #
4
4
  # A component of brice, the extra cool IRb goodness donator #
5
5
  # #
6
- # Copyright (C) 2008-2011 Jens Wille #
6
+ # Copyright (C) 2008-2012 Jens Wille #
7
7
  # #
8
8
  # Authors: #
9
9
  # Jens Wille <jens.wille@uni-koeln.de> #
@@ -29,6 +29,18 @@ require 'brice'
29
29
  module Brice
30
30
 
31
31
  # IRb history support.
32
+ #
33
+ # Configure with <tt>config.history.opt = { ... }</tt>, where the following
34
+ # keys are recognized (see DEFAULTS):
35
+ #
36
+ # <tt>:path</tt>:: The path to your +.irb_history+ file.
37
+ # <tt>:size</tt>:: The number of entries to keep in the history file.
38
+ # <tt>:perms</tt>:: The mode to open the history file with.
39
+ # <tt>:uniq</tt>:: Whether only unique history entries shall be saved.
40
+ # May also be <tt>:reverse</tt> to keep the most recent
41
+ # ones.
42
+ # <tt>:merge</tt>:: Whether to preserve, i.e. merge, the history across
43
+ # overlapping sessions.
32
44
 
33
45
  class History
34
46
 
@@ -1,8 +1,8 @@
1
- # Load AddedMethods[http://added_methods.rubyforge.org/] if one
2
- # (or both) of the following environment variables has been set:
1
+ # Load AddedMethods[http://blackwinter.github.com/added_methods] if
2
+ # one (or both) of the following environment variables has been set:
3
3
  #
4
- # <tt>WATCH_FOR_ADDED_METHODS</tt>:: Regular expression or <tt>true</tt>
5
- # <tt>WATCH_FOR_ADDED_METHODS_IN</tt>:: Space- or comma-delimited list of class names
4
+ # +WATCH_FOR_ADDED_METHODS+:: Regular expression or +true+
5
+ # +WATCH_FOR_ADDED_METHODS_IN+:: Space- or comma-delimited list of class names
6
6
 
7
7
  brice 'added_methods' do |config|
8
8
 
@@ -2,14 +2,18 @@
2
2
 
3
3
  brice 'libs' => nil do |config|
4
4
 
5
- (config.empty? ? %w[
6
- pp
7
- yaml
8
- tempfile
9
- benchmark
10
- backports
11
- what_methods
12
- irb/completion
13
- ] : config).each { |lib| brice_require lib }
5
+ unless config.empty?
6
+ config.each { |lib| brice_require lib }
7
+ else
8
+ %w[
9
+ pp
10
+ yaml
11
+ tempfile
12
+ benchmark
13
+ backports
14
+ what_methods
15
+ irb/completion
16
+ ].each { |lib| brice_require lib, true }
17
+ end
14
18
 
15
19
  end
@@ -1,4 +1,4 @@
1
- # Prompt configuration
1
+ # Configure the IRb prompt
2
2
 
3
3
  brice 'prompt' => nil do |config|
4
4
 
@@ -10,11 +10,13 @@ brice 'prompt' => nil do |config|
10
10
  }
11
11
  }
12
12
 
13
- alias_method :_brice_original_evaluate, :evaluate
13
+ if Object.const_defined?(:Benchmark)
14
+ alias_method :_brice_original_evaluate, :evaluate
14
15
 
15
- # Capture execution time
16
- def evaluate(line, line_no)
17
- @runtime = Benchmark.realtime { _brice_original_evaluate(line, line_no) }
16
+ # Capture execution time
17
+ def evaluate(*args)
18
+ @runtime = Benchmark.realtime { _brice_original_evaluate(*args) }
19
+ end
18
20
  end
19
21
  end
20
22
 
@@ -30,18 +32,21 @@ brice 'prompt' => nil do |config|
30
32
  prefix = "#{RUBY_VERSION}"
31
33
  prefix << "p#{RUBY_PATCHLEVEL}" if defined?(RUBY_PATCHLEVEL)
32
34
 
35
+ prompt_return = Object.const_defined?(:Benchmark) ?
36
+ lambda { |rt| "#{rt} => %s\n" } : "=> %s\n"
37
+
33
38
  IRB.conf[:PROMPT].update(
34
39
  :BRICE_SIMPLE => {
35
40
  :PROMPT_I => ' ',
36
41
  :PROMPT_S => ' ',
37
42
  :PROMPT_C => ' ',
38
- :RETURN => lambda { |rt| "#{rt} => %s\n" }
43
+ :RETURN => prompt_return
39
44
  },
40
45
  :BRICE_VERBOSE => {
41
46
  :PROMPT_I => "#{prefix}> ",
42
47
  :PROMPT_S => "#{prefix}> ",
43
48
  :PROMPT_C => "#{prefix}> ",
44
- :RETURN => lambda { |rt| "#{rt} => %s\n" }
49
+ :RETURN => prompt_return
45
50
  }
46
51
  )
47
52
 
@@ -3,7 +3,7 @@
3
3
  # #
4
4
  # A component of brice, the extra cool IRb goodness donator #
5
5
  # #
6
- # Copyright (C) 2008-2011 Jens Wille #
6
+ # Copyright (C) 2008-2012 Jens Wille #
7
7
  # #
8
8
  # Authors: #
9
9
  # Jens Wille <jens.wille@uni-koeln.de> #
@@ -30,6 +30,11 @@ require 'brice'
30
30
  module Brice
31
31
 
32
32
  # Convenient shortcut methods.
33
+ #
34
+ # Set <tt>config.shortcuts.opt = { :object => false }</tt> to disable
35
+ # ObjectShortcuts, or <tt>config.shortcuts.opt = { :ri => false }</tt>
36
+ # to disable #ri shortcuts.
37
+
33
38
  module Shortcuts
34
39
 
35
40
  extend self
data/lib/brice/version.rb CHANGED
@@ -4,7 +4,7 @@ module Brice
4
4
 
5
5
  MAJOR = 0
6
6
  MINOR = 2
7
- TINY = 3
7
+ TINY = 4
8
8
 
9
9
  class << self
10
10
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: brice
3
3
  version: !ruby/object:Gem::Version
4
- hash: 17
4
+ hash: 31
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 3
10
- version: 0.2.3
9
+ - 4
10
+ version: 0.2.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jens Wille
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-12-13 00:00:00 Z
18
+ date: 2012-01-28 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: ruby-nuggets
@@ -44,44 +44,44 @@ extra_rdoc_files:
44
44
  - COPYING
45
45
  - ChangeLog
46
46
  files:
47
+ - lib/brice/shortcuts.rb
48
+ - lib/brice/version.rb
47
49
  - lib/brice/config.rb
50
+ - lib/brice/init.rb
48
51
  - lib/brice/dsl.rb
49
52
  - lib/brice/colours.rb
53
+ - lib/brice/history.rb
54
+ - lib/brice/rc/060_init.rb
55
+ - lib/brice/rc/090_devel.rb
56
+ - lib/brice/rc/050_shortcuts.rb
50
57
  - lib/brice/rc/040_colours.rb
51
58
  - lib/brice/rc/070_prompt.rb
52
59
  - lib/brice/rc/030_history.rb
53
- - lib/brice/rc/050_shortcuts.rb
54
- - lib/brice/rc/090_devel.rb
60
+ - lib/brice/rc/080_rails.rb
55
61
  - lib/brice/rc/020_libs.rb
56
- - lib/brice/rc/060_init.rb
57
62
  - lib/brice/rc/010_added_methods.rb
58
- - lib/brice/rc/080_rails.rb
59
- - lib/brice/version.rb
60
- - lib/brice/history.rb
61
- - lib/brice/init.rb
62
- - lib/brice/shortcuts.rb
63
63
  - lib/brice.rb
64
+ - TODO
65
+ - README
64
66
  - ChangeLog
65
67
  - COPYING
66
- - README
67
68
  - Rakefile
68
- - TODO
69
69
  - spec/brice/history_spec.rb
70
70
  - spec/spec_helper.rb
71
71
  - .rspec
72
- homepage: http://prometheus.rubyforge.org/brice
72
+ homepage: http://prometheus.rubyforge.org/
73
73
  licenses: []
74
74
 
75
75
  post_install_message:
76
76
  rdoc_options:
77
- - --line-numbers
78
77
  - --all
79
78
  - --main
80
79
  - README
81
80
  - --charset
82
81
  - UTF-8
83
82
  - --title
84
- - brice Application documentation (v0.2.3)
83
+ - brice Application documentation (v0.2.4)
84
+ - --line-numbers
85
85
  require_paths:
86
86
  - lib
87
87
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -105,7 +105,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
105
105
  requirements: []
106
106
 
107
107
  rubyforge_project: prometheus
108
- rubygems_version: 1.8.12
108
+ rubygems_version: 1.8.11
109
109
  signing_key:
110
110
  specification_version: 3
111
111
  summary: Extra cool IRb goodness for the masses