mushin_ext_github 0.1.0 → 0.2.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2983aafb781fa5ad94196faa0d82589492e5cf93
4
- data.tar.gz: 201ae63794c299319cedaa90c3caf5aada784235
3
+ metadata.gz: 20da49b6e6d93c4c1202fc3611e18fe60dcf3ace
4
+ data.tar.gz: 95e0a341d36a68627a782be2f3f65d175e07cbb1
5
5
  SHA512:
6
- metadata.gz: 13f7b405402d17c013a8e2f07202408de678d59e593016573517d888ca7533fa8b1bb14ed7ca14d8c37fdd7cf451654a8d5d2daab8a9791e41d7468d68278c00
7
- data.tar.gz: 7cd1e3b8920afa6ced278e6ecdc14a47b1ba7affac36fdf2341c8301c5bc8fb268c74e8c0dade9720569a0048f70059ceb38920bb2e7eeb6bbba8670729b58ec
6
+ metadata.gz: 0a2dcefba04c954cdfc5c398d56b7adf8700972b6fbfc5e6d6598af6840f5b5803a772d6b98de2026ba0d6cb90719d830e9686a90975cd0f800e70104154a008
7
+ data.tar.gz: 7c55779027cd6cb5f4cd3fa9f5752f2643b50521a69cf4502eb2275c6f8d676a27f0617cbc577ca546104aab97a6967c84b684b5ed95a9fdd5934b4835d95908
data/.gitignore CHANGED
@@ -7,3 +7,5 @@
7
7
  /pkg/
8
8
  /spec/reports/
9
9
  /tmp/
10
+ /DATA/
11
+ *.yml
data/Github.gemspec CHANGED
@@ -33,6 +33,6 @@ Gem::Specification.new do |spec|
33
33
  spec.add_development_dependency "bundler", "~> 1.13"
34
34
  spec.add_development_dependency "rake", "~> 10.0"
35
35
  spec.add_development_dependency "minitest", "~> 5.0"
36
- spec.add_dependency 'mushin'
36
+ spec.add_dependency 'mushin'
37
+ spec.add_dependency "octokit", "~> 4.0"
37
38
  end
38
-
@@ -1,3 +1,3 @@
1
1
  module Github
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -1,27 +1,48 @@
1
- require 'mushin'
2
- require_relative 'Github/version'
3
-
1
+ require 'mushin'
2
+ require 'octokit'
3
+ require_relative 'Github/version'
4
4
 
5
5
  module Github
6
- class Ext
7
- using Mushin::Ext
6
+ class Ext
7
+ using Mushin::Ext
8
8
 
9
- def initialize app=nil, opts={}, params={}
10
- @app = app
11
- @opts = opts
12
- @params = params
13
- end
14
- def call env
15
- env ||= Hash.new
16
- # write inbound code
17
- if @opts[:cqrs] == :cqrs_query then
18
- # write your code here if it is a cqrs query
19
- else
20
- # write your code here if it is a cqrs command
21
- end
22
- @app.call(env)
23
- # write outbound code
9
+ def initialize app=nil, opts={}, params={}
10
+ @app = app
11
+ @opts = opts
12
+ @params = params
13
+ end
14
+ def call env
15
+ env ||= Hash.new
16
+
17
+ case @opts[:cqrs]
18
+ when :cqrs_query
19
+ #inbound code
20
+ @app.call(env)
21
+ #outbound code
22
+ when :cqrs_command
23
+ #inbound code
24
+ @client = Octokit::Client.new(:login => @opts[:auth_username], :password => @opts[:auth_password])
25
+ user = @client.user
26
+ env[:login] = user.login
27
+
28
+ #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
29
+ if !@params[:username].nil? && !@params[:reponame].nil? then
30
+ @slug = @params[:username] + "/" + @params[:reponame]
31
+ env[:slug] = @slug
32
+ env[:repo_metadata] = @client.repo(@slug).to_h
33
+ env[:clone_url] = @client.repo(@slug).clone_url
34
+ elsif !@params[:slug].nil? then
35
+ @slug = @params[:slug]
36
+ env[:slug] = @slug
37
+ env[:repo_metadata] = @client.repo(@slug).to_h
38
+ env[:clone_url] = @client.repo(@slug).clone_url
24
39
  end
40
+ @app.call(env)
41
+ #outbound code
42
+ else
43
+ raise "you must specifiy if your cqrs call is command or query?"
25
44
  end
45
+ end
46
+ end
26
47
 
27
48
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mushin_ext_github
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - zotherstupidguy
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: octokit
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '4.0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '4.0'
69
83
  description: a mushin-ext for github
70
84
  email:
71
85
  - zotherstupidguy@gmail.com