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:
parent
45e9bf33b5
commit
42c37777bf
1 changed files with 15 additions and 16 deletions
|
@ -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" }
|
||||
|
||||
|
|
Loading…
Reference in a new issue