gist 4.4.2 → 4.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (7) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +0 -9
  3. data/bin/gist +15 -1
  4. data/build/gist +38 -2
  5. data/build/gist.1 +1 -17
  6. data/lib/gist.rb +23 -1
  7. metadata +3 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e12581fd7b9192039f572f5db1410b6bdab6f0db
4
- data.tar.gz: 8a4610f6c68462becff34e98313008156e45c5c7
3
+ metadata.gz: 687ff483f835c421449de703f4b33a8ec8341ed7
4
+ data.tar.gz: f5f46207b5e3cf3aa7d05253eb7f0f946e5429b3
5
5
  SHA512:
6
- metadata.gz: 17306b9e02e386fa63a545fa704298a1a6564736f4939752f68ca0c56176a16e17aa4817d57bc1a25098e86b05e979f03dae084c675f867a635d3667c43f4fab
7
- data.tar.gz: ebd268363f70e892bb7b4bca00df423cb95afe2e54cefd53682628a9a1d4be6c146efcbbacb53664067d40ee3b5ae234883547eca29ebb8b67c68d9ef033e366
6
+ metadata.gz: 903fd99ebdfc68873b338965fc03cc2f7bb1aa08acf22d6f16c8c12aeb736df1fec1d798419f1a734b2b26177869514f4c7125610419d66347f3e8338a1afdcc
7
+ data.tar.gz: 8261a612326028a57aad653ba0889f004c20d6183658f4068736fdfa6f30466cac978912fe96e443b20a1ca99b8e9aeb3e9693913234650934006a9c0e2012f5
data/README.md CHANGED
@@ -85,15 +85,6 @@ an OAuth2 token (with the "gist" permission).
85
85
  2-factor auth code:
86
86
  Success! https://github.com/settings/applications
87
87
 
88
- You can read the 2-factor auth code from an sms or the authentication app,
89
- depending on how you [set your account up](https://github.com/settings/admin).
90
-
91
- Note: 2-factor authentication
92
- [just appeared recently](https://github.com/blog/1614-two-factor-authentication),
93
- so if you run into errors, update the gist gem.
94
-
95
- gem update gist
96
-
97
88
  This token is stored in `~/.gist` and used for all future gisting. If you need to
98
89
  you can revoke it from https://github.com/settings/applications, or just delete the
99
90
  file. If you need to store tokens for both github.com and a Github Enterprise instance
data/bin/gist CHANGED
@@ -2,7 +2,10 @@
2
2
 
3
3
  # Silence Ctrl-C's
4
4
  trap('INT'){ exit 1 }
5
- trap('PIPE', 'EXIT')
5
+
6
+ if Signal.list.include? 'PIPE'
7
+ trap('PIPE', 'EXIT')
8
+ end
6
9
 
7
10
  require 'optparse'
8
11
  require 'gist'
@@ -46,6 +49,7 @@ original gist with the same GitHub account.
46
49
 
47
50
  Usage: #{executable_name} [-o|-c|-e] [-p] [-s] [-R] [-d DESC] [-a] [-u URL] [-P] [-f NAME|-t EXT]* FILE*
48
51
  #{executable_name} --login
52
+ #{executable_name} [-l|-r]
49
53
 
50
54
  EOS
51
55
 
@@ -115,6 +119,10 @@ Usage: #{executable_name} [-o|-c|-e] [-p] [-s] [-R] [-d DESC] [-a] [-u URL] [-P]
115
119
  options[:list] = user
116
120
  end
117
121
 
122
+ opts.on("-r", "--read ID [FILENAME]", "Read a gist and print out the contents") do |id|
123
+ options[:read] = id
124
+ end
125
+
118
126
  opts.on_tail("-h","--help", "Show this message.") do
119
127
  puts opts
120
128
  exit
@@ -153,6 +161,12 @@ begin
153
161
  exit
154
162
  end
155
163
 
164
+ if options.key? :read
165
+ file_name = ARGV.first
166
+ Gist.read_gist(options[:read], file_name)
167
+ exit
168
+ end
169
+
156
170
  if options[:paste]
157
171
  puts Gist.gist(Gist.paste, options)
158
172
  else
data/build/gist CHANGED
@@ -1318,7 +1318,7 @@ end
1318
1318
  module Gist
1319
1319
  extend self
1320
1320
 
1321
- VERSION = '4.4.2'
1321
+ VERSION = '4.5.0'
1322
1322
 
1323
1323
  # A list of clipboard commands with copy and paste support.
1324
1324
  CLIPBOARD_COMMANDS = {
@@ -1507,6 +1507,28 @@ module Gist
1507
1507
 
1508
1508
  end
1509
1509
 
1510
+ def read_gist(id, file_name=nil)
1511
+ url = "#{base_path}/gists/#{id}"
1512
+ request = Net::HTTP::Get.new(url)
1513
+ response = http(api_url, request)
1514
+
1515
+ if response.code == '200'
1516
+ body = JSON.parse(response.body)
1517
+ files = body["files"]
1518
+
1519
+ if file_name
1520
+ file = files[file_name]
1521
+ raise Error, "Gist with id of #{id} and file #{file_name} does not exist." unless file
1522
+ else
1523
+ file = files.values.first
1524
+ end
1525
+
1526
+ puts file["content"]
1527
+ else
1528
+ raise Error, "Gist with id of #{id} does not exist."
1529
+ end
1530
+ end
1531
+
1510
1532
  def get_gist_pages(url)
1511
1533
 
1512
1534
  request = Net::HTTP::Get.new(url)
@@ -1820,7 +1842,10 @@ end
1820
1842
 
1821
1843
  # Silence Ctrl-C's
1822
1844
  trap('INT'){ exit 1 }
1823
- trap('PIPE', 'EXIT')
1845
+
1846
+ if Signal.list.include? 'PIPE'
1847
+ trap('PIPE', 'EXIT')
1848
+ end
1824
1849
 
1825
1850
  require 'optparse'
1826
1851
 
@@ -1863,6 +1888,7 @@ original gist with the same GitHub account.
1863
1888
 
1864
1889
  Usage: #{executable_name} [-o|-c|-e] [-p] [-s] [-R] [-d DESC] [-a] [-u URL] [-P] [-f NAME|-t EXT]* FILE*
1865
1890
  #{executable_name} --login
1891
+ #{executable_name} [-l|-r]
1866
1892
 
1867
1893
  EOS
1868
1894
 
@@ -1932,6 +1958,10 @@ Usage: #{executable_name} [-o|-c|-e] [-p] [-s] [-R] [-d DESC] [-a] [-u URL] [-P]
1932
1958
  options[:list] = user
1933
1959
  end
1934
1960
 
1961
+ opts.on("-r", "--read ID [FILENAME]", "Read a gist and print out the contents") do |id|
1962
+ options[:read] = id
1963
+ end
1964
+
1935
1965
  opts.on_tail("-h","--help", "Show this message.") do
1936
1966
  puts opts
1937
1967
  exit
@@ -1970,6 +2000,12 @@ begin
1970
2000
  exit
1971
2001
  end
1972
2002
 
2003
+ if options.key? :read
2004
+ file_name = ARGV.first
2005
+ Gist.read_gist(options[:read], file_name)
2006
+ exit
2007
+ end
2008
+
1973
2009
  if options[:paste]
1974
2010
  puts Gist.gist(Gist.paste, options)
1975
2011
  else
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "GIST" "1" "July 2015" "" "Gist manual"
4
+ .TH "GIST" "1" "November 2015" "" "Gist manual"
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBgist\fR \- upload code to https://gist\.github\.com
@@ -123,22 +123,6 @@ Success! https://github\.com/settings/applications
123
123
  .IP "" 0
124
124
  .
125
125
  .P
126
- You can read the 2\-factor auth code from an sms or the authentication app, depending on how you set your account up \fIhttps://github\.com/settings/admin\fR\.
127
- .
128
- .P
129
- Note: 2\-factor authentication just appeared recently \fIhttps://github\.com/blog/1614\-two\-factor\-authentication\fR, so if you run into errors, update the gist gem\.
130
- .
131
- .IP "" 4
132
- .
133
- .nf
134
-
135
- gem update gist
136
- .
137
- .fi
138
- .
139
- .IP "" 0
140
- .
141
- .P
142
126
  This token is stored in \fB~/\.gist\fR 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\. If you need to store tokens for both github\.com and a Github Enterprise instance you can save your Github Enterprise token in \fB~/\.gist\.github\.example\.com\fR where "github\.example\.com" is the URL for your Github Enterprise instance\.
143
127
  .
144
128
  .IP "\(bu" 4
@@ -12,7 +12,7 @@ end
12
12
  module Gist
13
13
  extend self
14
14
 
15
- VERSION = '4.4.2'
15
+ VERSION = '4.5.0'
16
16
 
17
17
  # A list of clipboard commands with copy and paste support.
18
18
  CLIPBOARD_COMMANDS = {
@@ -201,6 +201,28 @@ module Gist
201
201
 
202
202
  end
203
203
 
204
+ def read_gist(id, file_name=nil)
205
+ url = "#{base_path}/gists/#{id}"
206
+ request = Net::HTTP::Get.new(url)
207
+ response = http(api_url, request)
208
+
209
+ if response.code == '200'
210
+ body = JSON.parse(response.body)
211
+ files = body["files"]
212
+
213
+ if file_name
214
+ file = files[file_name]
215
+ raise Error, "Gist with id of #{id} and file #{file_name} does not exist." unless file
216
+ else
217
+ file = files.values.first
218
+ end
219
+
220
+ puts file["content"]
221
+ else
222
+ raise Error, "Gist with id of #{id} does not exist."
223
+ end
224
+ end
225
+
204
226
  def get_gist_pages(url)
205
227
 
206
228
  request = Net::HTTP::Get.new(url)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gist
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.4.2
4
+ version: 4.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Conrad Irwin
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-07-21 00:00:00.000000000 Z
12
+ date: 2015-11-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -121,3 +121,4 @@ signing_key:
121
121
  specification_version: 4
122
122
  summary: Just allows you to upload gists
123
123
  test_files: []
124
+ has_rdoc: