Skip to content

Commit caac50b

Browse files
committed
integrate feedback from #4
1 parent 210335c commit caac50b

File tree

3 files changed

+61
-33
lines changed

3 files changed

+61
-33
lines changed

README.md

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -126,20 +126,23 @@ require 'serpapi'
126126

127127
company_list = %w[meta amazon apple netflix google]
128128
client = SerpApi::Client.new(engine: 'google', async: true, persistent: true, api_key: ENV.fetch('SERPAPI_KEY', nil))
129-
search_queue = Queue.new
129+
schedule_search = Queue.new
130+
result = nil
130131
company_list.each do |company|
131132
result = client.search({ q: company })
132133
puts "#{company}: search results found in cache for: #{company}" if result[:search_metadata][:status] =~ /Cached/
133134

134-
search_queue.push(result[:search_metadata][:id])
135+
schedule_search.push(result[:search_metadata][:id])
135136
end
136137

137-
puts 'wait for all requests to be completed'
138+
puts "Last search submited at: #{result[:search_metadata][:created_at]}"
139+
140+
puts 'wait 10s for all requests to be completed '
138141
sleep(10)
139142

140143
puts 'wait until all searches are cached or success'
141-
until search_queue.empty?
142-
search_id = search_queue.pop
144+
until schedule_search.empty?
145+
search_id = schedule_search.pop
143146

144147
search_archived = client.search_archive(search_id)
145148

@@ -150,10 +153,10 @@ until search_queue.empty?
150153
next
151154
end
152155

153-
search_queue.push(result)
156+
schedule_search.push(result)
154157
end
155158

156-
search_queue.close
159+
schedule_search.close
157160
puts 'done'
158161
```
159162

@@ -1023,12 +1026,13 @@ The class SerpApi::Client (client side / ruby):
10231026
Et voila!
10241027

10251028
## Continuous integration
1026-
We love "true open source" and "continuous integration", and Test Drive Development (TDD).
1027-
We are using RSpec to test [our infrastructure around the clock]) using Github Action to achieve the best QoS (Quality Of Service).
1029+
We love [continuous integration](https://en.wikipedia.org/wiki/Continuous_integration) (CI) and [Test-Driven Development](https://en.wikipedia.org/wiki/Test-driven_development) (TDD) at SerpApi.
1030+
We use RSpec and Github Actions to test our infrastructure around the clock, and that includes all changes to our clients.
10281031

10291032
The directory spec/ includes specification which serves the dual purposes of examples and functional tests.
10301033

1031-
Set your secret API key in your shell before running a test.
1034+
Set your secret API key in your shell before running a test.
1035+
The SerpApi key can be obtained from [serpapi.com/signup](https://serpapi.com/users/sign_up?plan=free).
10321036
```bash
10331037
export SERPAPI_KEY="your_secret_key"
10341038
```
@@ -1044,19 +1048,29 @@ Check code quality using Lint.
10441048
$ rake lint
10451049
```
10461050

1047-
Run regression.
1051+
Run basic test
10481052
```bash
10491053
$ rake test
10501054
```
10511055

1052-
To flush the flow.
1053-
```bash
1054-
$ rake
1056+
Review coverage report generated by `rake test`
1057+
```sh
1058+
open coverage/index.html
10551059
```
10561060

1057-
Open coverage report generated by `rake test`
1061+
Review documentation generated by `rake doc`
10581062
```sh
1059-
open coverage/index.html
1063+
open doc/index.html
1064+
```
1065+
1066+
Run full regression test suite on the examples.
1067+
```bash
1068+
rake regression
1069+
```
1070+
1071+
Test the actuall packaged gem locally using the demo scripts.
1072+
```bash
1073+
$ rake oobt
10601074
```
10611075

10621076
Open ./Rakefile for more information.

README.md.erb

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -538,12 +538,13 @@ The class SerpApi::Client (client side / ruby):
538538
Et voila!
539539

540540
## Continuous integration
541-
We love "true open source" and "continuous integration", and Test Drive Development (TDD).
542-
We are using RSpec to test [our infrastructure around the clock]) using Github Action to achieve the best QoS (Quality Of Service).
541+
We love [continuous integration](https://en.wikipedia.org/wiki/Continuous_integration) (CI) and [Test-Driven Development](https://en.wikipedia.org/wiki/Test-driven_development) (TDD) at SerpApi.
542+
We use RSpec and Github Actions to test our infrastructure around the clock, and that includes all changes to our clients.
543543

544544
The directory spec/ includes specification which serves the dual purposes of examples and functional tests.
545545

546-
Set your secret API key in your shell before running a test.
546+
Set your secret API key in your shell before running a test.
547+
The SerpApi key can be obtained from [serpapi.com/signup](https://serpapi.com/users/sign_up?plan=free).
547548
```bash
548549
export SERPAPI_KEY="your_secret_key"
549550
```
@@ -559,19 +560,29 @@ Check code quality using Lint.
559560
$ rake lint
560561
```
561562

562-
Run regression.
563+
Run basic test
563564
```bash
564565
$ rake test
565566
```
566567

567-
To flush the flow.
568-
```bash
569-
$ rake
568+
Review coverage report generated by `rake test`
569+
```sh
570+
open coverage/index.html
570571
```
571572

572-
Open coverage report generated by `rake test`
573+
Review documentation generated by `rake doc`
573574
```sh
574-
open coverage/index.html
575+
open doc/index.html
576+
```
577+
578+
Run full regression test suite on the examples.
579+
```bash
580+
rake regression
581+
```
582+
583+
Test the actuall packaged gem locally using the demo scripts.
584+
```bash
585+
$ rake oobt
575586
```
576587

577588
Open ./Rakefile for more information.

demo/demo_async.rb

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,25 +33,28 @@
3333
# target MAANG companies
3434
company_list = %w[meta amazon apple netflix google]
3535
client = SerpApi::Client.new(engine: 'google', async: true, persistent: true, api_key: ENV.fetch('SERPAPI_KEY', nil))
36-
search_queue = Queue.new
36+
schedule_search = Queue.new
37+
result = nil
3738
company_list.each do |company|
38-
# store request into a search_queue - no-blocker
39+
# store request into a schedule_search - no-blocker
3940
result = client.search({ q: company })
4041
puts "#{company}: search results found in cache for: #{company}" if result[:search_metadata][:status] =~ /Cached/
4142

4243
# add results to the client queue
43-
search_queue.push(result[:search_metadata][:id])
44+
schedule_search.push(result[:search_metadata][:id])
4445
end
4546

47+
puts "Last search submited at: #{result[:search_metadata][:created_at]}"
48+
4649
# wait for all requests to be completed
47-
puts 'wait for all requests to be completed'
50+
puts 'wait 10s for all requests to be completed '
4851
# wait for 10 seconds to allow all requests to be processed
4952
sleep(10)
5053

5154
puts 'wait until all searches are cached or success'
52-
until search_queue.empty?
55+
until schedule_search.empty?
5356
# extract client id
54-
search_id = search_queue.pop
57+
search_id = schedule_search.pop
5558

5659
# retrieve client from the archive - blocker
5760
search_archived = client.search_archive(search_id)
@@ -67,9 +70,9 @@
6770

6871
# add results back to the client queue
6972
# if the search is still in progress
70-
search_queue.push(result)
73+
schedule_search.push(result)
7174
end
7275

7376
# destroy the queue
74-
search_queue.close
77+
schedule_search.close
7578
puts 'done'

0 commit comments

Comments
 (0)