1
0
Fork 0
mirror of https://github.com/pry/pry.git synced 2022-11-09 12:35:05 -05:00

improved gist command refactor slightly

This commit is contained in:
John Mair 2011-12-31 00:11:41 +13:00
parent 45e9bf33b5
commit 42c37777bf

View file

@ -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" }