eac_rails_remotes 0.1.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/eac_rails_remotes/instances_controller.rb +1 -1
- data/app/models/eac_rails_remotes/instance.rb +5 -5
- data/config/initializers/menus.rb +8 -0
- data/config/locales/en.yml +6 -0
- data/config/locales/pt-BR.yml +6 -0
- data/config/routes.rb +1 -1
- data/lib/eac_rails_remotes/import_file.rb +8 -7
- data/lib/eac_rails_remotes/version.rb +1 -1
- data/lib/tasks/eac_rails_remotes.rake +2 -2
- metadata +18 -31
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4841c8183bc679d302393c35663151c6c63f8e64fd4937da94ca5a9ba61fedd6
|
4
|
+
data.tar.gz: 7694337fe74e34603388ef82a7b4a5f550f757e1ba623d8ce39f406a4bc6a62c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d7ef61cbc2ab71a56ed14cdc73ec154dce0e7524809f4252f2dda546247bead6ca0f077fb9e1f5410c9bd36a6dfa17d51b69a9c4d0d5cd012fdcdf7da3b1b55e
|
7
|
+
data.tar.gz: 41f36454134b62b52f82189c36522e3a997c1b6474416cbc665bcb9b05d060c04d690947e1b179457b3c595820fe5b85c1791cc2f5d42fd56dd256bb365394f4
|
@@ -10,7 +10,7 @@ module EacRailsRemotes
|
|
10
10
|
|
11
11
|
validates :source, presence: true
|
12
12
|
validates :entity, presence: true
|
13
|
-
validates :code, presence: true, uniqueness: { scope: %i[source entity] }
|
13
|
+
validates :code, presence: true, uniqueness: { scope: %i[source entity] } # rubocop:disable Rails/UniqueValidationWithoutIndex
|
14
14
|
validates :data, presence: true
|
15
15
|
validates :export_status, presence: true, inclusion: { in: lists.export_status.values }
|
16
16
|
|
@@ -39,7 +39,7 @@ module EacRailsRemotes
|
|
39
39
|
private
|
40
40
|
|
41
41
|
def target_attributes
|
42
|
-
|
42
|
+
EacRubyUtils::Yaml.load(data).to_h { |k, v| target_attribute(k, v) }
|
43
43
|
end
|
44
44
|
|
45
45
|
def target_attribute(attr, value)
|
@@ -47,13 +47,13 @@ module EacRailsRemotes
|
|
47
47
|
return [attr, value] unless a
|
48
48
|
|
49
49
|
ri = self.class.find_by(source: source, entity: a.klass.name, code: value)
|
50
|
-
[a.name, ri
|
50
|
+
[a.name, ri&.target]
|
51
51
|
end
|
52
52
|
|
53
53
|
# @return [ActiveRecord::Reflection::BelongsToReflection, nil]
|
54
54
|
def entity_association_class(attribute)
|
55
55
|
entity_class.reflect_on_all_associations(:belongs_to)
|
56
|
-
|
56
|
+
.find { |x| x.foreign_key.to_sym == attribute.to_sym }
|
57
57
|
end
|
58
58
|
|
59
59
|
def entity_class
|
@@ -67,7 +67,7 @@ module EacRailsRemotes
|
|
67
67
|
class << self
|
68
68
|
def import(record)
|
69
69
|
ri = where(source: record[:source], entity: record[:entity], code: record[:code])
|
70
|
-
|
70
|
+
.first_or_initialize
|
71
71
|
ri.data = record[:data].to_yaml
|
72
72
|
ri.export_status = EXPORT_STATUS_NEW_DATA
|
73
73
|
ri.save!
|
@@ -0,0 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_rails_utils/patches/application'
|
4
|
+
|
5
|
+
Rails.application.root_menu.group(:admin).group(:eac_rails_remotes, :eac_rails_remotes)
|
6
|
+
.within do |g|
|
7
|
+
g.action(:instances).label(-> { EacRailsRemotes::Instance.plural_name })
|
8
|
+
end
|
data/config/locales/en.yml
CHANGED
data/config/locales/pt-BR.yml
CHANGED
data/config/routes.rb
CHANGED
@@ -19,7 +19,7 @@ module EacRailsRemotes
|
|
19
19
|
|
20
20
|
def init_counts
|
21
21
|
@initial_counts = current_counts
|
22
|
-
@counts =
|
22
|
+
@counts = @initial_counts.keys.index_with { |_k| 0 }
|
23
23
|
end
|
24
24
|
|
25
25
|
class Counter
|
@@ -65,22 +65,23 @@ module EacRailsRemotes
|
|
65
65
|
"#{source}|#{entity}"
|
66
66
|
end
|
67
67
|
|
68
|
-
def entity_to_h(entity)
|
69
|
-
|
68
|
+
def entity_to_h(entity) # rubocop:disable Metrics/MethodLength
|
69
|
+
case entity
|
70
|
+
when String
|
70
71
|
m = /\A([^\|]+)\|([^\|]+)\z/.match(entity)
|
71
72
|
return { source: m[1], entity: m[2] } if m
|
72
73
|
|
73
74
|
raise "Entity pattern no matched: \"#{entity}\""
|
74
|
-
|
75
|
+
when ::EacRailsRemotes::Instance
|
75
76
|
return { source: entity.source, entity: entity.entity }
|
76
|
-
|
77
|
+
when Hash
|
77
78
|
return entity
|
78
79
|
end
|
79
80
|
raise "Entity class not mapped: #{entity}|#{entity.class}"
|
80
81
|
end
|
81
82
|
|
82
83
|
def initial_counts
|
83
|
-
|
84
|
+
@counts.keys.to_h { |e, _c| [e, initial_count(e)] }
|
84
85
|
end
|
85
86
|
|
86
87
|
def found_counts
|
@@ -88,7 +89,7 @@ module EacRailsRemotes
|
|
88
89
|
end
|
89
90
|
|
90
91
|
def new_counts
|
91
|
-
|
92
|
+
@counts.keys.index_with { |e| current_count(e) - initial_count(e) }
|
92
93
|
end
|
93
94
|
|
94
95
|
def initial_count(entity)
|
@@ -3,11 +3,11 @@
|
|
3
3
|
namespace :eac_rails_remotes do
|
4
4
|
desc 'Import content from file'
|
5
5
|
task :import_file, [:file] => :environment do |_t, args|
|
6
|
-
|
6
|
+
EacRailsRemotes::ImportFile.new(args.file).perform
|
7
7
|
end
|
8
8
|
|
9
9
|
desc 'Export pending remote instances'
|
10
10
|
task export_all: :environment do |_t, _args|
|
11
|
-
|
11
|
+
EacRailsRemotes::Instance.new.perform
|
12
12
|
end
|
13
13
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eac_rails_remotes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Put here the authors
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-01-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: eac_active_scaffold
|
@@ -16,88 +16,74 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '0.
|
19
|
+
version: '0.5'
|
20
20
|
- - ">="
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: 0.2
|
22
|
+
version: 0.5.2
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
27
|
- - "~>"
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: '0.
|
29
|
+
version: '0.5'
|
30
30
|
- - ">="
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: 0.2
|
32
|
+
version: 0.5.2
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: eac_rails_utils
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
36
36
|
requirements:
|
37
37
|
- - "~>"
|
38
38
|
- !ruby/object:Gem::Version
|
39
|
-
version: '0.
|
39
|
+
version: '0.22'
|
40
40
|
- - ">="
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
version: 0.
|
42
|
+
version: 0.22.2
|
43
43
|
type: :runtime
|
44
44
|
prerelease: false
|
45
45
|
version_requirements: !ruby/object:Gem::Requirement
|
46
46
|
requirements:
|
47
47
|
- - "~>"
|
48
48
|
- !ruby/object:Gem::Version
|
49
|
-
version: '0.
|
49
|
+
version: '0.22'
|
50
50
|
- - ">="
|
51
51
|
- !ruby/object:Gem::Version
|
52
|
-
version: 0.
|
52
|
+
version: 0.22.2
|
53
53
|
- !ruby/object:Gem::Dependency
|
54
54
|
name: eac_ruby_utils
|
55
55
|
requirement: !ruby/object:Gem::Requirement
|
56
56
|
requirements:
|
57
57
|
- - "~>"
|
58
58
|
- !ruby/object:Gem::Version
|
59
|
-
version: '0.
|
59
|
+
version: '0.120'
|
60
60
|
type: :runtime
|
61
61
|
prerelease: false
|
62
62
|
version_requirements: !ruby/object:Gem::Requirement
|
63
63
|
requirements:
|
64
64
|
- - "~>"
|
65
65
|
- !ruby/object:Gem::Version
|
66
|
-
version: '0.
|
66
|
+
version: '0.120'
|
67
67
|
- !ruby/object:Gem::Dependency
|
68
68
|
name: eac_rails_gem_support
|
69
69
|
requirement: !ruby/object:Gem::Requirement
|
70
70
|
requirements:
|
71
71
|
- - "~>"
|
72
72
|
- !ruby/object:Gem::Version
|
73
|
-
version: '0.
|
74
|
-
type: :development
|
75
|
-
prerelease: false
|
76
|
-
version_requirements: !ruby/object:Gem::Requirement
|
77
|
-
requirements:
|
78
|
-
- - "~>"
|
79
|
-
- !ruby/object:Gem::Version
|
80
|
-
version: '0.7'
|
81
|
-
- !ruby/object:Gem::Dependency
|
82
|
-
name: eac_ruby_gem_support
|
83
|
-
requirement: !ruby/object:Gem::Requirement
|
84
|
-
requirements:
|
85
|
-
- - "~>"
|
86
|
-
- !ruby/object:Gem::Version
|
87
|
-
version: '0.5'
|
73
|
+
version: '0.9'
|
88
74
|
- - ">="
|
89
75
|
- !ruby/object:Gem::Version
|
90
|
-
version: 0.
|
76
|
+
version: 0.9.1
|
91
77
|
type: :development
|
92
78
|
prerelease: false
|
93
79
|
version_requirements: !ruby/object:Gem::Requirement
|
94
80
|
requirements:
|
95
81
|
- - "~>"
|
96
82
|
- !ruby/object:Gem::Version
|
97
|
-
version: '0.
|
83
|
+
version: '0.9'
|
98
84
|
- - ">="
|
99
85
|
- !ruby/object:Gem::Version
|
100
|
-
version: 0.
|
86
|
+
version: 0.9.1
|
101
87
|
description:
|
102
88
|
email:
|
103
89
|
executables: []
|
@@ -108,6 +94,7 @@ files:
|
|
108
94
|
- app/assets/stylesheets/eac_rails_remotes/application.scss
|
109
95
|
- app/controllers/eac_rails_remotes/instances_controller.rb
|
110
96
|
- app/models/eac_rails_remotes/instance.rb
|
97
|
+
- config/initializers/menus.rb
|
111
98
|
- config/locales/en.yml
|
112
99
|
- config/locales/pt-BR.yml
|
113
100
|
- config/routes.rb
|
@@ -129,7 +116,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
129
116
|
requirements:
|
130
117
|
- - ">="
|
131
118
|
- !ruby/object:Gem::Version
|
132
|
-
version: '
|
119
|
+
version: '2.7'
|
133
120
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
134
121
|
requirements:
|
135
122
|
- - ">="
|