eac_rails_remotes 0.2.0 → 0.2.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: 80028cb05c286cf27f364b68491b1461f0a51c61cb481f2c13c638fbcc8cdf1a
4
- data.tar.gz: b033f0b5e926bf57c20ae4aa38109ca4538a184ec3df2a89ffe368291d6810bc
3
+ metadata.gz: 4841c8183bc679d302393c35663151c6c63f8e64fd4937da94ca5a9ba61fedd6
4
+ data.tar.gz: 7694337fe74e34603388ef82a7b4a5f550f757e1ba623d8ce39f406a4bc6a62c
5
5
  SHA512:
6
- metadata.gz: 0dbfe134a2ef93805a029f48e1bb0062c88a0835419b2898a9ea3cb63e0237a535f9ad6ae5a827096851054dbab6515ea609ade7201b1291f415aa93a0e2301a
7
- data.tar.gz: cbe1477e6976c5c6250552a563c306dfdd8fdf220445444b2c6252ee4792c4acdca57c2e3aae75826d4591501bd3d39428cef8cc805d51e6f29ef0cc62df266e
6
+ metadata.gz: d7ef61cbc2ab71a56ed14cdc73ec154dce0e7524809f4252f2dda546247bead6ca0f077fb9e1f5410c9bd36a6dfa17d51b69a9c4d0d5cd012fdcdf7da3b1b55e
7
+ data.tar.gz: 41f36454134b62b52f82189c36522e3a997c1b6474416cbc665bcb9b05d060c04d690947e1b179457b3c595820fe5b85c1791cc2f5d42fd56dd256bb365394f4
@@ -20,7 +20,7 @@ module EacRailsRemotes
20
20
  }
21
21
  active_scaffold_config.columns[:entity].options = {
22
22
  options: ::EacRailsRemotes::Instance.select(:entity).order(entity: :asc).distinct
23
- .pluck(:entity)
23
+ .pluck(:entity)
24
24
  }
25
25
  end
26
26
  end
@@ -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
- Hash[EacRubyUtils::Yaml.load(data).map { |k, v| target_attribute(k, v) }]
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 ? ri.target : nil]
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
- .find { |x| x.foreign_key.to_sym == attribute.to_sym }
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
- .first_or_initialize
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!
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'eac_rails_utils/patches/application'
4
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 })
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
8
  end
data/config/routes.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- ::EacRailsRemotes::Engine.routes.draw do
3
+ EacRailsRemotes::Engine.routes.draw do
4
4
  resources(:instances, concerns: active_scaffold)
5
5
  end
@@ -19,7 +19,7 @@ module EacRailsRemotes
19
19
 
20
20
  def init_counts
21
21
  @initial_counts = current_counts
22
- @counts = Hash[@initial_counts.keys.map { |k| [k, 0] }]
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
- if entity.is_a?(String)
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
- elsif entity.is_a?(::EacRailsRemotes::Instance)
75
+ when ::EacRailsRemotes::Instance
75
76
  return { source: entity.source, entity: entity.entity }
76
- elsif entity.is_a?(Hash)
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
- Hash[@counts.keys.map { |e, _c| [e, initial_count(e)] }]
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
- Hash[@counts.keys.map { |e| [e, current_count(e) - initial_count(e)] }]
92
+ @counts.keys.index_with { |e| current_count(e) - initial_count(e) }
92
93
  end
93
94
 
94
95
  def initial_count(entity)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacRailsRemotes
4
- VERSION = '0.2.0'
4
+ VERSION = '0.2.1'
5
5
  end
@@ -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
- ::EacRailsRemotes::ImportFile.new(args.file).perform
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
- ::EacRailsRemotes::Instance.new.perform
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.2.0
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: 2023-09-18 00:00:00.000000000 Z
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
@@ -19,7 +19,7 @@ dependencies:
19
19
  version: '0.5'
20
20
  - - ">="
21
21
  - !ruby/object:Gem::Version
22
- version: 0.5.1
22
+ version: 0.5.2
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -29,7 +29,7 @@ dependencies:
29
29
  version: '0.5'
30
30
  - - ">="
31
31
  - !ruby/object:Gem::Version
32
- version: 0.5.1
32
+ version: 0.5.2
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: eac_rails_utils
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -37,6 +37,9 @@ dependencies:
37
37
  - - "~>"
38
38
  - !ruby/object:Gem::Version
39
39
  version: '0.22'
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: 0.22.2
40
43
  type: :runtime
41
44
  prerelease: false
42
45
  version_requirements: !ruby/object:Gem::Requirement
@@ -44,40 +47,43 @@ dependencies:
44
47
  - - "~>"
45
48
  - !ruby/object:Gem::Version
46
49
  version: '0.22'
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: 0.22.2
47
53
  - !ruby/object:Gem::Dependency
48
54
  name: eac_ruby_utils
49
55
  requirement: !ruby/object:Gem::Requirement
50
56
  requirements:
51
57
  - - "~>"
52
58
  - !ruby/object:Gem::Version
53
- version: '0.119'
54
- - - ">="
55
- - !ruby/object:Gem::Version
56
- version: 0.119.2
59
+ version: '0.120'
57
60
  type: :runtime
58
61
  prerelease: false
59
62
  version_requirements: !ruby/object:Gem::Requirement
60
63
  requirements:
61
64
  - - "~>"
62
65
  - !ruby/object:Gem::Version
63
- version: '0.119'
64
- - - ">="
65
- - !ruby/object:Gem::Version
66
- version: 0.119.2
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.7.2
73
+ version: '0.9'
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: 0.9.1
74
77
  type: :development
75
78
  prerelease: false
76
79
  version_requirements: !ruby/object:Gem::Requirement
77
80
  requirements:
78
81
  - - "~>"
79
82
  - !ruby/object:Gem::Version
80
- version: 0.7.2
83
+ version: '0.9'
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: 0.9.1
81
87
  description:
82
88
  email:
83
89
  executables: []
@@ -110,7 +116,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
110
116
  requirements:
111
117
  - - ">="
112
118
  - !ruby/object:Gem::Version
113
- version: '0'
119
+ version: '2.7'
114
120
  required_rubygems_version: !ruby/object:Gem::Requirement
115
121
  requirements:
116
122
  - - ">="