Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature-initial-config-addClassesFolder #25

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Tests

on: pull_request

jobs:
rspec:
name: RSpec
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/setup-ruby@v1
with:
ruby-version: 3.1.x
- name: Setup RSpec
run: |
[ -f Gemfile ] && bundle
gem install --no-document rspec -v '>=3.0, < 4.0'
- name: RSpec Report
run: rspec --force-color --format documentation
1 change: 1 addition & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ AllCops:
Exclude:
- "Guardfile"
- "Rakefile"
- 'classes/main.rb'
- "node_modules/**/*"

DisplayCopNames: true
Expand Down
6 changes: 3 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
source 'https://rubygems.org'

gem 'json', '~> 2.6'
gem 'rspec'
gem 'rubocop', '>= 1.0', '< 2.0'

gem 'rspec'
source 'https://rubygems.org'
1 change: 1 addition & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ PLATFORMS
x86_64-darwin-23

DEPENDENCIES
json (~> 2.6)
rspec
rubocop (>= 1.0, < 2.0)

Expand Down
41 changes: 41 additions & 0 deletions classes/item.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
class Item
attr_reader :id, :publish_date

def initialize(_publish_date, archived: true)
@id = Random.rand(1..1000)
@publish_date = date
@archived = archived
end

def genre=(genre)
@genre = genre
genre.add_item(self) unless genre.items.include?(self)
end

def author=(author)
@author = author
author.add_item(self) unless author.items.include?(self)
end

def source=(source)
@source = source
source.add_item(self) unless source.items.include?(self)
end

def label=(label)
@label = label
label.add_item(self) unless label.items.include?(self)
end

def move_to_archive
return unless can_be_archived?

@archived = true
end

private

def can_be_archived?
publish_date < 10.years.ago
end
end
45 changes: 45 additions & 0 deletions classes/main.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
def main
puts 'Welcome to the Catalog of my things App!'
puts '----------------------------------------'
loop do
puts 'Please select an option by entering a number:'
puts '1. List all books'
puts '2. List all music albums'
puts '3. List of games'
puts '4. List all labels'
puts '5. List all genres'
puts '6. List all authors'
puts '7. Add a book'
puts '8. Add a music album'
puts '9. Add a game'
puts '10. Exit'
options = gets.chomp.to_i
case options
when 1
puts 'List of all books'
when 2
puts 'List of all music albums'
when 3
puts 'List of all games'
when 4
puts 'List of all labels'
when 5
puts 'List of all genres'
when 6
puts 'List of all authors'
when 7
puts 'Add a book'
when 8
puts 'Add a music album'
when 9
puts 'Add a game'
when 10
puts 'Goodbye!'
break
else
puts 'Invalid option. Please try again.'
end
end
end

main
96 changes: 0 additions & 96 deletions spec/spec_helper.rb

This file was deleted.

Loading