redmine_remotes 0.9.0 → 0.11.1

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: 7d3b9ae54d882f36e34f1ff7a0e76d75f8bf601730101584fc0ee6bd3026ae59
4
- data.tar.gz: dada38afebcf9b89d454a7163b637b658834178561d48260aff831c507a6337d
3
+ metadata.gz: e499a582893530c8e53c6174e5bbe89dbff261899ce3c48ff5002176c07fd051
4
+ data.tar.gz: 923f63c7df6752559d627378db5db04e1abfb5d943701359e12ab5ce6adde310
5
5
  SHA512:
6
- metadata.gz: 335421b0f747cc7db893a74e7c351760cafb4d9a360473abbc7f362e0b6b6be663f87ef801738b72d32a59a3b107d7816a09aaf3036c506d55b6a79bca6d2e74
7
- data.tar.gz: 3ebc5ee52fc4a9dd4b7ee67b3cb3ffbeb65bee168a86a9533a376643a4d16647c0798a9ecd1e2608fdc7ac6935a6cfc346eade934db098e26195e54f4a801c27
6
+ metadata.gz: 21f2d90dea92f674f3ae6c9eccbfcc79af983ea24c77f30b7e9dffb7be035eb68057c54f6480b7e64da023794510828d1ec4c37d03b6473dbc6a5f6cb5c5f1b9
7
+ data.tar.gz: 05acaabae871c31d996a739d1875aa2896cb4ae1d53199ea93b0bfa645fb6e1f7bd351de295416030db25100e74a0dd26bc4ea9b79675d48ee587a1e8982fcb3
@@ -1,15 +1,15 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'eac/model'
3
+ require 'eac_rails_utils/models/fetch_errors'
4
4
  require 'eac_ruby_utils/core_ext'
5
5
 
6
6
  module RedmineRemotes
7
7
  module Tableless
8
8
  module RemoteIssueFetch
9
- class Base < ::EacRailsUtils::TablelessModel
9
+ class Base < ::EacRailsUtils::Models::Tableless
10
10
  enable_simple_cache
11
11
  require_sub __FILE__
12
- include ::Eac::Model
12
+ include ::EacRailsUtils::Models::FetchErrors
13
13
 
14
14
  validates :local_tracker, presence: true
15
15
  validates :remote_tracker, presence: true
@@ -3,7 +3,7 @@
3
3
  module RedmineRemotes
4
4
  module Tableless
5
5
  module RemoteIssueFetch
6
- class Base < ::EacRailsUtils::TablelessModel
6
+ class Base < ::EacRailsUtils::Models::Tableless
7
7
  private
8
8
 
9
9
  def save_local_issue
@@ -48,24 +48,14 @@ module RedmineRemotes
48
48
 
49
49
  ::RemoteUser.find_local_user(
50
50
  provider_issue.author_login,
51
- remote_tracker
52
- )
53
- end
54
-
55
- def local_issue_status
56
- local_issue_status_from_remote_tracker || local_issue_status_from_local_tracker
57
- end
58
-
59
- def local_issue_status_from_remote_tracker
60
- ::RemoteIssueStatus.find_local_issue_status(
61
- provider_issue.status_name,
62
51
  remote_tracker,
63
- local_tracker
52
+ true
64
53
  )
65
54
  end
66
55
 
67
- def local_issue_status_from_local_tracker
68
- local_tracker.default_status
56
+ def local_issue_status
57
+ remote_tracker.try(:find_local_issue_status, local_tracker, provider_issue.status_name,
58
+ true)
69
59
  end
70
60
 
71
61
  def local_issue_description
@@ -3,7 +3,7 @@
3
3
  module RedmineRemotes
4
4
  module Tableless
5
5
  module RemoteIssueFetch
6
- class Base < ::EacRailsUtils::TablelessModel
6
+ class Base < ::EacRailsUtils::Models::Tableless
7
7
  private
8
8
 
9
9
  def provider_issue_uncached
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'eac_ruby_utils/core_ext'
4
- require 'eac/model'
5
4
 
6
5
  module RedmineRemotes
7
6
  module Tableless
@@ -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
@@ -11,18 +11,7 @@ class RemoteUser < ActiveRecord::Base
11
11
  validates :remote_login, presence: true, uniqueness: { scope: [:remote_tracker] }
12
12
  validates :local_user, presence: true
13
13
 
14
- class << self
15
- def find_local_user(remote_login, remote_tracker = nil)
16
- [remote_tracker, nil].each do |tracker|
17
- remote_user = ::RemoteUser.where(
18
- remote_tracker: tracker,
19
- remote_login: remote_login_sanitize(remote_login)
20
- ).first
21
- return remote_user.local_user if remote_user
22
- end
23
- return remote_tracker.default_local_user if remote_tracker.present?
24
-
25
- nil
26
- end
14
+ def self.find_local_user(remote_login, remote_tracker = nil, register_not_found = false)
15
+ ::RemoteUser::FindLocalUser.new(remote_login, remote_tracker, register_not_found).result
27
16
  end
28
17
  end
@@ -0,0 +1,60 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ class RemoteUser < ActiveRecord::Base
6
+ class FindLocalUser
7
+ common_constructor :remote_login, :remote_tracker, :register_not_found do
8
+ self.remote_login = ::RemoteUser.remote_login_sanitize(remote_login)
9
+ end
10
+
11
+ def result
12
+ result_by_local_user || result_by_remote_user || result_by_register_not_found ||
13
+ result_by_remote_tracker_default
14
+ end
15
+
16
+ private
17
+
18
+ def result_by_local_user
19
+ result_by_local_user_login || result_by_local_user_mail_address
20
+ end
21
+
22
+ def result_by_local_user_login
23
+ ::User.find_by(login: remote_login)
24
+ end
25
+
26
+ def result_by_local_user_mail_address
27
+ condition = ::EmailAddress.arel_table[:address].matches("#{remote_login}@%")
28
+ ::EmailAddress.where(condition).first.try(:user)
29
+ end
30
+
31
+ def result_by_register_not_found
32
+ return nil unless register_not_found
33
+ return nil if remote_tracker.blank?
34
+
35
+ ::RemoteUser.create!(remote_login: remote_login, remote_tracker: remote_tracker,
36
+ local_user: remote_tracker.default_local_user).local_user
37
+ end
38
+
39
+ def result_by_remote_user
40
+ remote_trackers_to_search
41
+ .map { |tracker| remote_tracker_result(tracker) }
42
+ .find(&:present?)
43
+ end
44
+
45
+ def result_by_remote_tracker_default
46
+ remote_tracker.try(:default_local_user)
47
+ end
48
+
49
+ def remote_tracker_result(remote_tracker)
50
+ ::RemoteUser.where(
51
+ remote_tracker: remote_tracker,
52
+ remote_login: remote_login
53
+ ).first.try(:local_user)
54
+ end
55
+
56
+ def remote_trackers_to_search
57
+ remote_tracker.if_present([]) { |v| [v] } + [nil]
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RedmineRemotes
4
+ module Esosti
5
+ class << self
6
+ RICH_TEXT_COMMENT = /<!--\s*RICH\s+TEXT\s-->/i.freeze
7
+
8
+ def remote_text_to_local(remote_text)
9
+ ::Redmine::WikiFormatting.html_parser.to_text(
10
+ remote_text.gsub(RICH_TEXT_COMMENT, '').each_line.map(&:strip).join(" \n")
11
+ ).each_line.map(&:strip).join("\n").gsub(/\n+/, "\n")
12
+ end
13
+ end
14
+ end
15
+ end
@@ -23,7 +23,9 @@ module RedmineRemotes
23
23
  end
24
24
 
25
25
  def description
26
- related_mbos.fetch('LONGDESCRIPTION').first.fetch('Attributes').fetch('LDTEXT')
26
+ ::RedmineRemotes::Esosti.remote_text_to_local(
27
+ related_mbos.fetch('LONGDESCRIPTION').first.fetch('Attributes').fetch('LDTEXT')
28
+ )
27
29
  end
28
30
 
29
31
  def related_mbos
@@ -3,7 +3,7 @@
3
3
  module RedmineRemotes
4
4
  SLUG = 'redmine_remotes'
5
5
  NAME = 'Redmine Remotes'
6
- VERSION = '0.9.0'
6
+ VERSION = '0.11.1'
7
7
  AUTHOR = 'Eduardo Henrique Bogoni'
8
8
  SUMMARY = 'Integração do Redmine com trackers diversos.'
9
9
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redmine_remotes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.11.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eduardo Henrique Bogoni
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-05-08 00:00:00.000000000 Z
11
+ date: 2020-06-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aranha-parsers
@@ -30,20 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0.27'
34
- - - ">="
35
- - !ruby/object:Gem::Version
36
- version: 0.27.1
33
+ version: '0.28'
37
34
  type: :runtime
38
35
  prerelease: false
39
36
  version_requirements: !ruby/object:Gem::Requirement
40
37
  requirements:
41
38
  - - "~>"
42
39
  - !ruby/object:Gem::Version
43
- version: '0.27'
44
- - - ">="
45
- - !ruby/object:Gem::Version
46
- version: 0.27.1
40
+ version: '0.28'
47
41
  - !ruby/object:Gem::Dependency
48
42
  name: curb
49
43
  requirement: !ruby/object:Gem::Requirement
@@ -70,34 +64,28 @@ dependencies:
70
64
  requirements:
71
65
  - - "~>"
72
66
  - !ruby/object:Gem::Version
73
- version: '0.5'
67
+ version: '0.11'
74
68
  type: :runtime
75
69
  prerelease: false
76
70
  version_requirements: !ruby/object:Gem::Requirement
77
71
  requirements:
78
72
  - - "~>"
79
73
  - !ruby/object:Gem::Version
80
- version: '0.5'
74
+ version: '0.11'
81
75
  - !ruby/object:Gem::Dependency
82
76
  name: eac_ruby_utils
83
77
  requirement: !ruby/object:Gem::Requirement
84
78
  requirements:
85
79
  - - "~>"
86
80
  - !ruby/object:Gem::Version
87
- version: '0.10'
88
- - - ">="
89
- - !ruby/object:Gem::Version
90
- version: 0.10.1
81
+ version: '0.35'
91
82
  type: :runtime
92
83
  prerelease: false
93
84
  version_requirements: !ruby/object:Gem::Requirement
94
85
  requirements:
95
86
  - - "~>"
96
87
  - !ruby/object:Gem::Version
97
- version: '0.10'
98
- - - ">="
99
- - !ruby/object:Gem::Version
100
- version: 0.10.1
88
+ version: '0.35'
101
89
  - !ruby/object:Gem::Dependency
102
90
  name: validate_url
103
91
  requirement: !ruby/object:Gem::Requirement
@@ -145,9 +133,11 @@ files:
145
133
  - app/models/remote_issue.rb
146
134
  - app/models/remote_issue_status.rb
147
135
  - app/models/remote_tracker.rb
136
+ - app/models/remote_tracker/find_issue_local_status.rb
148
137
  - app/models/remote_tracker/remote.rb
149
138
  - app/models/remote_tracker_setting.rb
150
139
  - app/models/remote_user.rb
140
+ - app/models/remote_user/find_local_user.rb
151
141
  - app/views/project_remote_issues/_issues.html.erb
152
142
  - app/views/project_remote_issues/_trackers.html.erb
153
143
  - app/views/project_remote_issues/index.html.erb
@@ -170,6 +160,7 @@ files:
170
160
  - db/migrate/20200505161002_add_timestamps_to_remote_users.rb
171
161
  - init.rb
172
162
  - lib/redmine_remotes.rb
163
+ - lib/redmine_remotes/esosti.rb
173
164
  - lib/redmine_remotes/esosti/entities/issue.rb
174
165
  - lib/redmine_remotes/esosti/instance.rb
175
166
  - lib/redmine_remotes/jira/entities/issue.rb