gist 4.0.3 → 4.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +2 -2
  3. data/lib/gist.rb +16 -4
  4. data/spec/ghe_spec.rb +11 -0
  5. metadata +17 -30
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c2a2602f4c36da451b2c5a2178c0212892ee1803
4
+ data.tar.gz: 30bd2defacb65e653da924b422c64caa90acb274
5
+ SHA512:
6
+ metadata.gz: f2560a91c5d57ab0c9a5c1153fd22f906ca02ab3212705db4c5936d8c9c18e9bc9f3cbed0d46f11232b1befa7d4e4c0d549f5996dece869de8ac175e86dd7b7b
7
+ data.tar.gz: ab29ddbc115d300ffa75ac55104c7bf2ef1225a75fbefbde9ea03bd673ef715d1f1d22be91106aaea8ff62943d4031c7977ca64e8fa52e03bbc150d6a3c8ca2d
data/README.md CHANGED
@@ -52,9 +52,9 @@ upload content to https://gist.github.com/.
52
52
 
53
53
  gist -c <a.rb
54
54
 
55
- ‌If you'd like to copy the resulting embeddable URL to your clipboard, use `--copy-js`.
55
+ ‌If you'd like to copy the resulting embeddable URL to your clipboard, use `-e`.
56
56
 
57
- gist --copy-js <a.rb
57
+ gist -e <a.rb
58
58
 
59
59
  ‌And you can just ask gist to open a browser window directly with `-o`.
60
60
 
@@ -7,7 +7,7 @@ require 'uri'
7
7
  module Gist
8
8
  extend self
9
9
 
10
- VERSION = '4.0.3'
10
+ VERSION = '4.1.0'
11
11
 
12
12
  # A list of clipboard commands with copy and paste support.
13
13
  CLIPBOARD_COMMANDS = {
@@ -137,13 +137,16 @@ module Gist
137
137
  # and OAuth2 access token, which is then stored in ~/.gist
138
138
  #
139
139
  # @raise [Gist::Error] if something went wrong
140
+ # @param [Hash] credentials login details
141
+ # @option credentials [String] :username
142
+ # @option credentials [String] :password
140
143
  # @see http://developer.github.com/v3/oauth/
141
- def login!
144
+ def login!(credentials={})
142
145
  puts "Obtaining OAuth2 access_token from github."
143
146
  print "GitHub username: "
144
- username = $stdin.gets.strip
147
+ username = credentials[:username] || $stdin.gets.strip
145
148
  print "GitHub password: "
146
- password = begin
149
+ password = credentials[:password] || begin
147
150
  `stty -echo` rescue nil
148
151
  $stdin.gets.strip
149
152
  ensure
@@ -162,6 +165,15 @@ module Gist
162
165
 
163
166
  response = http(api_url, request)
164
167
 
168
+ if Net::HTTPUnauthorized === response && response['X-GitHub-OTP']
169
+ print "2-factor auth code: "
170
+ twofa_code = $stdin.gets.strip
171
+ puts ""
172
+
173
+ request['X-GitHub-OTP'] = twofa_code
174
+ response = http(api_url, request)
175
+ end
176
+
165
177
  if Net::HTTPCreated === response
166
178
  File.open(auth_token_file, 'w') do |f|
167
179
  f.write JSON.parse(response.body)['token']
@@ -58,6 +58,17 @@ describe '...' do
58
58
 
59
59
  assert_requested(:post, /#{MOCK_AUTHZ_GHE_URL}authorizations/)
60
60
  end
61
+
62
+ context "when credentials are passed in" do
63
+
64
+ it "uses them" do
65
+ $stdin = StringIO.new "#{MOCK_USER}_wrong\n#{MOCK_PASSWORD}_wrong\n"
66
+ Gist.login! username: MOCK_USER, password: MOCK_PASSWORD
67
+
68
+ assert_requested(:post, /#{MOCK_AUTHZ_GITHUB_URL}authorizations/)
69
+ end
70
+
71
+ end
61
72
  end
62
73
 
63
74
  describe :gist do
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gist
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.3
5
- prerelease:
4
+ version: 4.1.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Conrad Irwin
@@ -10,86 +9,76 @@ authors:
10
9
  autorequire:
11
10
  bindir: bin
12
11
  cert_chain: []
13
- date: 2013-05-15 00:00:00.000000000 Z
12
+ date: 2013-09-07 00:00:00.000000000 Z
14
13
  dependencies:
15
14
  - !ruby/object:Gem::Dependency
16
15
  name: json
17
16
  requirement: !ruby/object:Gem::Requirement
18
- none: false
19
17
  requirements:
20
- - - ! '>='
18
+ - - '>='
21
19
  - !ruby/object:Gem::Version
22
20
  version: '0'
23
21
  type: :runtime
24
22
  prerelease: false
25
23
  version_requirements: !ruby/object:Gem::Requirement
26
- none: false
27
24
  requirements:
28
- - - ! '>='
25
+ - - '>='
29
26
  - !ruby/object:Gem::Version
30
27
  version: '0'
31
28
  - !ruby/object:Gem::Dependency
32
29
  name: rake
33
30
  requirement: !ruby/object:Gem::Requirement
34
- none: false
35
31
  requirements:
36
- - - ! '>='
32
+ - - '>='
37
33
  - !ruby/object:Gem::Version
38
34
  version: '0'
39
35
  type: :development
40
36
  prerelease: false
41
37
  version_requirements: !ruby/object:Gem::Requirement
42
- none: false
43
38
  requirements:
44
- - - ! '>='
39
+ - - '>='
45
40
  - !ruby/object:Gem::Version
46
41
  version: '0'
47
42
  - !ruby/object:Gem::Dependency
48
43
  name: rspec
49
44
  requirement: !ruby/object:Gem::Requirement
50
- none: false
51
45
  requirements:
52
- - - ! '>='
46
+ - - '>='
53
47
  - !ruby/object:Gem::Version
54
48
  version: '0'
55
49
  type: :development
56
50
  prerelease: false
57
51
  version_requirements: !ruby/object:Gem::Requirement
58
- none: false
59
52
  requirements:
60
- - - ! '>='
53
+ - - '>='
61
54
  - !ruby/object:Gem::Version
62
55
  version: '0'
63
56
  - !ruby/object:Gem::Dependency
64
57
  name: webmock
65
58
  requirement: !ruby/object:Gem::Requirement
66
- none: false
67
59
  requirements:
68
- - - ! '>='
60
+ - - '>='
69
61
  - !ruby/object:Gem::Version
70
62
  version: '0'
71
63
  type: :development
72
64
  prerelease: false
73
65
  version_requirements: !ruby/object:Gem::Requirement
74
- none: false
75
66
  requirements:
76
- - - ! '>='
67
+ - - '>='
77
68
  - !ruby/object:Gem::Version
78
69
  version: '0'
79
70
  - !ruby/object:Gem::Dependency
80
71
  name: ronn
81
72
  requirement: !ruby/object:Gem::Requirement
82
- none: false
83
73
  requirements:
84
- - - ! '>='
74
+ - - '>='
85
75
  - !ruby/object:Gem::Version
86
76
  version: '0'
87
77
  type: :development
88
78
  prerelease: false
89
79
  version_requirements: !ruby/object:Gem::Requirement
90
- none: false
91
80
  requirements:
92
- - - ! '>='
81
+ - - '>='
93
82
  - !ruby/object:Gem::Version
94
83
  version: '0'
95
84
  description: Provides a single function (Gist.gist) that uploads a gist.
@@ -122,27 +111,25 @@ files:
122
111
  homepage: https://github.com/defunkt/gist
123
112
  licenses:
124
113
  - MIT
114
+ metadata: {}
125
115
  post_install_message:
126
116
  rdoc_options: []
127
117
  require_paths:
128
118
  - lib
129
119
  required_ruby_version: !ruby/object:Gem::Requirement
130
- none: false
131
120
  requirements:
132
- - - ! '>='
121
+ - - '>='
133
122
  - !ruby/object:Gem::Version
134
123
  version: '0'
135
124
  required_rubygems_version: !ruby/object:Gem::Requirement
136
- none: false
137
125
  requirements:
138
- - - ! '>='
126
+ - - '>='
139
127
  - !ruby/object:Gem::Version
140
128
  version: '0'
141
129
  requirements: []
142
130
  rubyforge_project:
143
- rubygems_version: 1.8.23
131
+ rubygems_version: 2.0.3
144
132
  signing_key:
145
- specification_version: 3
133
+ specification_version: 4
146
134
  summary: Just allows you to upload gists
147
135
  test_files: []
148
- has_rdoc: