danger-clubhouse 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ef1035b0495aaba41c126c302c14cd336884189c
4
+ data.tar.gz: 79378bbb8e1aea86a0b13684f865321db471398f
5
+ SHA512:
6
+ metadata.gz: fc9871612ff18e7e07bd881332a2c3838072b3f72712b55890ad1128cc447de9be5411ddd04fb19f4ecf000c49537b9d59d19f0a34d952ea7bb8fd4a45978d76
7
+ data.tar.gz: eb89b5aab6c59eef97449e10489af8ce82996b830b9651692334625d57b26d7ab966e2775de403f410456b93087a0035b6e9064ab308aff9ecff96c01ed8bb6c
@@ -0,0 +1,5 @@
1
+ .DS_Store
2
+ pkg
3
+ .idea/
4
+ Gemfile.lock
5
+ .yardoc
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format=documentation
@@ -0,0 +1,7 @@
1
+ AllCops:
2
+ Include:
3
+ - Rakefile
4
+ Exclude:
5
+ - vendor/**/*
6
+
7
+ inherit_from: .rubocop_todo.yml
@@ -0,0 +1,44 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2016-11-21 18:59:46 -0500 using RuboCop version 0.43.0.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 1
10
+ Metrics/AbcSize:
11
+ Max: 19
12
+
13
+ # Offense count: 40
14
+ # Configuration parameters: AllowHeredoc, AllowURI, URISchemes.
15
+ # URISchemes: http, https
16
+ Metrics/LineLength:
17
+ Max: 254
18
+
19
+ # Offense count: 3
20
+ # Configuration parameters: CountComments.
21
+ Metrics/MethodLength:
22
+ Max: 14
23
+
24
+ # Offense count: 1
25
+ Style/Documentation:
26
+ Exclude:
27
+ - 'spec/**/*'
28
+ - 'test/**/*'
29
+ - 'lib/changelog/plugin.rb'
30
+
31
+ # Offense count: 3
32
+ Style/DoubleNegation:
33
+ Exclude:
34
+ - 'lib/changelog/changelog_file.rb'
35
+
36
+ # Offense count: 2
37
+ # Configuration parameters: NamePrefix, NamePrefixBlacklist, NameWhitelist.
38
+ # NamePrefix: is_, has_, have_
39
+ # NamePrefixBlacklist: is_, has_, have_
40
+ # NameWhitelist: is_a?
41
+ Style/PredicateName:
42
+ Exclude:
43
+ - 'spec/**/*'
44
+ - 'lib/changelog/plugin.rb'
@@ -0,0 +1,14 @@
1
+ language: ruby
2
+
3
+ cache:
4
+ directories:
5
+ - bundle
6
+
7
+ rvm:
8
+ - 2.3.1
9
+
10
+ before_script:
11
+ - bundle exec danger
12
+
13
+ script:
14
+ - bundle exec rake spec
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
@@ -0,0 +1,19 @@
1
+ # A guardfile for making Danger Plugins
2
+ # For more info see https://github.com/guard/guard#readme
3
+
4
+ # To run, use `bundle exec guard`.
5
+
6
+ guard :rspec, cmd: 'bundle exec rspec' do
7
+ require 'guard/rspec/dsl'
8
+ dsl = Guard::RSpec::Dsl.new(self)
9
+
10
+ # RSpec files
11
+ rspec = dsl.rspec
12
+ watch(rspec.spec_helper) { rspec.spec_dir }
13
+ watch(rspec.spec_support) { rspec.spec_dir }
14
+ watch(rspec.spec_files)
15
+
16
+ # Ruby files
17
+ ruby = dsl.ruby
18
+ dsl.watch_spec_files_for(ruby.lib_files)
19
+ end
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2016 Teng Siong Ong <siong1987@gmail.com>
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,31 @@
1
+ # danger-clubhouse
2
+
3
+ A pull request plugin to [danger.systems](http://danger.systems) that
4
+ links to stories from [Clubhouse](https://app.clubhouse.io).
5
+
6
+ ## Installation
7
+
8
+ Add `danger-clubhouse` to your Gemfile.
9
+
10
+ ```
11
+ gem 'danger-clubhouse'
12
+ ```
13
+
14
+ ## Usage
15
+
16
+ ### clubhouse.organization
17
+
18
+ Set the orgazination name for Clubhouse.
19
+
20
+ ### clubhouse.link_stories!
21
+
22
+ Find stories in the format of chXXX from commits and branch name and
23
+ link to them.
24
+
25
+ ![](images/have_you_updated_changelog.png)
26
+
27
+ ## Copyright
28
+
29
+ Copyright (c) Teng Siong Ong, 2016
30
+
31
+ MIT License, see [LICENSE](LICENSE.txt) for details.
@@ -0,0 +1,23 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+ require 'rubocop/rake_task'
4
+
5
+ RSpec::Core::RakeTask.new(:specs)
6
+
7
+ task default: [:rubocop, :specs]
8
+
9
+ task :spec do
10
+ Rake::Task['specs'].invoke
11
+ Rake::Task['rubocop'].invoke
12
+ Rake::Task['spec_docs'].invoke
13
+ end
14
+
15
+ desc 'Run RuboCop on the lib/specs directory'
16
+ RuboCop::RakeTask.new(:rubocop) do |task|
17
+ task.patterns = ['lib/**/*.rb', 'spec/**/*.rb']
18
+ end
19
+
20
+ desc 'Ensure that the plugin passes `danger plugins lint`'
21
+ task :spec_docs do
22
+ sh 'bundle exec danger plugins lint'
23
+ end
@@ -0,0 +1,32 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'clubhouse/gem_version.rb'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'danger-clubhouse'
8
+ spec.version = Clubhouse::VERSION
9
+ spec.authors = ['siong1987']
10
+ spec.email = ['siong1987@gmail.com']
11
+ spec.description = 'A danger.systems plugin that links to your clubhouse stories.'
12
+ spec.summary = 'A danger.systems plugin that links to your clubhouse stories.'
13
+ spec.homepage = 'https://github.com/siong1987/danger-clubhouse'
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.add_runtime_dependency 'danger-plugin-api', '~> 1.0'
22
+
23
+ spec.add_development_dependency 'bundler', '~> 1.3'
24
+ spec.add_development_dependency 'rake', '~> 10.0'
25
+ spec.add_development_dependency 'rspec', '~> 3.4'
26
+ spec.add_development_dependency 'rubocop', '~> 0.41'
27
+ spec.add_development_dependency 'yard', '~> 0.8'
28
+ spec.add_development_dependency 'guard', '~> 2.14'
29
+ spec.add_development_dependency 'guard-rspec', '~> 4.7'
30
+ spec.add_development_dependency 'listen', '3.0.7'
31
+ spec.add_development_dependency 'pry', '~> 0.10'
32
+ end
@@ -0,0 +1,3 @@
1
+ module Clubhouse
2
+ VERSION = '0.0.1'.freeze
3
+ end
@@ -0,0 +1,80 @@
1
+ module Danger
2
+ # This is your plugin class. Any attributes or methods you expose here will
3
+ # be available from within your Dangerfile.
4
+ #
5
+ # To be published on the Danger plugins site, you will need to have
6
+ # the public interface documented. Danger uses [YARD](http://yardoc.org/)
7
+ # for generating documentation from your plugin source, and you can verify
8
+ # by running `danger plugins lint` or `bundle exec rake spec`.
9
+ #
10
+ # You should replace these comments with a public description of your library.
11
+ #
12
+ # @example Ensure people are well warned about merging on Mondays
13
+ #
14
+ # my_plugin.warn_on_mondays
15
+ #
16
+ # @see Teng Siong Ong/danger-clubhouse
17
+ # @tags monday, weekends, time, rattata
18
+ #
19
+ # This plugin will detect stories from clubhouse and link to them.
20
+ #
21
+ # @example Customize the clubhouse organization and check for stories to link to them.
22
+ #
23
+ # clubhouse.organization = 'organization'
24
+ # clubhouse.link_stories!
25
+ #
26
+ # @see siong1987/danger-clubhouse
27
+ # @tags clubhouse
28
+ class DangerClubhouse < Plugin
29
+ # The clubhouse organization name, you must set this!
30
+ #
31
+ # @return [String]
32
+ attr_accessor :organization
33
+
34
+ # Check the branch and commit messages to find clubhouse stories to link to.
35
+ #
36
+ # @return [void]
37
+ def link_stories!
38
+ clubhouse_story_ids = []
39
+
40
+ # Check for the branch
41
+ if (story_id = find_story_id(github.branch_for_head))
42
+ clubhouse_story_ids << story_id
43
+ end
44
+
45
+ # Check all the commit messages
46
+ messages.each do |message|
47
+ if (story_id = find_story_id(message))
48
+ clubhouse_story_ids << story_id
49
+ end
50
+ end
51
+
52
+ post!(clubhouse_story_ids) unless clubhouse_story_ids.empty?
53
+ end
54
+
55
+ # Find clubhouse story id in the body
56
+ #
57
+ # @return [String, nil]
58
+ def find_story_id(body)
59
+ if (match = body.match(/ch(\d+)/))
60
+ return match[1]
61
+ end
62
+
63
+ nil
64
+ end
65
+
66
+ private
67
+
68
+ def post!(story_ids)
69
+ message = "### Clubhouse stories\n\n"
70
+ story_ids.each do |id|
71
+ message << "* [https://app.clubhouse.io/#{organization}/stories/#{id}](https://app.clubhouse.io/#{organization}/stories/#{id}) \n"
72
+ end
73
+ markdown message
74
+ end
75
+
76
+ def messages
77
+ git.commits.map(&:message)
78
+ end
79
+ end
80
+ end
@@ -0,0 +1 @@
1
+ require 'clubhouse/gem_version'
@@ -0,0 +1 @@
1
+ require 'clubhouse/plugin'
@@ -0,0 +1,107 @@
1
+ require File.expand_path('../spec_helper', __FILE__)
2
+
3
+ module Danger
4
+ describe Danger::DangerClubhouse do
5
+ it 'should be a plugin' do
6
+ expect(Danger::DangerClubhouse.new(nil)).to be_a Danger::Plugin
7
+ end
8
+
9
+ #
10
+ # You should test your custom attributes and methods here
11
+ #
12
+ describe 'with Dangerfile' do
13
+ let(:dangerfile) { testing_dangerfile }
14
+ let(:clubhouse) do
15
+ dangerfile.clubhouse.organization = 'organization'
16
+ dangerfile.clubhouse
17
+ end
18
+ let(:status_report) { clubhouse.status_report }
19
+
20
+ context 'link_stories!' do
21
+ let(:branch) { 'new_branch' }
22
+ let(:body) { 'new body' }
23
+
24
+ subject do
25
+ clubhouse.link_stories!
26
+ end
27
+
28
+ before do
29
+ commit = double(:commit, message: body)
30
+ allow(clubhouse.git).to receive(:commits).and_return([commit])
31
+
32
+ allow(clubhouse.github).to receive(:branch_for_head).and_return(branch)
33
+ end
34
+
35
+ context 'in commit' do
36
+ context 'with story id' do
37
+ let(:body) { 'This is cool [ch345]' }
38
+
39
+ it 'links the story' do
40
+ subject
41
+
42
+ expect(status_report[:markdowns].map(&:message)).to eq [
43
+ "### Clubhouse stories\n\n* [https://app.clubhouse.io/organization/stories/345](https://app.clubhouse.io/organization/stories/345) \n"
44
+ ]
45
+ end
46
+ end
47
+
48
+ context 'without story id' do
49
+ let(:body) { 'This is cool' }
50
+
51
+ it 'links to no stories' do
52
+ subject
53
+
54
+ expect(status_report[:markdowns].map(&:message)).to eq []
55
+ end
56
+ end
57
+ end
58
+
59
+ context 'in branch' do
60
+ context 'with story id' do
61
+ let(:branch) { 'siong/ch345/cool-fix' }
62
+
63
+ it 'links the story' do
64
+ subject
65
+
66
+ expect(status_report[:markdowns].map(&:message)).to eq [
67
+ "### Clubhouse stories\n\n* [https://app.clubhouse.io/organization/stories/345](https://app.clubhouse.io/organization/stories/345) \n"
68
+ ]
69
+ end
70
+ end
71
+
72
+ context 'without story id' do
73
+ let(:branch) { 'siong/cool-fix' }
74
+
75
+ it 'links to no stories' do
76
+ subject
77
+
78
+ expect(status_report[:markdowns].map(&:message)).to eq []
79
+ end
80
+ end
81
+ end
82
+ end
83
+
84
+ context 'find_story_id' do
85
+ subject do
86
+ clubhouse.find_story_id(body)
87
+ end
88
+
89
+ context 'with proper story id in body' do
90
+ let(:body) { 'This is cool [ch345]' }
91
+
92
+ it 'finds the story id' do
93
+ expect(subject).to eq('345')
94
+ end
95
+ end
96
+
97
+ context 'without story id in body' do
98
+ let(:body) { 'This is cool' }
99
+
100
+ it 'returns nil' do
101
+ expect(subject).to eq(nil)
102
+ end
103
+ end
104
+ end
105
+ end
106
+ end
107
+ end
@@ -0,0 +1,38 @@
1
+ require 'pathname'
2
+ ROOT = Pathname.new(File.expand_path('../../', __FILE__))
3
+ $LOAD_PATH.unshift((ROOT + 'lib').to_s)
4
+ $LOAD_PATH.unshift((ROOT + 'spec').to_s)
5
+
6
+ require 'bundler/setup'
7
+ require 'pry'
8
+
9
+ require 'rspec'
10
+ require 'danger'
11
+
12
+ RSpec.configure do |config|
13
+ config.filter_gems_from_backtrace 'bundler'
14
+ config.color = true
15
+ config.tty = true
16
+ end
17
+
18
+ require 'danger_plugin'
19
+
20
+ def testing_ui
21
+ Cork::Board.new(silent: true)
22
+ end
23
+
24
+ def testing_env
25
+ {
26
+ 'HAS_JOSH_K_SEAL_OF_APPROVAL' => 'true',
27
+ 'TRAVIS_PULL_REQUEST' => '800',
28
+ 'TRAVIS_REPO_SLUG' => 'siong1987/danger-clubhouse',
29
+ 'TRAVIS_COMMIT_RANGE' => '759adcbd0d8f...13c4dc8bb61d',
30
+ 'DANGER_GITHUB_API_TOKEN' => '123sbdq54erfsd3422gdfio'
31
+ }
32
+ end
33
+
34
+ # A stubbed out Dangerfile for use in tests
35
+ def testing_dangerfile
36
+ env = Danger::EnvironmentManager.new(testing_env)
37
+ Danger::Dangerfile.new(env, testing_ui)
38
+ end
metadata ADDED
@@ -0,0 +1,203 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: danger-clubhouse
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - siong1987
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-12-22 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: danger-plugin-api
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.3'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.3'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.4'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.4'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubocop
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.41'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.41'
83
+ - !ruby/object:Gem::Dependency
84
+ name: yard
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0.8'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '0.8'
97
+ - !ruby/object:Gem::Dependency
98
+ name: guard
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '2.14'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '2.14'
111
+ - !ruby/object:Gem::Dependency
112
+ name: guard-rspec
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '4.7'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '4.7'
125
+ - !ruby/object:Gem::Dependency
126
+ name: listen
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - '='
130
+ - !ruby/object:Gem::Version
131
+ version: 3.0.7
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - '='
137
+ - !ruby/object:Gem::Version
138
+ version: 3.0.7
139
+ - !ruby/object:Gem::Dependency
140
+ name: pry
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: '0.10'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: '0.10'
153
+ description: A danger.systems plugin that links to your clubhouse stories.
154
+ email:
155
+ - siong1987@gmail.com
156
+ executables: []
157
+ extensions: []
158
+ extra_rdoc_files: []
159
+ files:
160
+ - ".gitignore"
161
+ - ".rspec"
162
+ - ".rubocop.yml"
163
+ - ".rubocop_todo.yml"
164
+ - ".travis.yml"
165
+ - Gemfile
166
+ - Guardfile
167
+ - LICENSE.txt
168
+ - README.md
169
+ - Rakefile
170
+ - danger-clubhouse.gemspec
171
+ - lib/clubhouse/gem_version.rb
172
+ - lib/clubhouse/plugin.rb
173
+ - lib/danger_clubhouse.rb
174
+ - lib/danger_plugin.rb
175
+ - spec/clubhouse_spec.rb
176
+ - spec/spec_helper.rb
177
+ homepage: https://github.com/siong1987/danger-clubhouse
178
+ licenses:
179
+ - MIT
180
+ metadata: {}
181
+ post_install_message:
182
+ rdoc_options: []
183
+ require_paths:
184
+ - lib
185
+ required_ruby_version: !ruby/object:Gem::Requirement
186
+ requirements:
187
+ - - ">="
188
+ - !ruby/object:Gem::Version
189
+ version: '0'
190
+ required_rubygems_version: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - ">="
193
+ - !ruby/object:Gem::Version
194
+ version: '0'
195
+ requirements: []
196
+ rubyforge_project:
197
+ rubygems_version: 2.4.5.1
198
+ signing_key:
199
+ specification_version: 4
200
+ summary: A danger.systems plugin that links to your clubhouse stories.
201
+ test_files:
202
+ - spec/clubhouse_spec.rb
203
+ - spec/spec_helper.rb