riblet 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -11,12 +11,17 @@ Update your .irbrc file to add your favorite libraries with Riblet.
11
11
  require 'rubygems'
12
12
  require 'riblet'
13
13
 
14
- add_on 'ap' do
15
- name 'Awesome Print'
14
+ add_on 'wirble' do
15
+ name 'Wirble'
16
16
  desc 'Pretty print your Ruby objects with style -- in full color and with proper indentation'
17
- install 'gem install awesome_print'
17
+ install 'gem install wirble'
18
18
  source 'http://github.com/michaeldv/awesome_print'
19
- usage 'ap <object>, options = {}'
19
+ usage 'Auto'
20
+
21
+ init do
22
+ Wirble.init
23
+ Wirble.colorize
24
+ end
20
25
  end
21
26
 
22
27
  == Note on Patches/Pull Requests
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.2.0
data/lib/riblet.rb CHANGED
@@ -1,3 +1,14 @@
1
+ module Riblet
2
+ @@addons = []
3
+ def self.addons
4
+ @@addons
5
+ end
6
+
7
+ def self.addons=(riblet)
8
+ @@addons << riblet
9
+ end
10
+ end
11
+
1
12
  require 'riblet/add_on'
2
13
  require 'riblet/irb'
3
14
 
data/lib/riblet/add_on.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  module Riblet
2
2
  class Addon
3
+ attr_accessor :loaded
3
4
 
4
5
  def initialize(require_name, required=true)
5
6
  @require_name = require_name
@@ -21,7 +22,23 @@ module Riblet
21
22
  "Install with: '#{@install}'" if @install
22
23
  end
23
24
 
24
- def to_s
25
+ def to_s(type=nil)
26
+ if type == :usage
27
+ "#{Color::CYAN}#{self.full_name}#{Color::RESET} - Usage: #{Color::YELLOW}#{self.usage_msg || '<missing>'}#{Color::RESET}"
28
+ else
29
+ <<-EOF
30
+ #{Color::CYAN}#{@require_name}#{Color::RESET}
31
+ Name: #{Color::YELLOW}#{@name}#{Color::RESET}
32
+ Desc: #{Color::YELLOW}#{@desc}#{Color::RESET}
33
+ Install: #{Color::YELLOW}#{@install}#{Color::RESET}
34
+ Source: #{Color::YELLOW}#{@source}#{Color::RESET}
35
+ Usage: #{Color::YELLOW}#{@usage}#{Color::RESET}
36
+
37
+ EOF
38
+ end
39
+ end
40
+
41
+ def full_name
25
42
  if @name
26
43
  "#{@name} (#{@require_name})"
27
44
  else
@@ -29,17 +46,23 @@ module Riblet
29
46
  end
30
47
  end
31
48
 
49
+ def usage_msg
50
+ "#{@usage}" if @usage
51
+ end
52
+
32
53
  def self.load(require_name, required=true, &config)
33
54
  definition = self.new(require_name, required)
34
55
  definition.instance_eval(&config) if block_given?
35
56
 
36
- if required && (require require_name)
37
- ($irb_add_ons ||= []) << definition
57
+ if require require_name
58
+ Riblet.addons << definition
38
59
  definition.perform_init
39
- puts "#{Color::BOLD}Loaded #{Color::CYAN}#{definition.to_s}#{Color::RESET}"
60
+ definition.loaded = true
40
61
  end
62
+
63
+ return definition
41
64
  rescue LoadError
42
- puts "#{Color::RED}Unable to load: #{Color::YELLOW}#{definition.to_s}#{Color::RED}. #{definition.install_str}#{Color::RESET}"
65
+ puts "#{Color::RED}Unable to load: #{Color::YELLOW}#{definition.full_name}#{Color::RED}. #{definition.install_str}#{Color::RESET}"
43
66
  exit if required
44
67
  end
45
68
 
data/lib/riblet/irb.rb CHANGED
@@ -1,7 +1,22 @@
1
1
  module Riblet
2
2
  module IRB
3
3
  def add_on(require_name, required=true, &config)
4
- Riblet::Addon.load(require_name, required, &config)
4
+ riblet = Riblet::Addon.load(require_name, required, &config)
5
+
6
+ puts "** Loaded: #{riblet.to_s(:usage)}" if riblet && riblet.loaded
7
+ end
8
+
9
+ def riblets(type=nil)
10
+ puts "Using #{Riblet.addons.size} riblet(s)...\n\n"
11
+
12
+ Riblet.addons.each do |addon|
13
+ puts addon.to_s(type)
14
+ end
15
+ nil
16
+ end
17
+
18
+ def riblet(type=nil)
19
+ riblets(type)
5
20
  end
6
21
  end
7
22
  end
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 1
7
+ - 2
8
8
  - 0
9
- version: 0.1.0
9
+ version: 0.2.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Luke Pillow
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-05-08 00:00:00 -05:00
17
+ date: 2010-05-11 00:00:00 -05:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency