Skip to content

Commit 14f80ee

Browse files
authored
Merge pull request #269 from phallstrom/gist-default-file-arb
when gisting stdin default to filename 'a.rb' instead of '-'
2 parents c817380 + fc87a5a commit 14f80ee

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

lib/gist.rb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,14 @@ def auth_token
7676
#
7777
# @see http://developer.github.com/v3/gists/
7878
def gist(content, options = {})
79-
filename = options[:filename] || "a.rb"
79+
filename = options[:filename] || default_filename
8080
multi_gist({filename => content}, options)
8181
end
8282

83+
def default_filename
84+
"gistfile1.txt"
85+
end
86+
8387
# Upload a gist to https://gist.github.com
8488
#
8589
# @param [Hash] files the code you'd like to gist: filename => content
@@ -114,7 +118,8 @@ def multi_gist(files, options={})
114118
if content.to_s.strip == ""
115119
raise "Cannot gist empty files" unless options[:skip_empty]
116120
else
117-
json[:files][File.basename(name)] = {:content => content}
121+
name = name == "-" ? default_filename : File.basename(name)
122+
json[:files][name] = {:content => content}
118123
end
119124
end
120125

0 commit comments

Comments
 (0)