Class: Github::Ext
- Inherits:
-
Object
- Object
- Github::Ext
- Defined in:
- lib/mushin_ext_github.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app = nil, opts = {}, params = {}) ⇒ Ext
constructor
A new instance of Ext.
Constructor Details
#initialize(app = nil, opts = {}, params = {}) ⇒ Ext
Returns a new instance of Ext.
9 10 11 12 13 |
# File 'lib/mushin_ext_github.rb', line 9 def initialize app=nil, opts={}, params={} @app = app @opts = opts @params = params end |
Instance Method Details
#call(env) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/mushin_ext_github.rb', line 14 def call env env ||= Hash.new case @opts[:cqrs] when :cqrs_query #inbound code @app.call(env) #outbound code when :cqrs_command #inbound code @client = Octokit::Client.new(:login => @opts[:auth_username], :password => @opts[:auth_password]) user = @client.user env[:login] = user.login #TODO in case of private repos the clone_url should be prefixed with a token and passed to other domain extenstions to handle the local work if !@params[:username].nil? && !@params[:reponame].nil? then @slug = @params[:username] + "/" + @params[:reponame] env[:slug] = @slug env[:repo_metadata] = @client.repo(@slug).to_h env[:clone_url] = @client.repo(@slug).clone_url elsif !@params[:slug].nil? then @slug = @params[:slug] env[:slug] = @slug env[:repo_metadata] = @client.repo(@slug).to_h env[:clone_url] = @client.repo(@slug).clone_url end @app.call(env) #outbound code else raise "you must specifiy if your cqrs call is command or query?" end end |