0 Replies - 345 Views - Last Post: 01 June 2014 - 12:00 AM Rate Topic: -----

#1 Lemur  Icon User is offline

  • Pragmatism over Dogma
  • member icon


Reputation: 1359
  • View blog
  • Posts: 3,425
  • Joined: 28-November 09

[Gem] Pry Macros

Posted 01 June 2014 - 12:00 AM

https://github.com/baweaver/pry-macro

Start recording:

[1] pry(main)> record
[2] pry(main)> 1
=> 1
[3] pry(main)> 'foo'
=> "foo"
[4] pry(main)> ls
self.methods: inspect  to_s
locals: _  __  _dir_  _ex_  _file_  _in_  _out_  _pry_


Stop the recording and name it:

[5] pry(main)> stop
Macro Name: testing



Run it like any other command:

[6] pry(main)> testing
=> 1
=> "foo"
self.methods: inspect  to_s
locals: _  __  _dir_  _ex_  _file_  _in_  _out_  _pry_


Like it? You can save it and have it automatically append to your PryRC:

[10] pry(main)> save_macro testing


...and here it is, nice and formatted:

Pry::Commands.block_command 'testing', 'no description' do
  _pry_.input = StringIO.new(
    <<-MACRO.gsub(/^ {4,6}/, '')
      1
      'foo'
      ls
    MACRO
  )
end


Is This A Good Question/Topic? 0
  • +

Page 1 of 1