Class: Slackdo::Task
- Inherits:
-
Object
- Object
- Slackdo::Task
- Defined in:
- lib/slackdo.rb
Instance Method Summary collapse
- #add_task ⇒ Object
- #get_category ⇒ Object
- #get_message ⇒ Object
- #get_notes ⇒ Object
- #set_category(cat) ⇒ Object
- #set_message(text) ⇒ Object
- #set_notes(notes) ⇒ Object
Instance Method Details
#add_task ⇒ Object
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
# File 'lib/slackdo.rb', line 139 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 cli_category = cli.ask 'What is the category of this new task? eg. DEV or GENERAL' = 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_category(cli_category) set_notes(cli_note) notifier.post text: "• [#{cli_category}] #{cli_message}", attachments: [note] puts 'Item was posted to Slack...' end |
#get_category ⇒ Object
124 125 126 |
# File 'lib/slackdo.rb', line 124 def get_category return $category end |
#get_message ⇒ Object
130 131 132 |
# File 'lib/slackdo.rb', line 130 def return end |
#get_notes ⇒ Object
136 137 138 |
# File 'lib/slackdo.rb', line 136 def get_notes return $note_content end |
#set_category(cat) ⇒ Object
121 122 123 |
# File 'lib/slackdo.rb', line 121 def set_category(cat) $category = cat end |
#set_message(text) ⇒ Object
127 128 129 |
# File 'lib/slackdo.rb', line 127 def (text) = text end |
#set_notes(notes) ⇒ Object
133 134 135 |
# File 'lib/slackdo.rb', line 133 def set_notes(notes) $note_content = notes end |