Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor reading from stdin so --type option works #112

Closed
wants to merge 2 commits into from
Closed

Refactor reading from stdin so --type option works #112

wants to merge 2 commits into from

Conversation

simeonwillbanks
Copy link

When reading from stdin, a filename must be set with an extension since the GitHub gist API infers file type from filename and not extension. Thanks to @ottomata for the original implementation. Fixes Issue #101.

…ce the GitHub gist API infers file type from filename and not extension. Thanks to @ottomata for the original implementation. Fixes Issue #101.
@simeonwillbanks
Copy link
Author

Testing

$curl -s https://raw.github.com/LessonPlanet/gist/issue-101-type-option-not-working-from-stdin/gist > gist && chmod 755 gist && mv gist /usr/local/bin/gist

$mvim /usr/local/bin/gist # Edit file to include 09a79f8

$exec $SHELL

$cat test.rb | gist -trb -d'Testing 09a79f8dc3'
https://gist.github.com/3183191

@simeonwillbanks
Copy link
Author

Testing Again

$ gst

On branch issue-101-type-option-not-working-from-stdin

$ rake standalone

$ mv gist /usr/local/bin && chmod 755 /usr/local/bin/gist

$ diff /usr/local/bin/gist gist
1203,1212c1203
< # NOTE github gist API doesn't seem to
< # pay any attention to :extension here.
< # Since we don't have a read filename,
< # create one based on timestamp and extension.
< # Automatic syntax highlighting must be inferred
< files = [{
< :input => input,
< :extension => gist_extension,
< :filename => Time.now.utc.to_s.gsub(/\W/, '') + gist_extension
< }]

    files = [{:input => input, :extension => gist_extension}]

$ exec $SHELL

$ gist -d'issue-101-type-option-not-working-from-stdin gist binary' test.txt
https://gist.github.com/3183292

@simeonwillbanks
Copy link
Author

Here is the binary for review.

https://gist.github.com/3183335

…extension is nil. Therefore, call #to_s to avoid "can't convert nil into String" error.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant