From 42c37777bf9b752087c0465aada6181f86b11b41 Mon Sep 17 00:00:00 2001 From: John Mair Date: Sat, 31 Dec 2011 00:11:41 +1300 Subject: [PATCH] improved gist command refactor slightly --- lib/pry/default_commands/documentation.rb | 31 +++++++++++------------ 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/lib/pry/default_commands/documentation.rb b/lib/pry/default_commands/documentation.rb index e4ed2841..9c6b3258 100644 --- a/lib/pry/default_commands/documentation.rb +++ b/lib/pry/default_commands/documentation.rb @@ -69,16 +69,15 @@ class Pry def call(*args) require 'gist' - self.opts = options(args) - + gather_options(args) process_options perform_gist end - def options(args) + def gather_options(args) self.input_ranges = [] - parse_options!(args) do |opt| + self.opts = parse_options!(args) do |opt| opt.banner unindent <<-USAGE Usage: gist [OPTIONS] [METH] Gist method (doc or source) or input expression to github. @@ -100,6 +99,18 @@ class Pry end end + def process_options + if opts.present?(:in) + in_option + elsif opts.present?(:file) + file_option + elsif opts.present?(:doc) + doc_option + elsif opts.present?(:method) + method_option + end + end + def in_option self.code_type = :ruby self.content = "" @@ -150,18 +161,6 @@ class Pry self.code_type = meth.source_type end - def process_options - if opts.present?(:in) - in_option - elsif opts.present?(:file) - file_option - elsif opts.present?(:doc) - doc_option - elsif opts.present?(:method) - method_option - end - end - def perform_gist type_map = { :ruby => "rb", :c => "c", :plain => "plain" }