ripl-commands 0.1.0
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/.gemspec +18 -0
 - data/CHANGELOG.rdoc +2 -0
 - data/LICENSE.txt +22 -0
 - data/README.rdoc +53 -0
 - data/Rakefile +35 -0
 - data/lib/ripl/commands.rb +38 -0
 - metadata +75 -0
 
    
        data/.gemspec
    ADDED
    
    | 
         @@ -0,0 +1,18 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # -*- encoding: utf-8 -*-
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'rubygems' unless Object.const_defined?(:Gem)
         
     | 
| 
      
 3 
     | 
    
         
            +
            require File.dirname(__FILE__) + "/lib/ripl/commands"
         
     | 
| 
      
 4 
     | 
    
         
            +
             
         
     | 
| 
      
 5 
     | 
    
         
            +
            Gem::Specification.new do |s|
         
     | 
| 
      
 6 
     | 
    
         
            +
              s.name        = "ripl-commands"
         
     | 
| 
      
 7 
     | 
    
         
            +
              s.version     = Ripl::Commands::VERSION
         
     | 
| 
      
 8 
     | 
    
         
            +
              s.authors     = ["Gabriel Horner"]
         
     | 
| 
      
 9 
     | 
    
         
            +
              s.email       = "gabriel.horner@gmail.com"
         
     | 
| 
      
 10 
     | 
    
         
            +
              s.homepage    = "http://github.com/cldwalker/ripl-commands"
         
     | 
| 
      
 11 
     | 
    
         
            +
              s.summary = "This ripl plugin adds commands to ripl that are similar to irb's"
         
     | 
| 
      
 12 
     | 
    
         
            +
              s.description =  "This ripl plugin provides a core group of commands for any ripl shell. It aims to match and surpass functionality in irb's commands."
         
     | 
| 
      
 13 
     | 
    
         
            +
              s.required_rubygems_version = ">= 1.3.6"
         
     | 
| 
      
 14 
     | 
    
         
            +
              s.rubyforge_project = 'tagaholic'
         
     | 
| 
      
 15 
     | 
    
         
            +
              s.files = Dir.glob(%w[{lib,test}/**/*.rb bin/* [A-Z]*.{txt,rdoc} ext/**/*.{rb,c} **/deps.rip]) + %w{Rakefile .gemspec}
         
     | 
| 
      
 16 
     | 
    
         
            +
              s.extra_rdoc_files = ["README.rdoc", "LICENSE.txt"]
         
     | 
| 
      
 17 
     | 
    
         
            +
              s.license = 'MIT'
         
     | 
| 
      
 18 
     | 
    
         
            +
            end
         
     | 
    
        data/CHANGELOG.rdoc
    ADDED
    
    
    
        data/LICENSE.txt
    ADDED
    
    | 
         @@ -0,0 +1,22 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            The MIT LICENSE
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            Copyright (c) 2010 Gabriel Horner
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            Permission is hereby granted, free of charge, to any person obtaining
         
     | 
| 
      
 6 
     | 
    
         
            +
            a copy of this software and associated documentation files (the
         
     | 
| 
      
 7 
     | 
    
         
            +
            "Software"), to deal in the Software without restriction, including
         
     | 
| 
      
 8 
     | 
    
         
            +
            without limitation the rights to use, copy, modify, merge, publish,
         
     | 
| 
      
 9 
     | 
    
         
            +
            distribute, sublicense, and/or sell copies of the Software, and to
         
     | 
| 
      
 10 
     | 
    
         
            +
            permit persons to whom the Software is furnished to do so, subject to
         
     | 
| 
      
 11 
     | 
    
         
            +
            the following conditions:
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
            The above copyright notice and this permission notice shall be
         
     | 
| 
      
 14 
     | 
    
         
            +
            included in all copies or substantial portions of the Software.
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
            THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
         
     | 
| 
      
 17 
     | 
    
         
            +
            EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
         
     | 
| 
      
 18 
     | 
    
         
            +
            MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
         
     | 
| 
      
 19 
     | 
    
         
            +
            NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
         
     | 
| 
      
 20 
     | 
    
         
            +
            LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
         
     | 
| 
      
 21 
     | 
    
         
            +
            OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
         
     | 
| 
      
 22 
     | 
    
         
            +
            WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
         
     | 
    
        data/README.rdoc
    ADDED
    
    | 
         @@ -0,0 +1,53 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            == Description
         
     | 
| 
      
 2 
     | 
    
         
            +
            This ripl plugin provides a core group of commands for any ripl shell. It aims to
         
     | 
| 
      
 3 
     | 
    
         
            +
            match and surpass functionality in {irb's commands}[http://tagaholic.me/2009/05/11/demystifying-irb-commands.html]. 
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            == Install
         
     | 
| 
      
 6 
     | 
    
         
            +
            Install the gem with:
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
                sudo gem install ripl-commands
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
            == Usage
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
            Add to your ~/.riplrc
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
                require 'ripl/commands'
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
            Try it out:
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
                $ ripl
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
                # set any ripl config dynamically
         
     | 
| 
      
 21 
     | 
    
         
            +
                >> config :prompt, lambda { "ripl(main):" + Ripl.shell.line.to_s + "> " }
         
     | 
| 
      
 22 
     | 
    
         
            +
                => #<Proc:0x0063e2f0@(ripl):1>
         
     | 
| 
      
 23 
     | 
    
         
            +
                ripl(main):2>  config :result_prompt, '<> '
         
     | 
| 
      
 24 
     | 
    
         
            +
                <> "<> "
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
                # Jump around in different objects as irb does with subsessions and workspaces
         
     | 
| 
      
 27 
     | 
    
         
            +
                >> jump 'dude'
         
     | 
| 
      
 28 
     | 
    
         
            +
                => 'dude'
         
     | 
| 
      
 29 
     | 
    
         
            +
                >> self
         
     | 
| 
      
 30 
     | 
    
         
            +
                => 'dude'
         
     | 
| 
      
 31 
     | 
    
         
            +
                # Autocomplet for the new current object
         
     | 
| 
      
 32 
     | 
    
         
            +
                >> cap[TAB]
         
     | 
| 
      
 33 
     | 
    
         
            +
                capitalize   capitalize!
         
     | 
| 
      
 34 
     | 
    
         
            +
                >> capitalize
         
     | 
| 
      
 35 
     | 
    
         
            +
                => 'Dude'
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
                # To see where you've jumped
         
     | 
| 
      
 38 
     | 
    
         
            +
                >> jumps
         
     | 
| 
      
 39 
     | 
    
         
            +
                => [main, 'dude']
         
     | 
| 
      
 40 
     | 
    
         
            +
             
     | 
| 
      
 41 
     | 
    
         
            +
                # Jumping to a number translates to jumping to an existing jump
         
     | 
| 
      
 42 
     | 
    
         
            +
                >> jump 0
         
     | 
| 
      
 43 
     | 
    
         
            +
                => main
         
     | 
| 
      
 44 
     | 
    
         
            +
             
     | 
| 
      
 45 
     | 
    
         
            +
                # To list what commands ripl has
         
     | 
| 
      
 46 
     | 
    
         
            +
                >> list
         
     | 
| 
      
 47 
     | 
    
         
            +
                => ["list", "config", "jumps", "jump"]
         
     | 
| 
      
 48 
     | 
    
         
            +
             
     | 
| 
      
 49 
     | 
    
         
            +
            == Todo
         
     | 
| 
      
 50 
     | 
    
         
            +
            * Explain how to extend commands
         
     | 
| 
      
 51 
     | 
    
         
            +
            * Add exit for a jump
         
     | 
| 
      
 52 
     | 
    
         
            +
            * Add command completion
         
     | 
| 
      
 53 
     | 
    
         
            +
            * Fix stacktrace interference caused by jumps
         
     | 
    
        data/Rakefile
    ADDED
    
    | 
         @@ -0,0 +1,35 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'rake'
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'fileutils'
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            def gemspec
         
     | 
| 
      
 5 
     | 
    
         
            +
              @gemspec ||= eval(File.read('.gemspec'), binding, '.gemspec')
         
     | 
| 
      
 6 
     | 
    
         
            +
            end
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
            desc "Build the gem"
         
     | 
| 
      
 9 
     | 
    
         
            +
            task :gem=>:gemspec do
         
     | 
| 
      
 10 
     | 
    
         
            +
              sh "gem build .gemspec"
         
     | 
| 
      
 11 
     | 
    
         
            +
              FileUtils.mkdir_p 'pkg'
         
     | 
| 
      
 12 
     | 
    
         
            +
              FileUtils.mv "#{gemspec.name}-#{gemspec.version}.gem", 'pkg'
         
     | 
| 
      
 13 
     | 
    
         
            +
            end
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
            desc "Install the gem locally"
         
     | 
| 
      
 16 
     | 
    
         
            +
            task :install => :gem do
         
     | 
| 
      
 17 
     | 
    
         
            +
              sh %{gem install pkg/#{gemspec.name}-#{gemspec.version}}
         
     | 
| 
      
 18 
     | 
    
         
            +
            end
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
            desc "Generate the gemspec"
         
     | 
| 
      
 21 
     | 
    
         
            +
            task :generate do
         
     | 
| 
      
 22 
     | 
    
         
            +
              puts gemspec.to_ruby
         
     | 
| 
      
 23 
     | 
    
         
            +
            end
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
            desc "Validate the gemspec"
         
     | 
| 
      
 26 
     | 
    
         
            +
            task :gemspec do
         
     | 
| 
      
 27 
     | 
    
         
            +
              gemspec.validate
         
     | 
| 
      
 28 
     | 
    
         
            +
            end
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
            desc 'Run tests'
         
     | 
| 
      
 31 
     | 
    
         
            +
            task :test do |t|
         
     | 
| 
      
 32 
     | 
    
         
            +
              sh 'bacon -q -Ilib -I. test/*_test.rb'
         
     | 
| 
      
 33 
     | 
    
         
            +
            end
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
            task :default => :test
         
     | 
| 
         @@ -0,0 +1,38 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'ripl'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            module Ripl
         
     | 
| 
      
 4 
     | 
    
         
            +
              module Commands
         
     | 
| 
      
 5 
     | 
    
         
            +
                VERSION = '0.1.0'
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
                module Core
         
     | 
| 
      
 8 
     | 
    
         
            +
                  def self.jumps
         
     | 
| 
      
 9 
     | 
    
         
            +
                    @jumps ||= [Ripl.shell.loop_eval("self")]
         
     | 
| 
      
 10 
     | 
    
         
            +
                  end
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
                  def list
         
     | 
| 
      
 13 
     | 
    
         
            +
                    Ripl::Commands.instance_methods
         
     | 
| 
      
 14 
     | 
    
         
            +
                  end
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
                  def config(name, val)
         
     | 
| 
      
 17 
     | 
    
         
            +
                    Ripl.shell.respond_to?("#{name}=") ? Ripl.shell.send("#{name}=", val) :
         
     | 
| 
      
 18 
     | 
    
         
            +
                      Ripl.config[name] = val
         
     | 
| 
      
 19 
     | 
    
         
            +
                  end
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
                  def jump(obj)
         
     | 
| 
      
 22 
     | 
    
         
            +
                    obj = Core.jumps[obj] || obj if obj.is_a?(Fixnum)
         
     | 
| 
      
 23 
     | 
    
         
            +
                    if !Core.jumps.include?(obj)
         
     | 
| 
      
 24 
     | 
    
         
            +
                      Core.jumps << obj
         
     | 
| 
      
 25 
     | 
    
         
            +
                      Ripl.shell.add_commands(obj)
         
     | 
| 
      
 26 
     | 
    
         
            +
                    end
         
     | 
| 
      
 27 
     | 
    
         
            +
                    Ripl.shell.binding = obj.send(:binding)
         
     | 
| 
      
 28 
     | 
    
         
            +
                    obj
         
     | 
| 
      
 29 
     | 
    
         
            +
                  end
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
                  def jumps
         
     | 
| 
      
 32 
     | 
    
         
            +
                    Core.jumps
         
     | 
| 
      
 33 
     | 
    
         
            +
                  end
         
     | 
| 
      
 34 
     | 
    
         
            +
                end
         
     | 
| 
      
 35 
     | 
    
         
            +
              end
         
     | 
| 
      
 36 
     | 
    
         
            +
            end
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
      
 38 
     | 
    
         
            +
            Ripl::Commands.send :include, Ripl::Commands::Core
         
     | 
    
        metadata
    ADDED
    
    | 
         @@ -0,0 +1,75 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            --- !ruby/object:Gem::Specification 
         
     | 
| 
      
 2 
     | 
    
         
            +
            name: ripl-commands
         
     | 
| 
      
 3 
     | 
    
         
            +
            version: !ruby/object:Gem::Version 
         
     | 
| 
      
 4 
     | 
    
         
            +
              hash: 27
         
     | 
| 
      
 5 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 6 
     | 
    
         
            +
              segments: 
         
     | 
| 
      
 7 
     | 
    
         
            +
              - 0
         
     | 
| 
      
 8 
     | 
    
         
            +
              - 1
         
     | 
| 
      
 9 
     | 
    
         
            +
              - 0
         
     | 
| 
      
 10 
     | 
    
         
            +
              version: 0.1.0
         
     | 
| 
      
 11 
     | 
    
         
            +
            platform: ruby
         
     | 
| 
      
 12 
     | 
    
         
            +
            authors: 
         
     | 
| 
      
 13 
     | 
    
         
            +
            - Gabriel Horner
         
     | 
| 
      
 14 
     | 
    
         
            +
            autorequire: 
         
     | 
| 
      
 15 
     | 
    
         
            +
            bindir: bin
         
     | 
| 
      
 16 
     | 
    
         
            +
            cert_chain: []
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
            date: 2010-11-18 00:00:00 -05:00
         
     | 
| 
      
 19 
     | 
    
         
            +
            default_executable: 
         
     | 
| 
      
 20 
     | 
    
         
            +
            dependencies: []
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
            description: This ripl plugin provides a core group of commands for any ripl shell. It aims to match and surpass functionality in irb's commands.
         
     | 
| 
      
 23 
     | 
    
         
            +
            email: gabriel.horner@gmail.com
         
     | 
| 
      
 24 
     | 
    
         
            +
            executables: []
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
            extensions: []
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
            extra_rdoc_files: 
         
     | 
| 
      
 29 
     | 
    
         
            +
            - README.rdoc
         
     | 
| 
      
 30 
     | 
    
         
            +
            - LICENSE.txt
         
     | 
| 
      
 31 
     | 
    
         
            +
            files: 
         
     | 
| 
      
 32 
     | 
    
         
            +
            - lib/ripl/commands.rb
         
     | 
| 
      
 33 
     | 
    
         
            +
            - LICENSE.txt
         
     | 
| 
      
 34 
     | 
    
         
            +
            - CHANGELOG.rdoc
         
     | 
| 
      
 35 
     | 
    
         
            +
            - README.rdoc
         
     | 
| 
      
 36 
     | 
    
         
            +
            - Rakefile
         
     | 
| 
      
 37 
     | 
    
         
            +
            - .gemspec
         
     | 
| 
      
 38 
     | 
    
         
            +
            has_rdoc: true
         
     | 
| 
      
 39 
     | 
    
         
            +
            homepage: http://github.com/cldwalker/ripl-commands
         
     | 
| 
      
 40 
     | 
    
         
            +
            licenses: 
         
     | 
| 
      
 41 
     | 
    
         
            +
            - MIT
         
     | 
| 
      
 42 
     | 
    
         
            +
            post_install_message: 
         
     | 
| 
      
 43 
     | 
    
         
            +
            rdoc_options: []
         
     | 
| 
      
 44 
     | 
    
         
            +
             
     | 
| 
      
 45 
     | 
    
         
            +
            require_paths: 
         
     | 
| 
      
 46 
     | 
    
         
            +
            - lib
         
     | 
| 
      
 47 
     | 
    
         
            +
            required_ruby_version: !ruby/object:Gem::Requirement 
         
     | 
| 
      
 48 
     | 
    
         
            +
              none: false
         
     | 
| 
      
 49 
     | 
    
         
            +
              requirements: 
         
     | 
| 
      
 50 
     | 
    
         
            +
              - - ">="
         
     | 
| 
      
 51 
     | 
    
         
            +
                - !ruby/object:Gem::Version 
         
     | 
| 
      
 52 
     | 
    
         
            +
                  hash: 3
         
     | 
| 
      
 53 
     | 
    
         
            +
                  segments: 
         
     | 
| 
      
 54 
     | 
    
         
            +
                  - 0
         
     | 
| 
      
 55 
     | 
    
         
            +
                  version: "0"
         
     | 
| 
      
 56 
     | 
    
         
            +
            required_rubygems_version: !ruby/object:Gem::Requirement 
         
     | 
| 
      
 57 
     | 
    
         
            +
              none: false
         
     | 
| 
      
 58 
     | 
    
         
            +
              requirements: 
         
     | 
| 
      
 59 
     | 
    
         
            +
              - - ">="
         
     | 
| 
      
 60 
     | 
    
         
            +
                - !ruby/object:Gem::Version 
         
     | 
| 
      
 61 
     | 
    
         
            +
                  hash: 23
         
     | 
| 
      
 62 
     | 
    
         
            +
                  segments: 
         
     | 
| 
      
 63 
     | 
    
         
            +
                  - 1
         
     | 
| 
      
 64 
     | 
    
         
            +
                  - 3
         
     | 
| 
      
 65 
     | 
    
         
            +
                  - 6
         
     | 
| 
      
 66 
     | 
    
         
            +
                  version: 1.3.6
         
     | 
| 
      
 67 
     | 
    
         
            +
            requirements: []
         
     | 
| 
      
 68 
     | 
    
         
            +
             
     | 
| 
      
 69 
     | 
    
         
            +
            rubyforge_project: tagaholic
         
     | 
| 
      
 70 
     | 
    
         
            +
            rubygems_version: 1.3.7
         
     | 
| 
      
 71 
     | 
    
         
            +
            signing_key: 
         
     | 
| 
      
 72 
     | 
    
         
            +
            specification_version: 3
         
     | 
| 
      
 73 
     | 
    
         
            +
            summary: This ripl plugin adds commands to ripl that are similar to irb's
         
     | 
| 
      
 74 
     | 
    
         
            +
            test_files: []
         
     | 
| 
      
 75 
     | 
    
         
            +
             
     |