Browse files

Mindless rename jist->gist

  • Loading branch information...
1 parent a05092f commit ca024d228c3d76587c8646cc92a5dc8bde254b40 @ConradIrwin committed May 2, 2013
Showing with 101 additions and 101 deletions.
  1. +34 −34 README.md
  2. +1 −1 Rakefile
  3. +17 −17 bin/{jist → gist}
  4. +6 −6 jist.gemspec → gist.gemspec
  5. +16 −16 lib/{jist.rb → gist.rb}
  6. +8 −8 spec/clipboard_spec.rb
  7. +15 −15 spec/ghe_spec.rb
  8. +2 −2 spec/proxy_spec.rb
  9. +1 −1 spec/shorten_spec.rb
  10. +1 −1 spec/spec_helper.rb
View
68 README.md
@@ -1,124 +1,124 @@
-Jist is a gem that allows you to publish a [gist](https://gist.github.com) from Ruby.
+Gist is a gem that allows you to publish a [gist](https://gist.github.com) from Ruby.
# Installation
-As with all ruby gems, you can install Jist (assuming you have ruby and rubygems) with:
+As with all ruby gems, you can install Gist (assuming you have ruby and rubygems) with:
```shell
-$ gem install jist
+$ gem install gist
```
If you want to use the library in your application, and you're using Bundler. Add the
following to your Gemfile.
```ruby
source :rubygems
-gem 'jist'
+gem 'gist'
```
# Command
-The jist gem provides a `jist` command that you can use from your terminal to
+The gist gem provides a `gist` command that you can use from your terminal to
upload content to https://gist.github.com/.
It's easy to use. To upload the contents of `a.rb` just:
```shell
-$ jist a.rb
+$ gist a.rb
https://gist.github.com/0d07bc98c139810a4075
```
Upload multiple files :
```shell
-$ jist a b c
-$ jist *.rb
+$ gist a b c
+$ gist *.rb
```
By default it reads from STDIN, and you can set a filename with `-f`.
```shell
-$ jist -f test.rb <a.rb
+$ gist -f test.rb <a.rb
https://gist.github.com/7db51bb5f4f35c480fc8
```
Alternatively, you can just paste from the clipboard:
```shell
-$ jist -P
+$ gist -P
https://gist.github.com/6a330a11a0db8e52a6ee
```
Use `-p` to make the gist public and `-d` to add a description.
```shell
-$ jist -p -d "Random rbx bug" a.rb
+$ gist -p -d "Random rbx bug" a.rb
https://gist.github.com/2977722
```
You can update existing gists with `-u`:
```shell
-$ jist lib/jist.rb bin/jist -u 42f2c239d2eb57299408
+$ gist lib/gist.rb bin/gist -u 42f2c239d2eb57299408
https://gist.github.com/42f2c239d2eb57299408
```
If you'd like to copy the resulting URL to your clipboard, use `-c`.
```shell
-$ jist -c <a.rb
+$ gist -c <a.rb
https://gist.github.com/7db51bb5f4f35c480fc8
```
If you'd like to copy the resulting embeddable URL to your clipboard, use `--copy-js`.
```shell
-$ jist --copy-js <a.rb
+$ gist --copy-js <a.rb
<script src="https://gist.github.com/7db51bb5f4f35c480fc8"></script>
```
-And you can just ask jist to open a browser window directly with `-o`.
+And you can just ask gist to open a browser window directly with `-o`.
```shell
-$ jist -o <a.rb
+$ gist -o <a.rb
https://gist.github.com/7db51bb5f4f35c480fc8
```
-See `jist --help` for more detail.
+See `gist --help` for more detail.
## Login
If you want to associate your gists with your github account, you need to login
-with jist. It doesn't store your username and password, it just uses them to get
+with gist. It doesn't store your username and password, it just uses them to get
an OAuth2 token (with the "gist" permission).
```shell
-jist --login
+gist --login
Obtaining OAuth2 access_token from github.
Github username: ConradIrwin
Github password:
Success! https://github.com/settings/applications
```
-This token is stored in `~/.jist` and used for all future gisting. If you need to
+This token is stored in `~/.gist` and used for all future gisting. If you need to
you can revoke it from https://github.com/settings/applications, or just delete the
file.
After you've done this, you can still upload gists anonymously with `-a`.
```shell
-jist -a a.rb
+gist -a a.rb
https://gist.github.com/6bf7ec379fc9119b1f15
```
# Library
-You can also use Jist as a library from inside your ruby code:
+You can also use Gist as a library from inside your ruby code:
```ruby
-Jist.gist("Look.at(:my => 'awesome').code")
+Gist.gist("Look.at(:my => 'awesome').code")
```
If you need more advanced features you can also pass:
-* `:access_token` to authenticate using OAuth2 (default is `File.read("~/.jist")).
+* `:access_token` to authenticate using OAuth2 (default is `File.read("~/.gist")).
* `:filename` to change the syntax highlighting (default is `a.rb`).
* `:public` if you want your gist to have a guessable url.
* `:description` to add a description to your gist.
@@ -132,43 +132,43 @@ NOTE: The access_token must have the "gist" scope.
If you want to upload multiple files in the same gist, you can:
```ruby
-Jist.multi_gist("a.rb" => "Foo.bar", "a.py" => "Foo.bar")
+Gist.multi_gist("a.rb" => "Foo.bar", "a.py" => "Foo.bar")
```
-If you'd rather use jist's builtin access_token, then you can force the user to
+If you'd rather use gist's builtin access_token, then you can force the user to
obtain one by calling:
```ruby
-Jist.login!
+Gist.login!
```
This will take them through the process of obtaining an OAuth2 token, and storing it
-in `~/.jist`, where it can later be read by `Jist.gist`
+in `~/.gist`, where it can later be read by `Gist.gist`
GitHub enterprise
==================
-If you'd like `jist` to use your locally installed [Github Enterprise](https://enterprise.github.com/),
+If you'd like `gist` to use your locally installed [Github Enterprise](https://enterprise.github.com/),
you need to export the `GITHUB_URL` environment variable in your `~/.bashrc`.
```bash
export GITHUB_URL=http://github.internal.example.com/
```
-Once you've done this and restarted your terminal (or run `source ~/.bashrc`), jist will
+Once you've done this and restarted your terminal (or run `source ~/.bashrc`), gist will
automatically use github enterprise instead of the public github.com
Configuration
=============
-If you'd like `-o` or `-c` to be the default when you use the jist executable, add an
+If you'd like `-o` or `-c` to be the default when you use the gist executable, add an
alias to your `~/.bashrc` (or equivalent). For example:
```ruby
-alias jist='jist -c'
+alias gist='gist -c'
```
-If you'd prefer jist to open a different browser, then you can export the BROWSER
+If you'd prefer gist to open a different browser, then you can export the BROWSER
environment variable:
```ruby
@@ -179,7 +179,7 @@ If clipboard or browser integration don't work on your platform, please file a b
(more ideally) a pull request.
If you need to use an HTTP proxy to access the internet, export the `HTTP_PROXY` or
-`http_proxy` environment variable and jist will use it.
+`http_proxy` environment variable and gist will use it.
Meta-fu
=======
View
2 Rakefile
@@ -6,5 +6,5 @@ task :test do
end
task :clipfailtest do
- sh 'PATH=/ /usr/bin/ruby -Ilib -S bin/jist -ac < lib/jist.rb'
+ sh 'PATH=/ /usr/bin/ruby -Ilib -S bin/gist -ac < lib/gist.rb'
end
View
34 bin/jist → bin/gist
@@ -1,7 +1,7 @@
#!/usr/bin/env ruby
require 'optparse'
-require File.expand_path('../../lib/jist', __FILE__)
+require File.expand_path('../../lib/gist', __FILE__)
# For the holdings of options.
options = {}
@@ -10,33 +10,33 @@ filenames = []
opts = OptionParser.new do |opts|
executable_name = File.split($0)[1]
opts.banner = <<-EOS
-Jist (v#{Jist::VERSION}) lets you upload to https://gist.github.com/
+Gist (v#{Gist::VERSION}) lets you upload to https://gist.github.com/
The content to be uploaded can be passed as a list of files, if none are
specified STDIN will be read. The default filename for STDIN is "a.rb", and all
filenames can be overridden by repeating the "-f" flag. The most useful reason
to do this is to change the syntax highlighting.
If you'd like your gists to be associated with your GitHub account, so that you
-can edit them and find them in future, first use `jist --login` to obtain an
-Oauth2 access token. This is stored and used by jist in the future.
+can edit them and find them in future, first use `gist --login` to obtain an
+Oauth2 access token. This is stored and used by gist in the future.
Public gists have guessable URLs and can be created with "-p", you can also set
the description at the top of the gist by passing "-d".
Anonymous gists are not associated with your GitHub account, they can be created
-with "-a" even after you have used "jist --login". If you already have an access
+with "-a" even after you have used "gist --login". If you already have an access
token with the "gist" scope, you can pass that with "-t".
If you would like to shorten the resulting gist URL, use the -s flag. This will
use GitHub's URL shortener, git.io.
To copy the resulting URL to your clipboard you can use the -c option, or to just
open it directly in your browser, use -o. Using the -e option will copy the embeddable
-URL to the clipboard. You can add `alias jist='jist -c'` to your shell's rc file to configure this
+URL to the clipboard. You can add `alias gist='gist -c'` to your shell's rc file to configure this
behaviour by default.
-Instead of creating a new jist, you can update an existing one by passing its ID
+Instead of creating a new gist, you can update an existing one by passing its ID
or URL with "-u". For this to work, you must be logged in, and have created the
original gist with the same GitHub account.
@@ -45,8 +45,8 @@ Usage: #{executable_name} [-o|-c|-e] [-p] [-s] [-d DESC] [-t TOKEN|-a] [-u URL]
EOS
- opts.on("--login", "Authenticate jist on this computer.") do
- Jist.login!
+ opts.on("--login", "Authenticate gist on this computer.") do
+ Gist.login!
exit
end
@@ -91,7 +91,7 @@ Usage: #{executable_name} [-o|-c|-e] [-p] [-s] [-d DESC] [-t TOKEN|-a] [-u URL]
options[:open] = true
end
- opts.on("-P", "--paste", "Paste from the clipboard to jist") do
+ opts.on("-P", "--paste", "Paste from the clipboard to gist") do
options[:paste] = true
end
@@ -101,7 +101,7 @@ Usage: #{executable_name} [-o|-c|-e] [-p] [-s] [-d DESC] [-t TOKEN|-a] [-u URL]
end
opts.on_tail("-v", "--version", "Print the version.") do
- puts "jist v#{Jist::VERSION}"
+ puts "gist v#{Gist::VERSION}"
exit
end
@@ -110,7 +110,7 @@ opts.parse!
begin
options[:output] = if options[:embed] && options[:shorten]
- raise Jist::Error, "--embed does not make sense with --shorten"
+ raise Gist::Error, "--embed does not make sense with --shorten"
elsif options[:embed]
:javascript
elsif options[:shorten]
@@ -120,23 +120,23 @@ begin
end
if options[:paste]
- puts Jist.gist(Jist.paste, options)
+ puts Gist.gist(Gist.paste, options)
elsif ARGV.size == 0
$stderr.puts "(type a gist. <ctrl-c> to cancel, <ctrl-d> when done)" if $stdin.tty?
- puts Jist.gist(ARGF.read, options)
+ puts Gist.gist(ARGF.read, options)
else
files = {}
ARGV.zip(filenames).each do |(file, name)|
files[name || file] = begin
File.read(File.expand_path(file))
rescue => e
- raise e.extend(Jist::Error)
+ raise e.extend(Gist::Error)
end
end
- puts Jist.multi_gist(files, options)
+ puts Gist.multi_gist(files, options)
end
-rescue Jist::Error => e
+rescue Gist::Error => e
puts "Error: #{e.message}"
exit 1
rescue Interrupt
View
12 jist.gemspec → gist.gemspec
@@ -1,17 +1,17 @@
-require './lib/jist'
+require './lib/gist'
Gem::Specification.new do |s|
- s.name = 'jist'
- s.version = Jist::VERSION
+ s.name = 'gist'
+ s.version = Gist::VERSION
s.summary = 'Just allows you to upload gists'
- s.description = 'Provides a single function (Jist.gist) that uploads a gist.'
- s.homepage = 'https://github.com/ConradIrwin/jist'
+ s.description = 'Provides a single function (Gist.gist) that uploads a gist.'
+ s.homepage = 'https://github.com/ConradIrwin/gist'
s.email = 'conrad.irwin@gmail.com'
s.authors = ['Conrad Irwin']
s.license = 'MIT'
s.files = `git ls-files`.split("\n")
s.require_paths = ["lib"]
- s.executables << 'jist'
+ s.executables << 'gist'
s.add_dependency 'json'
%w(rake rspec webmock).each do |gem|
View
32 lib/jist.rb → lib/gist.rb
@@ -4,7 +4,7 @@
require 'uri'
# It just gists.
-module Jist
+module Gist
extend self
VERSION = '1.5.1'
@@ -25,7 +25,7 @@ module Jist
URL_ENV_NAME = "GITHUB_URL"
- USER_AGENT = "jist/#{VERSION} (Net::HTTP, #{RUBY_DESCRIPTION})"
+ USER_AGENT = "gist/#{VERSION} (Net::HTTP, #{RUBY_DESCRIPTION})"
# Exception tag for errors raised while gisting.
module Error;
@@ -55,7 +55,7 @@ def gist(content, options = {})
# @option options [String] :description the description
# @option options [Boolean] :public (false) is this gist public
# @option options [Boolean] :anonymous (false) is this gist anonymous
- # @option options [String] :access_token (`File.read("~/.jist")`) The OAuth2 access token.
+ # @option options [String] :access_token (`File.read("~/.gist")`) The OAuth2 access token.
# @option options [String] :update the URL or id of a gist to update
# @option options [Boolean] :copy (false) Copy resulting URL to clipboard, if successful.
# @option options [Boolean] :open (false) Open the resulting URL in a browser.
@@ -66,7 +66,7 @@ def gist(content, options = {})
# :all gives a Hash containing the parsed json response from the server
#
# @return [String, Hash] the return value as configured by options[:output]
- # @raise [Jist::Error] if something went wrong
+ # @raise [Gist::Error] if something went wrong
#
# @see http://developer.github.com/v3/gists/
def multi_gist(files, options={})
@@ -131,12 +131,12 @@ def shorten(url)
end
end
- # Log the user into jist.
+ # Log the user into gist.
#
# This method asks the user for a username and password, and tries to obtain
- # and OAuth2 access token, which is then stored in ~/.jist
+ # and OAuth2 access token, which is then stored in ~/.gist
#
- # @raise [Jist::Error] if something went wrong
+ # @raise [Gist::Error] if something went wrong
# @see http://developer.github.com/v3/oauth/
def login!
puts "Obtaining OAuth2 access_token from github."
@@ -154,8 +154,8 @@ def login!
request = Net::HTTP::Post.new("#{base_path}/authorizations")
request.body = JSON.dump({
:scopes => [:gist],
- :note => "The jist gem",
- :note_url => "https://github.com/ConradIrwin/jist"
+ :note => "The gist gem",
+ :note_url => "https://github.com/ConradIrwin/gist"
})
request.content_type = 'application/json'
request.basic_auth(username, password)
@@ -229,16 +229,16 @@ def on_success(body, options={})
json
end
- Jist.copy(output.to_s) if options[:copy]
- Jist.open(json['html_url']) if options[:open]
+ Gist.copy(output.to_s) if options[:copy]
+ Gist.open(json['html_url']) if options[:open]
output
end
# Copy a string to the clipboard.
#
# @param [String] content
- # @raise [Jist::Error] if no clipboard integration could be found
+ # @raise [Gist::Error] if no clipboard integration could be found
#
def copy(content)
IO.popen(clipboard_command(:copy), 'r+') { |clip| clip.print content }
@@ -259,7 +259,7 @@ def copy(content)
# Get a string from the clipboard.
#
# @param [String] content
- # @raise [Jist::Error] if no clipboard integration could be found
+ # @raise [Gist::Error] if no clipboard integration could be found
def paste
`#{clipboard_command(:paste)}`
end
@@ -285,7 +285,7 @@ def which(cmd, path=ENV['PATH'])
#
# @param [Symbol] action either :copy or :paste
# @return [String] the command to run
- # @raise [Jist::ClipboardError] if no clipboard integration could be found
+ # @raise [Gist::ClipboardError] if no clipboard integration could be found
def clipboard_command(action)
command = CLIPBOARD_COMMANDS.keys.detect do |cmd|
which cmd
@@ -338,9 +338,9 @@ def api_url
def auth_token_file
if ENV.key?(URL_ENV_NAME)
- File.expand_path "~/.jist.#{ENV[URL_ENV_NAME].gsub(/[^a-z.]/, '')}"
+ File.expand_path "~/.gist.#{ENV[URL_ENV_NAME].gsub(/[^a-z.]/, '')}"
else
- File.expand_path "~/.jist"
+ File.expand_path "~/.gist"
end
end
end
View
16 spec/clipboard_spec.rb
@@ -9,26 +9,26 @@
end
def ask_for_copy
- Jist.on_success({'html_url' => @bobo_url}.to_json, :copy => true, :output => :html_url)
+ Gist.on_success({'html_url' => @bobo_url}.to_json, :copy => true, :output => :html_url)
end
- def jist_but_dont_ask_for_copy
- Jist.on_success({'html_url' => 'http://example.com/'}.to_json, :output => :html_url)
+ def gist_but_dont_ask_for_copy
+ Gist.on_success({'html_url' => 'http://example.com/'}.to_json, :output => :html_url)
end
it 'should try to copy the url when the clipboard option is passed' do
- Jist.should_receive(:copy).with(@bobo_url)
+ Gist.should_receive(:copy).with(@bobo_url)
ask_for_copy
end
it 'should try to copy the embed url when the clipboard-js option is passed' do
js_link = %Q{<script src="#{@bobo_url}.js"></script>}
- Jist.should_receive(:copy).with(js_link)
- Jist.on_success({'html_url' => @bobo_url}.to_json, :copy => true, :output => :javascript)
+ Gist.should_receive(:copy).with(js_link)
+ Gist.on_success({'html_url' => @bobo_url}.to_json, :copy => true, :output => :javascript)
end
it "should not copy when not asked to" do
- Jist.should_not_receive(:copy).with(@bobo_url)
- jist_but_dont_ask_for_copy
+ Gist.should_not_receive(:copy).with(@bobo_url)
+ gist_but_dont_ask_for_copy
end
it "should raise an error if no copying mechanisms are available" do
View
30 spec/ghe_spec.rb
@@ -11,7 +11,7 @@
MOCK_GITHUB_URL = "https://api.github.com/"
before do
- @saved_env = ENV[Jist::URL_ENV_NAME]
+ @saved_env = ENV[Gist::URL_ENV_NAME]
# stub requests for /gists
stub_request(:post, /#{MOCK_GHE_URL}gists/).to_return(:body => %[{"html_url": "http://#{MOCK_GHE_HOST}"}])
@@ -25,7 +25,7 @@
end
after do
- ENV[Jist::URL_ENV_NAME] = @saved_env
+ ENV[Gist::URL_ENV_NAME] = @saved_env
end
describe :login! do
@@ -35,44 +35,44 @@
# stdin emulation
$stdin = StringIO.new "#{MOCK_USER}\n#{MOCK_PASSWORD}\n"
- # intercept for updating ~/.jist
+ # intercept for updating ~/.gist
File.stub(:open)
end
after do
$stdin = @saved_stdin
end
- it "should access to api.github.com when $#{Jist::URL_ENV_NAME} wasn't set" do
- ENV.delete Jist::URL_ENV_NAME
+ it "should access to api.github.com when $#{Gist::URL_ENV_NAME} wasn't set" do
+ ENV.delete Gist::URL_ENV_NAME
- Jist.login!
+ Gist.login!
assert_requested(:post, /#{MOCK_AUTHZ_GITHUB_URL}authorizations/)
end
- it "should access to #{MOCK_GHE_HOST} when $#{Jist::URL_ENV_NAME} was set" do
- ENV[Jist::URL_ENV_NAME] = MOCK_GHE_URL
+ it "should access to #{MOCK_GHE_HOST} when $#{Gist::URL_ENV_NAME} was set" do
+ ENV[Gist::URL_ENV_NAME] = MOCK_GHE_URL
- Jist.login!
+ Gist.login!
assert_requested(:post, /#{MOCK_AUTHZ_GHE_URL}authorizations/)
end
end
describe :gist do
- it "should access to api.github.com when $#{Jist::URL_ENV_NAME} wasn't set" do
- ENV.delete Jist::URL_ENV_NAME
+ it "should access to api.github.com when $#{Gist::URL_ENV_NAME} wasn't set" do
+ ENV.delete Gist::URL_ENV_NAME
- Jist.gist "test gist"
+ Gist.gist "test gist"
assert_requested(:post, /#{MOCK_GITHUB_URL}gists/)
end
- it "should access to #{MOCK_GHE_HOST} when $#{Jist::URL_ENV_NAME} was set" do
- ENV[Jist::URL_ENV_NAME] = MOCK_GHE_URL
+ it "should access to #{MOCK_GHE_HOST} when $#{Gist::URL_ENV_NAME} was set" do
+ ENV[Gist::URL_ENV_NAME] = MOCK_GHE_URL
- Jist.gist "test gist"
+ Gist.gist "test gist"
assert_requested(:post, /#{MOCK_GHE_URL}gists/)
end
View
4 spec/proxy_spec.rb
@@ -11,11 +11,11 @@
it "should be Net::HTTP when $HTTP_PROXY wasn't set" do
ENV['HTTP_PROXY'] = ''
- Jist.http_connection(FOO_URL).should be_an_instance_of(Net::HTTP)
+ Gist.http_connection(FOO_URL).should be_an_instance_of(Net::HTTP)
end
it "should be Net::HTTP::Proxy when $HTTP_PROXY was set" do
ENV['HTTP_PROXY'] = 'http://proxy.example.com:8080'
- Jist.http_connection(FOO_URL).should_not be_an_instance_of(Net::HTTP)
+ Gist.http_connection(FOO_URL).should_not be_an_instance_of(Net::HTTP)
end
end
View
2 spec/shorten_spec.rb
@@ -5,7 +5,7 @@
end
it "should return a shortened version of the URL" do
- Jist.gist("Test gist", :output => :short_url).should == "http://git.io/XXXXXX"
+ Gist.gist("Test gist", :output => :short_url).should == "http://git.io/XXXXXX"
end
end
View
2 spec/spec_helper.rb
@@ -11,5 +11,5 @@
end
require 'webmock/rspec'
-require_relative '../lib/jist'
+require_relative '../lib/gist'

0 comments on commit ca024d2

Please sign in to comment.