Code Monkey home page Code Monkey logo

test_reload_gem's People

Contributors

zachallett avatar

Watchers

 avatar  avatar

test_reload_gem's Issues

Why require the installed gem when you can require the src files?

I know this is 3 years old and has no activity, but I found your blog post today, and it's pretty useful. There's a mistake though. When you require the gem name:

require 'test_gem'

that is requiring the version of that gem that is installed. You would need to run gem build *.gemspec and gem install *.gem to install the version of your gem with the changes you just made during development. This isn't very useful, as most people don't build and install their gem for every little change. Instead, change that line to this:

require_relative 'lib/test_gem'

and as long as you are using Ruby's gem file structure conventions, it will load the actual files you are working with. This was you can save your files, and run reload! from pry without ever exiting. Here's the relevant sections from my Rakefile for reference (gem name is brewer):

task :console do
  require 'pry'
  require_relative 'lib/brewer'

  def reload!
    files = $LOADED_FEATURES.select { |feat| feat =~ /\/brewer\// }
    files.each { |file| load file }
  end

  ARGV.clear
  Pry.start
end

Other than that, this is cool, and I know I'm going to use it. Thanks.

Edit: This needs to be run from the root of your gem during development, but that's usually where people work anyway.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.