search_cli 0.1.0 → 0.1.1

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/search.rb +10 -0
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9f84eef621874a60fdab1c07b981cdca25473718f4c05d5ce9be56acf81299aa
4
- data.tar.gz: 18c29c0811f5b6b521dd1ec781864ac33accbde322b4556d972d67d13d0f9ea3
3
+ metadata.gz: 31c9ecae7f1852cf651c90c46e4c7198ff35764aa54733e762bebfa84df2d6b0
4
+ data.tar.gz: 62cca8c62d0b32661174dae7da35bd62a5ce8501ac033387fcea328fa051605d
5
5
  SHA512:
6
- metadata.gz: 75f0eec01042b6472244f29abf5240fa5d15d17c4dffd02ebe50671ce780962a3cba9cbc613b63dc97fcb055fbe40908b7d8d7c3e0d730cb1f78b9102b42951b
7
- data.tar.gz: b8fdb03758f1ddd732ea2870f5066a78125c5a9551c2079aa0f06a43e57a498b11598feab8f8711b71a2eb4b6ae6463b31bffdcbbe90a6fdab7781e304da26a1
6
+ metadata.gz: 883c3ae8e79df0e3c51d2f792b6e518fd291b3f3257fa039fc85c08791804d393832861d5fc2884742957f7d874192027a647deee54bbdff96ef3d91b6675113
7
+ data.tar.gz: 5baee7c866618b5faf03e166990c995ea37f376a9ad795e30e6c1eaa885424732d0500d45b325477bf7291adf647371afabf5345e59fbf145eb6ed42c7657bf8
@@ -6,19 +6,26 @@ require_relative './display_module'
6
6
 
7
7
  class SearchProviders
8
8
  def self.bing(keyword)
9
+ Display.before_result
9
10
  res = RestClient.get 'https://bing.com/search/', params: { q: keyword }
10
11
  tags = Nokogiri::HTML.parse(res).xpath('//li[@class="b_algo"] //h2 //a')
11
12
  tags.each do |tag|
12
13
  Display.tags tag
13
14
  end
15
+ Display.after_result
14
16
  end
15
17
 
16
18
  def self.gems(keyword)
19
+ Display.before_result
17
20
  res = RestClient.get "https://rubygems.org/search?utf8=%E2%9C%93&query=#{keyword}"
18
21
  tags = Nokogiri::HTML.parse(res).xpath('//a[@class="gems__gem"]')
19
22
  tags.each do |tag|
23
+ if tag[:href].start_with?('/')
24
+ tag[:href] = 'https://rubygems.org' + tag[:href]
25
+ end
20
26
  Display.tags tag
21
27
  end
28
+ Display.after_result
22
29
  end
23
30
 
24
31
  def self.so(keyword)
@@ -26,6 +33,9 @@ class SearchProviders
26
33
  res = RestClient.get "https://stackoverflow.com/search?q=#{keyword}"
27
34
  tags = Nokogiri::HTML.parse(res).xpath('//a[@class="question-hyperlink"]')
28
35
  tags.each do |tag|
36
+ if tag[:href].start_with?('/')
37
+ tag[:href] = 'https://stackoverflow.com' + tag[:href]
38
+ end
29
39
  Display.tags tag
30
40
  end
31
41
  Display.after_result
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: search_cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - imhta