gem-search 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -12,9 +12,9 @@ module Gem::Search
12
12
 
13
13
  opt_sort ||= 'name'
14
14
  url = "#{SEARCH_URL}#{query}"
15
-
16
- begin
17
- open(url) do |f|
15
+
16
+ begin
17
+ open_uri(url) do |f|
18
18
  gems = JSON.parse(f.read)
19
19
  if gems.size.zero?
20
20
  puts 'We did not find results.'
@@ -25,12 +25,24 @@ module Gem::Search
25
25
  render_header(fmt_size)
26
26
  render_body(gems, fmt_size)
27
27
  end
28
- rescue
28
+ rescue => e
29
29
  puts 'An unexpected Network error has occurred.'
30
+ puts e
30
31
  end
31
32
  end
32
33
 
33
34
  private
35
+ def open_uri(url, &block)
36
+ option = {}
37
+ proxy = URI.parse(url).find_proxy
38
+ if proxy
39
+ if proxy.user && proxy.password
40
+ option[:proxy_http_basic_authentication] = [proxy, proxy.usesr, proxy.password]
41
+ end
42
+ end
43
+ open(url, option, &block)
44
+ end
45
+
34
46
  def ruled_line_size(gems)
35
47
  line_size = DEFAULT_RULED_LINE_SIZE.dup
36
48
  max_name_size = gems.map { |gem| "#{gem['name']} (#{gem['version']})".size }.max
@@ -1,3 +1,3 @@
1
1
  module Gem::Search
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
@@ -14,7 +14,7 @@ describe Gem::Search::CLI do
14
14
  to_return(:status => 500, :body => '[]')
15
15
  end
16
16
  it 'should display a network error message' do
17
- capture(:stdout) { @cli.search('network_error_orccurred') }.should == "An unexpected Network error has occurred.\n"
17
+ capture(:stdout) { @cli.search('network_error_orccurred') }.should match(/An unexpected Network error has occurred.\n/)
18
18
  end
19
19
  end
20
20
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gem-search
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
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: 2013-02-03 00:00:00.000000000 Z
12
+ date: 2013-04-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: slop