├── .rspec ├── main.rb ├── Gemfile ├── .DS_Store ├── games.json ├── modules ├── .DS_Store ├── inputs.rb ├── genre_module.rb ├── make_json_game.rb ├── game_author_module.rb ├── book_module.rb ├── label_module.rb └── music_album_module.rb ├── music_albums.json ├── genre.rb ├── label.rb ├── music_album.rb ├── book.rb ├── author.rb ├── books.json ├── game.rb ├── .github └── workflows │ └── linters.yml ├── spec ├── author_spec.rb ├── genre_spec.rb ├── book_spec.rb ├── game_spec.rb ├── label_spec.rb ├── genre_module_spec.rb ├── music_album_spec.rb ├── music_album_module_spec.rb ├── book_module_spec.rb ├── label_module_spec.rb └── spec_helper.rb ├── LICENSE.md ├── .rubocop.yml ├── item.rb ├── schema.sql ├── Gemfile.lock ├── app.rb └── README.md /.rspec: -------------------------------------------------------------------------------- 1 | --require spec_helper 2 | -------------------------------------------------------------------------------- /main.rb: -------------------------------------------------------------------------------- 1 | require_relative 'app' 2 | app = App.new 3 | app.run 4 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | gem 'rubocop', '>= 1.0', '< 2.0' 2 | 3 | gem 'rspec', '~> 3.0' 4 | -------------------------------------------------------------------------------- /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ClaudiaRojasSoto/Catalog_Of_My_Things/HEAD/.DS_Store -------------------------------------------------------------------------------- /games.json: -------------------------------------------------------------------------------- 1 | [{"multiplayer":true,"last_played_at":"12-13-2423","publish_date":"23-12-2323","author":0}] -------------------------------------------------------------------------------- /modules/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ClaudiaRojasSoto/Catalog_Of_My_Things/HEAD/modules/.DS_Store -------------------------------------------------------------------------------- /music_albums.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": 704, 4 | "publish_date": "11-11-1111", 5 | "on_spotify": true, 6 | "genre": "1" 7 | } 8 | ] -------------------------------------------------------------------------------- /genre.rb: -------------------------------------------------------------------------------- 1 | class Genre 2 | attr_accessor :name, :id 3 | 4 | def initialize(id, name) 5 | @id = id 6 | @name = name 7 | @items = [] 8 | end 9 | 10 | def add_item(item) 11 | @items.push(item) 12 | item.genre = self 13 | end 14 | end 15 | -------------------------------------------------------------------------------- /label.rb: -------------------------------------------------------------------------------- 1 | # Class representing a Label 2 | class Label 3 | attr_accessor :title, :color 4 | attr_reader :id, :items 5 | 6 | def initialize(id, title, color) 7 | @id = id 8 | @title = title 9 | @color = color 10 | @items = [] 11 | end 12 | 13 | def add_item(item) 14 | @items.push(item) 15 | item.label = self 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /music_album.rb: -------------------------------------------------------------------------------- 1 | require_relative 'item' 2 | 3 | class MusicAlbum < Item 4 | attr_accessor :on_spotify 5 | 6 | def initialize(params = {}) 7 | super(params) 8 | @on_spotify = params[:on_spotify] 9 | end 10 | 11 | def on_spotify? 12 | @on_spotify 13 | end 14 | 15 | private 16 | 17 | def can_be_archived? 18 | super && @on_spotify 19 | end 20 | end 21 | -------------------------------------------------------------------------------- /book.rb: -------------------------------------------------------------------------------- 1 | require_relative 'item' 2 | 3 | # Class representing a Book 4 | class Book < Item 5 | attr_accessor :publisher, :cover_state 6 | 7 | def initialize(params = {}) 8 | super(params) 9 | @publisher = params[:publisher] 10 | @cover_state = params[:cover_state] 11 | end 12 | 13 | private 14 | 15 | def can_be_archived? 16 | super || @cover_state == 'bad' 17 | end 18 | end 19 | -------------------------------------------------------------------------------- /author.rb: -------------------------------------------------------------------------------- 1 | class Author 2 | attr_accessor :first_name, :last_name 3 | 4 | def initialize(first_name, last_name, items = [], id = 1) 5 | @first_name = first_name 6 | @last_name = last_name 7 | @items = items 8 | @id = id 9 | end 10 | 11 | def add_item(item) 12 | @items.push(item) 13 | item.author = self 14 | end 15 | 16 | private 17 | 18 | attr_reader :id, :items 19 | end 20 | -------------------------------------------------------------------------------- /books.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": 2400, 4 | "publisher": "1", 5 | "cover_state": "good", 6 | "publish_date": null, 7 | "label": "New" 8 | }, 9 | { 10 | "id": 8047, 11 | "publisher": "2", 12 | "cover_state": "bad", 13 | "publish_date": null, 14 | "label": "Gift" 15 | }, 16 | { 17 | "id": 8163, 18 | "publisher": "3", 19 | "cover_state": "bad", 20 | "publish_date": "2022-11-30", 21 | "label": "New" 22 | } 23 | ] -------------------------------------------------------------------------------- /game.rb: -------------------------------------------------------------------------------- 1 | require_relative 'item' 2 | require 'date' 3 | 4 | class Game < Item 5 | attr_accessor :multiplayer, :last_played_at 6 | 7 | def initialize(multiplayer, last_played_at, publish_date, author) 8 | super(genre: nil, source: nil, label: nil, author: author, publish_date: publish_date) 9 | @multiplayer = multiplayer 10 | @last_played_at = last_played_at 11 | end 12 | 13 | private 14 | 15 | def can_be_archived? 16 | year = Time.now.year - Date.parse(last_played_at).year 17 | (super && year > 2) 18 | end 19 | end 20 | -------------------------------------------------------------------------------- /.github/workflows/linters.yml: -------------------------------------------------------------------------------- 1 | name: Linters 2 | 3 | on: pull_request 4 | 5 | jobs: 6 | rubocop: 7 | name: Rubocop 8 | runs-on: ubuntu-22.04 9 | 10 | steps: 11 | - uses: actions/checkout@v3 12 | - uses: actions/setup-ruby@v1 13 | with: 14 | ruby-version: ">=3.1.x" 15 | - name: Setup Rubocop 16 | run: | 17 | gem install --no-document rubocop -v '>= 1.0, < 2.0' # https://docs.rubocop.org/en/stable/installation/ 18 | [ -f .rubocop.yml ] || wget https://raw.githubusercontent.com/microverseinc/linters-config/master/ruby/.rubocop.yml 19 | - name: Rubocop Report 20 | run: rubocop --color -------------------------------------------------------------------------------- /modules/inputs.rb: -------------------------------------------------------------------------------- 1 | def add_multiplayer 2 | puts '~~ Add Game ~~' 3 | print 'Do you want multiplayer or not [Y/N] : ' 4 | input = gets.chomp 5 | while input != 'Y' && input != 'y' && input != 'N' && input != 'n' 6 | print 'Do you want multiplayer or not [Y/N](good answer please) : ' 7 | input = gets.chomp 8 | end 9 | return true if %w[Y y].include?(input) 10 | 11 | false 12 | end 13 | 14 | def add_last_played_at 15 | print 'Add date for last_played : ' 16 | gets.chomp 17 | end 18 | 19 | def add_publish_date 20 | print 'Add publish date : ' 21 | gets.chomp 22 | end 23 | 24 | def index_author 25 | print 'Add author by the index : ' 26 | gets.chomp 27 | end 28 | -------------------------------------------------------------------------------- /modules/genre_module.rb: -------------------------------------------------------------------------------- 1 | module GenreModule 2 | def self.add_genre(genres) 3 | id = generate_id(genres) 4 | name = genre_name 5 | 6 | genre = Genre.new(id, name) 7 | genres << genre 8 | puts 'Genre successfully added.' 9 | end 10 | 11 | def self.list_genres(genres) 12 | puts 'List of Genres:' 13 | genres.each_with_index do |genre, index| 14 | puts "#{index + 1}. Name: #{genre.name}" 15 | end 16 | end 17 | 18 | def self.genre_name 19 | puts 'Enter the Genre name:' 20 | gets.chomp 21 | end 22 | 23 | def self.generate_id(genres) 24 | max_id = genres.map { |genre| genre.id.to_i }.max || 0 25 | (max_id + 1).to_s 26 | end 27 | end 28 | -------------------------------------------------------------------------------- /modules/make_json_game.rb: -------------------------------------------------------------------------------- 1 | require 'json' 2 | 3 | module Output 4 | def write_file(taked_game, file_name) 5 | json_file = JSON.generate(taked_game) 6 | File.open(file_name, 'w') 7 | File.write(file_name, json_file) 8 | end 9 | 10 | def read_file_game 11 | return [] unless File.exist?('games.json') 12 | 13 | file_name = 'games.json' 14 | File.open(file_name) 15 | take_data = File.read('games.json') 16 | @taked_games = JSON.parse(take_data) 17 | convert_game 18 | end 19 | 20 | def convert_game 21 | @taked_games.each do |i| 22 | @games.push(Game.new(i['multiplayer'], i['last_played_at'], i['publish_date'], @authors[i['author'].to_i])) 23 | end 24 | end 25 | end 26 | -------------------------------------------------------------------------------- /spec/author_spec.rb: -------------------------------------------------------------------------------- 1 | require_relative '../author' 2 | require_relative '../item' 3 | 4 | describe Author do 5 | describe '#Check attribute' do 6 | context 'Check the first_name and the last_name' do 7 | it 'returns franck and sefu' do 8 | @author = Author.new('franck', 'sefu') 9 | expect(@author.first_name).to eq('franck') 10 | expect(@author.last_name).to eq('sefu') 11 | end 12 | end 13 | 14 | context 'when last_played_at is less than 2 years' do 15 | it 'returns false' do 16 | @author = Author.new('Germine', 'guz') 17 | @item = Item.new({ id: 1 }) 18 | @author.add_item(@item) 19 | expect(@item.author).to eq(@author) 20 | end 21 | end 22 | end 23 | end 24 | -------------------------------------------------------------------------------- /spec/genre_spec.rb: -------------------------------------------------------------------------------- 1 | # genre_spec.rb 2 | require_relative '../genre' 3 | 4 | RSpec.describe Genre do 5 | before :each do 6 | @genre = Genre.new(1, 'Action') 7 | end 8 | 9 | describe '#add_item' do 10 | context 'when adding an item to the genre' do 11 | it 'adds the item to the genre' do 12 | item = double('item') 13 | expect(item).to receive(:genre=).with(@genre) 14 | @genre.add_item(item) 15 | expect(@genre.instance_variable_get(:@items)).to include(item) 16 | end 17 | 18 | it 'sets the genre of the item to the genre itself' do 19 | item = double('item') 20 | expect(item).to receive(:genre=).with(@genre) 21 | @genre.add_item(item) 22 | end 23 | end 24 | end 25 | end 26 | -------------------------------------------------------------------------------- /spec/book_spec.rb: -------------------------------------------------------------------------------- 1 | # Test para book.rb 2 | require_relative '../book' 3 | require_relative '../item' 4 | require_relative '../modules/book_module' 5 | 6 | RSpec.describe Book do 7 | before :each do 8 | @book = Book.new( 9 | publisher: 'Some Publisher', 10 | cover_state: 'good', 11 | id: 1, 12 | label: 'Some Label', 13 | publish_date: '01-01-2022' 14 | ) 15 | end 16 | 17 | describe '#can_be_archived?' do 18 | context 'when cover_state is good' do 19 | it 'returns false' do 20 | expect(@book.send(:can_be_archived?)).to eq(false) 21 | end 22 | end 23 | 24 | context 'when cover_state is bad' do 25 | it 'returns true' do 26 | @book.cover_state = 'bad' 27 | expect(@book.send(:can_be_archived?)).to eq(true) 28 | end 29 | end 30 | end 31 | end 32 | -------------------------------------------------------------------------------- /spec/game_spec.rb: -------------------------------------------------------------------------------- 1 | require_relative '../game' 2 | require_relative '../author' 3 | require 'rspec' 4 | 5 | RSpec.describe Game do 6 | describe '#can_be_archived?' do 7 | context 'when last_played_at is greater than 2 years' do 8 | it 'returns return true' do 9 | author_mock = instance_double(Author, first_name: 'franck', last_name: 'sefu') 10 | @game = Game.new(true, '12-12-2000', '12-12-2001', author_mock) 11 | expect(@game.send(:can_be_archived?)).to eq(true) 12 | end 13 | end 14 | 15 | context 'when last_played_at is less than 2 years' do 16 | it 'returns false' do 17 | author_mock = instance_double(Author, first_name: 'Guy', last_name: 'sefu') 18 | @game = Game.new(true, '12-12-2023', '12-12-2023', author_mock) 19 | expect(@game.send(:can_be_archived?)).to eq(false) 20 | end 21 | end 22 | end 23 | end 24 | -------------------------------------------------------------------------------- /spec/label_spec.rb: -------------------------------------------------------------------------------- 1 | require_relative '../label' 2 | require_relative '../item' 3 | 4 | RSpec.describe Label do 5 | before :each do 6 | @label = Label.new(1, 'Fiction', 'Red') 7 | end 8 | 9 | describe '#initialize' do 10 | it 'creates an instance of Label with given attributes' do 11 | expect(@label.id).to eq(1) 12 | expect(@label.title).to eq('Fiction') 13 | expect(@label.color).to eq('Red') 14 | end 15 | 16 | it 'initializes items as an empty array' do 17 | expect(@label.items).to eq([]) 18 | end 19 | end 20 | 21 | describe '#add_item' do 22 | it 'adds an item to the items array' do 23 | item = Item.new({ id: 1, label: @label }) 24 | @label.add_item(item) 25 | expect(@label.items).to include(item) 26 | end 27 | 28 | it 'sets the item label to itself' do 29 | item = Item.new({ id: 1, label: @label }) 30 | @label.add_item(item) 31 | expect(item.label).to eq(@label) 32 | end 33 | end 34 | end 35 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright 2023, Claudia Rojas 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the software, and to permit persons to whom the software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the software. 6 | 7 | THE software IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE software OR THE USE OR OTHER DEALINGS IN THE software. 8 | -------------------------------------------------------------------------------- /spec/genre_module_spec.rb: -------------------------------------------------------------------------------- 1 | require_relative '../modules/genre_module' 2 | require_relative '../genre' 3 | 4 | RSpec.describe GenreModule do 5 | describe '.add_genre' do 6 | it 'adds a genre to the genres array' do 7 | genres = [] 8 | allow(GenreModule).to receive(:genre_name).and_return('Action') 9 | allow(GenreModule).to receive(:generate_id).with([]).and_return('1') 10 | 11 | GenreModule.add_genre(genres) 12 | 13 | expect(genres.size).to eq(1) 14 | expect(genres.first.name).to eq('Action') 15 | end 16 | end 17 | 18 | describe '.list_genres' do 19 | it 'lists the genres' do 20 | genres = [Genre.new('1', 'Action'), Genre.new('2', 'Adventure')] 21 | expected_output = "List of Genres:\n1. Name: Action\n2. Name: Adventure\n" 22 | 23 | expect { GenreModule.list_genres(genres) }.to output(expected_output).to_stdout 24 | end 25 | end 26 | 27 | describe '.generate_id' do 28 | it 'generates a unique ID' do 29 | genres = [Genre.new('1', 'Action'), Genre.new('2', 'Adventure')] 30 | id = GenreModule.generate_id(genres) 31 | 32 | expect(id).to eq('3') 33 | end 34 | end 35 | end 36 | -------------------------------------------------------------------------------- /.rubocop.yml: -------------------------------------------------------------------------------- 1 | AllCops: 2 | NewCops: enable 3 | Exclude: 4 | - "Guardfile" 5 | - "Rakefile" 6 | - "node_modules/**/*" 7 | 8 | DisplayCopNames: true 9 | 10 | Layout/LineLength: 11 | Max: 120 12 | Metrics/MethodLength: 13 | Max: 20 14 | Metrics/AbcSize: 15 | Max: 50 16 | Metrics/ClassLength: 17 | Max: 150 18 | Metrics/BlockLength: 19 | IgnoredMethods: ['describe'] 20 | Max: 30 21 | 22 | 23 | Style/Documentation: 24 | Enabled: false 25 | Style/ClassAndModuleChildren: 26 | Enabled: false 27 | Style/EachForSimpleLoop: 28 | Enabled: false 29 | Style/AndOr: 30 | Enabled: false 31 | Style/DefWithParentheses: 32 | Enabled: false 33 | Style/FrozenStringLiteralComment: 34 | EnforcedStyle: never 35 | 36 | Layout/HashAlignment: 37 | EnforcedColonStyle: key 38 | Layout/ExtraSpacing: 39 | AllowForAlignment: false 40 | Layout/MultilineMethodCallIndentation: 41 | Enabled: true 42 | EnforcedStyle: indented 43 | Lint/RaiseException: 44 | Enabled: false 45 | Lint/StructNewOverride: 46 | Enabled: false 47 | Style/HashEachMethods: 48 | Enabled: false 49 | Style/HashTransformKeys: 50 | Enabled: false 51 | Style/HashTransformValues: 52 | Enabled: false -------------------------------------------------------------------------------- /modules/game_author_module.rb: -------------------------------------------------------------------------------- 1 | require_relative 'inputs' 2 | require_relative '../game' 3 | require_relative '../author' 4 | 5 | module GameAuthor 6 | def add_games() 7 | multiplayer = add_multiplayer 8 | last_played = add_last_played_at 9 | publish_date = add_publish_date 10 | list_author 11 | index = index_author.to_i 12 | author = @authors[index] 13 | [multiplayer, last_played, publish_date, author, index] 14 | end 15 | 16 | def list_game 17 | if @games.empty? 18 | puts 'No game yet, Add if you wanna see ' 19 | else 20 | @games.each_with_index do |elt, idx| 21 | puts " IDX:#{idx} multiplayer : #{elt.multiplayer} last played at : #{elt.last_played_at} " 22 | puts " Author : '#{elt.author.first_name} #{elt.author.last_name}'\n " 23 | end 24 | end 25 | end 26 | 27 | def list_author 28 | @authors.each_with_index do |elt, idx| 29 | puts "\n #{idx}) '#{elt.first_name} #{elt.last_name}' " 30 | end 31 | end 32 | 33 | def initialize_author 34 | arr = [] 35 | arr.push(Author.new('Martin', 'Acero')) 36 | arr.push(Author.new('Emmanuella', 'Davila')) 37 | arr.push(Author.new('Angel', 'Salvador')) 38 | arr 39 | end 40 | end 41 | -------------------------------------------------------------------------------- /spec/music_album_spec.rb: -------------------------------------------------------------------------------- 1 | require_relative '../music_album' 2 | require_relative '../item' 3 | require_relative '../modules/music_album_module' 4 | 5 | RSpec.describe MusicAlbum do 6 | before(:each) do 7 | @genre_mock = double('Genre') 8 | @params = { 9 | publish_date: '10-10-2010', 10 | on_spotify: true, 11 | genre: @genre_mock 12 | } 13 | @music_album = MusicAlbum.new(@params) 14 | end 15 | 16 | describe '#initialize' do 17 | it 'correctly assigns values' do 18 | expect(@music_album.on_spotify).to eq(true) 19 | end 20 | end 21 | 22 | describe '#on_spotify?' do 23 | it 'returns the correct on_spotify value' do 24 | expect(@music_album.on_spotify?).to eq(true) 25 | end 26 | end 27 | 28 | describe '#can_be_archived?' do 29 | context 'when conditions are met' do 30 | it 'returns true' do 31 | allow(@music_album).to receive(:can_be_archived?).and_return(true) 32 | expect(@music_album.send(:can_be_archived?)).to eq(true) 33 | end 34 | end 35 | 36 | context 'when conditions are not met' do 37 | it 'returns false' do 38 | allow(@music_album).to receive(:can_be_archived?).and_return(false) 39 | expect(@music_album.send(:can_be_archived?)).to eq(false) 40 | end 41 | end 42 | end 43 | end 44 | -------------------------------------------------------------------------------- /item.rb: -------------------------------------------------------------------------------- 1 | require 'date' 2 | 3 | # Class representing an Item 4 | class Item 5 | attr_accessor :id, :genre, :author, :label, :publish_date 6 | 7 | def initialize(params = {}) 8 | @id = params[:id] || Random.rand(1..10_000) 9 | @genre = params[:genre] 10 | @author = params[:author] 11 | @label = params[:label] 12 | @publish_date = parse_date(params[:publish_date]) 13 | @archived = false 14 | end 15 | 16 | def move_to_archive 17 | @archived = true if can_be_archived? 18 | end 19 | 20 | def add_genre(genre) 21 | @genre = genre 22 | genre.items.push(self) unless genre.items.include?(self) 23 | end 24 | 25 | def add_author(author) 26 | @author = author 27 | author.items.push(self) unless author.items.include?(self) 28 | end 29 | 30 | def add_label(label) 31 | @label = label 32 | label.items.push(self) unless label.items.include?(self) 33 | end 34 | 35 | private 36 | 37 | attr_reader :archived 38 | 39 | def parse_date(date_string) 40 | return nil unless date_string 41 | 42 | begin 43 | Date.strptime(date_string, '%d-%m-%Y') 44 | rescue Date::Error 45 | # Silenciosamente establece la fecha de publicación a nil 46 | nil 47 | end 48 | end 49 | 50 | def can_be_archived? 51 | (Time.now.year - @publish_date.year > 10) 52 | end 53 | end 54 | -------------------------------------------------------------------------------- /schema.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE Label ( 2 | id INT PRIMARY KEY AUTO_INCREMENT, 3 | title VARCHAR(255), 4 | color VARCHAR(20) 5 | ); 6 | 7 | CREATE TABLE Genre ( 8 | id INT PRIMARY KEY AUTO_INCREMENT, 9 | name VARCHAR(255) 10 | ); 11 | 12 | 13 | CREATE TABLE Item ( 14 | id INT PRIMARY KEY AUTO_INCREMENT, 15 | genre_id INT, 16 | author_id INT, 17 | label_id INT, 18 | publish_date DATE, 19 | archived BOOLEAN, 20 | FOREIGN KEY (genre_id) REFERENCES Genre(id), 21 | FOREIGN KEY (author_id) REFERENCES Author(id), 22 | FOREIGN KEY (label_id) REFERENCES Label(id) 23 | ); 24 | 25 | CREATE TABLE Book ( 26 | item_id INT PRIMARY KEY, 27 | publisher VARCHAR(255), 28 | cover_state VARCHAR(50), 29 | FOREIGN KEY (item_id) REFERENCES Item(id) 30 | ); 31 | 32 | CREATE TABLE MusicAlbum ( 33 | item_id INT PRIMARY KEY, 34 | on_spotify BOOLEAN, 35 | ); 36 | 37 | 38 | CREATE TABLE Games ( 39 | id INT GENERATED ALWAYS AS IDENTITY, 40 | multiplayer BOOLEAN NOT NULL, 41 | last_payed_at DATE NOT NULL, 42 | PRIMARY KEY (id), 43 | FOREIGN KEY (item_id) REFERENCES Item(id) 44 | ); 45 | 46 | 47 | CREATE TABLE Author ( 48 | id INT GENERATED ALWAYS AS IDENTITY, 49 | first_name VARCHAR(50) NOT NULL, 50 | last_name VARCHAR(50) NOT NULL, 51 | items INTEGER, 52 | PRIMARY KEY (id) 53 | ); 54 | -------------------------------------------------------------------------------- /spec/music_album_module_spec.rb: -------------------------------------------------------------------------------- 1 | require_relative '../modules/music_album_module' 2 | require_relative '../music_album' 3 | require_relative '../genre' 4 | 5 | RSpec.describe MusicAlbumModule do 6 | describe '.add_music_album' do 7 | it 'adds a music album to the albums array' do 8 | albums = [] 9 | genres = [Genre.new(1, 'Rock'), Genre.new(2, 'Pop')] 10 | allow(described_class).to receive(:enter_publish_date).and_return('01-01-2022') 11 | allow(described_class).to receive(:on_spotify?).and_return(true) 12 | allow(described_class).to receive(:select_genre).with(genres).and_return(genres.first) 13 | 14 | described_class.add_music_album(albums, genres) 15 | 16 | expect(albums.size).to eq(1) 17 | expect(albums.first).to be_a(MusicAlbum) 18 | end 19 | 20 | it 'handles no genres available' do 21 | albums = [] 22 | genres = [] 23 | 24 | expect { described_class.add_music_album(albums, genres) } 25 | .to output("No genres available. Please add them first.\n").to_stdout 26 | expect(albums).to be_empty 27 | end 28 | end 29 | 30 | describe '.list_albums' do 31 | it 'lists the music albums' do 32 | albums = [MusicAlbum.new(publish_date: '01-01-2022', on_spotify: true, genre: Genre.new(1, 'Rock'))] 33 | 34 | expect { described_class.list_albums(albums) } 35 | .to output(/List of Music Albums:\n\d+\..+/).to_stdout 36 | end 37 | end 38 | end 39 | -------------------------------------------------------------------------------- /Gemfile.lock: -------------------------------------------------------------------------------- 1 | GEM 2 | specs: 3 | ast (2.4.2) 4 | base64 (0.1.1) 5 | diff-lcs (1.5.0) 6 | json (2.6.3) 7 | language_server-protocol (3.17.0.3) 8 | parallel (1.23.0) 9 | parser (3.2.2.3) 10 | ast (~> 2.4.1) 11 | racc 12 | racc (1.7.1) 13 | rainbow (3.1.1) 14 | regexp_parser (2.8.1) 15 | rexml (3.2.6) 16 | rspec (3.12.0) 17 | rspec-core (~> 3.12.0) 18 | rspec-expectations (~> 3.12.0) 19 | rspec-mocks (~> 3.12.0) 20 | rspec-core (3.12.2) 21 | rspec-support (~> 3.12.0) 22 | rspec-expectations (3.12.3) 23 | diff-lcs (>= 1.2.0, < 2.0) 24 | rspec-support (~> 3.12.0) 25 | rspec-mocks (3.12.5) 26 | diff-lcs (>= 1.2.0, < 2.0) 27 | rspec-support (~> 3.12.0) 28 | rspec-support (3.12.0) 29 | rubocop (1.56.1) 30 | base64 (~> 0.1.1) 31 | json (~> 2.3) 32 | language_server-protocol (>= 3.17.0) 33 | parallel (~> 1.10) 34 | parser (>= 3.2.2.3) 35 | rainbow (>= 2.2.2, < 4.0) 36 | regexp_parser (>= 1.8, < 3.0) 37 | rexml (>= 3.2.5, < 4.0) 38 | rubocop-ast (>= 1.28.1, < 2.0) 39 | ruby-progressbar (~> 1.7) 40 | unicode-display_width (>= 2.4.0, < 3.0) 41 | rubocop-ast (1.29.0) 42 | parser (>= 3.2.1.0) 43 | ruby-progressbar (1.13.0) 44 | unicode-display_width (2.4.2) 45 | 46 | PLATFORMS 47 | x86_64-darwin-22 48 | x86_64-linux 49 | 50 | DEPENDENCIES 51 | rspec (~> 3.0) 52 | rubocop (>= 1.0, < 2.0) 53 | 54 | BUNDLED WITH 55 | 2.4.19 56 | -------------------------------------------------------------------------------- /spec/book_module_spec.rb: -------------------------------------------------------------------------------- 1 | require_relative '../modules/book_module' 2 | require_relative '../book' 3 | require_relative '../label' 4 | 5 | RSpec.describe BookModule do 6 | before :each do 7 | @book = Book.new( 8 | publisher: 'Some Publisher', 9 | cover_state: 'good', 10 | id: 1, 11 | label: Label.new(1, 'Some Label', 'Red'), 12 | publish_date: '01-01-2021' 13 | ) 14 | 15 | @label = Label.new(1, 'Some Label', 'Red') 16 | @books = [@book] 17 | @labels = [@label] 18 | end 19 | 20 | describe '.list_books' do 21 | it 'prints the list of books' do 22 | expect { BookModule.list_books(@books) }.to output( 23 | /List of Books:.*1\. ID: \d+, Publisher: Some Publisher, Cover State: good, Label: Some Label/m 24 | ).to_stdout 25 | end 26 | end 27 | 28 | describe '.add_book' do 29 | before do 30 | allow(BookModule).to receive(:collect_attributes).and_return({ 31 | publisher: 'New Publisher', 32 | cover_state: 'bad', 33 | label: nil, 34 | publish_date: '01-01-2021' 35 | }) 36 | 37 | allow(BookModule).to receive(:collect_label_index).and_return(0) 38 | end 39 | 40 | it 'adds a book to the list' do 41 | expect { BookModule.add_book(@books, nil, nil, @labels) }.to change { @books.length }.from(1).to(2) 42 | end 43 | end 44 | end 45 | -------------------------------------------------------------------------------- /spec/label_module_spec.rb: -------------------------------------------------------------------------------- 1 | # spec/label_module_spec.rb 2 | require_relative '../modules/label_module' 3 | require_relative '../label' 4 | require_relative '../book' 5 | 6 | RSpec.describe LabelModule do 7 | before do 8 | @labels = [ 9 | Label.new('1', 'Label1', 'Red'), 10 | Label.new('2', 'Label2', 'Green') 11 | ] 12 | 13 | @book1 = double('Book') 14 | @book2 = double('Book') 15 | 16 | allow(@book1).to receive(:class).and_return(Book) 17 | allow(@book1).to receive(:id).and_return('1') 18 | allow(@book1).to receive(:label=) 19 | 20 | allow(@book2).to receive(:class).and_return(Book) 21 | allow(@book2).to receive(:id).and_return('2') 22 | allow(@book2).to receive(:label=) 23 | 24 | @label1 = @labels[0] 25 | @label2 = @labels[1] 26 | 27 | @label1.add_item(@book1) 28 | @label1.add_item(@book2) 29 | end 30 | 31 | describe '.list_labels' do 32 | # ... this test stays the same 33 | end 34 | 35 | describe '.add_label' do 36 | it 'adds a new label to the list' do 37 | allow(LabelModule).to receive(:label_title).and_return('NewLabel') 38 | allow(LabelModule).to receive(:label_color).and_return('NewColor') 39 | 40 | # Mocking Label.new to return a label double 41 | mock_label = double(Label, title: 'NewLabel', color: 'NewColor') 42 | 43 | # Stub the constructor for Label to return the mock_label 44 | allow(Label).to receive(:new).and_return(mock_label) 45 | 46 | expect { LabelModule.add_label(@labels) }.to change { @labels.count }.by(1) 47 | expect(@labels.last.title).to eq('NewLabel') 48 | expect(@labels.last.color).to eq('NewColor') 49 | end 50 | end 51 | end 52 | -------------------------------------------------------------------------------- /modules/book_module.rb: -------------------------------------------------------------------------------- 1 | module BookModule 2 | def self.list_books(books) 3 | puts 'List of Books:' 4 | books.each_with_index do |book, index| 5 | label_title = book.label ? book.label.title : 'N/A' 6 | puts "#{index + 1}. ID: #{book.id}, " \ 7 | "Publisher: #{book.publisher}, " \ 8 | "Cover State: #{book.cover_state}, " \ 9 | "Label: #{label_title}" 10 | end 11 | end 12 | 13 | def self.add_book(books, _genres, _authors, labels) 14 | attributes = collect_attributes 15 | selected_label_index = collect_label_index(labels) 16 | label = labels[selected_label_index] 17 | attributes[:label] = label 18 | 19 | book = Book.new(attributes) 20 | book.add_label(label) 21 | books << book 22 | puts 'Book successfully added.' 23 | end 24 | 25 | def self.collect_attributes 26 | { 27 | publisher: input('Enter the publisher:'), 28 | cover_state: cover_state_input, 29 | label: nil, 30 | publish_date: input('Enter the publish date (DD-MM-YYYY):') 31 | } 32 | end 33 | 34 | def self.input(prompt) 35 | puts prompt 36 | gets.chomp 37 | end 38 | 39 | def self.cover_state_input 40 | puts "Enter the cover state: 1 for 'good', 2 for 'bad'" 41 | loop do 42 | choice = gets.chomp 43 | return 'good' if choice == '1' 44 | return 'bad' if choice == '2' 45 | 46 | puts "Invalid input. Please enter 1 for 'good' or 2 for 'bad'." 47 | end 48 | end 49 | 50 | def self.collect_label_index(labels) 51 | puts 'Choose a Label:' 52 | labels.each_with_index do |label, index| 53 | puts "#{index + 1}. #{label.title}" 54 | end 55 | 56 | loop do 57 | choice = gets.chomp.to_i 58 | return choice - 1 if choice.between?(1, labels.length) 59 | 60 | puts "Invalid input. Please enter a number between 1 and #{labels.length}." 61 | end 62 | end 63 | end 64 | -------------------------------------------------------------------------------- /modules/label_module.rb: -------------------------------------------------------------------------------- 1 | module LabelModule 2 | def self.list_labels(labels) 3 | puts 'List of Labels:' 4 | labels.each_with_index do |label, index| 5 | puts "#{index + 1}. Title: #{label.title}, Color: #{label.color}" 6 | 7 | # List all the items associated with each label 8 | if label.items.empty? 9 | puts ' No items associated.' 10 | else 11 | puts ' Items associated:' 12 | label.items.each_with_index do |item, item_index| 13 | puts " #{item_index + 1}. Type: #{item.class.name}, ID: #{item.id}" 14 | 15 | # Print additional information based on the type of item 16 | case item 17 | when Book 18 | puts " Publisher: #{item.publisher}" 19 | puts " Cover State: #{item.cover_state}" 20 | end 21 | end 22 | end 23 | end 24 | end 25 | 26 | def self.add_label(labels) 27 | id = generate_id(labels) 28 | title = label_title 29 | color = label_color 30 | 31 | label = Label.new(id, title, color) 32 | labels << label 33 | puts 'Label successfully added.' 34 | end 35 | 36 | # Add a function to generate id 37 | def self.generate_id(labels) 38 | max_id = labels.map { |label| label.id.to_i }.max || 0 39 | (max_id + 1).to_s 40 | end 41 | 42 | def self.label_title 43 | puts 'Choose a Label title:' 44 | gets.chomp 45 | end 46 | 47 | def self.label_color 48 | puts 'Choose a Label color:' 49 | gets.chomp 50 | end 51 | 52 | def self.collect_label_index(labels) 53 | puts 'Choose a Label:' 54 | labels.each_with_index do |label, index| 55 | puts "#{index + 1}. #{label.title}" 56 | end 57 | 58 | loop do 59 | choice = gets.chomp.to_i 60 | return choice - 1 if choice.between?(1, labels.length) 61 | 62 | puts "Invalid input. Please enter a number between 1 and #{labels.length}." 63 | end 64 | end 65 | end 66 | -------------------------------------------------------------------------------- /modules/music_album_module.rb: -------------------------------------------------------------------------------- 1 | module MusicAlbumModule 2 | def self.add_music_album(albums, genres) 3 | if genres.empty? 4 | puts 'No genres available. Please add them first.' 5 | return 6 | end 7 | 8 | publish_date = enter_publish_date 9 | on_spotify = on_spotify? 10 | genre = select_genre(genres) 11 | 12 | album = MusicAlbum.new({ 13 | publish_date: publish_date, 14 | on_spotify: on_spotify, 15 | genre: genre 16 | }) 17 | 18 | albums << album 19 | puts 'Music Album successfully added.' 20 | end 21 | 22 | def self.enter_publish_date 23 | puts 'Enter the publish date (DD-MM-YYYY):' 24 | gets.chomp 25 | end 26 | 27 | def self.on_spotify? 28 | puts 'Is it on Spotify? (yes/no):' 29 | answer = gets.chomp 30 | %w[yes y].include?(answer) 31 | end 32 | 33 | def self.select_genre(genres) 34 | puts 'Select a genre by index:' 35 | genres.each_with_index do |genre, index| 36 | puts "#{index + 1}. #{genre.name}" 37 | end 38 | choice = gets.chomp.to_i 39 | genres[choice - 1] 40 | end 41 | 42 | def self.list_albums(albums) 43 | puts 'List of Music Albums:' 44 | albums.each_with_index do |album, index| 45 | puts "#{index + 1}. ID: #{album.id}, Genre: #{album.genre.name}, On Spotify: #{album.on_spotify}" 46 | end 47 | end 48 | 49 | def self.write_file(albums) 50 | albums_data = albums.map do |album| 51 | { 52 | 'id' => album.id, 53 | 'publish_date' => album.publish_date.strftime('%d-%m-%Y'), 54 | 'on_spotify' => album.on_spotify, 55 | 'genre' => album.genre.id 56 | } 57 | end 58 | File.write('music_albums.json', JSON.pretty_generate(albums_data)) 59 | end 60 | 61 | def self.read_file(genres) 62 | if File.exist?('music_albums.json') 63 | file = File.read('music_albums.json') 64 | JSON.parse(file).map do |album| 65 | music_album = MusicAlbum.new({ 66 | id: album['id'], 67 | publish_date: album['publish_date'], 68 | on_spotify: album['on_spotify'] 69 | }) 70 | music_album.genre = genres.find { |genre| genre.id == album['genre'] } 71 | music_album 72 | end 73 | else 74 | [] 75 | end 76 | end 77 | end 78 | -------------------------------------------------------------------------------- /app.rb: -------------------------------------------------------------------------------- 1 | require_relative 'book' 2 | require_relative 'modules/book_module' 3 | require_relative 'label' 4 | require_relative 'modules/label_module' 5 | require_relative 'music_album' 6 | require_relative 'modules/music_album_module' 7 | require_relative 'genre' 8 | require_relative 'modules/genre_module' 9 | require_relative 'modules/game_author_module' 10 | require_relative 'modules/make_json_game' 11 | require 'json' 12 | 13 | class App 14 | include Output 15 | include GameAuthor 16 | 17 | def initialize 18 | initialize_collections 19 | initialize_actions 20 | load_books_from_json 21 | @games = [] 22 | @authors = initialize_author 23 | @taked_games = [] 24 | end 25 | 26 | def run 27 | loop do 28 | display_menu 29 | choice = gets.chomp.to_i 30 | action = @actions[choice] 31 | if action 32 | action.call 33 | else 34 | puts 'Invalid choice.' 35 | end 36 | end 37 | end 38 | 39 | def find_label_by_title(title) 40 | @labels.find { |label| label.title == title } 41 | end 42 | 43 | private 44 | 45 | # Nueva función para cargar libros desde un archivo JSON 46 | def load_books_from_json(filename = 'books.json') 47 | return unless File.exist?(filename) 48 | 49 | data = JSON.parse(File.read(filename)) 50 | data.each do |book_data| 51 | book = Book.new( 52 | id: book_data['id'], 53 | title: book_data['title'], # Asegúrate de que esto esté en tus datos JSON 54 | publisher: book_data['publisher'], 55 | cover_state: book_data['cover_state'], 56 | publish_date: book_data['publish_date'], 57 | label: find_label_by_title(book_data['label']) 58 | ) 59 | @books << book 60 | end 61 | end 62 | 63 | def write_books_to_json(filename = 'books.json') 64 | books_data = @books.map do |book| 65 | { 66 | 'id' => book.id, 67 | 'publisher' => book.publisher, 68 | 'cover_state' => book.cover_state, 69 | 'publish_date' => book.publish_date, 70 | 'label' => book.label&.title 71 | } 72 | end 73 | 74 | File.write(filename, JSON.pretty_generate(books_data)) 75 | end 76 | 77 | def initialize_collections 78 | @books = [] 79 | @genres = initialize_genres 80 | @music_albums = MusicAlbumModule.read_file(@genres) 81 | @labels = initialize_labels 82 | end 83 | 84 | def initialize_actions 85 | @actions = { 86 | 1 => method(:add_book), 87 | 2 => method(:add_music_album), 88 | 3 => method(:add_game), 89 | 4 => method(:list_all_books), 90 | 5 => method(:list_all_music_albums), 91 | 6 => method(:list_all_games), 92 | 7 => method(:list_all_labels), 93 | 8 => method(:list_all_genres), 94 | 9 => method(:list_all_authors), 95 | 10 => method(:exit_app) 96 | } 97 | end 98 | 99 | def initialize_labels 100 | [ 101 | Label.new('1', 'New', 'Green'), 102 | Label.new('2', 'Older', 'Yellow'), 103 | Label.new('3', 'Gift', 'Red') 104 | ] 105 | end 106 | 107 | def initialize_genres 108 | [ 109 | Genre.new('1', 'Rock'), 110 | Genre.new('2', 'Jazz'), 111 | Genre.new('3', 'Classical') 112 | ] 113 | end 114 | 115 | def display_menu 116 | puts '1. Add Book' 117 | puts '2. Add Music Album' 118 | puts '3. Add Game' 119 | puts '4. List All Books' 120 | puts '5. List All Music Albums' 121 | puts '6. List All Games' 122 | puts '7. List All Labels' 123 | puts '8. List All Genres' 124 | puts '9. List All Authors' 125 | puts '10. Exit' 126 | end 127 | 128 | def exit_app 129 | puts 'Goodbye!' 130 | exit 131 | end 132 | 133 | def add_book 134 | if @labels.empty? 135 | puts 'No labels available. Please add a label first.' 136 | else 137 | BookModule.add_book(@books, @genres, @authors, @labels) 138 | write_books_to_json # Llama al método para guardar los libros en un archivo JSON 139 | end 140 | end 141 | 142 | def add_music_album 143 | if @labels.empty? || @genres.empty? 144 | puts 'No labels or genres available. Please add them first.' 145 | else 146 | MusicAlbumModule.add_music_album(@music_albums, @genres) 147 | MusicAlbumModule.write_file(@music_albums) 148 | end 149 | end 150 | 151 | def add_game 152 | arr = add_games 153 | @games.push(Game.new(arr[0], arr[1], arr[2], arr[3])) 154 | @taked_games.push({ multiplayer: arr[0], last_played_at: arr[1], publish_date: arr[2], author: arr[4] }) 155 | write_file(@taked_games, 'games.json') 156 | end 157 | 158 | def list_all_books 159 | BookModule.list_books(@books) 160 | end 161 | 162 | def list_all_music_albums 163 | MusicAlbumModule.list_albums(@music_albums) 164 | end 165 | 166 | def list_all_games 167 | read_file_game if @games == [] 168 | list_game 169 | end 170 | 171 | def list_all_labels 172 | LabelModule.list_labels(@labels) 173 | end 174 | 175 | def list_all_genres 176 | GenreModule.list_genres(@genres) 177 | end 178 | 179 | def list_all_authors 180 | list_author 181 | end 182 | end 183 | -------------------------------------------------------------------------------- /spec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | # This file was generated by the `rspec --init` command. Conventionally, all 2 | # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. 3 | # The generated `.rspec` file contains `--require spec_helper` which will cause 4 | # this file to always be loaded, without a need to explicitly require it in any 5 | # files. 6 | # 7 | # Given that it is always loaded, you are encouraged to keep this file as 8 | # light-weight as possible. Requiring heavyweight dependencies from this file 9 | # will add to the boot time of your test suite on EVERY test run, even for an 10 | # individual file that may not need all of that loaded. Instead, consider making 11 | # a separate helper file that requires the additional dependencies and performs 12 | # the additional setup, and require it from the spec files that actually need 13 | # it. 14 | # 15 | # See https://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration 16 | RSpec.configure do |config| 17 | # rspec-expectations config goes here. You can use an alternate 18 | # assertion/expectation library such as wrong or the stdlib/minitest 19 | # assertions if you prefer. 20 | config.expect_with :rspec do |expectations| 21 | # This option will default to `true` in RSpec 4. It makes the `description` 22 | # and `failure_message` of custom matchers include text for helper methods 23 | # defined using `chain`, e.g.: 24 | # be_bigger_than(2).and_smaller_than(4).description 25 | # # => "be bigger than 2 and smaller than 4" 26 | # ...rather than: 27 | # # => "be bigger than 2" 28 | expectations.include_chain_clauses_in_custom_matcher_descriptions = true 29 | end 30 | 31 | # rspec-mocks config goes here. You can use an alternate test double 32 | # library (such as bogus or mocha) by changing the `mock_with` option here. 33 | config.mock_with :rspec do |mocks| 34 | # Prevents you from mocking or stubbing a method that does not exist on 35 | # a real object. This is generally recommended, and will default to 36 | # `true` in RSpec 4. 37 | mocks.verify_partial_doubles = true 38 | end 39 | 40 | # This option will default to `:apply_to_host_groups` in RSpec 4 (and will 41 | # have no way to turn it off -- the option exists only for backwards 42 | # compatibility in RSpec 3). It causes shared context metadata to be 43 | # inherited by the metadata hash of host groups and examples, rather than 44 | # triggering implicit auto-inclusion in groups with matching metadata. 45 | config.shared_context_metadata_behavior = :apply_to_host_groups 46 | 47 | # The settings below are suggested to provide a good initial experience 48 | # with RSpec, but feel free to customize to your heart's content. 49 | # # This allows you to limit a spec run to individual examples or groups 50 | # # you care about by tagging them with `:focus` metadata. When nothing 51 | # # is tagged with `:focus`, all examples get run. RSpec also provides 52 | # # aliases for `it`, `describe`, and `context` that include `:focus` 53 | # # metadata: `fit`, `fdescribe` and `fcontext`, respectively. 54 | # config.filter_run_when_matching :focus 55 | # 56 | # # Allows RSpec to persist some state between runs in order to support 57 | # # the `--only-failures` and `--next-failure` CLI options. We recommend 58 | # # you configure your source control system to ignore this file. 59 | # config.example_status_persistence_file_path = "spec/examples.txt" 60 | # 61 | # # Limits the available syntax to the non-monkey patched syntax that is 62 | # # recommended. For more details, see: 63 | # # https://rspec.info/features/3-12/rspec-core/configuration/zero-monkey-patching-mode/ 64 | # config.disable_monkey_patching! 65 | # 66 | # # This setting enables warnings. It's recommended, but in some cases may 67 | # # be too noisy due to issues in dependencies. 68 | # config.warnings = true 69 | # 70 | # # Many RSpec users commonly either run the entire suite or an individual 71 | # # file, and it's useful to allow more verbose output when running an 72 | # # individual spec file. 73 | # if config.files_to_run.one? 74 | # # Use the documentation formatter for detailed output, 75 | # # unless a formatter has already been configured 76 | # # (e.g. via a command-line flag). 77 | # config.default_formatter = "doc" 78 | # end 79 | # 80 | # # Print the 10 slowest examples and example groups at the 81 | # # end of the spec run, to help surface which specs are running 82 | # # particularly slow. 83 | # config.profile_examples = 10 84 | # 85 | # # Run specs in random order to surface order dependencies. If you find an 86 | # # order dependency and want to debug it, you can fix the order by providing 87 | # # the seed, which is printed after each run. 88 | # # --seed 1234 89 | # config.order = :random 90 | # 91 | # # Seed global randomization in this process using the `--seed` CLI option. 92 | # # Setting this allows you to use `--seed` to deterministically reproduce 93 | # # test failures related to randomization by passing the same `--seed` value 94 | # # as the one that triggered the failure. 95 | # Kernel.srand config.seed 96 | end 97 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Catalog_Of_My_Things (Ruby Console App) 2 | 3 | ## 📗 Table of Contents 4 | 5 | - [Catalog\_Of\_My\_Things (Ruby Console App)](#catalog_of_my_things-ruby-console-app) 6 | - [📗 Table of Contents](#-table-of-contents) 7 | - [📖 Catalog\_Of\_My\_Things ](#-catalog_of_my_things-) 8 | - [🛠 Tech-stack ](#-tech-stack-) 9 | - [🛠 Built With ](#-built-with-) 10 | - [Key Features ](#key-features-) 11 | - [Presentation Video ](#video-demo-live) 12 | - [Future Features ](#future-features-) 13 | - [💻 Getting Started ](#-getting-started-) 14 | - [Setup ](#setup-) 15 | - [Prerequisites ](#prerequisites-) 16 | - [Usage ](#usage-) 17 | - [👥 Authors ](#-authors-) 18 | - [❓ FAQ ](#-faq-) 19 | - [🤝 Contributing ](#-contributing-) 20 | - [⭐️ Show Your Support ](#️-show-your-support-) 21 | - [📜 License ](#-license-) 22 | 23 | ## 📖 Catalog_Of_My_Things 24 | 25 | Welcome to the Catalog of My Things console app! This Ruby-based application allows you to manage collections of items you own, including books, music albums, movies, and games. You can keep track of various details about these items and perform tasks such as adding new items, listing items, and more. 26 | 27 | ## 🛠 Tech-stack 28 | 29 | This project is implemented using the Ruby programming language, known for its elegant syntax and flexibility. Ruby provides a suitable foundation for this Catalog of My Things code decoding project due to its ease of use and string manipulation capabilities. 30 | 31 | ## 🛠 Presentation Video 32 | 33 | [DemoVideo](https://drive.google.com/file/d/1df0qQwnMzH6Dl5KG98GtGVKKPHHHMISN/view?usp=sharing) 34 | 35 | 36 | ## 🛠 Built With 37 | 38 | This project is built using Ruby, a dynamic, open-source programming language known for its simplicity and productivity. Ruby's elegant syntax and powerful features make it a popular choice among developers. 39 | 40 | ## Key Features 41 | - [x] Implementation of functions using `def ...end` syntax. 42 | - [x] Display output using `puts ...`. 43 | - [x] Create classes using `class ...end` syntax. 44 | - [x] Preserve the data in `json` format. 45 | - [x] Retrieve data from the existing file and save to the their relavent arrays 46 | 47 | ## Future Features 48 | - User Authentication: Implement a user authentication system to allow multiple users to have their own catalogs and keep their data separate. 49 | - Search Functionality: Add a search feature that allows users to search for specific items in their catalog based on criteria such as title, author, or genre. 50 | - Data Export/Import: Provide the ability to export and import catalog data to and from CSV or other common formats for backup and sharing purposes. 51 | - Item Reviews: Allow users to leave reviews and ratings for items in their catalog, creating a personal rating system. 52 | 53 | ## 💻 Getting Started 54 | 55 | To get started with the Catalog of My Things app, follow the instructions below: 56 | 57 | ### Setup 58 | 59 | 1. Clone the project repository: 60 | bash 61 | git clone https://github.com/ClaudiaRojasSoto/Catalog_Of_My_Things.git 62 | 63 | 64 | 2. Navigate to the project folder: 65 | bash 66 | cd catalog_of_my_things 67 | 68 | 69 | ### Prerequisites 70 | 71 | To run the Catalog of My Things app, you'll need the following prerequisites: 72 | 73 | - An integrated development environment (IDE) like Visual Studio Code. 74 | - Ruby installed on your machine. 75 | - Git installed on your machine. 76 | - A GitHub account for version control. 77 | 78 | ## Usage 79 | 80 | Follow these steps to use the program: 81 | 82 | 1. Open your terminal. 83 | 2. Navigate to the directory where the program files are located using the `cd` command: 84 | 85 | bash 86 | cd /path/to/your/program/files 87 | 88 | 89 | 3. Start the Interactive Ruby (IRB) console by typing `irb` and pressing Enter: 90 | 91 | bash 92 | irb 93 | 94 | 95 | 4. Inside the IRB console, load the `main.rb` file to execute the program: 96 | 97 | ruby 98 | load 'main.rb' 99 | 100 | 101 | 5. The program will run, and you will see the main menu in the console, prompting you to choose an option. 102 | 103 | 6. Select an option by entering the corresponding number and follow any prompts for additional input. 104 | 105 | 7. Interact with the program as needed to perform tasks such as listing items, adding items, and more. 106 | 107 | That's it! You've successfully executed the program and can manage your catalog of items. 108 | 109 | ## 👥 Authors 110 | 111 | This project was developed by: 112 | 113 | 114 | 👤 **Claudia Rojas** 115 | - GitHub: [@ClaudiaRojas](https://github.com/ClaudiaRojasSoto) 116 | - LinkedIn: [@ClaudiaRojas](https://www.linkedin.com/in/claudia-rojas-soto/) 117 | 118 | 👤 **Pablo Bonasera** 119 | - GitHub: [@PabloBona](https://github.com/PabloBona) 120 | - LinkedIn: [@PabloBona](https://www.linkedin.com/in/pablo-bonasera/) 121 | 122 | 👤 **Franck Kalunga** 123 | - GitHub: [@FranckKalunga](https://github.com/) 124 | - LinkedIn: [@FranckKalunga](https://www.linkedin.com/in//) 125 | 126 | ## ❓ FAQ 127 | 128 | *Q: Is there a plan to add more features to this application?* 129 | A: Yes, the development team has plans to enhance this application's capabilities. One upcoming feature is to make the application executable via tactil, providing more convenience and accessibility to users. 130 | 131 | 132 | *Q: Where can I find more information about the Ruby programming language?* 133 | A: For more information about Ruby, its features, and its community, visit the official [Ruby website](https://www.ruby-lang.org/). 134 | 135 |
136 | 137 | ## 🤝 Contributing 138 | 139 | Contributions, issues, and feature requests are welcome! Feel free to check the [issues page](https://github.com/ClaudiaRojasSoto/Catalog_Of_My_Things/issues) and contribute to the project. 140 | 141 | ## ⭐️ Show Your Support 142 | 143 | If you find this project helpful, consider giving it a ⭐️ to show your support! 144 | 145 | ## 📜 License 146 | 147 | This project is licensed under the MIT License - you can click here to have more details [MIT](MIT.md). 148 | --------------------------------------------------------------------------------