riblet 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
data/.gitignore ADDED
@@ -0,0 +1,21 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## PROJECT::GENERAL
17
+ coverage
18
+ rdoc
19
+ pkg
20
+
21
+ ## PROJECT::SPECIFIC
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Luke Pillow
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,34 @@
1
+ = riblet
2
+
3
+ Riblet makes it easy to organize and maintain .irbrc files.
4
+
5
+ == Install
6
+ gem install riblet
7
+
8
+ == Usage
9
+ Update your .irbrc file to add your favorite libraries with Riblet.
10
+
11
+ require 'rubygems'
12
+ require 'riblet'
13
+
14
+ add_on 'ap' do
15
+ name 'Awesome Print'
16
+ desc 'Pretty print your Ruby objects with style -- in full color and with proper indentation'
17
+ install 'gem install awesome_print'
18
+ source 'http://github.com/michaeldv/awesome_print'
19
+ usage 'ap <object>, options = {}'
20
+ end
21
+
22
+ == Note on Patches/Pull Requests
23
+
24
+ * Fork the project.
25
+ * Make your feature addition or bug fix.
26
+ * Add tests for it. This is important so I don't break it in a
27
+ future version unintentionally.
28
+ * Commit, do not mess with rakefile, version, or history.
29
+ (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
30
+ * Send me a pull request. Bonus points for topic branches.
31
+
32
+ == Copyright
33
+
34
+ Copyright (c) 2010 Luke Pillow. See LICENSE for details.
data/Rakefile ADDED
@@ -0,0 +1,45 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "riblet"
8
+ gem.summary = %Q{Riblet makes it easy to organize and read .irbrc files. }
9
+ gem.description = %Q{Riblet makes it easy to organize and read .irbrc files. }
10
+ gem.email = "lpillow@gmail.com"
11
+ gem.homepage = "http://github.com/pillowfactory/riblet"
12
+ gem.authors = ["Luke Pillow"]
13
+ gem.add_development_dependency "rspec", ">= 1.2.9"
14
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
15
+ end
16
+ Jeweler::GemcutterTasks.new
17
+ rescue LoadError
18
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
19
+ end
20
+
21
+ require 'spec/rake/spectask'
22
+ Spec::Rake::SpecTask.new(:spec) do |spec|
23
+ spec.libs << 'lib' << 'spec'
24
+ spec.spec_files = FileList['spec/**/*_spec.rb']
25
+ end
26
+
27
+ Spec::Rake::SpecTask.new(:rcov) do |spec|
28
+ spec.libs << 'lib' << 'spec'
29
+ spec.pattern = 'spec/**/*_spec.rb'
30
+ spec.rcov = true
31
+ end
32
+
33
+ task :spec => :check_dependencies
34
+
35
+ task :default => :spec
36
+
37
+ require 'rake/rdoctask'
38
+ Rake::RDocTask.new do |rdoc|
39
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
40
+
41
+ rdoc.rdoc_dir = 'rdoc'
42
+ rdoc.title = "riblet #{version}"
43
+ rdoc.rdoc_files.include('README*')
44
+ rdoc.rdoc_files.include('lib/**/*.rb')
45
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,61 @@
1
+ module Riblet
2
+ class Addon
3
+
4
+ def initialize(require_name, required=true)
5
+ @require_name = require_name
6
+ @required = required
7
+ end
8
+
9
+ def name(name); @name = name; end
10
+ def desc(desc); @desc = desc; end
11
+ def install(install); @install = install; end
12
+ def source(source); @source = source; end
13
+ def usage(usage); @usage = usage; end
14
+ def init(&init_block); @init_block = init_block; end
15
+
16
+ def perform_init
17
+ @init_block.call if @init_block
18
+ end
19
+
20
+ def install_str
21
+ "Install with: '#{@install}'" if @install
22
+ end
23
+
24
+ def to_s
25
+ if @name
26
+ "#{@name} (#{@require_name})"
27
+ else
28
+ @require_name
29
+ end
30
+ end
31
+
32
+ def self.load(require_name, required=true, &config)
33
+ definition = self.new(require_name, required)
34
+ definition.instance_eval(&config) if block_given?
35
+
36
+ if required && (require require_name)
37
+ ($irb_add_ons ||= []) << definition
38
+ definition.perform_init
39
+ puts "#{Color::BOLD}Loaded #{Color::CYAN}#{definition.to_s}#{Color::RESET}"
40
+ end
41
+ rescue LoadError
42
+ puts "#{Color::RED}Unable to load: #{Color::YELLOW}#{definition.to_s}#{Color::RED}. #{definition.install_str}#{Color::RESET}"
43
+ exit if required
44
+ end
45
+
46
+ module Color
47
+ RESET = "\e[0m"
48
+ BOLD = "\e[1m"
49
+ UNDERLINE = "\e[4m"
50
+ LGRAY = "\e[0;37m"
51
+ GRAY = "\e[1;30m"
52
+ RED = "\e[31m"
53
+ GREEN = "\e[32m"
54
+ YELLOW = "\e[33m"
55
+ BLUE = "\e[34m"
56
+ MAGENTA = "\e[35m"
57
+ CYAN = "\e[36m"
58
+ WHITE = "\e[37m"
59
+ end
60
+ end
61
+ end
data/lib/riblet/irb.rb ADDED
@@ -0,0 +1,7 @@
1
+ module Riblet
2
+ module IRB
3
+ def add_on(require_name, required=true, &config)
4
+ Riblet::Addon.load(require_name, required, &config)
5
+ end
6
+ end
7
+ end
data/lib/riblet.rb ADDED
@@ -0,0 +1,4 @@
1
+ require 'riblet/add_on'
2
+ require 'riblet/irb'
3
+
4
+ include Riblet::IRB
@@ -0,0 +1,42 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+
3
+ describe Riblet::Addon do
4
+ context ".load" do
5
+ it "should accept the name of a library to load" do
6
+ Riblet::Addon.load('rubygems')
7
+ end
8
+
9
+ it "should accept an optional configuration block" do
10
+ Riblet::Addon.load('rubygems') { }
11
+ end
12
+
13
+ it "should accept an optional 'library required' boolean" do
14
+ Riblet::Addon.load('rubygems', false)
15
+ end
16
+
17
+ context "when library is prerequisite to loading IRB" do
18
+
19
+ context "and the library is loadable" do
20
+ it "should load the specifed library" do
21
+ lambda{ Set }.should raise_error(NameError)
22
+ Riblet::Addon.load('set')
23
+ Set.new
24
+ end
25
+
26
+ it "should run any optional initialization" do
27
+ success = false
28
+ Riblet::Addon.load('bigdecimal') do
29
+ init { success = true }
30
+ end
31
+ success.should == true
32
+ end
33
+ end
34
+
35
+ context "and library isn't loadable" do
36
+ it "should exit IRB" do
37
+ lambda{ Riblet::Addon.load('invalid lib') }.should raise_error(SystemExit)
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,10 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+
3
+ describe Riblet::IRB do
4
+ describe '.add_on' do
5
+ it "should delegate to Riblet::Adon" do
6
+ Riblet::Addon.should_receive(:load)
7
+ Riblet::IRB.add_on(:foo)
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,43 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "Riblet" do
4
+ describe ".add_on" do
5
+ it "should accept the name of a library to load" do
6
+ add_on('rubygems')
7
+ end
8
+
9
+ it "should accept an optional configuration block" do
10
+ add_on('rubygems') { }
11
+ end
12
+
13
+ it "should accept an optional 'library required' boolean" do
14
+ add_on('rubygems', false)
15
+ end
16
+
17
+ context "when library is prerequisite to loading IRB" do
18
+
19
+ context "and the library is loadable" do
20
+ it "should load the specifed library" do
21
+ lambda{ Base64 }.should raise_error(NameError)
22
+ add_on('base64')
23
+ Base64
24
+ end
25
+
26
+ it "should run any optional initialization" do
27
+ success = false
28
+ add_on('drb') do
29
+ init { success = true }
30
+ end
31
+ success.should == true
32
+ end
33
+ end
34
+
35
+ context "and library isn't loadable" do
36
+ it "should exit IRB" do
37
+ lambda{ add_on('invalid lib') }.should raise_error(SystemExit)
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
43
+
data/spec/spec.opts ADDED
@@ -0,0 +1 @@
1
+ --color
@@ -0,0 +1,9 @@
1
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
2
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
+ require 'riblet'
4
+ require 'spec'
5
+ require 'spec/autorun'
6
+
7
+ Spec::Runner.configure do |config|
8
+
9
+ end
metadata ADDED
@@ -0,0 +1,92 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: riblet
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 1
8
+ - 0
9
+ version: 0.1.0
10
+ platform: ruby
11
+ authors:
12
+ - Luke Pillow
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-05-08 00:00:00 -05:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: rspec
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 1
29
+ - 2
30
+ - 9
31
+ version: 1.2.9
32
+ type: :development
33
+ version_requirements: *id001
34
+ description: "Riblet makes it easy to organize and read .irbrc files. "
35
+ email: lpillow@gmail.com
36
+ executables: []
37
+
38
+ extensions: []
39
+
40
+ extra_rdoc_files:
41
+ - LICENSE
42
+ - README.rdoc
43
+ files:
44
+ - .document
45
+ - .gitignore
46
+ - LICENSE
47
+ - README.rdoc
48
+ - Rakefile
49
+ - VERSION
50
+ - lib/riblet.rb
51
+ - lib/riblet/add_on.rb
52
+ - lib/riblet/irb.rb
53
+ - spec/riblet/addon_spec.rb
54
+ - spec/riblet/irb_spec.rb
55
+ - spec/riblet_spec.rb
56
+ - spec/spec.opts
57
+ - spec/spec_helper.rb
58
+ has_rdoc: true
59
+ homepage: http://github.com/pillowfactory/riblet
60
+ licenses: []
61
+
62
+ post_install_message:
63
+ rdoc_options:
64
+ - --charset=UTF-8
65
+ require_paths:
66
+ - lib
67
+ required_ruby_version: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ segments:
72
+ - 0
73
+ version: "0"
74
+ required_rubygems_version: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ segments:
79
+ - 0
80
+ version: "0"
81
+ requirements: []
82
+
83
+ rubyforge_project:
84
+ rubygems_version: 1.3.6
85
+ signing_key:
86
+ specification_version: 3
87
+ summary: Riblet makes it easy to organize and read .irbrc files.
88
+ test_files:
89
+ - spec/riblet/addon_spec.rb
90
+ - spec/riblet/irb_spec.rb
91
+ - spec/riblet_spec.rb
92
+ - spec/spec_helper.rb