module TrelloDXY::Requests::Shared
Public Instance Methods
connect_to_trello()
click to toggle source
# File lib/trello_dxy/requests/shared.rb, line 6 def connect_to_trello Trello.configure do |config| config.developer_public_key = key config.member_token = token end end
get_key(key_name)
click to toggle source
# File lib/trello_dxy/requests/shared.rb, line 21 def get_key(key_name) make_dotfile key = '' File.open(ENV['HOME'] + '/.trello_dxy').read.each_line do |line| if line.start_with? key_name key = line.split('=').last.strip end end key end
key()
click to toggle source
# File lib/trello_dxy/requests/shared.rb, line 13 def key get_key 'TRELLO_DEVELOPER_PUBLIC_KEY' end
make_dotfile()
click to toggle source
# File lib/trello_dxy/requests/shared.rb, line 32 def make_dotfile current = {} dotfile_path = ENV['HOME'] + '/.trello_dxy' template_path = TrelloDXY::Utils.gem_libdir + '/templates/trello_dxy.erb' if File.exist? dotfile_path template = File.readlines(template_path) env = File.readlines(dotfile_path).each do |line| kv = line.chomp.split('=', 2) current[kv[0]] = kv[1] unless kv[1].nil? || kv[1].empty? end end trello_developer_public_key = current['TRELLO_DEVELOPER_PUBLIC_KEY'] || ask('Trello developer public key (visit https://trello.com/app-key): ') trello_member_token = current['TRELLO_MEMBER_TOKEN'] || ask("Trello member token (visit https://trello.com/1/connect?key=#{trello_developer_public_key}&name=trello_dxy&response_type=token): ") template_file = File.open(template_path, 'r').read erb = ERB.new(template_file) File.open(dotfile_path, 'w+') { |file| file.write(erb.result(binding)) } end
token()
click to toggle source
# File lib/trello_dxy/requests/shared.rb, line 17 def token get_key 'TRELLO_MEMBER_TOKEN' end