gisty 0.0.23 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -0
- data/lib/commands/post.rb +2 -1
- data/lib/commands/private_post.rb +2 -1
- data/lib/gisty.rb +24 -10
- metadata +19 -5
data/Rakefile
CHANGED
data/lib/commands/post.rb
CHANGED
@@ -8,8 +8,9 @@ cmd :post, 'file1 file2 ...', 'post new gist' do |fs|
|
|
8
8
|
puts "Error: #{e}"
|
9
9
|
else
|
10
10
|
id = url.split('/').last
|
11
|
+
html_url = "https://gist.github.com/#{id}"
|
12
|
+
system "open #{html_url}" if /darwin/ === RUBY_PLATFORM
|
11
13
|
@g.clone id
|
12
|
-
system "open #{url}" if /darwin/ === RUBY_PLATFORM
|
13
14
|
end
|
14
15
|
end
|
15
16
|
end
|
@@ -5,8 +5,9 @@ cmd :private_post, 'file1 file2 ...', 'post new private gist' do |fs|
|
|
5
5
|
rescue Exception => e
|
6
6
|
puts "Error: #{e}"
|
7
7
|
else
|
8
|
-
system "open #{url}" if /darwin/ === RUBY_PLATFORM
|
9
8
|
id = url.split('/').last
|
9
|
+
html_url = "https://gist.github.com/#{id}"
|
10
|
+
system "open #{html_url}" if /darwin/ === RUBY_PLATFORM
|
10
11
|
@g.clone id
|
11
12
|
end
|
12
13
|
end
|
data/lib/gisty.rb
CHANGED
@@ -1,13 +1,15 @@
|
|
1
1
|
require 'pathname'
|
2
2
|
require 'net/http'
|
3
|
+
require 'net/https'
|
3
4
|
require 'open-uri'
|
4
5
|
require 'fileutils'
|
5
6
|
require 'rubygems'
|
6
7
|
require 'nokogiri'
|
7
|
-
require '
|
8
|
+
require 'json'
|
9
|
+
require 'highline/import'
|
8
10
|
|
9
11
|
class Gisty
|
10
|
-
VERSION = '0.
|
12
|
+
VERSION = '0.1.1'
|
11
13
|
GIST_URL = 'https://gist.github.com/'
|
12
14
|
GISTY_URL = 'http://github.com/swdyh/gisty/tree/master'
|
13
15
|
COMMAND_PATH = Pathname.new(File.join(File.dirname(__FILE__), 'commands')).realpath.to_s
|
@@ -157,10 +159,22 @@ class Gisty
|
|
157
159
|
user.empty? ? {} : { 'login' => user, 'token' => token }
|
158
160
|
end
|
159
161
|
|
162
|
+
def get_password
|
163
|
+
pw = `git config --global github.password`.strip
|
164
|
+
if pw.size == 0
|
165
|
+
ask("Enter your password: ") { |q| q.echo = false }.strip
|
166
|
+
else
|
167
|
+
pw
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
160
171
|
def post params
|
161
|
-
url = URI.parse('https://
|
172
|
+
url = URI.parse('https://api.github.com/gists')
|
162
173
|
req = Net::HTTP::Post.new url.path
|
163
|
-
|
174
|
+
|
175
|
+
req.basic_auth @auth['login'], get_password
|
176
|
+
req.body = params.to_json
|
177
|
+
|
164
178
|
https = Net::HTTP.new(url.host, url.port)
|
165
179
|
https.use_ssl = true
|
166
180
|
https.verify_mode = @ssl_verify
|
@@ -182,10 +196,9 @@ class Gisty
|
|
182
196
|
raise InvalidFileException if list.any?{ |i| !i.file? }
|
183
197
|
|
184
198
|
params = {}
|
199
|
+
params['files'] = {}
|
185
200
|
list.each_with_index do |i, index|
|
186
|
-
params[
|
187
|
-
params["file_name[gistfile#{index + 1}]"] = i.basename.to_s
|
188
|
-
params["file_contents[gistfile#{index + 1}]"] = IO.read(i)
|
201
|
+
params['files'][i.basename.to_s] = { 'content' => IO.read(i) }
|
189
202
|
end
|
190
203
|
params
|
191
204
|
end
|
@@ -193,10 +206,11 @@ class Gisty
|
|
193
206
|
def create paths, opt = { :private => false }
|
194
207
|
params = build_params paths
|
195
208
|
if opt[:private]
|
196
|
-
params['
|
197
|
-
|
209
|
+
params['public'] = false
|
210
|
+
else
|
211
|
+
params['public'] = true
|
198
212
|
end
|
199
|
-
post params
|
213
|
+
post params
|
200
214
|
end
|
201
215
|
|
202
216
|
def read_by_url url
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gisty
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 1
|
9
|
+
- 1
|
10
|
+
version: 0.1.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- swdyh
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-
|
18
|
+
date: 2012-03-19 00:00:00 +09:00
|
19
19
|
default_executable: gisty
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -34,6 +34,20 @@ dependencies:
|
|
34
34
|
version: 1.0.0
|
35
35
|
type: :runtime
|
36
36
|
version_requirements: *id001
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: highline
|
39
|
+
prerelease: false
|
40
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
hash: 3
|
46
|
+
segments:
|
47
|
+
- 0
|
48
|
+
version: "0"
|
49
|
+
type: :runtime
|
50
|
+
version_requirements: *id002
|
37
51
|
description: yet another command line client for gist
|
38
52
|
email: http://mailhide.recaptcha.net/d?k=01AhB7crgrlHptVaYRD0oPwA==&c=L_iqOZrGmo6hcGpPTFg1QYnjr-WpAStyQ4Y8ShfgOHs=
|
39
53
|
executables:
|