class E4z::DevBot
Public Class Methods
new(path)
click to toggle source
# File lib/eezee_bot.rb, line 9 def initialize(path) @git = Git.init(path) @working_dir = path @eezee_token = ENV['E4Z_TOKEN'] @eezee_client = ::E4z::ApiClient.new(@eezee_token) end
Public Instance Methods
github_repo()
click to toggle source
# File lib/eezee_bot.rb, line 42 def github_repo @github_repo ||= @git.remotes.find { |r| r.name == 'origin' }.url.match(/:(.+)\.git/)[1] end
project_id()
click to toggle source
# File lib/eezee_bot.rb, line 46 def project_id @project_id ||= @eezee_client.find_project_by_github_slug(github_repo)['id'] end
project_slug()
click to toggle source
# File lib/eezee_bot.rb, line 38 def project_slug "project-#{project_id}" end
run()
click to toggle source
# File lib/eezee_bot.rb, line 16 def run ::E4z::SocketClient.new(project_slug) do |data| instruction_id = JSON.parse(data)['instruction_id'] instruction = @eezee_client.get_instruction(project_id, instruction_id) data = instruction['data'] execute = instruction['execute'] puts "Running `#{execute}` with #{data}" begin OpenStruct.new(data).instance_eval(execute) rescue Exception => e puts "Err log data: #{data}" puts "Err log execute: #{execute}" puts e.message end payload = { did_run: true } @eezee_client.update_instruction(project_id, instruction_id, payload) end end