redmine_remotes 0.11.0 → 0.15.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/project_remote_issues_controller/create.rb +1 -1
  3. data/app/controllers/project_remote_issues_controller/update.rb +1 -1
  4. data/app/controllers/remote_trackers_controller.rb +4 -1
  5. data/app/models/remote_issue.rb +11 -0
  6. data/app/models/remote_issue_fetch/base.rb +45 -0
  7. data/app/models/remote_issue_fetch/base/_local_issue.rb +77 -0
  8. data/app/models/remote_issue_fetch/base/_provider_issue.rb +18 -0
  9. data/app/models/remote_issue_fetch/base/_remote_issue.rb +19 -0
  10. data/app/models/remote_issue_fetch/create.rb +44 -0
  11. data/app/models/remote_issue_fetch/create/_local_issue.rb +21 -0
  12. data/app/models/remote_issue_fetch/create/_remote_issue.rb +21 -0
  13. data/app/models/remote_issue_fetch/update.rb +18 -0
  14. data/app/models/remote_issue_fetch/update/_local_issue.rb +15 -0
  15. data/app/models/remote_issue_fetch/update/_remote_issue.rb +15 -0
  16. data/app/models/remote_tracker.rb +7 -1
  17. data/app/models/remote_tracker/find_issue_local_status.rb +1 -1
  18. data/app/models/remote_tracker/remote.rb +32 -8
  19. data/app/models/remote_tracker_fetch.rb +47 -0
  20. data/app/models/remote_tracker_fetch/provider.rb +13 -0
  21. data/app/models/remote_tracker_fetch/remote_issues.rb +27 -0
  22. data/app/models/remote_tracker_fetch/remote_tracker.rb +16 -0
  23. data/app/models/remote_user/find_local_user.rb +3 -3
  24. data/config/initializers/001_patches.rb +1 -0
  25. data/config/locales/en.yml +1 -0
  26. data/config/locales/pt-BR.yml +1 -0
  27. data/config/routes.rb +6 -5
  28. data/db/migrate/20190531171641_create_remote_trackers.rb +1 -1
  29. data/db/migrate/20190910182842_create_remote_users.rb +1 -1
  30. data/db/migrate/20190910203552_create_remote_issue_statuses.rb +1 -1
  31. data/db/migrate/20190912000000_create_remote_issues.rb +1 -1
  32. data/db/migrate/20200602192120_add_outdated_at_to_remote_issues.rb +7 -0
  33. data/db/migrate/20200602194753_add_fetched_at_to_remote_issues.rb +7 -0
  34. data/db/migrate/20200602203020_add_fetched_at_to_remote_trackers.rb +7 -0
  35. data/lib/redmine_remotes/esosti/entities/issue.rb +40 -1
  36. data/lib/redmine_remotes/esosti/instance.rb +8 -5
  37. data/lib/redmine_remotes/jira/entities/issue.rb +6 -2
  38. data/lib/redmine_remotes/jira/instance.rb +4 -17
  39. data/lib/redmine_remotes/jobs/fetch_issues.rb +31 -0
  40. data/lib/redmine_remotes/jobs/fetch_trackers.rb +30 -0
  41. data/lib/redmine_remotes/patches/avmtrf1_rest_provider_instance.rb +22 -0
  42. data/lib/redmine_remotes/version.rb +1 -1
  43. data/lib/tasks/redmine_remotes.rake +16 -11
  44. metadata +49 -27
  45. data/app/models/redmine_remotes/tableless/remote_issue_fetch/base.rb +0 -39
  46. data/app/models/redmine_remotes/tableless/remote_issue_fetch/base/_local_issue.rb +0 -67
  47. data/app/models/redmine_remotes/tableless/remote_issue_fetch/base/_provider_issue.rb +0 -22
  48. data/app/models/redmine_remotes/tableless/remote_issue_fetch/create.rb +0 -57
  49. data/app/models/redmine_remotes/tableless/remote_issue_fetch/create/_local_issue.rb +0 -25
  50. data/app/models/redmine_remotes/tableless/remote_issue_fetch/create/_remote_issue.rb +0 -32
  51. data/app/models/redmine_remotes/tableless/remote_issue_fetch/update.rb +0 -30
  52. data/app/models/redmine_remotes/tableless/remote_issue_fetch/update/_local_issue.rb +0 -19
  53. data/app/models/redmine_remotes/tableless/remote_issue_fetch/update/_remote_issue.rb +0 -19
  54. data/lib/redmine_remotes/rest_provider/http_response.rb +0 -31
  55. data/lib/redmine_remotes/rest_provider/instance.rb +0 -35
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avmtrf1/rest_provider/instance'
4
+ require 'eac_ruby_utils/core_ext'
5
+
6
+ module RedmineRemotes
7
+ module Patches
8
+ module Avmtrf1RestProviderInstance
9
+ common_concern
10
+
11
+ module InstanceMethods
12
+ attr_reader :remote_tracker
13
+
14
+ private
15
+
16
+ attr_writer :remote_tracker
17
+ end
18
+ end
19
+ end
20
+ end
21
+
22
+ ::Avmtrf1::RestProvider::Instance.patch(::RedmineRemotes::Patches::Avmtrf1RestProviderInstance)
@@ -3,7 +3,7 @@
3
3
  module RedmineRemotes
4
4
  SLUG = 'redmine_remotes'
5
5
  NAME = 'Redmine Remotes'
6
- VERSION = '0.11.0'
6
+ VERSION = '0.15.0'
7
7
  AUTHOR = 'Eduardo Henrique Bogoni'
8
8
  SUMMARY = 'Integração do Redmine com trackers diversos.'
9
9
  end
@@ -1,16 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- namespace :redmine_remotes do
4
- Rake::TestTask.new(test: 'db:test:prepare') do |t|
5
- plugin_root = ::File.dirname(::File.dirname(__dir__))
6
-
7
- t.description = 'Run plugin redmine_remotes\'s tests.'
8
- t.libs << 'test'
9
- t.test_files = FileList["#{plugin_root}/test/**/*_test.rb"]
10
- t.verbose = false
11
- t.warning = false
12
- end
3
+ require 'redmine_plugins_helper/plugin_rake_task'
4
+ ::RedminePluginsHelper::PluginRakeTask.register(:redmine_remotes, :test)
13
5
 
6
+ namespace :redmine_remotes do
14
7
  namespace :issues do
15
8
  desc 'Adds a remote issue.'
16
9
  task :add, %i[remote_tracker_id issue_remote_code project_identifier local_tracker_id] =>
@@ -28,7 +21,7 @@ namespace :redmine_remotes do
28
21
  end
29
22
  ::Rails.logger.info("Local tracker: #{local_tracker}")
30
23
 
31
- add = ::RedmineRemotes::Tableless::RemoteIssueFetch::Create.new(
24
+ add = ::RemoteIssueFetch::Create.new(
32
25
  remote_tracker: remote_tracker, project: project, local_tracker: local_tracker,
33
26
  issue_remote_code: args.issue_remote_code
34
27
  )
@@ -38,5 +31,17 @@ namespace :redmine_remotes do
38
31
  ::Rails.logger.info "[Failed] #{add.errors.messages.pretty_inspect}"
39
32
  end
40
33
  end
34
+
35
+ desc 'Fetch all remote issues.'
36
+ task fetch: :environment do
37
+ ::RedmineRemotes::Jobs::FetchIssues.new.run
38
+ end
39
+ end
40
+
41
+ namespace :trackers do
42
+ desc 'Fetch all remote trackers.'
43
+ task fetch: :environment do
44
+ ::RedmineRemotes::Jobs::FetchTrackers.new.run
45
+ end
41
46
  end
42
47
  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.11.0
4
+ version: 0.15.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-25 00:00:00.000000000 Z
11
+ date: 2020-11-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aranha-parsers
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0.28'
33
+ version: '0.29'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0.28'
40
+ version: '0.29'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: curb
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -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
@@ -112,6 +106,26 @@ dependencies:
112
106
  - - ">="
113
107
  - !ruby/object:Gem::Version
114
108
  version: 1.0.8
109
+ - !ruby/object:Gem::Dependency
110
+ name: eac_ruby_gem_support
111
+ requirement: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - "~>"
114
+ - !ruby/object:Gem::Version
115
+ version: '0.1'
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: 0.1.2
119
+ type: :development
120
+ prerelease: false
121
+ version_requirements: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - "~>"
124
+ - !ruby/object:Gem::Version
125
+ version: '0.1'
126
+ - - ">="
127
+ - !ruby/object:Gem::Version
128
+ version: 0.1.2
115
129
  description:
116
130
  email:
117
131
  executables: []
@@ -127,20 +141,25 @@ files:
127
141
  - app/controllers/remote_tracker_settings_controller.rb
128
142
  - app/controllers/remote_trackers_controller.rb
129
143
  - app/controllers/remote_users_controller.rb
130
- - app/models/redmine_remotes/tableless/remote_issue_fetch/base.rb
131
- - app/models/redmine_remotes/tableless/remote_issue_fetch/base/_local_issue.rb
132
- - app/models/redmine_remotes/tableless/remote_issue_fetch/base/_provider_issue.rb
133
- - app/models/redmine_remotes/tableless/remote_issue_fetch/create.rb
134
- - app/models/redmine_remotes/tableless/remote_issue_fetch/create/_local_issue.rb
135
- - app/models/redmine_remotes/tableless/remote_issue_fetch/create/_remote_issue.rb
136
- - app/models/redmine_remotes/tableless/remote_issue_fetch/update.rb
137
- - app/models/redmine_remotes/tableless/remote_issue_fetch/update/_local_issue.rb
138
- - app/models/redmine_remotes/tableless/remote_issue_fetch/update/_remote_issue.rb
139
144
  - app/models/remote_issue.rb
145
+ - app/models/remote_issue_fetch/base.rb
146
+ - app/models/remote_issue_fetch/base/_local_issue.rb
147
+ - app/models/remote_issue_fetch/base/_provider_issue.rb
148
+ - app/models/remote_issue_fetch/base/_remote_issue.rb
149
+ - app/models/remote_issue_fetch/create.rb
150
+ - app/models/remote_issue_fetch/create/_local_issue.rb
151
+ - app/models/remote_issue_fetch/create/_remote_issue.rb
152
+ - app/models/remote_issue_fetch/update.rb
153
+ - app/models/remote_issue_fetch/update/_local_issue.rb
154
+ - app/models/remote_issue_fetch/update/_remote_issue.rb
140
155
  - app/models/remote_issue_status.rb
141
156
  - app/models/remote_tracker.rb
142
157
  - app/models/remote_tracker/find_issue_local_status.rb
143
158
  - app/models/remote_tracker/remote.rb
159
+ - app/models/remote_tracker_fetch.rb
160
+ - app/models/remote_tracker_fetch/provider.rb
161
+ - app/models/remote_tracker_fetch/remote_issues.rb
162
+ - app/models/remote_tracker_fetch/remote_tracker.rb
144
163
  - app/models/remote_tracker_setting.rb
145
164
  - app/models/remote_user.rb
146
165
  - app/models/remote_user/find_local_user.rb
@@ -164,6 +183,9 @@ files:
164
183
  - db/migrate/20200505153200_add_timestamps_to_redmine_trackers.rb
165
184
  - db/migrate/20200505160938_add_timestamps_to_remote_issues.rb
166
185
  - db/migrate/20200505161002_add_timestamps_to_remote_users.rb
186
+ - db/migrate/20200602192120_add_outdated_at_to_remote_issues.rb
187
+ - db/migrate/20200602194753_add_fetched_at_to_remote_issues.rb
188
+ - db/migrate/20200602203020_add_fetched_at_to_remote_trackers.rb
167
189
  - init.rb
168
190
  - lib/redmine_remotes.rb
169
191
  - lib/redmine_remotes/esosti.rb
@@ -171,13 +193,14 @@ files:
171
193
  - lib/redmine_remotes/esosti/instance.rb
172
194
  - lib/redmine_remotes/jira/entities/issue.rb
173
195
  - lib/redmine_remotes/jira/instance.rb
196
+ - lib/redmine_remotes/jobs/fetch_issues.rb
197
+ - lib/redmine_remotes/jobs/fetch_trackers.rb
198
+ - lib/redmine_remotes/patches/avmtrf1_rest_provider_instance.rb
174
199
  - lib/redmine_remotes/patches/issue.rb
175
200
  - lib/redmine_remotes/patches/issue_status.rb
176
201
  - lib/redmine_remotes/patches/project.rb
177
202
  - lib/redmine_remotes/patches/tracker.rb
178
203
  - lib/redmine_remotes/patches/user.rb
179
- - lib/redmine_remotes/rest_provider/http_response.rb
180
- - lib/redmine_remotes/rest_provider/instance.rb
181
204
  - lib/redmine_remotes/sanitizer.rb
182
205
  - lib/redmine_remotes/version.rb
183
206
  - lib/tasks/redmine_remotes.rake
@@ -199,8 +222,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
199
222
  - !ruby/object:Gem::Version
200
223
  version: '0'
201
224
  requirements: []
202
- rubyforge_project:
203
- rubygems_version: 2.7.7
225
+ rubygems_version: 3.0.8
204
226
  signing_key:
205
227
  specification_version: 4
206
228
  summary: Integração do Redmine com trackers diversos.
@@ -1,39 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac/model'
4
- require 'eac_ruby_utils/core_ext'
5
-
6
- module RedmineRemotes
7
- module Tableless
8
- module RemoteIssueFetch
9
- class Base < ::EacRailsUtils::TablelessModel
10
- enable_simple_cache
11
- require_sub __FILE__
12
- include ::Eac::Model
13
-
14
- validates :local_tracker, presence: true
15
- validates :remote_tracker, presence: true
16
- validates :issue_remote_code, presence: true
17
-
18
- validate :author_present
19
- validate :provider_issue_present
20
-
21
- def author_present
22
- return if provider_issue.blank?
23
- return if local_issue_author.present?
24
-
25
- errors.add(:remote_code,
26
- "Usuário local não encontrado para \"#{provider_issue.author_login}\"")
27
- end
28
-
29
- def provider_issue_present
30
- return if issue_remote_code.blank?
31
- return if provider_issue.present?
32
-
33
- errors.add(:remote_code,
34
- "Demanda remota não encontrada com o código \"#{issue_remote_code}\"")
35
- end
36
- end
37
- end
38
- end
39
- end
@@ -1,67 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module RedmineRemotes
4
- module Tableless
5
- module RemoteIssueFetch
6
- class Base < ::EacRailsUtils::TablelessModel
7
- private
8
-
9
- def save_local_issue
10
- save_local_issue_except_create_on && save_local_issue_created_on
11
- end
12
-
13
- def save_local_issue_created_on
14
- local_issue_provider_attributes[:created_on].if_present do |created_on|
15
- if created_on.present? && local_issue.created_on != created_on
16
- local_issue.update_column( # rubocop:disable Rails/SkipsModelValidations
17
- :created_on, created_on
18
- )
19
- end
20
- end
21
-
22
- true
23
- end
24
-
25
- def save_local_issue_except_create_on
26
- local_issue_provider_attributes.except(:created_on)
27
- .each { |attr, value| local_issue.send("#{attr}=", value) }
28
- return true if local_issue.save
29
-
30
- fetch_record_errors(local_issue, default_column: default_error_column)
31
- false
32
- end
33
-
34
- def local_issue_provider_attributes
35
- {
36
- subject: local_issue_subject, author: local_issue_author, status: local_issue_status,
37
- description: local_issue_description,
38
- created_on: provider_issue.created_on
39
- }
40
- end
41
-
42
- def local_issue_subject
43
- "[#{provider_issue.code}] #{provider_issue.subject}"
44
- end
45
-
46
- def local_issue_author_uncached
47
- return nil if provider_issue.blank?
48
-
49
- ::RemoteUser.find_local_user(
50
- provider_issue.author_login,
51
- remote_tracker,
52
- true
53
- )
54
- end
55
-
56
- def local_issue_status
57
- remote_tracker.try(:find_local_issue_status, local_tracker, provider_issue.status_name,
58
- true)
59
- end
60
-
61
- def local_issue_description
62
- provider_issue.description
63
- end
64
- end
65
- end
66
- end
67
- end
@@ -1,22 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module RedmineRemotes
4
- module Tableless
5
- module RemoteIssueFetch
6
- class Base < ::EacRailsUtils::TablelessModel
7
- private
8
-
9
- def provider_issue_uncached
10
- return nil if [remote_tracker, issue_remote_code].any?(&:blank?)
11
-
12
- remote_tracker.find_remote_issue(issue_remote_code)
13
- rescue ::RedmineRemotes::RestProvider::HttpResponse => e
14
- errors.add(default_error_column,
15
- "Requisição a \"#{e.url}\" retornou com status #{e.status}")
16
- ::Rails.logger.warn(e.body)
17
- nil
18
- end
19
- end
20
- end
21
- end
22
- end
@@ -1,57 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module RedmineRemotes
4
- module Tableless
5
- module RemoteIssueFetch
6
- class Create < ::RedmineRemotes::Tableless::RemoteIssueFetch::Base
7
- require_sub __FILE__
8
-
9
- attribute :issue_remote_code, ::String
10
- attribute :local_tracker_id, ::Integer
11
- attribute :project_id, ::Integer
12
- attribute :remote_tracker_id, ::Integer
13
-
14
- belongs_to :local_tracker, class_name: 'Tracker'
15
- belongs_to :project, class_name: 'Project'
16
- belongs_to :remote_tracker, class_name: 'RemoteTracker'
17
-
18
- validates :project, presence: true
19
-
20
- validate :tracker_in_project
21
-
22
- def create
23
- ::Issue.transaction do
24
- return false unless valid?
25
- return false unless save_local_issue
26
- return false unless create_remote_issue
27
- end
28
- true
29
- end
30
-
31
- def default_error_column
32
- :issue_remote_code
33
- end
34
-
35
- def save
36
- remote_issue_by_remote_code.present? ? update : create
37
- end
38
-
39
- def tracker_in_project
40
- return unless local_tracker.present? && project.present?
41
- return if project.trackers.include?(local_tracker)
42
-
43
- errors.add(:local_tracker, 'is not a tracker of project')
44
- end
45
-
46
- def update
47
- update_record = ::RedmineRemotes::Tableless::RemoteIssueFetch::Update
48
- .new(remote_issue: remote_issue_by_remote_code)
49
- return true if update_record.save
50
-
51
- fetch_record_errors(update_record, default_column: default_error_column)
52
- false
53
- end
54
- end
55
- end
56
- end
57
- end
@@ -1,25 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module RedmineRemotes
4
- module Tableless
5
- module RemoteIssueFetch
6
- class Create < ::RedmineRemotes::Tableless::RemoteIssueFetch::Base
7
- private
8
-
9
- def local_issue_provider_attributes
10
- super.merge(
11
- project: project, tracker: local_tracker, priority: local_issue_priority
12
- )
13
- end
14
-
15
- def local_issue_uncached
16
- remote_issue_by_remote_code.if_present(&:local_issue) || ::Issue.new
17
- end
18
-
19
- def local_issue_priority
20
- ::IssuePriority.default
21
- end
22
- end
23
- end
24
- end
25
- end