Class: Slackdo::Task

Inherits:
Object
  • Object
show all
Defined in:
lib/slackdo.rb

Instance Method Summary collapse

Instance Method Details

#add_taskObject



93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# File 'lib/slackdo.rb', line 93

def add_task
  file = File.read("#{ENV['HOME']}/.slackdo/config.json")
     hash = JSON.parse(file)
  webhook = hash['slack_webhook']
     notifier = Slack::Notifier.new webhook
     cli = HighLine.new
  category = cli.ask 'What is the category of this new task? eg. DEV or GENERAL'
     cli_message = cli.ask 'Type your new task:'
     want_note = cli.ask 'Do you want to add a note to this new task? y/n'
     cli_note = ''
     while want_note == 'y'
       note_text = cli.ask 'Type your note:'
       cli_note << "\n`- #{note_text}`"
       want_note = cli.ask 'Do you want to add another note to the task? y/n'
     end
     note = {
         fallback: "This should've been a new note but looks like something went wrong...",
         text: cli_note,
         color: "gray",
         mrkdwn_in: ["text"]
     }
  set_message("[#{category}] #{cli_message}")
  set_notes(cli_note)
     notifier.post text: "• [#{category}] #{cli_message}", attachments: [note]
  puts 'Item was posted to Slack...'
end

#get_messageObject



87
88
89
# File 'lib/slackdo.rb', line 87

def get_message
  return $message
end

#get_notesObject



90
91
92
# File 'lib/slackdo.rb', line 90

def get_notes
  return $note_content
end

#set_message(text) ⇒ Object



81
82
83
# File 'lib/slackdo.rb', line 81

def set_message(text)
  $message = text
end

#set_notes(notes) ⇒ Object



84
85
86
# File 'lib/slackdo.rb', line 84

def set_notes(notes)
  $note_content = notes
end