Sha256: c1f4ebfbaa8b0b55bb8a2ed2406801f11c544267cdcf58a1bc274190063e5053

Contents?: true

Size: 1.24 KB

Versions: 6

Compression:

Stored size: 1.24 KB

Contents

require 'pry'

class Object
  def cp data
    data = JSON.pretty_generate(data.to_hash) if data.respond_to?(:to_hash)
    Clipboard.copy data
    'copied'
  end

  # show method info
  # show User, :secure_hash
  def show klass, m
    klass = klass.class unless klass.respond_to?(:new)
    el = klass.instance_method(m)
    puts el.source_location.or([]).join(':').yellow
    puts '-'
    puts el.source
    nil
  end
end


ARGV[0] = 'console' if ARGV[0] == 'c'

LuxCli.class_eval do
  desc :console, 'Start console'
  def console
    $lux_start_time = Time.now

    require 'awesome_print'
    require 'clipboard'
    require './config/application'

    Lux.config.dump_errors   = true
    Lux.config.log_to_stdout = true

    if File.exist?('./config/console.rb')
      puts '* loading ./config/console.rb'
      require './config/console'
    else
      puts '* ./config/console.rb not found'
    end

    # AwesomePrint.pry!
    # nice object dump in console
    Pry.print = proc { |output, data|
      out = if data.is_a?(Hash)
        data.class.to_s+"\n"+JSON.pretty_generate(data).gsub(/"(\w+)":/) { '"%s":' % $1.yellow }
      else
        data.ai
      end

      output.puts out
    }

    # create mock session
    Lux::Current.new '/'

    Pry.start
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
lux-fw-0.5.37 ./bin/cli/console.rb
lux-fw-0.5.36 ./bin/cli/console.rb
lux-fw-0.5.35 ./bin/cli/console.rb
lux-fw-0.5.34 ./bin/cli/console.rb
lux-fw-0.5.33 ./bin/cli/console.rb
lux-fw-0.5.32 ./bin/cli/console.rb