Class: ConvoreSimple::Topic

Inherits:
Object
  • Object
show all
Defined in:
lib/convore-simple.rb

Class Method Summary collapse

Class Method Details

.say(message) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/convore-simple.rb', line 5

def self.say(message)
  user  = `git config user.convore`.chomp
  topic = `git config convore.topic`.chomp
  err   = "error: can't set git config"
  if user.empty?
    puts "Setting convore username (git config user.convore <username>)."
    print "Enter username: "
    user = gets.chomp
    puts err unless system("git config user.convore #{user}")
  end
  if topic.empty?
    puts "Setting convore topic id number (git config convore.topic <id>)."
    print "Enter topic id number: "
    topic = gets.chomp
    puts err unless system("git config convore.topic #{topic}")
  end
  url   = "https://convore.com/api/topics/#{topic}/messages/create.json"
  return `echo "#{message}" | curl -u "#{user}" -F message="<-" #{url}`
end