goog 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/bin/goog +15 -4
  2. data/lib/goog.rb +1 -1
  3. metadata +1 -1
data/bin/goog CHANGED
@@ -93,7 +93,7 @@ query = "/search?q=#{CGI.escape query}"
93
93
  if options[:date_range]
94
94
  query += "&as_qdr=#{options[:date_range]}"
95
95
  end
96
- pages = []
96
+ links = []
97
97
  (1..(options[:pages] || 1)).each do |page|
98
98
  if query.nil?
99
99
  exit
@@ -108,6 +108,7 @@ pages = []
108
108
  if link !~ /^https?:/
109
109
  link = "http://google.com#{link}"
110
110
  end
111
+ links << link
111
112
  title = li.at('h3 a').inner_text
112
113
  description = li.at('div.s')
113
114
  excerpt = if description
@@ -129,15 +130,15 @@ pages = []
129
130
  else
130
131
  ["#{number}. #{title}", excerpt, link].compact
131
132
  end
132
- puts '-' * 80
133
133
  $stdout.puts res
134
134
  $stdout.puts
135
135
  if options[:expand]
136
136
  $stderr.puts "Fetching #{title}: #{link}"
137
137
  puts "#{title}: #{link}"
138
138
  puts `elinks -dump -no-numbering '#{link}'`
139
+ puts '-' * 80
140
+ puts
139
141
  end
140
- puts
141
142
  }
142
143
 
143
144
  # find next page link
@@ -154,7 +155,17 @@ end
154
155
 
155
156
  if options[:less]
156
157
  $stdout.close
157
- exec "less -R #{$tempfile.path}"
158
+ $stdout = STDOUT
159
+ loop {
160
+ puts File.read($tempfile.path)
161
+ print "Show result number: "
162
+ n = STDIN.gets
163
+ if n !~ /\d/
164
+ exit
165
+ end
166
+ n = n.to_i
167
+ system "elinks -dump -no-numbering '#{links[n - 1]}' | less"
168
+ }
158
169
  end
159
170
 
160
171
  if options[:elinks]
@@ -1,3 +1,3 @@
1
1
  module Goog
2
- VERSION = '0.2.1'
2
+ VERSION = '0.2.2'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: goog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: