omg_pull_request 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/omg_pull_request/configuration.rb +0 -9
- data/lib/omg_pull_request/context.rb +0 -1
- data/lib/omg_pull_request/plugin.rb +37 -0
- data/lib/omg_pull_request/test_runner.rb +12 -20
- data/lib/omg_pull_request/version.rb +1 -1
- data/lib/omg_pull_request.rb +1 -0
- metadata +16 -17
- data/test/units/omg_pull_request/configuration_test.rb +0 -39
@@ -37,15 +37,6 @@ module OmgPullRequest
|
|
37
37
|
file
|
38
38
|
end
|
39
39
|
|
40
|
-
def plugins
|
41
|
-
return @plugins if @plugins
|
42
|
-
p = self.config['plugins'] || ''
|
43
|
-
|
44
|
-
@plugins = p.split(',').map(&:constantize).collect do |klass|
|
45
|
-
klass.new({ :options => config }.with_indifferent_access)
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
40
|
def omg_dir
|
50
41
|
File.join(local_repo, '.omgprrc')
|
51
42
|
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'singleton'
|
2
|
+
|
3
|
+
module OmgPullRequest
|
4
|
+
class Plugin
|
5
|
+
def self.initialize(&block)
|
6
|
+
ActiveSupport::Notifications.subscribe("omgpr:initialize") do |*args|
|
7
|
+
event = ActiveSupport::Notifications::Event.new(*args)
|
8
|
+
block.call(event.payload)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.subscribe(method, &block)
|
13
|
+
ActiveSupport::Notifications.subscribe("omgpr:#{method}") do |*args|
|
14
|
+
event = ActiveSupport::Notifications::Event.new(*args)
|
15
|
+
block.call(event.payload)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.instrument(event, args)
|
20
|
+
Plugin::Instrumenter.instance.instrument(event, args)
|
21
|
+
end
|
22
|
+
|
23
|
+
class Instrumenter
|
24
|
+
include Singleton
|
25
|
+
|
26
|
+
def initialize
|
27
|
+
Plugin.initialize do |attributes|
|
28
|
+
@attributes = attributes
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def instrument(event, args)
|
33
|
+
ActiveSupport::Notifications.instrument("omgpr:#{event}", (@attributes || {}).merge(args))
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
module OmgPullRequest
|
2
|
+
|
2
3
|
module TestRunner
|
3
4
|
|
4
5
|
def self.start_daemon(configuration=Configuration.new, daemonize=true)
|
@@ -11,23 +12,19 @@ module OmgPullRequest
|
|
11
12
|
:github_wrapper => github_wrapper
|
12
13
|
)
|
13
14
|
|
14
|
-
|
15
|
+
Plugin.instrument("initialize",
|
16
|
+
:configuration => configuration,
|
17
|
+
:github_wrapper => github_wrapper
|
18
|
+
)
|
15
19
|
|
16
20
|
while(true)
|
17
21
|
begin
|
18
|
-
pull_requests
|
19
|
-
|
20
|
-
|
22
|
+
pull_requests = github_wrapper.pull_requests
|
23
|
+
|
24
|
+
CONTEXT.get_recently_closed(pull_requests).each do |closed|
|
21
25
|
pr = github_wrapper.find_pull_request(closed)
|
22
|
-
|
23
|
-
|
24
|
-
plugins.each do |plugin|
|
25
|
-
if merged && plugin.respond_to?(:pull_request_merged)
|
26
|
-
plugin.pull_request_merged(pr)
|
27
|
-
elsif !merged && plugin.respond_to?(:pull_request_closed)
|
28
|
-
plugin.pull_request_closed(pr)
|
29
|
-
end
|
30
|
-
end
|
26
|
+
event = pr.merged ? 'merged' : 'closed'
|
27
|
+
Plugin.instrument(event, :pull_request => pr)
|
31
28
|
end
|
32
29
|
|
33
30
|
pull_requests.each do |pr|
|
@@ -39,13 +36,8 @@ module OmgPullRequest
|
|
39
36
|
)
|
40
37
|
next if CONTEXT.ran?(runner.request_sha)
|
41
38
|
CONTEXT.ran(runner.request_sha)
|
42
|
-
|
43
|
-
|
44
|
-
if plugin.respond_to?(:test_run)
|
45
|
-
plugin.test_run(pr)
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
39
|
+
|
40
|
+
Plugin.instrument("run", :pull_request => pr)
|
49
41
|
runner.run
|
50
42
|
end
|
51
43
|
|
data/lib/omg_pull_request.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: omg_pull_request
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -16,7 +16,7 @@ date: 2012-12-18 00:00:00.000000000 Z
|
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: aws-s3
|
19
|
-
requirement: &
|
19
|
+
requirement: &70129346855720 !ruby/object:Gem::Requirement
|
20
20
|
none: false
|
21
21
|
requirements:
|
22
22
|
- - ! '>='
|
@@ -24,10 +24,10 @@ dependencies:
|
|
24
24
|
version: 0.6.3
|
25
25
|
type: :runtime
|
26
26
|
prerelease: false
|
27
|
-
version_requirements: *
|
27
|
+
version_requirements: *70129346855720
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: faraday
|
30
|
-
requirement: &
|
30
|
+
requirement: &70129346854780 !ruby/object:Gem::Requirement
|
31
31
|
none: false
|
32
32
|
requirements:
|
33
33
|
- - ! '>='
|
@@ -35,10 +35,10 @@ dependencies:
|
|
35
35
|
version: 0.8.4
|
36
36
|
type: :runtime
|
37
37
|
prerelease: false
|
38
|
-
version_requirements: *
|
38
|
+
version_requirements: *70129346854780
|
39
39
|
- !ruby/object:Gem::Dependency
|
40
40
|
name: github_api
|
41
|
-
requirement: &
|
41
|
+
requirement: &70129346874260 !ruby/object:Gem::Requirement
|
42
42
|
none: false
|
43
43
|
requirements:
|
44
44
|
- - ! '>='
|
@@ -46,10 +46,10 @@ dependencies:
|
|
46
46
|
version: 0.8.2
|
47
47
|
type: :runtime
|
48
48
|
prerelease: false
|
49
|
-
version_requirements: *
|
49
|
+
version_requirements: *70129346874260
|
50
50
|
- !ruby/object:Gem::Dependency
|
51
51
|
name: uuid
|
52
|
-
requirement: &
|
52
|
+
requirement: &70129346873600 !ruby/object:Gem::Requirement
|
53
53
|
none: false
|
54
54
|
requirements:
|
55
55
|
- - ! '>='
|
@@ -57,10 +57,10 @@ dependencies:
|
|
57
57
|
version: 2.3.5
|
58
58
|
type: :runtime
|
59
59
|
prerelease: false
|
60
|
-
version_requirements: *
|
60
|
+
version_requirements: *70129346873600
|
61
61
|
- !ruby/object:Gem::Dependency
|
62
62
|
name: rake
|
63
|
-
requirement: &
|
63
|
+
requirement: &70129346872860 !ruby/object:Gem::Requirement
|
64
64
|
none: false
|
65
65
|
requirements:
|
66
66
|
- - ! '>='
|
@@ -68,10 +68,10 @@ dependencies:
|
|
68
68
|
version: 0.9.2.2
|
69
69
|
type: :runtime
|
70
70
|
prerelease: false
|
71
|
-
version_requirements: *
|
71
|
+
version_requirements: *70129346872860
|
72
72
|
- !ruby/object:Gem::Dependency
|
73
73
|
name: activesupport
|
74
|
-
requirement: &
|
74
|
+
requirement: &70129346872360 !ruby/object:Gem::Requirement
|
75
75
|
none: false
|
76
76
|
requirements:
|
77
77
|
- - ! '>='
|
@@ -79,10 +79,10 @@ dependencies:
|
|
79
79
|
version: 3.1.0
|
80
80
|
type: :runtime
|
81
81
|
prerelease: false
|
82
|
-
version_requirements: *
|
82
|
+
version_requirements: *70129346872360
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: i18n
|
85
|
-
requirement: &
|
85
|
+
requirement: &70129346871800 !ruby/object:Gem::Requirement
|
86
86
|
none: false
|
87
87
|
requirements:
|
88
88
|
- - ! '>='
|
@@ -90,7 +90,7 @@ dependencies:
|
|
90
90
|
version: 0.6.0
|
91
91
|
type: :runtime
|
92
92
|
prerelease: false
|
93
|
-
version_requirements: *
|
93
|
+
version_requirements: *70129346871800
|
94
94
|
description: Have tests run automatically for your Github Pull Request
|
95
95
|
email:
|
96
96
|
- kenmazaika@gmail.com
|
@@ -112,6 +112,7 @@ files:
|
|
112
112
|
- lib/omg_pull_request/github_wrapper.rb
|
113
113
|
- lib/omg_pull_request/lolcommits.rb
|
114
114
|
- lib/omg_pull_request/notifications.rb
|
115
|
+
- lib/omg_pull_request/plugin.rb
|
115
116
|
- lib/omg_pull_request/prowl.rb
|
116
117
|
- lib/omg_pull_request/storage/aws.rb
|
117
118
|
- lib/omg_pull_request/storage/gist.rb
|
@@ -140,7 +141,6 @@ files:
|
|
140
141
|
- test/mocks/pull_request.rb
|
141
142
|
- test/omg_pull_request/.gitkeep
|
142
143
|
- test/test_helper.rb
|
143
|
-
- test/units/omg_pull_request/configuration_test.rb
|
144
144
|
- test/units/omg_pull_request/context_test.rb
|
145
145
|
- test/units/omg_pull_request/git_client_test.rb
|
146
146
|
- test/units/omg_pull_request/github_wrapper_test.rb
|
@@ -190,7 +190,6 @@ test_files:
|
|
190
190
|
- test/mocks/pull_request.rb
|
191
191
|
- test/omg_pull_request/.gitkeep
|
192
192
|
- test/test_helper.rb
|
193
|
-
- test/units/omg_pull_request/configuration_test.rb
|
194
193
|
- test/units/omg_pull_request/context_test.rb
|
195
194
|
- test/units/omg_pull_request/git_client_test.rb
|
196
195
|
- test/units/omg_pull_request/github_wrapper_test.rb
|
@@ -1,39 +0,0 @@
|
|
1
|
-
require './test/test_helper.rb'
|
2
|
-
|
3
|
-
module OmgPullRequest
|
4
|
-
class ConfigurationTest < MiniTest::Unit::TestCase
|
5
|
-
def test_plugins
|
6
|
-
conf = { 'plugins' => 'OmgPullRequest::ConfigurationTest::MockPlugin1,OmgPullRequest::ConfigurationTest::MockPlugin2' }
|
7
|
-
|
8
|
-
configuration = OmgPullRequest::Configuration.new('config' => conf)
|
9
|
-
plugins = configuration.plugins
|
10
|
-
|
11
|
-
plugins.each do |plugin|
|
12
|
-
assert_equal({:options => conf }.with_indifferent_access, plugin.attributes)
|
13
|
-
assert_equal('mock_plugin_yeah', plugin.to_s)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
class MockPlugin1
|
18
|
-
attr_accessor :attributes
|
19
|
-
def initialize(attributes=Hash.new)
|
20
|
-
self.attributes = attributes
|
21
|
-
end
|
22
|
-
|
23
|
-
def to_s
|
24
|
-
"mock_plugin_yeah"
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
class MockPlugin2
|
29
|
-
attr_accessor :attributes
|
30
|
-
def initialize(attributes=Hash.new)
|
31
|
-
self.attributes = attributes
|
32
|
-
end
|
33
|
-
|
34
|
-
def to_s
|
35
|
-
"mock_plugin_yeah"
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|