redmine_remotes 0.9.1 → 0.12.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: 81fddbac08d334ddd2a052a196a055a5db15b5b5b64c2a33b3a5f9dd12f2b0f9
4
- data.tar.gz: 5dcff16fa4012c50371997ceb89a0a3a7c957ddeaa3eeaa0e774d63489de84a3
3
+ metadata.gz: 70c4977d8154fa08f7d03093a35dc948c5bd78639a2a2ce42352e58c5d737050
4
+ data.tar.gz: 8c56794c3633be3b5e731800025a61a73a8df6e17c50776a87790659e0b3235d
5
5
  SHA512:
6
- metadata.gz: 6811d6ff25bf95bb272097242eefd6faa8831e65d831c7200f3cdb48ef7704ecf3a67180e84a92c53852b86c3aceac6d1203ff5b8b4464bb9df24f601acea06f
7
- data.tar.gz: b713b31ef70aad6ff5324af4bcc087ce663b99577896908d6c02f0441e519806f66ce0fe0a2aa57487d32f057e61ad75cd30f0c7531f44927102595c8c2c3ae1
6
+ metadata.gz: 546876674ce5856dacf18ed183ddca546dcbdbe2ae17ede908b2512e18af12512f9fd8449d829a82105c654994f62a6a01589c42a2b7e055f5e94a64a182cec2
7
+ data.tar.gz: 2e821818b0294b9e8b889612666a7a10c0eb494abe661743bc8f9122ca741285364aea93e679bb30068b73c9aec7f53aa25f1c1e96b95a0ba2d887199509c280
@@ -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,28 +48,24 @@ module RedmineRemotes
48
48
 
49
49
  ::RemoteUser.find_local_user(
50
50
  provider_issue.author_login,
51
- remote_tracker
51
+ remote_tracker,
52
+ true
52
53
  )
53
54
  end
54
55
 
55
56
  def local_issue_status
56
- local_issue_status_from_remote_tracker || local_issue_status_from_local_tracker
57
+ remote_tracker.try(:find_local_issue_status, local_tracker, provider_issue.status_name,
58
+ true)
57
59
  end
58
60
 
59
- def local_issue_status_from_remote_tracker
60
- ::RemoteIssueStatus.find_local_issue_status(
61
- provider_issue.status_name,
62
- remote_tracker,
63
- local_tracker
64
- )
65
- end
61
+ def local_issue_description
62
+ <<~DESCRIPTION
63
+ #{provider_issue.description}
66
64
 
67
- def local_issue_status_from_local_tracker
68
- local_tracker.default_status
69
- end
65
+ ----
70
66
 
71
- def local_issue_description
72
- provider_issue.description
67
+ _Demanda remota importada de #{provider_issue.human_view_url}._
68
+ DESCRIPTION
73
69
  end
74
70
  end
75
71
  end
@@ -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
@@ -6,6 +6,10 @@ module RedmineRemotes
6
6
  module Esosti
7
7
  module Entities
8
8
  class Issue < ::Avmtrf1::Esosti::Entities::Issue
9
+ def human_view_url
10
+ instance.issue_human_view_url(uid)
11
+ end
12
+
9
13
  def author_login
10
14
  attributes.fetch('CREATEDBY').if_present { |v| v.gsub(/@[^@]+\z/, '') }
11
15
  end
@@ -23,7 +27,9 @@ module RedmineRemotes
23
27
  end
24
28
 
25
29
  def description
26
- related_mbos.fetch('LONGDESCRIPTION').first.fetch('Attributes').fetch('LDTEXT')
30
+ ::RedmineRemotes::Esosti.remote_text_to_local(
31
+ related_mbos.fetch('LONGDESCRIPTION').first.fetch('Attributes').fetch('LDTEXT')
32
+ )
27
33
  end
28
34
 
29
35
  def related_mbos
@@ -37,6 +43,10 @@ module RedmineRemotes
37
43
  def subject
38
44
  attributes.fetch('DESCRIPTION')
39
45
  end
46
+
47
+ def uid
48
+ attributes.fetch('TICKETUID').fetch('content')
49
+ end
40
50
  end
41
51
  end
42
52
  end
@@ -21,6 +21,10 @@ module RedmineRemotes
21
21
  def issue_get_url_suffix(provider_issue_id)
22
22
  "/os/MS_RMTICKET/?ticketid=#{provider_issue_id}"
23
23
  end
24
+
25
+ def issue_human_view_url(ticket_uid)
26
+ "#{root_url}/itsm/ui/maximo.jsp?event=loadapp&value=ms_viewsr&uniqueid=#{ticket_uid}"
27
+ end
24
28
  end
25
29
  end
26
30
  end
@@ -6,6 +6,10 @@ module RedmineRemotes
6
6
  module Jira
7
7
  module Entities
8
8
  class Issue < ::Avmtrf1::RestProvider::Entity
9
+ def human_view_url
10
+ instance.issue_human_view_url(code)
11
+ end
12
+
9
13
  def code
10
14
  data.fetch('key')
11
15
  end
@@ -29,6 +29,10 @@ module RedmineRemotes
29
29
  def issue_get_url_suffix(provider_issue_id)
30
30
  "/issue/#{provider_issue_id}"
31
31
  end
32
+
33
+ def issue_human_view_url(issue_code)
34
+ "#{root_url}/browse/#{issue_code.to_s.upcase}"
35
+ end
32
36
  end
33
37
  end
34
38
  end
@@ -3,7 +3,7 @@
3
3
  module RedmineRemotes
4
4
  SLUG = 'redmine_remotes'
5
5
  NAME = 'Redmine Remotes'
6
- VERSION = '0.9.1'
6
+ VERSION = '0.12.0'
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.1
4
+ version: 0.12.0
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-12 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
@@ -64,34 +64,28 @@ dependencies:
64
64
  requirements:
65
65
  - - "~>"
66
66
  - !ruby/object:Gem::Version
67
- version: '0.5'
67
+ version: '0.11'
68
68
  type: :runtime
69
69
  prerelease: false
70
70
  version_requirements: !ruby/object:Gem::Requirement
71
71
  requirements:
72
72
  - - "~>"
73
73
  - !ruby/object:Gem::Version
74
- version: '0.5'
74
+ version: '0.11'
75
75
  - !ruby/object:Gem::Dependency
76
76
  name: eac_ruby_utils
77
77
  requirement: !ruby/object:Gem::Requirement
78
78
  requirements:
79
79
  - - "~>"
80
80
  - !ruby/object:Gem::Version
81
- version: '0.10'
82
- - - ">="
83
- - !ruby/object:Gem::Version
84
- version: 0.10.1
81
+ version: '0.35'
85
82
  type: :runtime
86
83
  prerelease: false
87
84
  version_requirements: !ruby/object:Gem::Requirement
88
85
  requirements:
89
86
  - - "~>"
90
87
  - !ruby/object:Gem::Version
91
- version: '0.10'
92
- - - ">="
93
- - !ruby/object:Gem::Version
94
- version: 0.10.1
88
+ version: '0.35'
95
89
  - !ruby/object:Gem::Dependency
96
90
  name: validate_url
97
91
  requirement: !ruby/object:Gem::Requirement
@@ -139,9 +133,11 @@ files:
139
133
  - app/models/remote_issue.rb
140
134
  - app/models/remote_issue_status.rb
141
135
  - app/models/remote_tracker.rb
136
+ - app/models/remote_tracker/find_issue_local_status.rb
142
137
  - app/models/remote_tracker/remote.rb
143
138
  - app/models/remote_tracker_setting.rb
144
139
  - app/models/remote_user.rb
140
+ - app/models/remote_user/find_local_user.rb
145
141
  - app/views/project_remote_issues/_issues.html.erb
146
142
  - app/views/project_remote_issues/_trackers.html.erb
147
143
  - app/views/project_remote_issues/index.html.erb
@@ -164,6 +160,7 @@ files:
164
160
  - db/migrate/20200505161002_add_timestamps_to_remote_users.rb
165
161
  - init.rb
166
162
  - lib/redmine_remotes.rb
163
+ - lib/redmine_remotes/esosti.rb
167
164
  - lib/redmine_remotes/esosti/entities/issue.rb
168
165
  - lib/redmine_remotes/esosti/instance.rb
169
166
  - lib/redmine_remotes/jira/entities/issue.rb