Skip to content

Commit 8f0d515

Browse files
committed
code formatting to fix lint
1 parent 25af142 commit 8f0d515

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

demo/demo.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@
55
# Ensure that the `SERPAPI_KEY` environment variable is set before running this script.
66

77
raise 'SERPAPI_KEY environment variable must be set' if ENV['SERPAPI_KEY'].nil?
8+
89
require 'pp'
910
require 'serpapi'
1011

1112
default_params = {
1213
engine: 'google',
13-
api_key: ENV['SERPAPI_KEY']
14+
api_key: ENV.fetch('SERPAPI_KEY', nil)
1415
}
1516
client = SerpApi::Client.new(default_params)
1617
params = {

demo/demo_suggest.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
# This script demonstrates how to use the SerpApi Ruby client to fetch Google Autocomplete suggestions.
32
# It requires the `serpapi` gem and an environment variable `SERPAPI_KEY` containing your SerpApi API key.
43
#
@@ -23,7 +22,7 @@
2322
client: 'safari',
2423
hl: 'en',
2524
gl: 'us',
26-
api_key: ENV['SERPAPI_KEY'],
25+
api_key: ENV.fetch('SERPAPI_KEY', nil),
2726
persistent: false,
2827
timeout: 2
2928
}

demo/demo_thread_pool.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,13 @@
6161
runtime = Benchmark.measure do
6262
# create a thread pool of 4 threads with a persistent connection to serpapi.com
6363
pool = ConnectionPool.new(size: n, timeout: 5) do
64-
SerpApi::Client.new(engine: 'google', api_key: ENV['SERPAPI_KEY'], timeout: 30, persistent: true)
64+
SerpApi::Client.new(engine: 'google', api_key: ENV.fetch('SERPAPI_KEY', nil), timeout: 30, persistent: true)
6565
end
6666

6767
# run user thread to search for your favorites coffee type
6868
threads = %w[latte espresso cappuccino americano mocha macchiato frappuccino cold_brew].map do |query|
6969
Thread.new do
70-
pool.with do|socket|
70+
pool.with do |socket|
7171
results = socket.search({ q: query })
7272
puts "first result title: #{results[:organic_results].first[:title]} for query: #{results[:search_parameters][:q]}"
7373
end

0 commit comments

Comments
 (0)