Class: Tutter
- Inherits:
-
Sinatra::Base
- Object
- Sinatra::Base
- Tutter
- Defined in:
- lib/tutter.rb
Instance Method Summary collapse
-
#get_project_settings(project) ⇒ Object
Return project settings from config.
- #try_action(event, data) ⇒ Object
Instance Method Details
#get_project_settings(project) ⇒ Object
Return project settings from config
26 27 28 29 30 31 |
# File 'lib/tutter.rb', line 26 def get_project_settings project settings.config['projects'].each do |p| return p if p['name'] == project end false end |
#try_action(event, data) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/tutter.rb', line 33 def try_action event, data project = data['repository']['full_name'] || error(400, 'Bad request') conf = get_project_settings(project) || error(404, 'Project does not exist in tutter.conf') # Setup octokit endpoints Octokit.configure do |c| c.api_endpoint = conf['github_api_endpoint'] c.web_endpoint = conf['github_site'] end if conf['access_token_env_var'] access_token = ENV[conf['access_token_env_var']] || '' else access_token = conf['access_token'] || '' end client = Octokit::Client.new :access_token => access_token # Load action action = Action.create(conf['action'], conf['action_settings'], client, project, event, data) status_code, = action.run return status_code, end |