fourchette 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a81c926b6fccb25d10111bbd826e6f12ac1b4925
4
- data.tar.gz: b99d9faac8fc580772d1c5e45517343b9ae07427
3
+ metadata.gz: 8c9f8cf3c1ab81a0d6e9dccfe8bcdc3c514e63cb
4
+ data.tar.gz: e45ab1fae384d7d27177547d22f5bcaf45a4df79
5
5
  SHA512:
6
- metadata.gz: 486ac1c0d082e82aab0483acb3acfa34abbbc339c916962fa0bb38c1ef8a01299a9ece417bf3b526bf4f52d9abd06b780415f002e60fd83da721fb39f314f965
7
- data.tar.gz: e833fb94778d18cf6621d9e96524be64779119bb554796d7a50c3531dac281ae889f9c6b7e3da5dbf4632c5203039758d91c9a8f7facfc89a49a1b907483ae3d
6
+ metadata.gz: 72e449f543a1a0236c55b3032ce8369ebfcc085c5b19bcaa3f29e1edf2963ac2c811c8afb567825a2d4f4052f9bc38a230f127e9ffe599b31bb514b6366b1930
7
+ data.tar.gz: a0408665d2915e8f03dd0db64b8abf4913086c522f0fd33f2499a9723ac562e8e45e8a55371527f682566ddf55c7dfc48d9a9e9916f777e2c9d339da34a743e5
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
1
  source 'http://rubygems.org'
2
2
 
3
- gemspec
3
+ gemspec
4
+
5
+ gem 'puma'
data/README.md CHANGED
@@ -8,6 +8,7 @@
8
8
  <a href="https://codeclimate.com/github/jipiboily/fourchette"><img src="https://codeclimate.com/github/jipiboily/fourchette.png" /></a>
9
9
  <a href="https://github.com/jipiboily/fourchette"><img src="https://travis-ci.org/jipiboily/fourchette.png?branch=master" /></a>
10
10
  <a href='https://coveralls.io/r/jipiboily/fourchette'><img src='https://coveralls.io/repos/jipiboily/fourchette/badge.png' alt='Coverage Status' /></a>
11
+ <a href="http://badge.fury.io/rb/fourchette"><img src="https://badge.fury.io/rb/fourchette.svg" alt="Gem Version" height="18"></a>
11
12
  </p>
12
13
 
13
14
  **IMPORTANT: this is a work in progress, use at your own risk.**
@@ -99,6 +100,14 @@ Fourchette uses [Sucker Punch](https://github.com/brandonhilkert/sucker_punch),
99
100
 
100
101
  Bonus: if you need a tunnel to your local dev machine to work with GitHub hooks, you might want to look at https://ngrok.com/.
101
102
 
103
+ ### Logging
104
+
105
+ If you want the maximum output in your GitHub comments, set this environment variable:
106
+
107
+ ```
108
+ export DEBUG='true'
109
+ ```
110
+
102
111
  ## It needs some love...
103
112
 
104
113
  What needs to be improved?
data/fourchette.gemspec CHANGED
@@ -18,17 +18,16 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_dependency "bundler", "~> 1.5"
22
21
  spec.add_dependency "rake"
23
- spec.add_dependency "sinatra", "~> 1.4.4"
24
- spec.add_dependency "sinatra-contrib", "~> 1.4.2"
25
- spec.add_dependency "octokit", "~> 3.0.0"
26
- spec.add_dependency "git", "~> 1.2.6"
22
+ spec.add_dependency "sinatra"
23
+ spec.add_dependency "sinatra-contrib"
24
+ spec.add_dependency "octokit"
25
+ spec.add_dependency "git"
27
26
  spec.add_dependency "heroics", "0.0.2"
28
- spec.add_dependency "heroku", "~> 3.3.0" # Deprecated, but best/easiest solution for the pgbackups...
29
- spec.add_dependency "sucker_punch", "~> 1.0.2"
27
+ spec.add_dependency "heroku" # Deprecated, but best/easiest solution for the pgbackups...
28
+ spec.add_dependency "sucker_punch"
30
29
 
31
- spec.add_development_dependency 'foreman', '~> 0.63.0'
30
+ spec.add_development_dependency 'foreman'
32
31
  spec.add_development_dependency 'pry-debugger'
33
32
  spec.add_development_dependency 'rspec', '~> 2.14.1'
34
33
  spec.add_development_dependency 'coveralls'
data/lib/fourchette.rb CHANGED
@@ -29,6 +29,7 @@ end
29
29
 
30
30
 
31
31
  module Fourchette
32
+ DEBUG = ENV['DEBUG'] ? true : false
32
33
  end
33
34
 
34
35
  require_relative 'fourchette/logger'
@@ -4,6 +4,7 @@ class Fourchette::Fork
4
4
  def initialize params
5
5
  @params = params
6
6
  @heroku = Fourchette::Heroku.new
7
+ @github = Fourchette::GitHub.new
7
8
  end
8
9
 
9
10
  def update
@@ -65,7 +66,7 @@ class Fourchette::Fork
65
66
  end
66
67
 
67
68
  def create
68
- github.comment_pr(pr_number, "Fourchette is initializing a new fork.")
69
+ @github.comment_pr(pr_number, "Fourchette is initializing a new fork.") if Fourchette::DEBUG
69
70
  create_unless_exists
70
71
  update
71
72
  end
@@ -74,22 +75,9 @@ class Fourchette::Fork
74
75
  @heroku.delete(fork_name)
75
76
 
76
77
  # Update PR with URL
77
- github.comment_pr(pr_number, "Test app deleted!")
78
+ @github.comment_pr(pr_number, "Test app deleted!")
78
79
  end
79
-
80
- private
81
- def github
82
- @github ||= Fourchette::GitHub.new
83
- end
84
-
85
- def create_unless_exists
86
- unless @heroku.app_exists?(fork_name)
87
- @heroku.fork(ENV['FOURCHETTE_HEROKU_APP_TO_FORK'] ,fork_name)
88
- # Update PR with URL
89
- github.comment_pr(pr_number, "Test URL: #{@heroku.client.app.info(fork_name)['web_url']}")
90
- end
91
- end
92
-
80
+
93
81
  def fork_name
94
82
  "#{ENV['FOURCHETTE_HEROKU_APP_PREFIX']}-PR-#{pr_number}".downcase # It needs to be lowercase only.
95
83
  end
@@ -99,10 +87,19 @@ class Fourchette::Fork
99
87
  end
100
88
 
101
89
  def branch_name
102
- @branch_name ||= "remotes/origin/#{@params['pull_request']['head']['ref']}"
90
+ "remotes/origin/#{@params['pull_request']['head']['ref']}"
103
91
  end
104
92
 
105
93
  def pr_number
106
- @pr_number ||= @params['pull_request']['number']
94
+ @params['pull_request']['number']
95
+ end
96
+
97
+ private
98
+ def create_unless_exists
99
+ unless @heroku.app_exists?(fork_name)
100
+ @heroku.fork(ENV['FOURCHETTE_HEROKU_APP_TO_FORK'] ,fork_name)
101
+ # Update PR with URL
102
+ @github.comment_pr(pr_number, "Test URL: #{@heroku.client.app.info(fork_name)['web_url']}")
103
+ end
107
104
  end
108
105
  end
@@ -30,7 +30,7 @@ class Fourchette::GitHub
30
30
  end
31
31
 
32
32
  def comment_pr pr_number, comment
33
- comment = "****** FOURCHETTE COMMENT ******\n\n#{comment}\n\n****** END OF FOURCHETTE COMMENT ******"
33
+ comment = "****** FOURCHETTE COMMENT ******\n\n#{comment}\n\n****** END OF FOURCHETTE COMMENT ******" if Fourchette::DEBUG
34
34
  octokit.add_comment(ENV['FOURCHETTE_GITHUB_PROJECT'], pr_number, comment)
35
35
  end
36
36
 
@@ -3,12 +3,12 @@ class Fourchette::PullRequest
3
3
 
4
4
  def perform params
5
5
  callbacks = Fourchette::Callbacks.new(params)
6
- @params = params
6
+ fork = Fourchette::Fork.new(params)
7
7
 
8
8
  callbacks.before
9
9
 
10
- case action
11
- when 'synchronize' # new push against the PR
10
+ case params['action']
11
+ when 'synchronize' # new push against the PR (updating code, basically)
12
12
  fork.update
13
13
  when 'closed'
14
14
  fork.delete
@@ -20,12 +20,4 @@ class Fourchette::PullRequest
20
20
 
21
21
  callbacks.after
22
22
  end
23
-
24
- def action
25
- @params['action']
26
- end
27
-
28
- def fork
29
- @fork ||= Fourchette::Fork.new(@params)
30
- end
31
23
  end
@@ -1,3 +1,3 @@
1
1
  module Fourchette
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -0,0 +1,37 @@
1
+ require 'spec_helper'
2
+
3
+ describe Fourchette::PullRequest do
4
+ describe '#perform' do
5
+ let!(:fork) { double('fork') }
6
+ subject { described_class.new }
7
+
8
+ after do
9
+ Fourchette::Fork.stub(:new).and_return(fork)
10
+ subject.perform(params)
11
+ end
12
+
13
+ context 'action == synchronize' do
14
+ let!(:params) { { 'action' => 'synchronize' } }
15
+
16
+ it { fork.should_receive(:update) }
17
+ end
18
+
19
+ context 'action == closed' do
20
+ let!(:params) { { 'action' => 'closed' } }
21
+
22
+ it { fork.should_receive(:delete) }
23
+ end
24
+
25
+ context 'action == reopened' do
26
+ let!(:params) { { 'action' => 'reopened' } }
27
+
28
+ it { fork.should_receive(:create) }
29
+ end
30
+
31
+ context 'action == opened' do
32
+ let!(:params) { { 'action' => 'opened' } }
33
+
34
+ it { fork.should_receive(:create) }
35
+ end
36
+ end
37
+ end
metadata CHANGED
@@ -1,29 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fourchette
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jean-Philippe Boily
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-01 00:00:00.000000000 Z
11
+ date: 2014-04-11 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: bundler
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '1.5'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '1.5'
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: rake
29
15
  requirement: !ruby/object:Gem::Requirement
@@ -42,58 +28,58 @@ dependencies:
42
28
  name: sinatra
43
29
  requirement: !ruby/object:Gem::Requirement
44
30
  requirements:
45
- - - "~>"
31
+ - - ">="
46
32
  - !ruby/object:Gem::Version
47
- version: 1.4.4
33
+ version: '0'
48
34
  type: :runtime
49
35
  prerelease: false
50
36
  version_requirements: !ruby/object:Gem::Requirement
51
37
  requirements:
52
- - - "~>"
38
+ - - ">="
53
39
  - !ruby/object:Gem::Version
54
- version: 1.4.4
40
+ version: '0'
55
41
  - !ruby/object:Gem::Dependency
56
42
  name: sinatra-contrib
57
43
  requirement: !ruby/object:Gem::Requirement
58
44
  requirements:
59
- - - "~>"
45
+ - - ">="
60
46
  - !ruby/object:Gem::Version
61
- version: 1.4.2
47
+ version: '0'
62
48
  type: :runtime
63
49
  prerelease: false
64
50
  version_requirements: !ruby/object:Gem::Requirement
65
51
  requirements:
66
- - - "~>"
52
+ - - ">="
67
53
  - !ruby/object:Gem::Version
68
- version: 1.4.2
54
+ version: '0'
69
55
  - !ruby/object:Gem::Dependency
70
56
  name: octokit
71
57
  requirement: !ruby/object:Gem::Requirement
72
58
  requirements:
73
- - - "~>"
59
+ - - ">="
74
60
  - !ruby/object:Gem::Version
75
- version: 3.0.0
61
+ version: '0'
76
62
  type: :runtime
77
63
  prerelease: false
78
64
  version_requirements: !ruby/object:Gem::Requirement
79
65
  requirements:
80
- - - "~>"
66
+ - - ">="
81
67
  - !ruby/object:Gem::Version
82
- version: 3.0.0
68
+ version: '0'
83
69
  - !ruby/object:Gem::Dependency
84
70
  name: git
85
71
  requirement: !ruby/object:Gem::Requirement
86
72
  requirements:
87
- - - "~>"
73
+ - - ">="
88
74
  - !ruby/object:Gem::Version
89
- version: 1.2.6
75
+ version: '0'
90
76
  type: :runtime
91
77
  prerelease: false
92
78
  version_requirements: !ruby/object:Gem::Requirement
93
79
  requirements:
94
- - - "~>"
80
+ - - ">="
95
81
  - !ruby/object:Gem::Version
96
- version: 1.2.6
82
+ version: '0'
97
83
  - !ruby/object:Gem::Dependency
98
84
  name: heroics
99
85
  requirement: !ruby/object:Gem::Requirement
@@ -112,44 +98,44 @@ dependencies:
112
98
  name: heroku
113
99
  requirement: !ruby/object:Gem::Requirement
114
100
  requirements:
115
- - - "~>"
101
+ - - ">="
116
102
  - !ruby/object:Gem::Version
117
- version: 3.3.0
103
+ version: '0'
118
104
  type: :runtime
119
105
  prerelease: false
120
106
  version_requirements: !ruby/object:Gem::Requirement
121
107
  requirements:
122
- - - "~>"
108
+ - - ">="
123
109
  - !ruby/object:Gem::Version
124
- version: 3.3.0
110
+ version: '0'
125
111
  - !ruby/object:Gem::Dependency
126
112
  name: sucker_punch
127
113
  requirement: !ruby/object:Gem::Requirement
128
114
  requirements:
129
- - - "~>"
115
+ - - ">="
130
116
  - !ruby/object:Gem::Version
131
- version: 1.0.2
117
+ version: '0'
132
118
  type: :runtime
133
119
  prerelease: false
134
120
  version_requirements: !ruby/object:Gem::Requirement
135
121
  requirements:
136
- - - "~>"
122
+ - - ">="
137
123
  - !ruby/object:Gem::Version
138
- version: 1.0.2
124
+ version: '0'
139
125
  - !ruby/object:Gem::Dependency
140
126
  name: foreman
141
127
  requirement: !ruby/object:Gem::Requirement
142
128
  requirements:
143
- - - "~>"
129
+ - - ">="
144
130
  - !ruby/object:Gem::Version
145
- version: 0.63.0
131
+ version: '0'
146
132
  type: :development
147
133
  prerelease: false
148
134
  version_requirements: !ruby/object:Gem::Requirement
149
135
  requirements:
150
- - - "~>"
136
+ - - ">="
151
137
  - !ruby/object:Gem::Version
152
- version: 0.63.0
138
+ version: '0'
153
139
  - !ruby/object:Gem::Dependency
154
140
  name: pry-debugger
155
141
  requirement: !ruby/object:Gem::Requirement
@@ -206,7 +192,6 @@ files:
206
192
  - ".gitignore"
207
193
  - ".travis.yml"
208
194
  - Gemfile
209
- - Gemfile.lock
210
195
  - LICENSE.txt
211
196
  - Procfile
212
197
  - README.md
@@ -226,6 +211,7 @@ files:
226
211
  - lib/fourchette/web.rb
227
212
  - lib/fourchette/web/hooks.rb
228
213
  - spec/lib/fourchette/heroku_spec.rb
214
+ - spec/lib/fourchette/pull_request_spec.rb
229
215
  - spec/spec_helper.rb
230
216
  - spec/support/silent-logger.rb
231
217
  homepage: https://github.com/jipiboily/fourchette
@@ -254,5 +240,6 @@ specification_version: 4
254
240
  summary: Your new best friend for isolated testing environments on Heroku.
255
241
  test_files:
256
242
  - spec/lib/fourchette/heroku_spec.rb
243
+ - spec/lib/fourchette/pull_request_spec.rb
257
244
  - spec/spec_helper.rb
258
245
  - spec/support/silent-logger.rb