Skip to content

Instantly share code, notes, and snippets.

@runlevel5
Last active August 29, 2015 14:02
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save runlevel5/76f3f6577bd4bb499199 to your computer and use it in GitHub Desktop.
Save runlevel5/76f3f6577bd4bb499199 to your computer and use it in GitHub Desktop.
A simple rake task that replicates the `rails console` for Lotus Framework

Lotus Console

A simple rake task that replicates the rails console for Lotus Framework

How to?

I assume that your config/application.rb is the place where you initialize all Lotus boot config

below is my config/application.rb for your interest

# config/application.rb

require 'rubygems'

# Set up gems listed in the Gemfile.
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)

require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])


module Blog
  class Application < Lotus::Application
    configure do
      layout :application
      routes 'config/routes'

      load_paths << 'app'

      controller_pattern "%{controller}Controller::%{action}"
      view_pattern       "%{controller}::%{action}"
    end
  end
end

next, we add pry gem into our app by editing our Gemfile

# Gemfile

source 'https://rubygems.org'

gem 'lotusrb',          github: 'lotus/lotus'
gem 'lotus-utils',      github: 'lotus/utils'
gem 'lotus-helpers',    github: 'lotus/helpers'
gem 'lotus-model',      github: 'lotus/model'
gem 'lotus-controller', github: 'lotus/controller'
gem 'lotus-view',       github: 'lotus/view'
gem 'lotus-router',     github: 'lotus/router'

gem 'pry'

and make sure you run bundle install after that.

Now we create a Rakefile with following task

# Rakefile

desc 'Application console'
task :console do
  exec 'bundle exec pry -r./config/application.rb'
end

and now you can run bundle exec rake console to get all the sweetness of Rails console in Lotus.

Let's hope the next version of Lotus will bundle similar tool.

@rogerleite
Copy link

Great code! 👍
The question is, how to turn this on a Pull Request to https://github.com/lotus/lotus?

@runlevel5
Copy link
Author

@rogerleite: I'll wait till Lotus is officially released and then work out what to do

@codyeatworld
Copy link

This is really cool! 😺

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment