Class: Slackdo::Task

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

Instance Method Summary collapse

Instance Method Details

#add_taskObject



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_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(cli_message)
  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_categoryObject



124
125
126
# File 'lib/slackdo.rb', line 124

def get_category
  return $category
end

#get_messageObject



130
131
132
# File 'lib/slackdo.rb', line 130

def get_message
  return $message
end

#get_notesObject



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 set_message(text)
  $message = text
end

#set_notes(notes) ⇒ Object



133
134
135
# File 'lib/slackdo.rb', line 133

def set_notes(notes)
  $note_content = notes
end