search_cli 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/bin/search_cli +7 -0
- data/lib/display_module.rb +25 -0
- data/lib/search.rb +42 -0
- metadata +50 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: b5aa893ba0c71abb3c9ff569b8b1adbe3186862f1db50dc3746d5156fe261463
|
4
|
+
data.tar.gz: d600ee69265a6ca6c770b8c0d4aae20aa850420701ba449a41d5528b1180f7c8
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7600a075aaa9b98bcc4ae10a1e95175b125545c88b389564ee1b15a79470b922982a7f31659c4b3e2cbe8aae312e6d1a04f8c388f8f75bee35d1db9a332f3995
|
7
|
+
data.tar.gz: 15d15063dd9cef4a542a9f69c19afe610e4faccbbed965b58ef8c193c3a558e7040d4ed726bb83b2aae9259dd0e62ca9c991db74a8968799560d4c44363d78da
|
data/bin/search_cli
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
# diplay module for displaying messages in cli
|
3
|
+
module Display
|
4
|
+
def self.before_result
|
5
|
+
puts "Your results are.."
|
6
|
+
end
|
7
|
+
def self.after_result
|
8
|
+
puts "Thank you for using search_cli"
|
9
|
+
end
|
10
|
+
def self.help!
|
11
|
+
puts "help"
|
12
|
+
puts "search format: search-provider keyword/query"
|
13
|
+
puts "search-provider"
|
14
|
+
puts "bing -> bing search"
|
15
|
+
puts "gems -> rubygems search"
|
16
|
+
puts "so -> stackoverflow search"
|
17
|
+
end
|
18
|
+
def self.tags(tag)
|
19
|
+
puts '-----------------------------------------'
|
20
|
+
puts
|
21
|
+
puts tag.text.to_s
|
22
|
+
puts (tag[:href]).to_s
|
23
|
+
puts
|
24
|
+
end
|
25
|
+
end
|
data/lib/search.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rest-client'
|
4
|
+
require 'nokogiri'
|
5
|
+
require_relative './display_module'
|
6
|
+
|
7
|
+
class SearchProviders
|
8
|
+
def initialize(arg)
|
9
|
+
search = SearchProviders.method arg.first
|
10
|
+
keyword = arg[1..-1].join(' ')
|
11
|
+
search.call keyword
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.bing keyword
|
15
|
+
res = RestClient.get 'https://bing.com/search/', params: { q: keyword }
|
16
|
+
tags = Nokogiri::HTML.parse(res).xpath('//li[@class="b_algo"] //h2 //a')
|
17
|
+
tags.each do |tag|
|
18
|
+
Display.tags tag
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.gems keyword
|
23
|
+
res = RestClient.get "https://rubygems.org/search?utf8=%E2%9C%93&query=#{keyword}"
|
24
|
+
tags = Nokogiri::HTML.parse(res).xpath('//a[@class="gems__gem"]')
|
25
|
+
tags.each do |tag|
|
26
|
+
Display.tags tag
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.so keyword
|
31
|
+
Display.before_result
|
32
|
+
res = RestClient.get "https://stackoverflow.com/search?q=#{keyword}"
|
33
|
+
tags = Nokogiri::HTML.parse(res).xpath('//a[@class="question-hyperlink"]')
|
34
|
+
tags.each do |tag|
|
35
|
+
Display.tags tag
|
36
|
+
end
|
37
|
+
Display.after_result
|
38
|
+
end
|
39
|
+
def self.help(noarg=nil)
|
40
|
+
Display.help!
|
41
|
+
end
|
42
|
+
end
|
metadata
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: search_cli
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- imhta
|
8
|
+
- adbusaid10
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2019-07-28 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: ruby gem for search google, bing, rubygem , etc,. from cli
|
15
|
+
email:
|
16
|
+
- imhtapm@gmail.com
|
17
|
+
- abdusaid.ab@gmail.com
|
18
|
+
executables:
|
19
|
+
- search_cli
|
20
|
+
extensions: []
|
21
|
+
extra_rdoc_files: []
|
22
|
+
files:
|
23
|
+
- bin/search_cli
|
24
|
+
- lib/display_module.rb
|
25
|
+
- lib/search.rb
|
26
|
+
homepage: https://rubygems.org/gems/search_cli
|
27
|
+
licenses:
|
28
|
+
- MIT
|
29
|
+
metadata:
|
30
|
+
source_code_uri: https://github.com/imhta/search_cli
|
31
|
+
post_install_message:
|
32
|
+
rdoc_options: []
|
33
|
+
require_paths:
|
34
|
+
- lib
|
35
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
41
|
+
requirements:
|
42
|
+
- - ">="
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: '0'
|
45
|
+
requirements: []
|
46
|
+
rubygems_version: 3.0.3
|
47
|
+
signing_key:
|
48
|
+
specification_version: 4
|
49
|
+
summary: ruby gem for search google, bing, rubygem , etc,. from cli
|
50
|
+
test_files: []
|