swdyh-gisty 0.0.3 → 0.0.4
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.
- data/README.rdoc +9 -1
- data/lib/gisty.rb +2 -1
- data/test/gisty_test.rb +4 -9
- metadata +1 -1
data/README.rdoc
CHANGED
@@ -20,10 +20,18 @@ example .zshrc
|
|
20
20
|
|
21
21
|
export GISTY_DIR="$HOME/dev/gists"
|
22
22
|
|
23
|
-
|
23
|
+
set global git config. see "Global Git Config" at https://github.com/account
|
24
|
+
|
25
|
+
git config --global github.user your_id
|
26
|
+
git config --global github.token your_token
|
27
|
+
|
28
|
+
if you use zsh command completion, download this file to $fpath directory.
|
29
|
+
http://github.com/swdyh/gisty/raw/master/_gisty
|
30
|
+
|
24
31
|
|
25
32
|
== Features/Problems
|
26
33
|
|
34
|
+
use API token with HTTP. at your own risk.
|
27
35
|
|
28
36
|
== Synopsis
|
29
37
|
|
data/lib/gisty.rb
CHANGED
@@ -5,7 +5,7 @@ require 'rubygems'
|
|
5
5
|
require 'nokogiri'
|
6
6
|
|
7
7
|
class Gisty
|
8
|
-
VERSION = '0.0.
|
8
|
+
VERSION = '0.0.4'
|
9
9
|
GIST_URL = 'http://gist.github.com/'
|
10
10
|
|
11
11
|
def self.extract_ids url
|
@@ -25,6 +25,7 @@ class Gisty
|
|
25
25
|
|
26
26
|
def initialize path, login = nil, token = nil
|
27
27
|
@auth = (login && token) ? { :login => login, :token => token } : auth
|
28
|
+
raise 'auth error' if @auth[:login].nil? || @auth[:token].nil?
|
28
29
|
@auth_query = "login=#{@auth[:login]}&token=#{@auth[:token]}"
|
29
30
|
@dir = Pathname.pwd.realpath.join path
|
30
31
|
FileUtils.mkdir_p @dir unless @dir.exist?
|
data/test/gisty_test.rb
CHANGED
@@ -118,9 +118,8 @@ class GistyTest < Test::Unit::TestCase
|
|
118
118
|
end
|
119
119
|
|
120
120
|
def test_build_params
|
121
|
-
g = Gisty.new @gisty_dir
|
122
121
|
path = File.join('test', 'fixtures', 'foo.user.js')
|
123
|
-
params =
|
122
|
+
params = @gisty.build_params path
|
124
123
|
|
125
124
|
assert_equal '.js', params['file_ext[gistfile1]']
|
126
125
|
assert_equal 'foo.user.js', params['file_name[gistfile1]']
|
@@ -128,10 +127,9 @@ class GistyTest < Test::Unit::TestCase
|
|
128
127
|
end
|
129
128
|
|
130
129
|
def test_build_params_multi
|
131
|
-
g = Gisty.new @gisty_dir
|
132
130
|
path1 = File.join('test', 'fixtures', 'foo.user.js')
|
133
131
|
path2 = File.join('test', 'fixtures', 'bar.user.js')
|
134
|
-
params =
|
132
|
+
params = @gisty.build_params [path1, path2]
|
135
133
|
|
136
134
|
assert_equal '.js', params['file_ext[gistfile1]']
|
137
135
|
assert_equal 'foo.user.js', params['file_name[gistfile1]']
|
@@ -143,17 +141,14 @@ class GistyTest < Test::Unit::TestCase
|
|
143
141
|
|
144
142
|
def test_create
|
145
143
|
stub_post_form!
|
146
|
-
g = Gisty.new @gisty_dir
|
147
144
|
path = File.join('test', 'fixtures', 'foo.user.js')
|
148
|
-
|
145
|
+
@gisty.create path
|
149
146
|
end
|
150
147
|
|
151
148
|
def test_create_multi
|
152
|
-
stub_post_form!
|
153
|
-
g = Gisty.new @gisty_dir
|
154
149
|
path1 = File.join('test', 'fixtures', 'foo.user.js')
|
155
150
|
path2 = File.join('test', 'fixtures', 'bar.user.js')
|
156
|
-
|
151
|
+
@gisty.create [path1, path2]
|
157
152
|
end
|
158
153
|
end
|
159
154
|
|