what_is_this 0.1.0 → 1.0.0
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.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/bin/what_is_this +0 -1
- data/config/environment.rb +5 -0
- data/lib/what_is_this/Advanced_Search.rb +37 -38
- data/lib/what_is_this/Approx_Scraper.rb +30 -23
- data/lib/what_is_this/CLI.rb +89 -0
- data/lib/what_is_this/Install.rb +8 -4
- data/lib/what_is_this/Scraper_Tools.rb +95 -0
- data/lib/what_is_this/version.rb +1 -1
- data/lib/what_is_this.rb +3 -83
- data/what_is_this.gemspec +4 -4
- metadata +12 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 29cd24ea75288081beea53193b57bc165fa2a892bafb90587b7d3bbe0b1425c2
|
|
4
|
+
data.tar.gz: a57d2dd84df593b79813bb8559246813d1611b84e3e86b9f9d837d45115bbb6d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f008c6c14f4cdc300d31155dbb6a034458a41bef044a779deb1fec426f314863907d3ec58bbb9c9b212e692ee444e8e261939e21a1bcb420c573463725fbdc84
|
|
7
|
+
data.tar.gz: b150566f6a2605f797679e183bd5fc4d09fac2cb7557ce9d51919b3088dac3a6f27dd9727e351cfbfd529184f8a9d03105cf4ff4dc342a266fe2b025af04a466
|
data/Gemfile.lock
CHANGED
data/bin/what_is_this
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
class CLI::AdvancedSearch
|
|
2
|
-
attr_accessor :name, :markup, :downloads
|
|
2
|
+
attr_accessor :name, :markup, :downloads, :id
|
|
3
3
|
@@spacing = "\n\n\n"
|
|
4
4
|
@@message_spacing = " "
|
|
5
5
|
@@current_query = ""
|
|
@@ -7,18 +7,20 @@ class CLI::AdvancedSearch
|
|
|
7
7
|
|
|
8
8
|
@@all = []
|
|
9
9
|
|
|
10
|
-
def initialize(name = nil, markup = nil, downloads = nil )
|
|
10
|
+
def initialize(name = nil, markup = nil, downloads = nil, id = nil )
|
|
11
11
|
@name = name
|
|
12
12
|
@markup = markup
|
|
13
13
|
@downloads = downloads
|
|
14
|
+
@id = id
|
|
14
15
|
@@all << self
|
|
15
16
|
end
|
|
16
17
|
def self.new_from_query
|
|
17
|
-
Approx_Scraper.approx_names(@doc).each_with_index do |each, index|
|
|
18
|
+
CLI::Approx_Scraper.approx_names(@doc).each_with_index do |each, index|
|
|
18
19
|
self.new(
|
|
19
|
-
Approx_Scraper.approx_names(@doc)[index],
|
|
20
|
-
Approx_Scraper.approx_markups(@doc)[index],
|
|
21
|
-
Approx_Scraper.approx_downloads(@doc)[index]
|
|
20
|
+
CLI::Approx_Scraper.approx_names(@doc)[index],
|
|
21
|
+
CLI::Approx_Scraper.approx_markups(@doc)[index],
|
|
22
|
+
CLI::Approx_Scraper.approx_downloads(@doc)[index],
|
|
23
|
+
index + 1
|
|
22
24
|
)
|
|
23
25
|
end
|
|
24
26
|
display_data
|
|
@@ -57,6 +59,7 @@ class CLI::AdvancedSearch
|
|
|
57
59
|
|
|
58
60
|
def self.advanced_search_scrape(query, page = 1)
|
|
59
61
|
url = "https://rubygems.org/search?page=#{page}&query=#{query}"
|
|
62
|
+
puts url
|
|
60
63
|
@doc = Nokogiri::HTML(open(url))
|
|
61
64
|
self.new_from_query
|
|
62
65
|
|
|
@@ -77,6 +80,23 @@ class CLI::AdvancedSearch
|
|
|
77
80
|
self.advanced_search_properties
|
|
78
81
|
end
|
|
79
82
|
end
|
|
83
|
+
def self.post_search_query
|
|
84
|
+
search_results_found = CLI::Scraper_Tools.page(@doc)
|
|
85
|
+
max_pages = (search_results_found / 30).ceil
|
|
86
|
+
|
|
87
|
+
puts "Displaying page #{@@page} out of #{max_pages}"
|
|
88
|
+
temp_page = @@page
|
|
89
|
+
@@page = CLI::Scraper_Tools.navigate(@@page, max_pages, @@all)
|
|
90
|
+
|
|
91
|
+
if (temp_page != @@page)
|
|
92
|
+
self.clear_all_instances
|
|
93
|
+
end
|
|
94
|
+
self.advanced_search_scrape(@@current_query, @@page)
|
|
95
|
+
|
|
96
|
+
end
|
|
97
|
+
def self.clear_all_instances
|
|
98
|
+
@@all = []
|
|
99
|
+
end
|
|
80
100
|
def self.display_data
|
|
81
101
|
puts "======================================================="
|
|
82
102
|
begin
|
|
@@ -85,6 +105,8 @@ class CLI::AdvancedSearch
|
|
|
85
105
|
@@all.each do |each|
|
|
86
106
|
puts "---------------------------------"
|
|
87
107
|
puts ''
|
|
108
|
+
puts "##{each.id}"
|
|
109
|
+
puts ''
|
|
88
110
|
puts "About: #{each.name}"
|
|
89
111
|
puts ''
|
|
90
112
|
puts "Markup: #{each.markup}"
|
|
@@ -93,46 +115,23 @@ class CLI::AdvancedSearch
|
|
|
93
115
|
puts ''
|
|
94
116
|
puts "---------------------------------"
|
|
95
117
|
end
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
end
|
|
103
|
-
self.restart
|
|
118
|
+
|
|
119
|
+
if (CLI::Scraper_Tools.check_pagination(@doc) != "")
|
|
120
|
+
self.post_search_query
|
|
121
|
+
|
|
122
|
+
end
|
|
123
|
+
CLI.restart
|
|
104
124
|
else
|
|
105
125
|
puts "0 search results found"
|
|
106
126
|
self.restart
|
|
107
127
|
end
|
|
108
128
|
rescue => error
|
|
109
129
|
puts error.message
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
end
|
|
114
|
-
def self.navigate(page)
|
|
115
|
-
puts @@spacing + @@message_spacing + "To navigate type 'forward'(f) or 'back'(b), or 'home' to go back"
|
|
116
|
-
input = gets.chomp.to_str.downcase
|
|
117
|
-
case input
|
|
118
|
-
when "forward", "f"
|
|
119
|
-
self.forward(page)
|
|
120
|
-
when "back", "b"
|
|
121
|
-
self.back(page)
|
|
122
|
-
when "home"
|
|
123
|
-
CLI.restart
|
|
124
|
-
else
|
|
125
|
-
puts "Unrecognised command, try again"
|
|
126
|
-
self.navigate
|
|
130
|
+
CLI::Scraper_Tools.retry
|
|
131
|
+
self.restart
|
|
127
132
|
end
|
|
128
|
-
|
|
129
|
-
end
|
|
130
|
-
def self.forward(page)
|
|
131
|
-
page += 1
|
|
132
133
|
|
|
133
134
|
end
|
|
134
|
-
|
|
135
|
-
page -=1 unless page < 1
|
|
136
|
-
end
|
|
135
|
+
|
|
137
136
|
|
|
138
137
|
end
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
class CLI::Approx_Scraper
|
|
2
|
-
attr_accessor :name, :markup, :downloads
|
|
2
|
+
attr_accessor :name, :markup, :downloads, :id
|
|
3
3
|
@@page = 1
|
|
4
4
|
@@current_query = ""
|
|
5
5
|
|
|
@@ -11,20 +11,25 @@ class CLI::Approx_Scraper
|
|
|
11
11
|
@doc = Nokogiri::HTML(open(url))
|
|
12
12
|
self.new_from_query
|
|
13
13
|
end
|
|
14
|
-
def initialize(name=nil, markup=nil, downloads=nil)
|
|
14
|
+
def initialize(name=nil, markup=nil, downloads=nil, id=nil)
|
|
15
15
|
@name = name
|
|
16
16
|
@markup = markup
|
|
17
17
|
@downloads = downloads
|
|
18
|
+
@id = id
|
|
18
19
|
@@all << self
|
|
19
20
|
end
|
|
20
21
|
def self.new_from_query
|
|
22
|
+
|
|
21
23
|
approx_names(@doc).each_with_index do |each, index|
|
|
22
24
|
self.new(
|
|
23
25
|
approx_names(@doc)[index],
|
|
24
26
|
approx_markups(@doc)[index],
|
|
25
|
-
approx_downloads(@doc)[index]
|
|
27
|
+
approx_downloads(@doc)[index],
|
|
28
|
+
index + 1
|
|
29
|
+
|
|
26
30
|
)
|
|
27
31
|
end
|
|
32
|
+
|
|
28
33
|
display_approx
|
|
29
34
|
end
|
|
30
35
|
def self.approx_names(doc)
|
|
@@ -42,22 +47,26 @@ class CLI::Approx_Scraper
|
|
|
42
47
|
|
|
43
48
|
|
|
44
49
|
end
|
|
45
|
-
def self.
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
doc.css(".pagination").text
|
|
50
|
+
def self.post_search_query
|
|
51
|
+
search_results_found = CLI::Scraper_Tools.page(@doc)
|
|
52
|
+
max_pages = (search_results_found / 30).ceil
|
|
53
|
+
|
|
54
|
+
puts "Displaying page #{@@page} out of #{max_pages}"
|
|
55
|
+
temp_page = @@page
|
|
56
|
+
@@page = CLI::Scraper_Tools.navigate(@@page, max_pages, @@all)
|
|
53
57
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
58
|
+
if (temp_page != @@page)
|
|
59
|
+
self.clear_all_instances
|
|
60
|
+
end
|
|
61
|
+
self.get_approximate_data(@@current_query, @@page)
|
|
62
|
+
|
|
57
63
|
end
|
|
58
64
|
def self.approx_downloads(doc)
|
|
59
65
|
doc.css('.gems__gem__downloads__count').text.gsub(/[[:space:]]/, ' ').gsub(/Downloads/, '').split()
|
|
60
66
|
end
|
|
67
|
+
def self.clear_all_instances
|
|
68
|
+
@@all = []
|
|
69
|
+
end
|
|
61
70
|
def self.display_approx
|
|
62
71
|
puts "======================================================="
|
|
63
72
|
begin
|
|
@@ -65,6 +74,8 @@ class CLI::Approx_Scraper
|
|
|
65
74
|
@@all.each do |each|
|
|
66
75
|
puts "---------------------------------"
|
|
67
76
|
puts ''
|
|
77
|
+
puts "##{each.id}"
|
|
78
|
+
puts ''
|
|
68
79
|
puts "About: #{each.name}"
|
|
69
80
|
puts ''
|
|
70
81
|
puts "Markup: #{each.markup}"
|
|
@@ -73,22 +84,18 @@ class CLI::Approx_Scraper
|
|
|
73
84
|
puts ''
|
|
74
85
|
puts "---------------------------------"
|
|
75
86
|
end
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
puts self.page(@doc)
|
|
79
|
-
if (self.check_pagination(@doc) != "")
|
|
80
|
-
@@page = AdvancedSearch.navigate(@@page)
|
|
81
|
-
self.get_approximate_data(@@current_query, @@page)
|
|
87
|
+
if (CLI::Scraper_Tools.check_pagination(@doc) != "")
|
|
88
|
+
self.post_search_query
|
|
82
89
|
|
|
83
90
|
end
|
|
84
|
-
|
|
91
|
+
CLI.restart
|
|
85
92
|
else
|
|
86
93
|
puts "0 search results found"
|
|
87
|
-
|
|
94
|
+
CLI::Advanced_Search.restart
|
|
88
95
|
end
|
|
89
96
|
rescue => error
|
|
90
97
|
puts error.message
|
|
91
|
-
|
|
98
|
+
CLI::Scraper_Tools.retry
|
|
92
99
|
end
|
|
93
100
|
end
|
|
94
101
|
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
require_relative '../../config/environment.rb'
|
|
2
|
+
|
|
3
|
+
class CLI
|
|
4
|
+
@@spacing = "\n\n\n"
|
|
5
|
+
@@message_spacing = " "
|
|
6
|
+
def self.introduction
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
introduction_message = '
|
|
10
|
+
$$\ $$\ $$\ $$\ $$\ $$\
|
|
11
|
+
$$ | $$ | \__| $$ | $$ | \__|
|
|
12
|
+
$$\ $$\ $$\ $$$$$$$\ $$$$$$\ $$$$$$\ $$\ $$$$$$$\ $$$$$$\ $$$$$$$\ $$\ $$$$$$$\
|
|
13
|
+
$$ | $$ | $$ |$$ __$$\ \____$$\ \_$$ _| $$$$$$\ $$ |$$ _____|$$$$$$\ \_$$ _| $$ __$$\ $$ |$$ _____|
|
|
14
|
+
$$ | $$ | $$ |$$ | $$ | $$$$$$$ | $$ | \______|$$ |\$$$$$$\ \______| $$ | $$ | $$ |$$ |\$$$$$$\
|
|
15
|
+
$$ | $$ | $$ |$$ | $$ |$$ __$$ | $$ |$$\ $$ | \____$$\ $$ |$$\ $$ | $$ |$$ | \____$$\
|
|
16
|
+
\$$$$$\$$$$ |$$ | $$ |\$$$$$$$ | \$$$$ | $$ |$$$$$$$ | \$$$$ |$$ | $$ |$$ |$$$$$$$ |
|
|
17
|
+
\_____\____/ \__| \__| \_______| \____/ \__|\_______/ \____/ \__| \__|\__|\_______/ '
|
|
18
|
+
|
|
19
|
+
introduction_message.each_char {|c| putc c ; sleep 0.0015}
|
|
20
|
+
puts @@spacing + @@message_spacing + "Welcome to what-is-this! To begin please type either dependencies, install, search or quit:"
|
|
21
|
+
start
|
|
22
|
+
end
|
|
23
|
+
def self.start
|
|
24
|
+
input = CGI.escape(gets.chomp.downcase.strip)
|
|
25
|
+
puts @@spacing
|
|
26
|
+
case input
|
|
27
|
+
when 'search'
|
|
28
|
+
puts @@spacing + @@message_spacing + 'Would you like your search to be approximate(approx), advanced, exact or back to return?'
|
|
29
|
+
|
|
30
|
+
input = CGI.escape(gets.chomp.downcase.strip)
|
|
31
|
+
case input
|
|
32
|
+
when 'back'
|
|
33
|
+
self.restart
|
|
34
|
+
when 'approximate', 'approx'
|
|
35
|
+
approximate_search
|
|
36
|
+
when 'exact'
|
|
37
|
+
search
|
|
38
|
+
when 'advanced'
|
|
39
|
+
AdvancedSearch.advanced_search_properties
|
|
40
|
+
else
|
|
41
|
+
puts @@spacing + @@message_spacing + 'Command not recognised. Try again:'
|
|
42
|
+
restart
|
|
43
|
+
end
|
|
44
|
+
when 'install'
|
|
45
|
+
install
|
|
46
|
+
when 'dependencies'
|
|
47
|
+
Dependencies.display_dependencies
|
|
48
|
+
when 'quit'
|
|
49
|
+
quit
|
|
50
|
+
else
|
|
51
|
+
puts @@spacing + @@message_spacing + 'Command not recognised, try again!'
|
|
52
|
+
start
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
def self.approximate_search
|
|
56
|
+
puts @@spacing + @@message_spacing + "Please input your search term:"
|
|
57
|
+
query = CGI.escape(gets.chomp.downcase.strip)
|
|
58
|
+
Approx_Scraper.get_approximate_data(query)
|
|
59
|
+
restart
|
|
60
|
+
end
|
|
61
|
+
def self.search
|
|
62
|
+
puts @@spacing + @@message_spacing + "Enter gem you would like to know about"
|
|
63
|
+
query = CGI.escape(gets.chomp.downcase.strip)
|
|
64
|
+
Scraper.getData(query)
|
|
65
|
+
restart
|
|
66
|
+
end
|
|
67
|
+
def self.install
|
|
68
|
+
puts @@spacing + @@message_spacing + "Enter the gem that you would like to install and save as a dependency or back to return"
|
|
69
|
+
input = CGI.escape(gets.chomp)
|
|
70
|
+
case input
|
|
71
|
+
when 'back'
|
|
72
|
+
restart
|
|
73
|
+
else
|
|
74
|
+
Install.install(input)
|
|
75
|
+
end
|
|
76
|
+
restart
|
|
77
|
+
end
|
|
78
|
+
def self.quit
|
|
79
|
+
puts @@message_spacing + "Thanks for using 'what-is-this'... seeya!" + @@spacing
|
|
80
|
+
exit 1
|
|
81
|
+
end
|
|
82
|
+
def self.restart
|
|
83
|
+
puts @@spacing + @@message_spacing + 'To continue, type either dependencies, install, search, or quit:'
|
|
84
|
+
start
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
end
|
data/lib/what_is_this/Install.rb
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
|
-
require_relative '../config/environment.rb'
|
|
2
1
|
class CLI::Install
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
@@spacing = "\n\n\n"
|
|
3
|
+
@@message_spacing = " "
|
|
4
|
+
|
|
5
|
+
def self.install
|
|
5
6
|
puts @@spacing + @@message_spacing + "Enter the gem that you would like to install and save as a dependency"
|
|
6
7
|
input = CGI.escape(gets.chomp)
|
|
8
|
+
self.run_sys_command(input)
|
|
9
|
+
end
|
|
10
|
+
def self.run_sys_command(input)
|
|
7
11
|
system("bundle add #{input}")
|
|
8
12
|
puts @@spacing + @@message_spacing + "Gem installed!"
|
|
13
|
+
|
|
9
14
|
end
|
|
10
15
|
|
|
11
|
-
|
|
12
16
|
end
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
class CLI::Scraper_Tools
|
|
2
|
+
@@spacing = "\n\n\n"
|
|
3
|
+
@@message_spacing = " "
|
|
4
|
+
|
|
5
|
+
def self.page(doc)
|
|
6
|
+
returned_gems = doc.css('.gems__meter').text.split()
|
|
7
|
+
returned_gems[4].to_i
|
|
8
|
+
|
|
9
|
+
end
|
|
10
|
+
def self.check_pagination(doc)
|
|
11
|
+
|
|
12
|
+
doc.css(".pagination").text
|
|
13
|
+
|
|
14
|
+
end
|
|
15
|
+
def self.retry
|
|
16
|
+
puts "Unable to complete request, please try again: "
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def self.navigate(page, max_pages, all)
|
|
20
|
+
puts @@spacing + @@message_spacing + "For commands type: --help"
|
|
21
|
+
help_message = @@spacing + @@message_spacing + "
|
|
22
|
+
- forward, f => Go to next page \n
|
|
23
|
+
- back, b => Go to previous page \n
|
|
24
|
+
- first => Return to first page \n
|
|
25
|
+
- last => Go to last page \n
|
|
26
|
+
- page [number] => Jump to a certain page \n
|
|
27
|
+
- install [number] => Install a certain gem as a dependency \n
|
|
28
|
+
- inspect [number] => See full description of gem \n
|
|
29
|
+
- home => Returns to start screen \n
|
|
30
|
+
"
|
|
31
|
+
input = gets.chomp.to_str.downcase
|
|
32
|
+
|
|
33
|
+
case input
|
|
34
|
+
when "--help"
|
|
35
|
+
puts help_message
|
|
36
|
+
self.navigate(page, max_pages, all)
|
|
37
|
+
when "forward", "f"
|
|
38
|
+
page = self.forward(page, max_pages)
|
|
39
|
+
when "back", "b"
|
|
40
|
+
page = self.back(page)
|
|
41
|
+
when "home"
|
|
42
|
+
CLI::Approx_Scraper.clear_all_instances
|
|
43
|
+
CLI::AdvancedSearch.clear_all_instances
|
|
44
|
+
CLI.restart
|
|
45
|
+
|
|
46
|
+
when "first"
|
|
47
|
+
page = 1
|
|
48
|
+
when "last"
|
|
49
|
+
page = max_pages
|
|
50
|
+
when /page [0-9]+/
|
|
51
|
+
install_num = input.split()
|
|
52
|
+
page = install_num[1].to_s.to_i
|
|
53
|
+
when /install [0-9]+/
|
|
54
|
+
install_num = input.split()
|
|
55
|
+
install_num = install_num[1].to_s.to_i - 1
|
|
56
|
+
CLI::Install.run_sys_command(all[install_num].name.to_s)
|
|
57
|
+
when /inspect [0-9]/
|
|
58
|
+
inspect_num = input.split()
|
|
59
|
+
inspect_num = inspect_num[1].to_s.to_i - 1
|
|
60
|
+
CLI::Scraper.getData((all[inspect_num].name.to_s))
|
|
61
|
+
puts "Would you like to install this gem?(Y/N)"
|
|
62
|
+
input = gets.chomp
|
|
63
|
+
case input
|
|
64
|
+
when "y"
|
|
65
|
+
CLI::Install.run_sys_command(all[inspect_num].name.to_s)
|
|
66
|
+
puts "Restarting"
|
|
67
|
+
CLI.restart
|
|
68
|
+
when "n"
|
|
69
|
+
puts "Please continue or select --help for help"
|
|
70
|
+
else
|
|
71
|
+
puts "Input not recognised, try again"
|
|
72
|
+
self.navigate(page, max_pages, all)
|
|
73
|
+
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
else
|
|
78
|
+
puts "Unrecognised command, try again"
|
|
79
|
+
self.navigate(page, max_pages, all)
|
|
80
|
+
end
|
|
81
|
+
page
|
|
82
|
+
end
|
|
83
|
+
def self.forward(page, max_pages)
|
|
84
|
+
page += 1 unless page >= max_pages
|
|
85
|
+
page
|
|
86
|
+
|
|
87
|
+
end
|
|
88
|
+
def self.back(page)
|
|
89
|
+
page -=1 unless page <= 1
|
|
90
|
+
page
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
end
|
data/lib/what_is_this/version.rb
CHANGED
data/lib/what_is_this.rb
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require_relative "what_is_this/version"
|
|
4
|
+
require_relative "what_is_this/CLI"
|
|
5
|
+
require_relative "what_is_this/Scraper_Tools"
|
|
4
6
|
require_relative "what_is_this/Advanced_Search"
|
|
5
7
|
require_relative "what_is_this/Approx_Scraper"
|
|
6
8
|
require_relative "what_is_this/Dependencies"
|
|
@@ -8,87 +10,5 @@ require_relative "what_is_this/Install"
|
|
|
8
10
|
require_relative "what_is_this/Scraper"
|
|
9
11
|
|
|
10
12
|
module WhatIsThis
|
|
11
|
-
|
|
12
|
-
@@spacing = "\n\n\n"
|
|
13
|
-
@@message_spacing = " "
|
|
14
|
-
def self.introduction
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
introduction_message = '
|
|
18
|
-
$$\ $$\ $$\ $$\ $$\ $$\
|
|
19
|
-
$$ | $$ | \__| $$ | $$ | \__|
|
|
20
|
-
$$\ $$\ $$\ $$$$$$$\ $$$$$$\ $$$$$$\ $$\ $$$$$$$\ $$$$$$\ $$$$$$$\ $$\ $$$$$$$\
|
|
21
|
-
$$ | $$ | $$ |$$ __$$\ \____$$\ \_$$ _| $$$$$$\ $$ |$$ _____|$$$$$$\ \_$$ _| $$ __$$\ $$ |$$ _____|
|
|
22
|
-
$$ | $$ | $$ |$$ | $$ | $$$$$$$ | $$ | \______|$$ |\$$$$$$\ \______| $$ | $$ | $$ |$$ |\$$$$$$\
|
|
23
|
-
$$ | $$ | $$ |$$ | $$ |$$ __$$ | $$ |$$\ $$ | \____$$\ $$ |$$\ $$ | $$ |$$ | \____$$\
|
|
24
|
-
\$$$$$\$$$$ |$$ | $$ |\$$$$$$$ | \$$$$ | $$ |$$$$$$$ | \$$$$ |$$ | $$ |$$ |$$$$$$$ |
|
|
25
|
-
\_____\____/ \__| \__| \_______| \____/ \__|\_______/ \____/ \__| \__|\__|\_______/ '
|
|
26
|
-
|
|
27
|
-
introduction_message.each_char {|c| putc c ; sleep 0.0015}
|
|
28
|
-
puts @@spacing + @@message_spacing + "Welcome to what-is-this! To begin please type either dependencies, install, search or quit:"
|
|
29
|
-
start
|
|
30
|
-
end
|
|
31
|
-
def self.start
|
|
32
|
-
input = CGI.escape(gets.chomp.downcase.strip)
|
|
33
|
-
puts @@spacing
|
|
34
|
-
case input
|
|
35
|
-
when 'search'
|
|
36
|
-
puts @@spacing + @@message_spacing + 'Would you like your search to be approximate(approx), advanced, exact or back to return?'
|
|
37
|
-
|
|
38
|
-
input = CGI.escape(gets.chomp.downcase.strip)
|
|
39
|
-
case input
|
|
40
|
-
when 'back'
|
|
41
|
-
self.restart
|
|
42
|
-
when 'approximate', 'approx'
|
|
43
|
-
approximate_search
|
|
44
|
-
when 'exact'
|
|
45
|
-
search
|
|
46
|
-
when 'advanced'
|
|
47
|
-
AdvancedSearch.advanced_search_properties
|
|
48
|
-
else
|
|
49
|
-
puts @@spacing + @@message_spacing + 'Command not recognised. Try again:'
|
|
50
|
-
restart
|
|
51
|
-
end
|
|
52
|
-
when 'install'
|
|
53
|
-
install
|
|
54
|
-
when 'dependencies'
|
|
55
|
-
Dependencies.display_dependencies
|
|
56
|
-
when 'quit'
|
|
57
|
-
quit
|
|
58
|
-
else
|
|
59
|
-
puts @@spacing + @@message_spacing + 'Command not recognised, try again!'
|
|
60
|
-
start
|
|
61
|
-
end
|
|
62
|
-
end
|
|
63
|
-
def self.approximate_search
|
|
64
|
-
puts @@spacing + @@message_spacing + "Please input your search term:"
|
|
65
|
-
query = CGI.escape(gets.chomp.downcase.strip)
|
|
66
|
-
Approx_Scraper.get_approximate_data(query)
|
|
67
|
-
restart
|
|
68
|
-
end
|
|
69
|
-
def self.search
|
|
70
|
-
puts @@spacing + @@message_spacing + "Enter gem you would like to know about"
|
|
71
|
-
query = CGI.escape(gets.chomp.downcase.strip)
|
|
72
|
-
Scraper.getData(query)
|
|
73
|
-
restart
|
|
74
|
-
end
|
|
75
|
-
def self.install
|
|
76
|
-
puts @@spacing + @@message_spacing + "Enter the gem that you would like to install and save as a dependency or back to return"
|
|
77
|
-
input = CGI.escape(gets.chomp)
|
|
78
|
-
case input
|
|
79
|
-
when 'back'
|
|
80
|
-
restart
|
|
81
|
-
else
|
|
82
|
-
Install.install(input)
|
|
83
|
-
end
|
|
84
|
-
restart
|
|
85
|
-
end
|
|
86
|
-
def self.quit
|
|
87
|
-
puts @@message_spacing + "Thanks for using 'what-is-this'... seeya!" + @@spacing
|
|
88
|
-
exit 1
|
|
89
|
-
end
|
|
90
|
-
def self.restart
|
|
91
|
-
puts @@spacing + @@message_spacing + 'To continue, type either dependencies, install, search, or quit:'
|
|
92
|
-
start
|
|
93
|
-
end
|
|
13
|
+
|
|
94
14
|
end
|
data/what_is_this.gemspec
CHANGED
|
@@ -8,8 +8,8 @@ Gem::Specification.new do |spec|
|
|
|
8
8
|
spec.authors = ["D-Justice"]
|
|
9
9
|
spec.email = ["justice.damian96@gmail.com"]
|
|
10
10
|
|
|
11
|
-
spec.summary = "CLI that allows the user all the functionality of RubyGems.org within the terminal."
|
|
12
|
-
spec.description = "CLI that allows the user all the functionality of RubyGems.org within the terminal."
|
|
11
|
+
spec.summary = "CLI that allows the user all the functionality of RubyGems.org within the terminal. To begin, simply type 'what_is_this in your project folder after installing the gem."
|
|
12
|
+
spec.description = "CLI that allows the user all the functionality of RubyGems.org within the terminal. To begin, simply type 'what_is_this in your project folder after installing the gem."
|
|
13
13
|
spec.homepage = "https://github.com/D-Justice/what-is-this"
|
|
14
14
|
spec.license = "MIT"
|
|
15
15
|
spec.required_ruby_version = ">= 2.6.0"
|
|
@@ -27,8 +27,8 @@ Gem::Specification.new do |spec|
|
|
|
27
27
|
(f == __FILE__) || f.match(%r{\A(?:(?:test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
|
|
28
28
|
end
|
|
29
29
|
end
|
|
30
|
-
spec.bindir = "
|
|
31
|
-
spec.executables =
|
|
30
|
+
spec.bindir = "bin"
|
|
31
|
+
spec.executables = ["what_is_this"]
|
|
32
32
|
spec.require_paths = ["lib"]
|
|
33
33
|
|
|
34
34
|
# Uncomment to register a new dependency of your gem
|
metadata
CHANGED
|
@@ -1,20 +1,22 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: what_is_this
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 1.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- D-Justice
|
|
8
8
|
autorequire:
|
|
9
|
-
bindir:
|
|
9
|
+
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2022-01-02 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: CLI that allows the user all the functionality of RubyGems.org within
|
|
14
|
-
the terminal.
|
|
14
|
+
the terminal. To begin, simply type 'what_is_this in your project folder after installing
|
|
15
|
+
the gem.
|
|
15
16
|
email:
|
|
16
17
|
- justice.damian96@gmail.com
|
|
17
|
-
executables:
|
|
18
|
+
executables:
|
|
19
|
+
- what_is_this
|
|
18
20
|
extensions: []
|
|
19
21
|
extra_rdoc_files: []
|
|
20
22
|
files:
|
|
@@ -26,12 +28,15 @@ files:
|
|
|
26
28
|
- bin/console
|
|
27
29
|
- bin/setup
|
|
28
30
|
- bin/what_is_this
|
|
31
|
+
- config/environment.rb
|
|
29
32
|
- lib/what_is_this.rb
|
|
30
33
|
- lib/what_is_this/Advanced_Search.rb
|
|
31
34
|
- lib/what_is_this/Approx_Scraper.rb
|
|
35
|
+
- lib/what_is_this/CLI.rb
|
|
32
36
|
- lib/what_is_this/Dependencies.rb
|
|
33
37
|
- lib/what_is_this/Install.rb
|
|
34
38
|
- lib/what_is_this/Scraper.rb
|
|
39
|
+
- lib/what_is_this/Scraper_Tools.rb
|
|
35
40
|
- lib/what_is_this/version.rb
|
|
36
41
|
- sig/what_is_this.rbs
|
|
37
42
|
- what_is_this.gemspec
|
|
@@ -58,5 +63,6 @@ rubygems_version: 3.2.32
|
|
|
58
63
|
signing_key:
|
|
59
64
|
specification_version: 4
|
|
60
65
|
summary: CLI that allows the user all the functionality of RubyGems.org within the
|
|
61
|
-
terminal.
|
|
66
|
+
terminal. To begin, simply type 'what_is_this in your project folder after installing
|
|
67
|
+
the gem.
|
|
62
68
|
test_files: []
|