blackwinter-brice 0.0.1
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/COPYING +676 -0
- data/ChangeLog +5 -0
- data/README +56 -0
- data/Rakefile +24 -0
- data/lib/brice.rb +170 -0
- data/lib/brice/config.rb +159 -0
- data/lib/brice/dsl.rb +161 -0
- data/lib/brice/init.rb +3 -0
- data/lib/brice/version.rb +27 -0
- data/lib/rc/004_wirble.rb +27 -0
- data/lib/rc/005_added_methods.rb +24 -0
- data/lib/rc/010_libs.rb +16 -0
- data/lib/rc/015_utility_belt.rb +15 -0
- data/lib/rc/020_init.rb +25 -0
- data/lib/rc/030_prompt.rb +32 -0
- data/lib/rc/040_rails.rb +86 -0
- data/lib/rc/050_devel.rb +7 -0
- metadata +87 -0
data/lib/brice/init.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
class Brice
|
2
|
+
|
3
|
+
module Version
|
4
|
+
|
5
|
+
MAJOR = 0
|
6
|
+
MINOR = 0
|
7
|
+
TINY = 1
|
8
|
+
|
9
|
+
class << self
|
10
|
+
|
11
|
+
# Returns array representation.
|
12
|
+
def to_a
|
13
|
+
[MAJOR, MINOR, TINY]
|
14
|
+
end
|
15
|
+
|
16
|
+
# Short-cut for version string.
|
17
|
+
def to_s
|
18
|
+
to_a.join('.')
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
VERSION = Version.to_s
|
26
|
+
|
27
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# Configure wirble[http://pablotron.org/software/wirble/]
|
2
|
+
|
3
|
+
brice 'wirble' do |config|
|
4
|
+
|
5
|
+
# Save history newest-first, instead of default oldest-first.
|
6
|
+
class Wirble::History
|
7
|
+
def save_history
|
8
|
+
if Object.const_defined?(:IRB)
|
9
|
+
path, max_size, perms = %w[path size perms].map { |v| cfg(v) }
|
10
|
+
|
11
|
+
lines = Readline::HISTORY.to_a.reverse.uniq.reverse
|
12
|
+
lines = lines[-max_size..-1] if lines.size > max_size
|
13
|
+
|
14
|
+
real_path = File.expand_path(path)
|
15
|
+
File.open(real_path, perms) { |fh| fh.puts lines }
|
16
|
+
say 'Saved %d lines to history file %s.' % [lines.size, path]
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
# Make wirble and ruby-debug use the same histfile
|
22
|
+
silence { FILE_HISTORY = Wirble::History::DEFAULTS[:history_path] }
|
23
|
+
|
24
|
+
Wirble.init(:skip_prompt => true)
|
25
|
+
Wirble.colorize
|
26
|
+
|
27
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# Load Util::AddedMethods[http://prometheus.rubyforge.org/ruby-nuggets/classes/Util/AddedMethods.html]
|
2
|
+
# from ruby-nuggets[http://prometheus.rubyforge.org/ruby-nuggets/] if one (or both) of the following
|
3
|
+
# environment variables has been set:
|
4
|
+
#
|
5
|
+
# <tt>WATCH_FOR_ADDED_METHODS</tt>:: Regular expression or <tt>true</tt>
|
6
|
+
# <tt>WATCH_FOR_ADDED_METHODS_IN</tt>:: Space-delimited list of class names
|
7
|
+
|
8
|
+
brice 'added_methods' => 'nuggets/util/added_methods' do |config|
|
9
|
+
|
10
|
+
regexp = ENV['WATCH_FOR_ADDED_METHODS']
|
11
|
+
klasses = ENV['WATCH_FOR_ADDED_METHODS_IN']
|
12
|
+
|
13
|
+
if regexp || klasses
|
14
|
+
if regexp == 'true'
|
15
|
+
Util::AddedMethods.init
|
16
|
+
else
|
17
|
+
regexp = Regexp.new(regexp || '')
|
18
|
+
klasses = (klasses || '').split
|
19
|
+
|
20
|
+
Util::AddedMethods.init(regexp, klasses)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
data/lib/rc/010_libs.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# Load selected pieces from {Utility Belt}[http://utilitybelt.rubyforge.org/]
|
2
|
+
|
3
|
+
brice 'utility_belt' => %w[
|
4
|
+
utility_belt/interactive_editor
|
5
|
+
utility_belt/irb_verbosity_control
|
6
|
+
] do |config|
|
7
|
+
|
8
|
+
brice_require 'utility_belt/language_greps' do
|
9
|
+
|
10
|
+
alias :mgrep :grep_methods
|
11
|
+
alias :cgrep :grep_classes
|
12
|
+
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
data/lib/rc/020_init.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# Basic initialization for IRb
|
2
|
+
|
3
|
+
brice 'init' => nil do |config|
|
4
|
+
|
5
|
+
$KCODE = 'u'
|
6
|
+
|
7
|
+
IRB.conf[:AUTO_INDENT] = true
|
8
|
+
|
9
|
+
# Cf. <http://rubyforge.org/snippet/detail.php?type=snippet&id=22>
|
10
|
+
def aorta(obj)
|
11
|
+
tempfile = Tempfile.new('aorta')
|
12
|
+
YAML.dump(obj, tempfile)
|
13
|
+
tempfile.close
|
14
|
+
|
15
|
+
path = tempfile.path
|
16
|
+
|
17
|
+
system(ENV['VISUAL'] || ENV['EDITOR'] || 'vi', path)
|
18
|
+
return obj unless File.exists?(path)
|
19
|
+
|
20
|
+
content = YAML.load_file(path)
|
21
|
+
tempfile.unlink
|
22
|
+
content
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# Prompt configuration
|
2
|
+
|
3
|
+
brice 'prompt' => nil do |config|
|
4
|
+
|
5
|
+
class IRB::Context
|
6
|
+
%w[prompt_i prompt_s prompt_c prompt_n return_format].each { |name|
|
7
|
+
define_method(name) {
|
8
|
+
ivar = instance_variable_get("@#{name}")
|
9
|
+
ivar.respond_to?(:call) ? ivar['%.4f' % @runtime] : ivar
|
10
|
+
}
|
11
|
+
}
|
12
|
+
|
13
|
+
alias_method :_brice_original_evaluate, :evaluate
|
14
|
+
|
15
|
+
# Capture execution time
|
16
|
+
def evaluate(line, line_no)
|
17
|
+
@runtime = Benchmark.realtime { _brice_original_evaluate(line, line_no) }
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
IRB.conf[:PROMPT] ||= {} # prevent error in webrick
|
22
|
+
|
23
|
+
IRB.conf[:PROMPT][:BRICE] = { # name of prompt mode
|
24
|
+
:PROMPT_I => ' ', # normal prompt
|
25
|
+
:PROMPT_S => ' ', # prompt for continuing strings
|
26
|
+
:PROMPT_C => ' ', # prompt for continuing statement
|
27
|
+
:RETURN => lambda { |rt| "#{rt} => %s\n" } # format to return value
|
28
|
+
}
|
29
|
+
|
30
|
+
IRB.conf[:PROMPT_MODE] = :BRICE
|
31
|
+
|
32
|
+
end
|
data/lib/rc/040_rails.rb
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
# Rails settings (cf. <http://www.quotedprintable.com/2007/9/13/my-irbrc>)
|
2
|
+
|
3
|
+
brice 'rails' => nil do |config|
|
4
|
+
|
5
|
+
if rails_env = ENV['RAILS_ENV']
|
6
|
+
### prompt
|
7
|
+
hint = rails_env == 'development' ? '' : "@#{rails_env}"
|
8
|
+
|
9
|
+
svn = brice_require('nuggets/file/which') { File.which('svn') }
|
10
|
+
|
11
|
+
if svn and svn_info = YAML.load(`#{svn} info`)
|
12
|
+
repo = svn_info['Repository Root']
|
13
|
+
path = svn_info['URL'].sub(%r{#{Regexp.escape(repo)}/?}, '')
|
14
|
+
|
15
|
+
prompt = File.basename(repo) << hint
|
16
|
+
prompt << " [#{path}]" unless path.empty?
|
17
|
+
else
|
18
|
+
prompt = File.basename(Dir.pwd) << hint
|
19
|
+
end
|
20
|
+
|
21
|
+
# add "ENV['RAILS_SANDBOX'] = 'true'" in rails-X.X.X/lib/commands/console.rb
|
22
|
+
prompt << "#{ENV['RAILS_SANDBOX'] ? '>' : '$'} "
|
23
|
+
|
24
|
+
IRB.conf[:PROMPT] ||= {}
|
25
|
+
|
26
|
+
IRB.conf[:PROMPT][:RAILS] = {
|
27
|
+
:PROMPT_I => prompt,
|
28
|
+
:PROMPT_S => prompt,
|
29
|
+
:PROMPT_C => prompt,
|
30
|
+
:RETURN => IRB.conf[:PROMPT][:BRICE][:RETURN]
|
31
|
+
}
|
32
|
+
|
33
|
+
IRB.conf[:PROMPT_MODE] = :RAILS
|
34
|
+
|
35
|
+
### logger
|
36
|
+
brice_require 'logger' do
|
37
|
+
|
38
|
+
silence {
|
39
|
+
Object.const_set(:RAILS_DEFAULT_LOGGER, Logger.new(STDOUT))
|
40
|
+
}
|
41
|
+
|
42
|
+
define_irb_method(:logger) { |*args|
|
43
|
+
if args.empty?
|
44
|
+
RAILS_DEFAULT_LOGGER
|
45
|
+
else
|
46
|
+
level, previous_level = args.first, logger.level
|
47
|
+
|
48
|
+
logger.level = level.is_a?(Integer) ?
|
49
|
+
level : Logger.const_get(level.to_s.upcase)
|
50
|
+
|
51
|
+
if block_given?
|
52
|
+
begin
|
53
|
+
yield # RDoc: Warning: yield outside of method
|
54
|
+
ensure
|
55
|
+
logger.level = previous_level
|
56
|
+
end
|
57
|
+
else
|
58
|
+
logger
|
59
|
+
end
|
60
|
+
end
|
61
|
+
}
|
62
|
+
|
63
|
+
end
|
64
|
+
|
65
|
+
# people/6 ;-) ...inspired by:
|
66
|
+
# <http://github.com/xaviershay/dotfiles/tree/master/irbrc>
|
67
|
+
define_irb_method(:method_missing) { |method, *args|
|
68
|
+
begin
|
69
|
+
klass = method.to_s.classify.constantize
|
70
|
+
|
71
|
+
unless klass.respond_to?(:/)
|
72
|
+
if klass.respond_to?(:[])
|
73
|
+
class << klass; alias_method :/, :[]; end
|
74
|
+
else
|
75
|
+
class << klass; alias_method :/, :find; end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
klass
|
80
|
+
rescue NameError
|
81
|
+
super
|
82
|
+
end
|
83
|
+
}
|
84
|
+
end
|
85
|
+
|
86
|
+
end
|
data/lib/rc/050_devel.rb
ADDED
metadata
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: blackwinter-brice
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jens Wille
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2008-11-18 00:00:00 -08:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: ruby-nuggets
|
17
|
+
version_requirement:
|
18
|
+
version_requirements: !ruby/object:Gem::Requirement
|
19
|
+
requirements:
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: "0"
|
23
|
+
version:
|
24
|
+
description: Extra cool IRb goodness for the masses
|
25
|
+
email: jens.wille@uni-koeln.de
|
26
|
+
executables: []
|
27
|
+
|
28
|
+
extensions: []
|
29
|
+
|
30
|
+
extra_rdoc_files:
|
31
|
+
- COPYING
|
32
|
+
- ChangeLog
|
33
|
+
- README
|
34
|
+
files:
|
35
|
+
- lib/brice/init.rb
|
36
|
+
- lib/brice/version.rb
|
37
|
+
- lib/brice/dsl.rb
|
38
|
+
- lib/brice/config.rb
|
39
|
+
- lib/rc/010_libs.rb
|
40
|
+
- lib/rc/040_rails.rb
|
41
|
+
- lib/rc/015_utility_belt.rb
|
42
|
+
- lib/rc/030_prompt.rb
|
43
|
+
- lib/rc/050_devel.rb
|
44
|
+
- lib/rc/020_init.rb
|
45
|
+
- lib/rc/005_added_methods.rb
|
46
|
+
- lib/rc/004_wirble.rb
|
47
|
+
- lib/brice.rb
|
48
|
+
- COPYING
|
49
|
+
- README
|
50
|
+
- ChangeLog
|
51
|
+
- Rakefile
|
52
|
+
has_rdoc: true
|
53
|
+
homepage: http://prometheus.rubyforge.org/brice
|
54
|
+
post_install_message:
|
55
|
+
rdoc_options:
|
56
|
+
- --line-numbers
|
57
|
+
- --inline-source
|
58
|
+
- --title
|
59
|
+
- brice Application documentation
|
60
|
+
- --charset
|
61
|
+
- UTF-8
|
62
|
+
- --main
|
63
|
+
- README
|
64
|
+
- --all
|
65
|
+
require_paths:
|
66
|
+
- lib
|
67
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
68
|
+
requirements:
|
69
|
+
- - ">="
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: "0"
|
72
|
+
version:
|
73
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - ">="
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: "0"
|
78
|
+
version:
|
79
|
+
requirements: []
|
80
|
+
|
81
|
+
rubyforge_project: prometheus
|
82
|
+
rubygems_version: 1.2.0
|
83
|
+
signing_key:
|
84
|
+
specification_version: 2
|
85
|
+
summary: Extra cool IRb goodness for the masses
|
86
|
+
test_files: []
|
87
|
+
|