danger-asana 0.0.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 5d576307075e29a137d371e48efe1e166a9f30db05c7ca05e6f7a51d4cd2e5fd
4
+ data.tar.gz: f1235c2dc26383ca0914c47dba8e7c68124a18f312f4aa184c9d9c11fb63312b
5
+ SHA512:
6
+ metadata.gz: be2e9abe5abb3a79daafc8d9cd227e86452ae89beb34cfb357e6d6521b5a87bc57cdd827279b43d862109396ed0312dfdab1f6c0c4170b4371efd324382f8a54
7
+ data.tar.gz: 2d47a6c24fcd5f1cba85ec36c9ffeac9c648aafcf38fd54900f684ebe2fa39fc4eb5c6bd6d8302713af437241991a964c22d79b1da21f0f5579ec1cb85f33a9f
@@ -0,0 +1,34 @@
1
+ # This workflow uses actions that are not certified by GitHub.
2
+ # They are provided by a third-party and are governed by
3
+ # separate terms of service, privacy policy, and support
4
+ # documentation.
5
+ # This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
6
+ # For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
7
+
8
+ name: Ruby
9
+
10
+ on:
11
+ push:
12
+ branches: [ main ]
13
+ pull_request:
14
+ branches: [ main ]
15
+
16
+ jobs:
17
+ test:
18
+
19
+ runs-on: ubuntu-latest
20
+ strategy:
21
+ matrix:
22
+ ruby-version: ['2.6', '2.7', '3.0']
23
+
24
+ steps:
25
+ - uses: actions/checkout@v2
26
+ - name: Set up Ruby
27
+ uses: ruby/setup-ruby@v1
28
+ with:
29
+ ruby-version: ${{ matrix.ruby-version }}
30
+ bundler-cache: true
31
+ - name: Run tests
32
+ env:
33
+ _ASANA_TOKEN: ${{ secrets._ASANA_TOKEN }}
34
+ run: bundle exec rake spec
data/.gitignore ADDED
@@ -0,0 +1,33 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /spec/examples.txt
9
+ /test/tmp/
10
+ /test/version_tmp/
11
+ /tmp/
12
+
13
+ .byebug_history
14
+
15
+ .dat*
16
+ .repl_history
17
+ build/
18
+ *.bridgesupport
19
+ build-iPhoneOS/
20
+ build-iPhoneSimulator/
21
+
22
+ /.yardoc/
23
+ /_yardoc/
24
+ /doc/
25
+ /rdoc/
26
+
27
+ /.bundle/
28
+ /vendor/bundle
29
+ /lib/bundler/man/
30
+
31
+ .rvmrc
32
+
33
+ .DS_Store
data/.rubocop.yml ADDED
@@ -0,0 +1,238 @@
1
+ # Defaults can be found here: https://github.com/bbatsov/rubocop/blob/master/config/default.yml
2
+
3
+ # If you don't like these settings, just delete this file :)
4
+
5
+ AllCops:
6
+ TargetRubyVersion: 2.5
7
+
8
+ Style/StringLiterals:
9
+ EnforcedStyle: double_quotes
10
+ Enabled: true
11
+
12
+ # kind_of? is a good way to check a type
13
+ Style/ClassCheck:
14
+ EnforcedStyle: kind_of?
15
+
16
+ # specs sometimes have useless assignments, which is fine
17
+ Lint/UselessAssignment:
18
+ Exclude:
19
+ - '**/spec/**/*'
20
+
21
+ # We could potentially enable the 2 below:
22
+ Layout/FirstHashElementIndentation:
23
+ Enabled: false
24
+
25
+ Layout/HashAlignment:
26
+ Enabled: false
27
+
28
+ # HoundCI doesn't like this rule
29
+ Layout/DotPosition:
30
+ Enabled: false
31
+
32
+ # We allow !! as it's an easy way to convert ot boolean
33
+ Style/DoubleNegation:
34
+ Enabled: false
35
+
36
+ # Cop supports --auto-correct.
37
+ Lint/UnusedBlockArgument:
38
+ Enabled: false
39
+
40
+ # We want to allow class Fastlane:Class
41
+ Style/ClassAndModuleChildren:
42
+ Enabled: false
43
+
44
+ Metrics/AbcSize:
45
+ Max: 60
46
+
47
+ # The %w might be confusing for new users
48
+ Style/WordArray:
49
+ MinSize: 19
50
+
51
+ # raise and fail are both okay
52
+ Style/SignalException:
53
+ Enabled: false
54
+
55
+ # Better too much 'return' than one missing
56
+ Style/RedundantReturn:
57
+ Enabled: false
58
+
59
+ # Having if in the same line might not always be good
60
+ Style/IfUnlessModifier:
61
+ Enabled: false
62
+
63
+ # and and or is okay
64
+ Style/AndOr:
65
+ Enabled: false
66
+
67
+ # Configuration parameters: CountComments.
68
+ Metrics/ClassLength:
69
+ Max: 350
70
+
71
+ Metrics/CyclomaticComplexity:
72
+ Max: 17
73
+
74
+ # Configuration parameters: AllowURI, URISchemes.
75
+ Layout/LineLength:
76
+ Max: 370
77
+
78
+ # Configuration parameters: CountKeywordArgs.
79
+ Metrics/ParameterLists:
80
+ Max: 10
81
+
82
+ Metrics/PerceivedComplexity:
83
+ Max: 18
84
+
85
+ # Sometimes it's easier to read without guards
86
+ Style/GuardClause:
87
+ Enabled: false
88
+
89
+ # something = if something_else
90
+ # that's confusing
91
+ Style/ConditionalAssignment:
92
+ Enabled: false
93
+
94
+ # Better to have too much self than missing a self
95
+ Style/RedundantSelf:
96
+ Enabled: false
97
+
98
+ Metrics/MethodLength:
99
+ Max: 60
100
+
101
+ # We're not there yet
102
+ Style/Documentation:
103
+ Enabled: false
104
+
105
+ # Adds complexity
106
+ Style/IfInsideElse:
107
+ Enabled: false
108
+
109
+ # danger specific
110
+
111
+ Style/BlockComments:
112
+ Enabled: false
113
+
114
+ Layout/MultilineMethodCallIndentation:
115
+ EnforcedStyle: indented
116
+
117
+ # FIXME: 25
118
+ Metrics/BlockLength:
119
+ Max: 345
120
+ Exclude:
121
+ - "**/*_spec.rb"
122
+
123
+ Style/MixinGrouping:
124
+ Enabled: false
125
+
126
+ Naming/FileName:
127
+ Enabled: false
128
+
129
+ Layout/HeredocIndentation:
130
+ Enabled: false
131
+
132
+ Style/SpecialGlobalVars:
133
+ Enabled: false
134
+
135
+ Style/PercentLiteralDelimiters:
136
+ PreferredDelimiters:
137
+ "%": ()
138
+ "%i": ()
139
+ "%q": ()
140
+ "%Q": ()
141
+ "%r": "{}"
142
+ "%s": ()
143
+ "%w": ()
144
+ "%W": ()
145
+ "%x": ()
146
+
147
+ Security/YAMLLoad:
148
+ Enabled: false
149
+
150
+ Gemspec/DateAssignment:
151
+ Enabled: true
152
+
153
+ Layout/SpaceBeforeBrackets:
154
+ Enabled: true
155
+
156
+ Lint/AmbiguousAssignment:
157
+ Enabled: true
158
+
159
+ Lint/DeprecatedConstants:
160
+ Enabled: true
161
+
162
+ Lint/DuplicateBranch:
163
+ Enabled: true
164
+
165
+ Lint/DuplicateRegexpCharacterClassElement:
166
+ Enabled: true
167
+
168
+ Lint/EmptyBlock:
169
+ Enabled: true
170
+
171
+ Lint/EmptyClass:
172
+ Enabled: true
173
+
174
+ Lint/LambdaWithoutLiteralBlock:
175
+ Enabled: true
176
+
177
+ Lint/NoReturnInBeginEndBlocks:
178
+ Enabled: true
179
+
180
+ Lint/NumberedParameterAssignment:
181
+ Enabled: true
182
+
183
+ Lint/OrAssignmentToConstant:
184
+ Enabled: true
185
+
186
+ Lint/RedundantDirGlobSort:
187
+ Enabled: true
188
+
189
+ Lint/SymbolConversion:
190
+ Enabled: true
191
+
192
+ Lint/ToEnumArguments:
193
+ Enabled: true
194
+
195
+ Lint/TripleQuotes:
196
+ Enabled: true
197
+
198
+ Lint/UnexpectedBlockArity:
199
+ Enabled: true
200
+
201
+ Lint/UnmodifiedReduceAccumulator:
202
+ Enabled: true
203
+
204
+ Style/ArgumentsForwarding:
205
+ Enabled: true
206
+
207
+ Style/CollectionCompact:
208
+ Enabled: true
209
+
210
+ Style/DocumentDynamicEvalDefinition:
211
+ Enabled: true
212
+
213
+ Style/EndlessMethod:
214
+ Enabled: true
215
+
216
+ Style/HashConversion:
217
+ Enabled: true
218
+
219
+ Style/HashExcept:
220
+ Enabled: true
221
+
222
+ Style/IfWithBooleanLiteralBranches:
223
+ Enabled: true
224
+
225
+ Style/NegatedIfElseCondition:
226
+ Enabled: true
227
+
228
+ Style/NilLambda:
229
+ Enabled: true
230
+
231
+ Style/RedundantArgument:
232
+ Enabled: true
233
+
234
+ Style/SwapValues:
235
+ Enabled: true
236
+
237
+ Style/Next:
238
+ Enabled: false
data/.travis.yml ADDED
@@ -0,0 +1,12 @@
1
+ language: ruby
2
+ cache:
3
+ directories:
4
+ - bundle
5
+
6
+ rvm:
7
+ - 2.6
8
+ - 2.7
9
+ - 3.0
10
+
11
+ script:
12
+ - bundle exec rake spec
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,171 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ danger-asana (0.0.1)
5
+ asana (~> 0.10)
6
+ danger-plugin-api (~> 1.0)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ addressable (2.7.0)
12
+ public_suffix (>= 2.0.2, < 5.0)
13
+ asana (0.10.3)
14
+ faraday (~> 1.0)
15
+ faraday_middleware (~> 1.0)
16
+ faraday_middleware-multi_json (~> 0.0)
17
+ oauth2 (~> 1.4)
18
+ ast (2.4.2)
19
+ claide (1.0.3)
20
+ claide-plugins (0.9.2)
21
+ cork
22
+ nap
23
+ open4 (~> 1.3)
24
+ coderay (1.1.3)
25
+ colored2 (3.1.2)
26
+ cork (0.3.0)
27
+ colored2 (~> 3.1)
28
+ danger (8.2.3)
29
+ claide (~> 1.0)
30
+ claide-plugins (>= 0.9.2)
31
+ colored2 (~> 3.1)
32
+ cork (~> 0.1)
33
+ faraday (>= 0.9.0, < 2.0)
34
+ faraday-http-cache (~> 2.0)
35
+ git (~> 1.7)
36
+ kramdown (~> 2.3)
37
+ kramdown-parser-gfm (~> 1.0)
38
+ no_proxy_fix
39
+ octokit (~> 4.7)
40
+ terminal-table (>= 1, < 4)
41
+ danger-plugin-api (1.0.0)
42
+ danger (> 2.0)
43
+ diff-lcs (1.4.4)
44
+ faraday (1.3.0)
45
+ faraday-net_http (~> 1.0)
46
+ multipart-post (>= 1.2, < 3)
47
+ ruby2_keywords
48
+ faraday-http-cache (2.2.0)
49
+ faraday (>= 0.8)
50
+ faraday-net_http (1.0.1)
51
+ faraday_middleware (1.0.0)
52
+ faraday (~> 1.0)
53
+ faraday_middleware-multi_json (0.0.6)
54
+ faraday_middleware
55
+ multi_json
56
+ ffi (1.15.0)
57
+ formatador (0.2.5)
58
+ git (1.8.1)
59
+ rchardet (~> 1.8)
60
+ guard (2.16.2)
61
+ formatador (>= 0.2.4)
62
+ listen (>= 2.7, < 4.0)
63
+ lumberjack (>= 1.0.12, < 2.0)
64
+ nenv (~> 0.1)
65
+ notiffany (~> 0.0)
66
+ pry (>= 0.9.12)
67
+ shellany (~> 0.0)
68
+ thor (>= 0.18.1)
69
+ guard-compat (1.2.1)
70
+ guard-rspec (4.7.3)
71
+ guard (~> 2.1)
72
+ guard-compat (~> 1.1)
73
+ rspec (>= 2.99.0, < 4.0)
74
+ jwt (2.2.2)
75
+ kramdown (2.3.1)
76
+ rexml
77
+ kramdown-parser-gfm (1.1.0)
78
+ kramdown (~> 2.0)
79
+ listen (3.0.7)
80
+ rb-fsevent (>= 0.9.3)
81
+ rb-inotify (>= 0.9.7)
82
+ lumberjack (1.2.8)
83
+ method_source (1.0.0)
84
+ multi_json (1.15.0)
85
+ multi_xml (0.6.0)
86
+ multipart-post (2.1.1)
87
+ nap (1.1.0)
88
+ nenv (0.3.0)
89
+ no_proxy_fix (0.1.2)
90
+ notiffany (0.1.3)
91
+ nenv (~> 0.1)
92
+ shellany (~> 0.0)
93
+ oauth2 (1.4.7)
94
+ faraday (>= 0.8, < 2.0)
95
+ jwt (>= 1.0, < 3.0)
96
+ multi_json (~> 1.3)
97
+ multi_xml (~> 0.5)
98
+ rack (>= 1.2, < 3)
99
+ octokit (4.20.0)
100
+ faraday (>= 0.9)
101
+ sawyer (~> 0.8.0, >= 0.5.3)
102
+ open4 (1.3.4)
103
+ parallel (1.20.1)
104
+ parser (3.0.0.0)
105
+ ast (~> 2.4.1)
106
+ pry (0.14.0)
107
+ coderay (~> 1.1)
108
+ method_source (~> 1.0)
109
+ public_suffix (4.0.6)
110
+ rack (2.2.3)
111
+ rainbow (3.0.0)
112
+ rake (10.5.0)
113
+ rb-fsevent (0.10.4)
114
+ rb-inotify (0.10.1)
115
+ ffi (~> 1.0)
116
+ rchardet (1.8.0)
117
+ regexp_parser (2.1.1)
118
+ rexml (3.2.4)
119
+ rspec (3.10.0)
120
+ rspec-core (~> 3.10.0)
121
+ rspec-expectations (~> 3.10.0)
122
+ rspec-mocks (~> 3.10.0)
123
+ rspec-core (3.10.1)
124
+ rspec-support (~> 3.10.0)
125
+ rspec-expectations (3.10.1)
126
+ diff-lcs (>= 1.2.0, < 2.0)
127
+ rspec-support (~> 3.10.0)
128
+ rspec-mocks (3.10.2)
129
+ diff-lcs (>= 1.2.0, < 2.0)
130
+ rspec-support (~> 3.10.0)
131
+ rspec-support (3.10.2)
132
+ rubocop (1.11.0)
133
+ parallel (~> 1.10)
134
+ parser (>= 3.0.0.0)
135
+ rainbow (>= 2.2.2, < 4.0)
136
+ regexp_parser (>= 1.8, < 3.0)
137
+ rexml
138
+ rubocop-ast (>= 1.2.0, < 2.0)
139
+ ruby-progressbar (~> 1.7)
140
+ unicode-display_width (>= 1.4.0, < 3.0)
141
+ rubocop-ast (1.4.1)
142
+ parser (>= 2.7.1.5)
143
+ ruby-progressbar (1.11.0)
144
+ ruby2_keywords (0.0.4)
145
+ sawyer (0.8.2)
146
+ addressable (>= 2.3.5)
147
+ faraday (> 0.8, < 2.0)
148
+ shellany (0.0.1)
149
+ terminal-table (3.0.0)
150
+ unicode-display_width (~> 1.1, >= 1.1.1)
151
+ thor (1.1.0)
152
+ unicode-display_width (1.7.0)
153
+ yard (0.9.26)
154
+
155
+ PLATFORMS
156
+ ruby
157
+
158
+ DEPENDENCIES
159
+ bundler (~> 2.0)
160
+ danger-asana!
161
+ guard (~> 2.14)
162
+ guard-rspec (~> 4.7)
163
+ listen (= 3.0.7)
164
+ pry (~> 0.14)
165
+ rake (~> 10.0)
166
+ rspec (~> 3.4)
167
+ rubocop (~> 1.11)
168
+ yard (~> 0.9)
169
+
170
+ BUNDLED WITH
171
+ 2.2.15
data/Guardfile ADDED
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ guard :rspec, cmd: "bundle exec rspec" do
4
+ require "guard/rspec/dsl"
5
+ dsl = Guard::RSpec::Dsl.new(self)
6
+
7
+ rspec = dsl.rspec
8
+ watch(rspec.spec_helper) { rspec.spec_dir }
9
+ watch(rspec.spec_support) { rspec.spec_dir }
10
+ watch(rspec.spec_files)
11
+
12
+ ruby = dsl.ruby
13
+ dsl.watch_spec_files_for(ruby.lib_files)
14
+ end
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021 Thomas Joulin
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2021 Thomas Joulin <thomas.joulin@viki.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.
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # danger-asana
2
+
3
+ A [Danger](https://github.com/danger/danger) plugin for that links Asana issues to pull requests for both GitHub and GitLab.
4
+
5
+ ## Installation
6
+
7
+ $ gem install danger-asana
8
+
9
+ ## Usage
10
+
11
+ In your Dangerfile:
12
+
13
+ ```ruby
14
+ asana.check(
15
+ search_title: true,
16
+ search_commits: true,
17
+ search_commits: true,
18
+ )
19
+ ```
20
+
21
+ Generate a [Personal Access Token](https://developers.asana.com/docs/personal-access-token) on Asana and add it as en environment variable `_ASANA_TOKEN`
22
+
23
+ ## Development
24
+
25
+ 1. Clone this repo
26
+ 2. Run `bundle install` to setup dependencies.
27
+ 3. Run `bundle exec rake spec` to run the tests.
28
+ 4. Use `bundle exec guard` to automatically have tests run as you make changes.
29
+ 5. Make your changes.
data/Rakefile ADDED
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+ require "rubocop/rake_task"
6
+
7
+ RSpec::Core::RakeTask.new(:specs)
8
+
9
+ task default: :specs
10
+
11
+ task :spec do
12
+ Rake::Task["specs"].invoke
13
+ Rake::Task["rubocop"].invoke
14
+ Rake::Task["spec_docs"].invoke
15
+ end
16
+
17
+ desc "Run RuboCop on the lib/specs directory"
18
+ RuboCop::RakeTask.new(:rubocop) do |task|
19
+ task.patterns = ["lib/**/*.rb", "spec/**/*.rb"]
20
+ end
21
+
22
+ desc "Ensure that the plugin passes `danger plugins lint`"
23
+ task :spec_docs do
24
+ sh "bundle exec danger plugins lint"
25
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path("lib", __dir__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require "asana/gem_version"
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = "danger-asana"
9
+ spec.version = Asana::VERSION
10
+ spec.authors = ["Thomas Joulin"]
11
+ spec.email = ["thomas.joulin@gmail.com"]
12
+ spec.description = "A short description of danger-asana."
13
+ spec.summary = "A longer description of danger-asana."
14
+ spec.homepage = "https://github.com/thomasjoulin/danger-asana"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files`.split($/)
18
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
19
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_runtime_dependency "asana", "~> 0.10"
23
+ spec.add_runtime_dependency "danger-plugin-api", "~> 1.0"
24
+
25
+ spec.add_development_dependency "bundler", "~> 2.0"
26
+ spec.add_development_dependency "guard", "~> 2.14"
27
+ spec.add_development_dependency "guard-rspec", "~> 4.7"
28
+ spec.add_development_dependency "listen", "3.0.7"
29
+ spec.add_development_dependency "pry", "~> 0.14"
30
+ spec.add_development_dependency "rake", "~> 10.0"
31
+ spec.add_development_dependency "rspec", "~> 3.4"
32
+ spec.add_development_dependency "rubocop", "~> 1.11"
33
+ spec.add_development_dependency "yard", "~> 0.9"
34
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Asana
4
+ VERSION = "0.0.1"
5
+ end
@@ -0,0 +1,98 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "asana"
4
+
5
+ module Danger
6
+ # Links Asana issues to a pull request.
7
+ # @example Check PR for the following Asana project keys and links them
8
+ #
9
+ # asana.check()
10
+ #
11
+ # @see thomasjoulin/danger-asana
12
+ # @tags asana
13
+ #
14
+ class DangerAsana < Plugin
15
+ def initialize(dangerfile)
16
+ super(dangerfile)
17
+
18
+ @client = Asana::Client.new do |c|
19
+ c.authentication :access_token, ENV["_ASANA_TOKEN"]
20
+ c.default_headers "asana-enable" => "new_user_task_lists"
21
+ end
22
+ end
23
+
24
+ # Checks PR for Asana IDs and links them
25
+ #
26
+ # @return [void]
27
+ #
28
+ def check
29
+ issues = find_asana_issues
30
+
31
+ messages = []
32
+
33
+ issues.each do |issue|
34
+ task = find_by_id(issue)
35
+
36
+ unless task.nil?
37
+ messages << "**[#{task.name}](#{task.permalink_url})**\n#{task.notes} |"
38
+ end
39
+ end
40
+
41
+ unless messages.empty?
42
+ header = [
43
+ "Asana tasks in this PR |",
44
+ "--- |"
45
+ ]
46
+
47
+ markdown header
48
+ .concat(messages)
49
+ .join("\n")
50
+ end
51
+ end
52
+
53
+ private
54
+
55
+ def vcs_host
56
+ return gitlab if defined? @dangerfile.gitlab
57
+
58
+ return github
59
+ end
60
+
61
+ def find_asana_issues(search_title: true, search_commits: true, search_body: true)
62
+ regexps = [/\[#([^\]]+)\]/, %r{(?:https://)?app\.asana\.com/0/[0-9]+/([0-9]+)}x]
63
+
64
+ asana_issues = []
65
+
66
+ regexps.each do |regexp|
67
+ if search_title
68
+ vcs_host.pr_title.scan(regexp) do |match|
69
+ asana_issues << match
70
+ end
71
+ end
72
+
73
+ if search_commits
74
+ git.commits.map do |commit|
75
+ commit.message.scan(regexp) do |match|
76
+ asana_issues << match
77
+ end
78
+ end
79
+ end
80
+
81
+ if search_body
82
+ vcs_host.pr_body.scan(regexp) do |match|
83
+ asana_issues << match
84
+ end
85
+ end
86
+ end
87
+
88
+ return asana_issues.uniq
89
+ end
90
+
91
+ def find_by_id(id)
92
+ @client.tasks.find_by_id(id)
93
+ rescue Asana::Errors::NotFound
94
+ puts "task #{id} not found"
95
+ return nil
96
+ end
97
+ end
98
+ end
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "asana/gem_version"
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "asana/plugin"
@@ -0,0 +1,70 @@
1
+ # frozen_string_literal: true
2
+
3
+ require File.expand_path("spec_helper", __dir__)
4
+
5
+ module Danger
6
+ describe Danger::DangerAsana do
7
+ it "should be a plugin" do
8
+ expect(Danger::DangerAsana.new(nil)).to be_a Danger::Plugin
9
+ end
10
+
11
+ describe "with Dangerfile" do
12
+ before do
13
+ @dangerfile = testing_dangerfile
14
+ @asana = @dangerfile.asana
15
+ end
16
+
17
+ it "Finds multiple Asana tasks ids in body and title" do
18
+ allow(@asana).to receive_message_chain("github.pr_title").and_return("[#1200084894659941] Test PR")
19
+ allow(@asana).to receive_message_chain("github.pr_body").and_return("[#1200084894659949]")
20
+
21
+ allow(@asana).to receive_message_chain("find_by_id.name").and_return("task 1", "task 2")
22
+ allow(@asana).to receive_message_chain("find_by_id.notes").and_return("description 1", "description 2")
23
+ allow(@asana).to receive_message_chain("find_by_id.permalink_url").and_return("https://app.asana.com/0/1", "https://app.asana.com/0/2")
24
+
25
+ @asana.check
26
+
27
+ expect(@dangerfile.status_report[:markdowns].first.message).to eq(%(Asana tasks in this PR |
28
+ --- |
29
+ **[task 1](https://app.asana.com/0/1)**
30
+ description 1 |
31
+ **[task 2](https://app.asana.com/0/2)**
32
+ description 2 |))
33
+ end
34
+
35
+ it "Finds Asana tasks by URL" do
36
+ allow(@asana).to receive_message_chain("github.pr_title").and_return("Test PR")
37
+ allow(@asana).to receive_message_chain("github.pr_body").and_return("testing\n\nhttps://app.asana.com/0/1199918955119300/1200084193308092]\nhttps://app.asana.com/0/1199972814069143/1199619253751287")
38
+
39
+ allow(@asana).to receive_message_chain("find_by_id.name").and_return("task 1", "task 2")
40
+ allow(@asana).to receive_message_chain("find_by_id.notes").and_return("description 1", "description 2")
41
+ allow(@asana).to receive_message_chain("find_by_id.permalink_url").and_return("https://app.asana.com/0/1", "https://app.asana.com/0/2")
42
+
43
+ @asana.check
44
+
45
+ expect(@dangerfile.status_report[:markdowns].first.message).to eq(%(Asana tasks in this PR |
46
+ --- |
47
+ **[task 1](https://app.asana.com/0/1)**
48
+ description 1 |
49
+ **[task 2](https://app.asana.com/0/2)**
50
+ description 2 |))
51
+ end
52
+
53
+ it "Ignore duplicate task IDs" do
54
+ allow(@asana).to receive_message_chain("github.pr_title").and_return("[#1200084894659941]")
55
+ allow(@asana).to receive_message_chain("github.pr_body").and_return("https://app.asana.com/0/1199972814069143/1200084894659941")
56
+
57
+ allow(@asana).to receive_message_chain("find_by_id.name").and_return("task 1")
58
+ allow(@asana).to receive_message_chain("find_by_id.notes").and_return("description 1")
59
+ allow(@asana).to receive_message_chain("find_by_id.permalink_url").and_return("https://app.asana.com/0/1")
60
+
61
+ @asana.check
62
+
63
+ expect(@dangerfile.status_report[:markdowns].first.message).to eq(%(Asana tasks in this PR |
64
+ --- |
65
+ **[task 1](https://app.asana.com/0/1)**
66
+ description 1 |))
67
+ end
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,57 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "pathname"
4
+ ROOT = Pathname.new(File.expand_path("..", __dir__))
5
+ $:.unshift("#{ROOT}lib".to_s)
6
+ $:.unshift("#{ROOT}spec".to_s)
7
+
8
+ require "bundler/setup"
9
+ require "pry"
10
+
11
+ require "rspec"
12
+ require "danger"
13
+
14
+ if `git remote -v` == ""
15
+ puts "You cannot run tests without setting a local git remote on this repo"
16
+ puts "It's a weird side-effect of Danger's internals."
17
+ exit(0)
18
+ end
19
+
20
+ # Use coloured output, it's the best.
21
+ RSpec.configure do |config|
22
+ config.filter_gems_from_backtrace "bundler"
23
+ config.color = true
24
+ config.tty = true
25
+ end
26
+
27
+ require "danger_plugin"
28
+
29
+ # rubocop:disable Lint/NestedMethodDefinition
30
+ def testing_ui
31
+ @output = StringIO.new
32
+ def @output.winsize
33
+ [20, 9999]
34
+ end
35
+
36
+ cork = Cork::Board.new(out: @output)
37
+ def cork.string
38
+ out.string.gsub(/\e\[([;\d]+)?m/, "")
39
+ end
40
+ cork
41
+ end
42
+ # rubocop:enable Lint/NestedMethodDefinition
43
+
44
+ def testing_env
45
+ {
46
+ "HAS_JOSH_K_SEAL_OF_APPROVAL" => "true",
47
+ "TRAVIS_PULL_REQUEST" => "800",
48
+ "TRAVIS_REPO_SLUG" => "artsy/eigen",
49
+ "TRAVIS_COMMIT_RANGE" => "759adcbd0d8f...13c4dc8bb61d",
50
+ "DANGER_GITHUB_API_TOKEN" => "123sbdq54erfsd3422gdfio"
51
+ }
52
+ end
53
+
54
+ def testing_dangerfile
55
+ env = Danger::EnvironmentManager.new(testing_env)
56
+ Danger::Dangerfile.new(env, testing_ui)
57
+ end
metadata ADDED
@@ -0,0 +1,218 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: danger-asana
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Thomas Joulin
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2021-03-23 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: asana
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.10'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.10'
27
+ - !ruby/object:Gem::Dependency
28
+ name: danger-plugin-api
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '2.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '2.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: guard
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '2.14'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '2.14'
69
+ - !ruby/object:Gem::Dependency
70
+ name: guard-rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '4.7'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '4.7'
83
+ - !ruby/object:Gem::Dependency
84
+ name: listen
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '='
88
+ - !ruby/object:Gem::Version
89
+ version: 3.0.7
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '='
95
+ - !ruby/object:Gem::Version
96
+ version: 3.0.7
97
+ - !ruby/object:Gem::Dependency
98
+ name: pry
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '0.14'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '0.14'
111
+ - !ruby/object:Gem::Dependency
112
+ name: rake
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '10.0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '10.0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: rspec
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '3.4'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '3.4'
139
+ - !ruby/object:Gem::Dependency
140
+ name: rubocop
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: '1.11'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: '1.11'
153
+ - !ruby/object:Gem::Dependency
154
+ name: yard
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "~>"
158
+ - !ruby/object:Gem::Version
159
+ version: '0.9'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - "~>"
165
+ - !ruby/object:Gem::Version
166
+ version: '0.9'
167
+ description: A short description of danger-asana.
168
+ email:
169
+ - thomas.joulin@gmail.com
170
+ executables: []
171
+ extensions: []
172
+ extra_rdoc_files: []
173
+ files:
174
+ - ".github/workflows/ruby.yml"
175
+ - ".gitignore"
176
+ - ".rubocop.yml"
177
+ - ".travis.yml"
178
+ - Gemfile
179
+ - Gemfile.lock
180
+ - Guardfile
181
+ - LICENSE
182
+ - LICENSE.txt
183
+ - README.md
184
+ - Rakefile
185
+ - danger-asana.gemspec
186
+ - lib/asana/gem_version.rb
187
+ - lib/asana/plugin.rb
188
+ - lib/danger_asana.rb
189
+ - lib/danger_plugin.rb
190
+ - spec/asana_spec.rb
191
+ - spec/spec_helper.rb
192
+ homepage: https://github.com/thomasjoulin/danger-asana
193
+ licenses:
194
+ - MIT
195
+ metadata: {}
196
+ post_install_message:
197
+ rdoc_options: []
198
+ require_paths:
199
+ - lib
200
+ required_ruby_version: !ruby/object:Gem::Requirement
201
+ requirements:
202
+ - - ">="
203
+ - !ruby/object:Gem::Version
204
+ version: '0'
205
+ required_rubygems_version: !ruby/object:Gem::Requirement
206
+ requirements:
207
+ - - ">="
208
+ - !ruby/object:Gem::Version
209
+ version: '0'
210
+ requirements: []
211
+ rubyforge_project:
212
+ rubygems_version: 2.7.11
213
+ signing_key:
214
+ specification_version: 4
215
+ summary: A longer description of danger-asana.
216
+ test_files:
217
+ - spec/asana_spec.rb
218
+ - spec/spec_helper.rb