monster_encyclopedia 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +79 -2
- data/documentation/Monster Encyclopedia.png +0 -0
- data/documentation/features +13 -0
- data/lib/add_monster.rb +50 -0
- data/lib/data.csv +8 -0
- data/lib/encyclopedia_menu.rb +52 -0
- data/lib/invalid_and_exit.rb +22 -0
- data/lib/monster_encyclopedia/version.rb +1 -1
- data/lib/remove_monster.rb +45 -0
- data/lib/view_monsters.rb +21 -0
- data/monster_encyclopedia.gemspec +0 -6
- metadata +10 -3
- data/lib/monster_encyclopedia.rb +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4a9fa49c824cc1924f275a5cd7c55ff802b768a47eadaafb3eb5f34900065563
|
4
|
+
data.tar.gz: cf76318d2e60f2a33b7e1454a5e5f29c9eb413c67b9a15e282fa71d6f2bbcfb2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 56562d3957b0c1a73de034fcb67d3a2b8b6b06d2598b20f20b99a94c4805eaa1567405980d318fcc5c32ceed826560c31f3b42dd271ca878499c6d4339a77006
|
7
|
+
data.tar.gz: a29044e5367416e347ed63b0cb0c938561ce4e36724625e39d2d2e31a77ce49a125846200ec7ce6b17162672b86dcf1557a10f756f40ef4e1a5a3fc175b9ec81
|
data/README.md
CHANGED
@@ -1,8 +1,20 @@
|
|
1
|
+
|
1
2
|
# MonsterEncyclopedia
|
2
3
|
|
3
4
|
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/monster_encyclopedia`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
5
|
|
5
|
-
|
6
|
+
Hello and thankyou for using the Monster Encyclopedia! this program is a useful application for all your monster hunting needs!
|
7
|
+
It can be used to view documented monster details, add newly discovered monsters to your database or remove monsters if they have been proven false!
|
8
|
+
It utilizes the gems colorize, tty-prompt, artii and csv for a great user experience!
|
9
|
+
Have fun.
|
10
|
+
|
11
|
+
## Links
|
12
|
+
-[GitHub](https://github.com/RobThomas30/Monster-Encyclopedia/commits/master)
|
13
|
+
-[Trello](https://trello.com/b/AvlKLu12/monsterencyclopedia)
|
14
|
+
|
15
|
+
## Tests
|
16
|
+
|
17
|
+
|
6
18
|
|
7
19
|
## Installation
|
8
20
|
|
@@ -20,9 +32,69 @@ Or install it yourself as:
|
|
20
32
|
|
21
33
|
$ gem install monster_encyclopedia
|
22
34
|
|
35
|
+
|
23
36
|
## Usage
|
24
37
|
|
25
|
-
|
38
|
+
When running Monster Encyclopedia you will be briefly greeted on the opening screen before the menu launches.
|
39
|
+
|
40
|
+
Menu:
|
41
|
+
This is the hub of the application and can be navigated with the arrow keys, press enter to select.
|
42
|
+
The menu consists of 4 options:
|
43
|
+
-View Monsters
|
44
|
+
-Add Monster
|
45
|
+
-Remove Monster
|
46
|
+
-Exit
|
47
|
+
|
48
|
+
View Monsters:
|
49
|
+
If you select the view monster option the program will call on the csv database and print the data to the screen, monsters will be ordered by name alphabetically and will also show where they have been seen followed by a description of the monster.
|
50
|
+
|
51
|
+
Add Monsters:
|
52
|
+
If you select add monster option from the menu you will be prompted to write in the name, location and description of a monster.
|
53
|
+
After completing these 3 steps you will be asked to confirm that what you have input is correct you can press 1 or 2 and enter to confirm:
|
54
|
+
-Press 1 to confirm your input and append the csv database with your new entry.
|
55
|
+
-Press 2 if your information is incorrect or you change your mind about adding a new entry you can select this option and it will not append the csv
|
56
|
+
|
57
|
+
Remove Monster:
|
58
|
+
If you select this option the screen will be populated with only the names of the monsters from the csv, you will be prompted to type the name of the monster you wish to remove from the database.
|
59
|
+
*To ensure you don't accidentally remove the wrong monster you must type the name of the monster exactly how it appears on screen(case sensitive)
|
60
|
+
|
61
|
+
Exit:
|
62
|
+
If you select this option the program will display a goodby message accompanied by the logo before the program closes.
|
63
|
+
|
64
|
+
|
65
|
+
## Features
|
66
|
+
|
67
|
+
Persistent memory:
|
68
|
+
This application communicates with a csv file which allows it to read, write and re-write data.
|
69
|
+
It will even store the applications data after the program closes!
|
70
|
+
-Read: When reading from the csv first the program 'requires csv' then reads in the information and stores it in a variable.
|
71
|
+
It then uses this variable to print to screen for the user.
|
72
|
+
-Write: When writing to the csv the program utilizes the -ab function to append the csv with a new entry.
|
73
|
+
-Re-write: When deleting something from the csv it combines both read and write functions by reading in the csv and converting it to an array of hashes if the user input is the same as a monster name it will remove that monster from the array and then use the -w function to overwrite the csv data.
|
74
|
+
|
75
|
+
Gem integration:
|
76
|
+
The Monster Encyclopedia utilizes multiple gems that make it easier to navigate the application and enhance its appearance.
|
77
|
+
-TTY Prompt: Allows the user to navigate the main menu using the arrow keys
|
78
|
+
-Colorize: Adds a splash of colour to the application!
|
79
|
+
-Artii: Was used to make a logo for startup and shutdown.
|
80
|
+
|
81
|
+
|
82
|
+
## Statement of Purpose
|
83
|
+
|
84
|
+
The Application:
|
85
|
+
- The monster Encyclopedia will allow users to view, add and remove "entries" in the encyclopedia which will consist of monster name, location and description.
|
86
|
+
Why:
|
87
|
+
- The monster encyclopedia will allow adventurers to keep track of their discoveries in an organized logbook type application.
|
88
|
+
Target Audience:
|
89
|
+
- The target audience is unorganized scientists and monster hunters that need an application to track their discoveries and experiments.
|
90
|
+
How:
|
91
|
+
- The app will be easy to navigate utilizing with simple instructions built into the app telling the user what to do and how to use it.
|
92
|
+
-the menu will be traversable with the arrow keys and enter to select.
|
93
|
+
-When adding or removing a monster entry the user will be required to type in information.
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
|
26
98
|
|
27
99
|
## Development
|
28
100
|
|
@@ -42,3 +114,8 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
42
114
|
## Code of Conduct
|
43
115
|
|
44
116
|
Everyone interacting in the MonsterEncyclopedia project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/monster_encyclopedia/blob/master/CODE_OF_CONDUCT.md).
|
117
|
+
|
118
|
+
|
119
|
+
## UML
|
120
|
+
|
121
|
+
![](.docs/)
|
Binary file
|
@@ -0,0 +1,13 @@
|
|
1
|
+
Features
|
2
|
+
|
3
|
+
Menu:
|
4
|
+
The menu of the Monster Encyclopedia terminal application will serve as a central hub.
|
5
|
+
On startup a welcome message and logo will display, then the menu will run showing the user the available functions/options.
|
6
|
+
-View entries
|
7
|
+
-Add new monster
|
8
|
+
-Remove a monster
|
9
|
+
-Exit program
|
10
|
+
A ruby gem will be used to make the menu interactive, the arrow keys will be used to navigate and enter will confirm your choice.
|
11
|
+
|
12
|
+
View monsters:
|
13
|
+
|
data/lib/add_monster.rb
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
|
2
|
+
class Monster
|
3
|
+
attr_reader :name, :location, :description
|
4
|
+
def initialize(name, location, description)
|
5
|
+
@name = name
|
6
|
+
@location = location
|
7
|
+
@description = description
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def add_monster(monsters_array)
|
12
|
+
info = true
|
13
|
+
|
14
|
+
while info == true
|
15
|
+
system 'clear'
|
16
|
+
puts '-'.colorize(:light_red) * 45
|
17
|
+
puts "What is the name of the monster?"
|
18
|
+
print '> '
|
19
|
+
monster_name = gets.chomp
|
20
|
+
puts '-'.colorize(:light_red) * 45
|
21
|
+
puts "Where was the monster sighted?"
|
22
|
+
print '> '
|
23
|
+
monster_location = gets.chomp
|
24
|
+
puts '-'.colorize(:light_red) * 45
|
25
|
+
puts "What does the monster look like?"
|
26
|
+
print '> '
|
27
|
+
monster_description = gets.chomp
|
28
|
+
puts '-'.colorize(:light_red) * 45
|
29
|
+
puts "Is your entry correct?"
|
30
|
+
puts "1. Yes => Add entry to encyclopedia"
|
31
|
+
puts "2. No => Cancel entry return to menu"
|
32
|
+
while info == true
|
33
|
+
case gets.chomp.to_i
|
34
|
+
when 1
|
35
|
+
new_monster = Monster.new(monster_name, monster_location, monster_description)
|
36
|
+
monsters_array << new_monster
|
37
|
+
CSV.open("data.csv", "ab") do |csv|
|
38
|
+
csv << [monster_name, monster_location, monster_description]
|
39
|
+
system 'clear'
|
40
|
+
info = false
|
41
|
+
end
|
42
|
+
when 2
|
43
|
+
system 'clear'
|
44
|
+
info = false
|
45
|
+
else
|
46
|
+
puts "Please pick 1 or 2"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
data/lib/data.csv
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
name,location,description
|
2
|
+
Lock-ness Monster,Scotland,A large amphibious dinosaur like monster with a long neck and fins instead of legs.
|
3
|
+
Cthulu,???,An enormous being with a tentacle covered face rumoured to be sleeping at the bottom of the ocean.
|
4
|
+
Bigfoot,North America,A slightly larger than man sized monster covered in white hair.
|
5
|
+
Tooth Fairy,Bedrooms of children,Unsighted however when a child leaves a tooth under their pillow it will take the tooth and leave a coin
|
6
|
+
Guy,Coder Academy,A nice chap that broke my code then helped me fix it.
|
7
|
+
Godzilla,Manhatten,A gigantic iguana altered by radiation it breathes fire and destroys buildings with ease
|
8
|
+
Bunyip,Australia,A slightly larger than man gangly long limbed monster that lives in australian wetlands
|
@@ -0,0 +1,52 @@
|
|
1
|
+
|
2
|
+
require_relative 'view_monsters.rb'
|
3
|
+
require_relative 'add_monster.rb'
|
4
|
+
require_relative 'remove_monster'
|
5
|
+
require_relative 'invalid_and_exit'
|
6
|
+
require 'csv'
|
7
|
+
require 'tty-prompt'
|
8
|
+
require 'colorize'
|
9
|
+
require 'artii'
|
10
|
+
|
11
|
+
$prompt = TTY::Prompt.new
|
12
|
+
|
13
|
+
system 'clear'
|
14
|
+
puts "-".colorize(:red) * 45
|
15
|
+
puts "Welcome to Monster Encyclopedia!"
|
16
|
+
puts "-".colorize(:red) * 45
|
17
|
+
text = Artii::Base.new :font => 'epic'
|
18
|
+
puts text.asciify('--M:E--').colorize(:color => :black, :background => :red)
|
19
|
+
puts '-'.colorize(:light_red) * 45
|
20
|
+
sleep 3
|
21
|
+
|
22
|
+
def menu()
|
23
|
+
system 'clear'
|
24
|
+
puts "-".colorize(:red) * 45
|
25
|
+
puts "Welcome to the Monster Encyclopedia"
|
26
|
+
puts "-".colorize(:red) * 45
|
27
|
+
input = $prompt.select("What would you like to do?") do |menu|
|
28
|
+
menu.choice name: "View all entries", value: 1
|
29
|
+
menu.choice name: "Add a new monster to the encyclopedia", value: 2
|
30
|
+
menu.choice name: "Remove a monster from the encyclopedia", value: 3
|
31
|
+
menu.choice name: "Close encyclopedia", value: 4
|
32
|
+
end
|
33
|
+
return input
|
34
|
+
end
|
35
|
+
|
36
|
+
while true
|
37
|
+
input = menu()
|
38
|
+
monsters_array = []
|
39
|
+
|
40
|
+
case input
|
41
|
+
when 1
|
42
|
+
view_monsters()
|
43
|
+
when 2
|
44
|
+
add_monster(monsters_array)
|
45
|
+
when 3
|
46
|
+
remove_monster(monsters_array)
|
47
|
+
when 4
|
48
|
+
exit_program()
|
49
|
+
else
|
50
|
+
invalid_input()
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
|
2
|
+
def invalid_input
|
3
|
+
system 'clear'
|
4
|
+
puts '-'.colorize(:light_red) * 45
|
5
|
+
puts "Please pick a number from the menu."
|
6
|
+
puts '-'.colorize(:light_red) * 45
|
7
|
+
sleep 3.0
|
8
|
+
system 'clear'
|
9
|
+
end
|
10
|
+
|
11
|
+
def exit_program()
|
12
|
+
system 'clear'
|
13
|
+
puts '-'.colorize(:light_red) * 45
|
14
|
+
puts "Thankyou for using the Monster Encyclopedia!"
|
15
|
+
puts '-'.colorize(:light_red) * 45
|
16
|
+
text = Artii::Base.new :font => 'epic'
|
17
|
+
puts text.asciify('--M:E--').colorize(:color => :black, :background => :red)
|
18
|
+
puts '-'.colorize(:light_red) * 45
|
19
|
+
sleep 3.0
|
20
|
+
system "clear"
|
21
|
+
exit
|
22
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
def remove_monster(monsters_array)
|
2
|
+
monster = []
|
3
|
+
monster_names = []
|
4
|
+
csv_text = File.read('data.csv')
|
5
|
+
csv = CSV.parse(csv_text, :headers => true)
|
6
|
+
csv.each do |row|
|
7
|
+
monster << row.to_hash
|
8
|
+
end
|
9
|
+
|
10
|
+
system 'clear'
|
11
|
+
|
12
|
+
monster.sort_by! { |mon| mon["name"]}
|
13
|
+
monster.each do |thing|
|
14
|
+
puts '-'.colorize(:red) * 45
|
15
|
+
puts "Name: #{thing["name"]}"
|
16
|
+
puts
|
17
|
+
monster_names << thing["name"]
|
18
|
+
end
|
19
|
+
|
20
|
+
puts "Which monster would you like to remove from the encyclopedia?"
|
21
|
+
input = gets.chomp
|
22
|
+
|
23
|
+
if monster_names.include?(input)
|
24
|
+
table = CSV.table("data.csv")
|
25
|
+
table.delete_if.with_index do |row, index|
|
26
|
+
next if index.zero?
|
27
|
+
row[0] == input
|
28
|
+
end
|
29
|
+
|
30
|
+
File.open("data.csv", 'w') do |data|
|
31
|
+
data.write(table.to_csv)
|
32
|
+
end
|
33
|
+
system 'clear'
|
34
|
+
puts '-'.colorize(:red) * 45
|
35
|
+
puts "#{input} was deleted!"
|
36
|
+
puts '-'.colorize(:red) * 45
|
37
|
+
sleep 2
|
38
|
+
else
|
39
|
+
system 'clear'
|
40
|
+
puts '-'.colorize(:red) * 45
|
41
|
+
puts "No monster by that name..."
|
42
|
+
puts '-'.colorize(:red) * 45
|
43
|
+
sleep 2
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
|
2
|
+
def view_monsters()
|
3
|
+
monsters_array = []
|
4
|
+
csv_text = File.read('data.csv')
|
5
|
+
csv = CSV.parse(csv_text, :headers => true)
|
6
|
+
csv.each do |row|
|
7
|
+
monster = row.to_hash
|
8
|
+
monsters_array << monster
|
9
|
+
system 'clear'
|
10
|
+
end
|
11
|
+
monsters_array.sort_by! { |mon| mon["name"]}
|
12
|
+
monsters_array.each do |monster|
|
13
|
+
puts '-'.colorize(:red) * 45
|
14
|
+
puts "Name:" + " #{monster["name"]}".colorize(:light_red)
|
15
|
+
puts "Found: #{monster["location"]}"
|
16
|
+
puts
|
17
|
+
puts "Description: #{monster["description"]}"
|
18
|
+
puts
|
19
|
+
end
|
20
|
+
gets
|
21
|
+
end
|
@@ -12,12 +12,6 @@ Gem::Specification.new do |spec|
|
|
12
12
|
spec.license = "MIT"
|
13
13
|
spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
|
14
14
|
|
15
|
-
# spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
|
16
|
-
|
17
|
-
# spec.metadata["homepage_uri"] = spec.homepage
|
18
|
-
# spec.metadata["source_code_uri"] = "TODO: Put your gem's public repo URL here."
|
19
|
-
# spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
|
20
|
-
|
21
15
|
# Specify which files should be added to the gem when it is released.
|
22
16
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
23
17
|
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: monster_encyclopedia
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Thomas
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-03-
|
11
|
+
date: 2020-03-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colorize
|
@@ -39,8 +39,15 @@ files:
|
|
39
39
|
- Rakefile
|
40
40
|
- bin/console
|
41
41
|
- bin/setup
|
42
|
-
-
|
42
|
+
- documentation/Monster Encyclopedia.png
|
43
|
+
- documentation/features
|
44
|
+
- lib/add_monster.rb
|
45
|
+
- lib/data.csv
|
46
|
+
- lib/encyclopedia_menu.rb
|
47
|
+
- lib/invalid_and_exit.rb
|
43
48
|
- lib/monster_encyclopedia/version.rb
|
49
|
+
- lib/remove_monster.rb
|
50
|
+
- lib/view_monsters.rb
|
44
51
|
- monster_encyclopedia.gemspec
|
45
52
|
homepage: https://github.com/RobThomas30/Monster-Encyclopedia
|
46
53
|
licenses:
|