Class: E4z::DevBot
- Inherits:
-
Object
- Object
- E4z::DevBot
- Defined in:
- lib/eezee_bot.rb
Instance Method Summary collapse
- #github_repo ⇒ Object
-
#initialize(path) ⇒ DevBot
constructor
A new instance of DevBot.
- #project_id ⇒ Object
- #project_slug ⇒ Object
- #run ⇒ Object
Constructor Details
Instance Method Details
#github_repo ⇒ Object
42 43 44 |
# 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 ⇒ Object
46 47 48 |
# 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 ⇒ Object
38 39 40 |
# File 'lib/eezee_bot.rb', line 38 def project_slug "project-#{project_id}" end |
#run ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# 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. end payload = { did_run: true } @eezee_client.update_instruction(project_id, instruction_id, payload) end end |