jist 1.0.1 → 1.1.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.
- data/README.md +3 -0
- data/lib/jist.rb +21 -7
- data/spec/proxy_spec.rb +19 -0
- metadata +3 -2
data/README.md
CHANGED
@@ -153,6 +153,9 @@ export BROWSER=google-chrome
|
|
153
153
|
If clipboard or browser integration don't work on your platform, please file a bug or
|
154
154
|
(more ideally) a pull request.
|
155
155
|
|
156
|
+
If you need to use an HTTP proxy to access the internet, export the `HTTP_PROXY` or
|
157
|
+
`http_proxy` environment variable and jist will use it.
|
158
|
+
|
156
159
|
Meta-fu
|
157
160
|
=======
|
158
161
|
|
data/lib/jist.rb
CHANGED
@@ -6,7 +6,7 @@ require 'json'
|
|
6
6
|
module Jist
|
7
7
|
extend self
|
8
8
|
|
9
|
-
VERSION = '1.0
|
9
|
+
VERSION = '1.1.0'
|
10
10
|
|
11
11
|
# A list of clipboard commands with copy and paste support.
|
12
12
|
CLIPBOARD_COMMANDS = {
|
@@ -148,17 +148,31 @@ module Jist
|
|
148
148
|
raise e.extend Error
|
149
149
|
end
|
150
150
|
|
151
|
+
# Return HTTP connection
|
152
|
+
#
|
153
|
+
# @return [Net::HTTP]
|
154
|
+
def http_connection
|
155
|
+
env = ENV['http_proxy'] || ENV['HTTP_PROXY']
|
156
|
+
connection = if env
|
157
|
+
uri = URI(env)
|
158
|
+
proxy_host, proxy_port = uri.host, uri.port
|
159
|
+
Net::HTTP::Proxy(proxy_host, proxy_port).new("api.github.com", 443)
|
160
|
+
else
|
161
|
+
Net::HTTP.new("api.github.com", 443)
|
162
|
+
end
|
163
|
+
connection.use_ssl = true
|
164
|
+
connection.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
165
|
+
connection.open_timeout = 10
|
166
|
+
connection.read_timeout = 10
|
167
|
+
connection
|
168
|
+
end
|
169
|
+
|
151
170
|
# Run an HTTP operation against api.github.com
|
152
171
|
#
|
153
172
|
# @param [Net::HTTPRequest] request
|
154
173
|
# @return [Net::HTTPResponse]
|
155
174
|
def http(request)
|
156
|
-
|
157
|
-
connection.use_ssl = true
|
158
|
-
connection.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
159
|
-
connection.open_timeout = 10
|
160
|
-
connection.read_timeout = 10
|
161
|
-
connection.start do |http|
|
175
|
+
http_connection().start do |http|
|
162
176
|
http.request request
|
163
177
|
end
|
164
178
|
rescue Timeout::Error
|
data/spec/proxy_spec.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
describe '...' do
|
2
|
+
before do
|
3
|
+
@saved_env = ENV['HTTP_PROXY']
|
4
|
+
end
|
5
|
+
|
6
|
+
after do
|
7
|
+
ENV['HTTP_PROXY'] = @saved_env
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should be Net::HTTP when $HTTP_PROXY wasn't set" do
|
11
|
+
ENV['HTTP_PROXY'] = ''
|
12
|
+
Jist.http_connection().should be_an_instance_of(Net::HTTP)
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should be Net::HTTP::Proxy when $HTTP_PROXY was set" do
|
16
|
+
ENV['HTTP_PROXY'] = 'http://proxy.example.com:8080'
|
17
|
+
Jist.http_connection().should_not be_an_instance_of(Net::HTTP)
|
18
|
+
end
|
19
|
+
end
|
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: 1.0
|
4
|
+
version: 1.1.0
|
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-
|
12
|
+
date: 2012-10-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: json
|
@@ -76,6 +76,7 @@ files:
|
|
76
76
|
- jist.gemspec
|
77
77
|
- lib/jist.rb
|
78
78
|
- spec/clipboard_spec.rb
|
79
|
+
- spec/proxy_spec.rb
|
79
80
|
- spec/spec_helper.rb
|
80
81
|
homepage: https://github.com/ConradIrwin/jist
|
81
82
|
licenses:
|