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

Improvements #9

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions configurations.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"db_path": "birthdays.yaml",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it makes more sense to change db_path to birthdays_path

"slack_url": "https://hooks.slack.com/...",
"channel_name": "general",
"greeting_message": "Happy birthday !",
Expand Down
3 changes: 1 addition & 2 deletions lib/birthday_bot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@
require 'birthday_reader'

class BirthdayBot
@@path = "birthdays.txt"

def initialize()
@config = ConfigReader.new
@config.load('configurations.json')
end

def start!
birthdays = BirthdayReader.get_birthdays(@@path)
birthdays = BirthdayReader.get_birthdays(@config.db_path)
today = Time.now

puts "Checking who was born today (#{today.to_s})"
Expand Down
4 changes: 3 additions & 1 deletion lib/config_reader.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
require 'json'

class ConfigReader
attr_accessor :slack_url,
attr_accessor :db_path,
:slack_url,
:channel_name,
:greeting_message,
:bot_name,
Expand All @@ -11,6 +12,7 @@ def load(filename)
if File.exist?(filename)
file = File.read(filename)
config = JSON.parse(file)
@db_path = config['db_path']
@slack_url = config['slack_url']
@channel_name = config['channel_name']
@greeting_message = config['greeting_message']
Expand Down