eezee_bot 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b91ec179fb55dff9e1f2bf0df54268a3d5d0e97a
4
+ data.tar.gz: 6bec1de8c34db596ff21411f2be518d25f64c0ba
5
+ SHA512:
6
+ metadata.gz: 7d19c7f8853ce641b17e0183854c2c24fc500c774ae72578fb1e8c4b4e018fd9be8ae3ba2ebd4e52342fb4a8624acfa27936443fcc5200ffa86ba9d68c8f3f2b
7
+ data.tar.gz: 13df1dda6a6678b1fef1b7494aec39a5629d820a8ffacc214c8129a95888a03bfb59bbfc4cdf2233b06288f83ebd7dd8e6405c50823369254b89b13de47c980e
@@ -0,0 +1,5 @@
1
+
2
+ #!/usr/bin/env ruby
3
+
4
+ require 'eezee_bot'
5
+ E4z::DevBot.new(Dir.pwd).run
@@ -0,0 +1,29 @@
1
+ require 'httparty'
2
+ module E4z
3
+ class ApiClient
4
+ include HTTParty
5
+ dev = 'http://nlp-playground-137981.nitrousapp.com:3000/'
6
+ prod = 'http://eezee.org'
7
+ base_uri prod
8
+
9
+ def initialize(token)
10
+ @token = token
11
+ end
12
+
13
+ def find_project_by_github_slug(github_slug)
14
+ self.class.get("/projects/find.json", options(by: 'github_full_name', value: github_slug))
15
+ end
16
+
17
+ def get_instruction(project_id, instruction_id)
18
+ self.class.get("/projects/#{project_id}/instructions/#{instruction_id}", options)
19
+ end
20
+
21
+ def update_instruction(project_id, instruction_id, body)
22
+ self.class.patch("/projects/#{project_id}/instructions/#{instruction_id}", options({}, body))
23
+ end
24
+
25
+ def options(params={}, body={})
26
+ {query: {github_token: @token}.merge(params), body: body}
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,50 @@
1
+ require 'ostruct'
2
+ require 'cgi'
3
+ require 'git'
4
+ require 'socket_client'
5
+ require 'eezee_api'
6
+
7
+ module E4z
8
+ class DevBot
9
+ def initialize(path)
10
+ @git = Git.init(path)
11
+ @working_dir = path
12
+ @eezee_token = ENV['E4Z_TOKEN']
13
+ @eezee_client = ::E4z::ApiClient.new(@eezee_token)
14
+ end
15
+
16
+ def run
17
+ ::E4z::SocketClient.new(project_slug) do |data|
18
+ instruction_id = JSON.parse(data)['instruction_id']
19
+ instruction = @eezee_client.get_instruction(project_id, instruction_id)
20
+ data = instruction['data']
21
+ execute = instruction['execute']
22
+
23
+ puts "Running `#{execute}` with #{data}"
24
+
25
+ begin
26
+ OpenStruct.new(data).instance_eval(execute)
27
+ rescue Exception => e
28
+ puts "Err log data: #{data}"
29
+ puts "Err log execute: #{execute}"
30
+ puts e.message
31
+ end
32
+
33
+ payload = { did_run: true }
34
+ @eezee_client.update_instruction(project_id, instruction_id, payload)
35
+ end
36
+ end
37
+
38
+ def project_slug
39
+ "project-#{project_id}"
40
+ end
41
+
42
+ def github_repo
43
+ @github_repo ||= @git.remotes.find { |r| r.name == 'origin' }.url.match(/:(.+)\.git/)[1]
44
+ end
45
+
46
+ def project_id
47
+ @project_id ||= @eezee_client.find_project_by_github_slug(github_repo)['id']
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,24 @@
1
+ require 'pusher-client'
2
+
3
+ module E4z
4
+ class SocketClient
5
+ def initialize(project_slug)
6
+ @project_slug = project_slug
7
+
8
+ socket.subscribe(@project_slug)
9
+ socket[@project_slug].bind('run_instruction') do |data|
10
+ yield(data)
11
+ end
12
+
13
+ socket.connect
14
+ end
15
+
16
+ def options
17
+ { secure: true }
18
+ end
19
+
20
+ def socket
21
+ @socket ||= PusherClient::Socket.new(ENV['PUSHER_TOKEN'], options)
22
+ end
23
+ end
24
+ end
metadata ADDED
@@ -0,0 +1,90 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: eezee_bot
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Manuel Arno Korfmann
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-11-02 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: pusher-client
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '='
18
+ - !ruby/object:Gem::Version
19
+ version: 0.6.2
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '='
25
+ - !ruby/object:Gem::Version
26
+ version: 0.6.2
27
+ - !ruby/object:Gem::Dependency
28
+ name: git
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '='
32
+ - !ruby/object:Gem::Version
33
+ version: 1.2.9.1
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '='
39
+ - !ruby/object:Gem::Version
40
+ version: 1.2.9.1
41
+ - !ruby/object:Gem::Dependency
42
+ name: httparty
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '='
46
+ - !ruby/object:Gem::Version
47
+ version: 0.13.7
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '='
53
+ - !ruby/object:Gem::Version
54
+ version: 0.13.7
55
+ description: Executes your eezee instructions on your local machine!
56
+ email: manu@@korfmann.info
57
+ executables:
58
+ - eezee_bot
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - bin/eezee_bot
63
+ - lib/eezee_api.rb
64
+ - lib/eezee_bot.rb
65
+ - lib/socket_client.rb
66
+ homepage: http://eezee.org
67
+ licenses:
68
+ - MIT
69
+ metadata: {}
70
+ post_install_message:
71
+ rdoc_options: []
72
+ require_paths:
73
+ - lib
74
+ required_ruby_version: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ required_rubygems_version: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ requirements: []
85
+ rubyforge_project:
86
+ rubygems_version: 2.4.3
87
+ signing_key:
88
+ specification_version: 4
89
+ summary: eeZee bot for local dev
90
+ test_files: []