Module: Pico::PryContext
Instance Attribute Summary collapse
-
#commands_defined ⇒ Object
readonly
Returns the value of attribute commands_defined.
Instance Method Summary collapse
- #define_commands ⇒ Object
- #define_rake_command ⇒ Object
- #define_reload_command ⇒ Object
- #define_tmux_command ⇒ Object
- #start! ⇒ Object
Instance Attribute Details
#commands_defined ⇒ Object (readonly)
Returns the value of attribute commands_defined.
9 10 11 |
# File 'lib/pico/pry_context.rb', line 9 def commands_defined @commands_defined end |
Instance Method Details
#define_commands ⇒ Object
20 21 22 23 24 25 |
# File 'lib/pico/pry_context.rb', line 20 def define_commands define_reload_command define_rake_command define_tmux_command if ENV['TMUX'] @commands_defined = true end |
#define_rake_command ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/pico/pry_context.rb', line 36 def define_rake_command Pry::Commands.create_command "rake", keep_retval: true do description "Run the test suite" def process build_passed = Pico::TestRunner.run! operator = args.shift command = args.shift evaluate_hook(build_passed, operator, command, args) if operator build_passed end def evaluate_hook(build_passed, operator, command, args) if operator == '&&' run(command, args) if build_passed elsif operator == '||' run(command, args) unless build_passed else raise ArgumentError, "Must supply either '&&' or '||' operators, followed by a pry command" end end end def define_tmux_command Pry::Commands.create_command "tmux" do description "Run a tmux command" def process system 'tmux', *args end end end end |
#define_reload_command ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'lib/pico/pry_context.rb', line 27 def define_reload_command Pry::Commands.block_command "reload!", "Reload #{Pico.application.name}" do puts "Reloading #{Pico.application.name}..." Pico.application.reload! _pry_.binding_stack.push Pico.application.mod.__binding__ _pry_.binding_stack.shift until _pry_.binding_stack.size == 1 end end |
#define_tmux_command ⇒ Object
59 60 61 62 63 64 65 66 67 |
# File 'lib/pico/pry_context.rb', line 59 def define_tmux_command Pry::Commands.create_command "tmux" do description "Run a tmux command" def process system 'tmux', *args end end end |
#start! ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/pico/pry_context.rb', line 11 def start! if Pico.application.booted? raise Error, "cannot start pry context if application has booted" end define_commands unless commands_defined Pico.boot! Pico.application.mod.pry end |