jist 0.9.0 → 0.9.1
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/jist +21 -18
- data/lib/jist.rb +17 -12
- metadata +4 -5
data/bin/jist
CHANGED
@@ -13,29 +13,28 @@ opts = OptionParser.new do |opts|
|
|
13
13
|
opts.banner = <<-EOS
|
14
14
|
Jist (v#{Jist::VERSION}) lets you upload to https://gist.github.com/
|
15
15
|
|
16
|
-
Usage: #{executable_name} [-p] [-d DESC] [-t TOKEN] [-u URL] [-f NAME]* [FILE]*
|
16
|
+
Usage: #{executable_name} [-p] [-d DESC] [-t TOKEN|-a] [-u URL] [-f NAME]* [FILE]*
|
17
17
|
#{executable_name} --login
|
18
18
|
|
19
|
-
|
20
|
-
|
21
|
-
|
19
|
+
The content to be uploaded can be passed as a list of files, if none are
|
20
|
+
specified STDIN will be read. The default filename for STDIN is "a.rb", and all
|
21
|
+
filenames can be overridden by repeating the "-f" flag. The most useful reason
|
22
|
+
to do this is to change the syntax highlighting.
|
22
23
|
|
23
|
-
If you'd like your gists to be associated with your
|
24
|
-
|
25
|
-
|
24
|
+
If you'd like your gists to be associated with your GitHub account, so that you
|
25
|
+
can edit them and find them in future, first use `jist --login` to obtain an
|
26
|
+
Oauth2 access token. This is stored and used by jist in the future.
|
26
27
|
|
27
|
-
|
28
|
-
|
28
|
+
Public gists have guessable URLs and can be created with "-p", you can also set
|
29
|
+
the description at the top of the gist by passing "-d".
|
29
30
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
files, then the -f parameter will be used to name the contents of STDIN. If you
|
34
|
-
don't specify the -f parameter at all when using STDIN, "a.rb" will be used.
|
31
|
+
Anonymous gists are not associated with your GitHub account, they can be created
|
32
|
+
with "-a" even after you have used "jist --login". If you already have an access
|
33
|
+
token with the "gist" scope, you can pass that with "-t".
|
35
34
|
|
36
|
-
|
37
|
-
|
38
|
-
gist.
|
35
|
+
Instead of creating a new jist, you can update an existing one by passing its ID
|
36
|
+
or URL with "-u". For this to work, you must be logged in, and have created the
|
37
|
+
original gist with the same GitHub account.
|
39
38
|
|
40
39
|
EOS
|
41
40
|
|
@@ -89,7 +88,11 @@ begin
|
|
89
88
|
else
|
90
89
|
files = {}
|
91
90
|
ARGV.zip(filenames).each do |(file, name)|
|
92
|
-
files[name || file] =
|
91
|
+
files[name || file] = begin
|
92
|
+
File.read(File.expand_path(file))
|
93
|
+
rescue => e
|
94
|
+
raise e.extend(Jist::Error)
|
95
|
+
end
|
93
96
|
end
|
94
97
|
|
95
98
|
puts Jist.multi_gist(files, options)['html_url']
|
data/lib/jist.rb
CHANGED
@@ -5,7 +5,7 @@ require 'json'
|
|
5
5
|
# It just gists.
|
6
6
|
module Jist
|
7
7
|
|
8
|
-
VERSION = '0.9.
|
8
|
+
VERSION = '0.9.1'
|
9
9
|
|
10
10
|
# Exception tag for errors raised while gisting.
|
11
11
|
module Error; end
|
@@ -73,13 +73,21 @@ module Jist
|
|
73
73
|
request = Net::HTTP::Post.new(url)
|
74
74
|
request.body = JSON.dump(json)
|
75
75
|
|
76
|
-
|
76
|
+
retried = false
|
77
77
|
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
78
|
+
begin
|
79
|
+
response = http(request)
|
80
|
+
if Net::HTTPSuccess === response
|
81
|
+
JSON.parse(response.body)
|
82
|
+
else
|
83
|
+
raise "Got #{response.class} from gist: #{response.body}"
|
84
|
+
end
|
85
|
+
rescue => e
|
86
|
+
raise if retried
|
87
|
+
retried = true
|
88
|
+
retry
|
82
89
|
end
|
90
|
+
|
83
91
|
rescue => e
|
84
92
|
raise e.extend Error
|
85
93
|
end
|
@@ -126,18 +134,15 @@ module Jist
|
|
126
134
|
raise e.extend Error
|
127
135
|
end
|
128
136
|
|
129
|
-
private
|
130
|
-
|
131
|
-
module_function
|
132
137
|
# Run an HTTP operation against api.github.com
|
133
138
|
#
|
134
|
-
# @param [Net::
|
135
|
-
# @return [Net::
|
139
|
+
# @param [Net::HTTPRequest] request
|
140
|
+
# @return [Net::HTTPResponse]
|
136
141
|
def http(request)
|
137
142
|
connection = Net::HTTP.new("api.github.com", 443)
|
138
143
|
connection.use_ssl = true
|
139
144
|
connection.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
140
|
-
connection.open_timeout =
|
145
|
+
connection.open_timeout = 10
|
141
146
|
connection.read_timeout = 10
|
142
147
|
connection.start do |http|
|
143
148
|
http.request request
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jist
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-07-
|
12
|
+
date: 2012-07-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: json
|
@@ -35,8 +35,7 @@ extensions: []
|
|
35
35
|
extra_rdoc_files: []
|
36
36
|
files:
|
37
37
|
- lib/jist.rb
|
38
|
-
-
|
39
|
-
YmluL2ppc3Q=
|
38
|
+
- bin/jist
|
40
39
|
homepage: https://github.com/ConradIrwin/jist
|
41
40
|
licenses: []
|
42
41
|
post_install_message:
|
@@ -57,7 +56,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
57
56
|
version: '0'
|
58
57
|
requirements: []
|
59
58
|
rubyforge_project:
|
60
|
-
rubygems_version: 1.8.
|
59
|
+
rubygems_version: 1.8.24
|
61
60
|
signing_key:
|
62
61
|
specification_version: 3
|
63
62
|
summary: Just allows you to upload gists
|