Class: Slackdo::Config
- Inherits:
-
Object
- Object
- Slackdo::Config
- Defined in:
- lib/slackdo.rb
Instance Method Summary collapse
Instance Method Details
#configure_init ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/slackdo.rb', line 9 def configure_init system "mkdir #{ENV['HOME']}/.slackdo &> /dev/null" unless File.exist?("#{ENV['HOME']}/.slackdo/config.json") system "touch #{ENV['HOME']}/.slackdo/config.json" hash = { "slack_webhook" => "", "allow_trello_pushing" => "false", "trello_public_key" => "", "trello_member_token" => "", "trello_list_id" => "" } File.open("#{ENV['HOME']}/.slackdo/config.json",'w') do |f| f.write(hash.to_json) end end end |
#configure_slack_webhook ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/slackdo.rb', line 41 def configure_slack_webhook cli = HighLine.new file = File.read("#{ENV['HOME']}/.slackdo/config.json") hash = JSON.parse(file) webhook = cli.ask 'What is your Slack webhook?'.strip hash["slack_webhook"] = webhook File.open("#{ENV['HOME']}/.slackdo/config.json",'w') do |f| f.write(hash.to_json) end puts 'Slack API was configured...' end |
#configure_trello_api ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/slackdo.rb', line 25 def configure_trello_api cli = HighLine.new file = File.read("#{ENV['HOME']}/.slackdo/config.json") hash = JSON.parse(file) public_key = cli.ask 'What is your Trello public key?'.strip member_token = cli.ask 'What is your Trello member token?'.strip list_id = cli.ask 'What is your board list ID where the cards should be created?'.strip hash["trello_public_key"] = public_key hash["trello_member_token"] = member_token hash["allow_trello_pushing"] = "true" hash["trello_list_id"] = list_id File.open("#{ENV['HOME']}/.slackdo/config.json",'w') do |f| f.write(hash.to_json) end puts 'Trello API was configured...' end |