redmine_remotes 0.10.0 → 0.11.0

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
  SHA256:
3
- metadata.gz: 2a0671e339c9e225c9413feb402fed23e0ac5e930a3e72027aa2b183749441d5
4
- data.tar.gz: eb1245a9f15262922b95bec5574bdbb3dbc84f286d7fed371970b759657f6e2d
3
+ metadata.gz: 7fe74fdd135a685b96165bd9ed58d166cfb9ba5b28535eca5bc25f12a730e656
4
+ data.tar.gz: ceb58f6cebd35a0db510929df86cac7465be85f1de0f79717e2fda174fe69b90
5
5
  SHA512:
6
- metadata.gz: 0af87885a31cc69c7ec0cc8f1bbd7201b189b8c5f260382d990189affb7ab642b5eba050231e3e7c0a78f5d65a134c21490148d5461858c61af9ad92c813e578
7
- data.tar.gz: 322120abe8ba4dde501c3d6cccc3a3315933d18f585d4c7eb9a86b8c147ec797c0dcb2bff8b08ac29001466eb12e2824cb29a1ef7394b5db1d8f21cbe4c31778
6
+ metadata.gz: 77dbf10449d5d38021cf698ab65ce4225cf33377e6e5a3b4cf25ca52bba04f9216959c83a26b8cfacd25a703f887d0cb597fe0b4b28b56737c3f9baa2b89effb
7
+ data.tar.gz: 61dcddd64c24be40ed2dfacf389f535c1c56beab448b17cd817bce2e3164000b2ea190cdb195a7cfedd0f7bf59890ccdd5bc6f566870608c362a9c1e4962e633
@@ -54,19 +54,8 @@ module RedmineRemotes
54
54
  end
55
55
 
56
56
  def local_issue_status
57
- local_issue_status_from_remote_tracker || local_issue_status_from_local_tracker
58
- end
59
-
60
- def local_issue_status_from_remote_tracker
61
- ::RemoteIssueStatus.find_local_issue_status(
62
- provider_issue.status_name,
63
- remote_tracker,
64
- local_tracker
65
- )
66
- end
67
-
68
- def local_issue_status_from_local_tracker
69
- local_tracker.default_status
57
+ remote_tracker.try(:find_local_issue_status, local_tracker, provider_issue.status_name,
58
+ true)
70
59
  end
71
60
 
72
61
  def local_issue_description
@@ -13,15 +13,4 @@ class RemoteIssueStatus < ActiveRecord::Base
13
13
  validates :remote_tracker, presence: true
14
14
  validates :local_tracker, presence: true
15
15
  validates :local_issue_status, presence: true
16
-
17
- class << self
18
- def find_local_issue_status(remote_name, remote_tracker, local_tracker)
19
- record = ::RemoteIssueStatus.where(
20
- remote_name: remote_name_sanitize(remote_name),
21
- remote_tracker: remote_tracker,
22
- local_tracker: local_tracker
23
- ).first
24
- record ? record.local_issue_status : nil
25
- end
26
- end
27
16
  end
@@ -27,6 +27,11 @@ class RemoteTracker < ActiveRecord::Base
27
27
  validates :password, presence: true
28
28
  validates :default_local_user, presence: true
29
29
 
30
+ def find_local_issue_status(local_tracker, remote_status_name, register_not_found = false)
31
+ ::RemoteTracker::FindIssueLocalStatus.new(self, local_tracker, remote_status_name,
32
+ register_not_found).result
33
+ end
34
+
30
35
  def to_s
31
36
  "#{root_url} [#{profile_label}, #{username}]"
32
37
  end
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ class RemoteTracker < ActiveRecord::Base
6
+ class FindIssueLocalStatus
7
+ common_constructor :remote_tracker, :local_tracker, :remote_status_name, :register_not_found
8
+
9
+ # @return [Tracker]
10
+ def result
11
+ result_by_remote_issue_status || result_by_register_not_found || result_by_local_issue_status
12
+ end
13
+
14
+ private
15
+
16
+ def result_by_register_not_found
17
+ return nil unless register_not_found
18
+
19
+ ::RemoteIssueStatus.create!(
20
+ remote_issue_status_find_attributes.merge(local_issue_status: result_by_local_issue_status)
21
+ ).local_issue_status
22
+ end
23
+
24
+ def result_by_remote_issue_status
25
+ ::RemoteIssueStatus.where(remote_issue_status_find_attributes).first.try(:local_issue_status)
26
+ end
27
+
28
+ def result_by_local_issue_status
29
+ local_tracker.default_status
30
+ end
31
+
32
+ def remote_issue_status_find_attributes
33
+ {
34
+ remote_name: ::RemoteIssueStatus.remote_name_sanitize(remote_status_name),
35
+ remote_tracker: remote_tracker,
36
+ local_tracker: local_tracker
37
+ }
38
+ end
39
+ end
40
+ end
@@ -3,7 +3,7 @@
3
3
  module RedmineRemotes
4
4
  SLUG = 'redmine_remotes'
5
5
  NAME = 'Redmine Remotes'
6
- VERSION = '0.10.0'
6
+ VERSION = '0.11.0'
7
7
  AUTHOR = 'Eduardo Henrique Bogoni'
8
8
  SUMMARY = 'Integração do Redmine com trackers diversos.'
9
9
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redmine_remotes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 0.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eduardo Henrique Bogoni
@@ -139,6 +139,7 @@ files:
139
139
  - app/models/remote_issue.rb
140
140
  - app/models/remote_issue_status.rb
141
141
  - app/models/remote_tracker.rb
142
+ - app/models/remote_tracker/find_issue_local_status.rb
142
143
  - app/models/remote_tracker/remote.rb
143
144
  - app/models/remote_tracker_setting.rb
144
145
  - app/models/remote_user.rb