eac_rails_remotes 0.2.2 → 0.3.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: 6903aa1398db3b734eed5e828852b4bf2246c3753d39de910e6c7cdf40025534
4
- data.tar.gz: ac5c398bfbc9e08a902411eebdb31ddc8f752512c600c83ec2549a3c01de3657
3
+ metadata.gz: a6cc86581c903002e2e9913cb8d5177fcf6584335981aafe7f635a2e6bf91793
4
+ data.tar.gz: 734e7de9b68fca2663e6ec6a932169ab7580e0597f5d12d17bf48f731b23e54b
5
5
  SHA512:
6
- metadata.gz: 9da077ff9c7fef3ddd5558e6344a59e818810119232857c16fa59dfd4c8c09b3beda256384d116de2ec61e4c3cd17d3d5d723c4ab40a9ba48a132437b7802758
7
- data.tar.gz: 67ba1d56af99046790ffc80b21179db64ca3bd1e8de042fc811eaef54f1afd455909882935239bea201e128f95a4cd5c192292a04f73f8480be2b546cbce7e1d
6
+ metadata.gz: bde88ca426dffcf997c6a79101d7165eb7fc3b15593650b3345772b7d8566d6355ed48fc3870d9e41160f5030a81ce558ad6adffb27b27ae5d0587df4d9f9ffb
7
+ data.tar.gz: c57298ba0a909455c8b212dbabd35b9b353fae6cecc27abf320662574b85873eb43dd8780faba300bd2361fbf30726b64dfc3642353a2ebe1ece03db8769572a
@@ -24,6 +24,16 @@ module EacRailsRemotes
24
24
  "#{source}|#{entity}|#{code}"
25
25
  end
26
26
 
27
+ # @return [Object]
28
+ def assert_target
29
+ return target if target.present?
30
+
31
+ export if export_status != EXPORT_STATUS_ERROR
32
+ return target if target.present?
33
+
34
+ raise "Export failed (ID: #{id}, export message: \"#{export_message}\""
35
+ end
36
+
27
37
  def export
28
38
  Rails.logger.info("Exporting #{self}")
29
39
  t = target || entity_class.new
@@ -65,14 +75,24 @@ module EacRailsRemotes
65
75
  end
66
76
 
67
77
  class << self
78
+ # @param record [Hash]
79
+ # @return [EacRailsRemotes::Instance]
68
80
  def import(record)
69
- ri = where(source: record[:source], entity: record[:entity], code: record[:code])
70
- .first_or_initialize
71
- ri.data = record[:data].to_yaml
72
- ri.export_status = EXPORT_STATUS_NEW_DATA
73
- ri.save!
81
+ ri = where(source: record.fetch(:source), entity: sanitize_entity(record.fetch(:entity)),
82
+ code: record.fetch(:code)).first_or_initialize
83
+ ri.data = record.fetch(:data).to_yaml
84
+ if ri.data_changed?
85
+ ri.export_status = EXPORT_STATUS_NEW_DATA
86
+ ri.save!
87
+ end
74
88
  ri
75
89
  end
90
+
91
+ # @oaram entity [Object]
92
+ # @return [String]
93
+ def sanitize_entity(entity)
94
+ entity.is_a?(::Module) ? entity.name : entity.to_s
95
+ end
76
96
  end
77
97
  end
78
98
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacRailsRemotes
4
- VERSION = '0.2.2'
4
+ VERSION = '0.3.0'
5
5
  end
@@ -8,6 +8,6 @@ namespace :eac_rails_remotes do
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.pendent.each(&:export)
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.2
4
+ version: 0.3.0
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: 2024-02-12 00:00:00.000000000 Z
11
+ date: 2024-09-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: eac_active_scaffold
@@ -16,54 +16,68 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.5'
19
+ version: '0.6'
20
20
  - - ">="
21
21
  - !ruby/object:Gem::Version
22
- version: 0.5.3
22
+ version: 0.6.1
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.5'
29
+ version: '0.6'
30
30
  - - ">="
31
31
  - !ruby/object:Gem::Version
32
- version: 0.5.3
32
+ version: 0.6.1
33
33
  - !ruby/object:Gem::Dependency
34
- name: eac_rails_utils
34
+ name: eac_rails_gem_support
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
37
  - - "~>"
38
38
  - !ruby/object:Gem::Version
39
- version: '0.22'
39
+ version: '0.10'
40
40
  - - ">="
41
41
  - !ruby/object:Gem::Version
42
- version: 0.22.2
42
+ version: 0.10.1
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.22'
49
+ version: '0.10'
50
50
  - - ">="
51
51
  - !ruby/object:Gem::Version
52
- version: 0.22.2
52
+ version: 0.10.1
53
+ - !ruby/object:Gem::Dependency
54
+ name: eac_rails_utils
55
+ requirement: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - "~>"
58
+ - !ruby/object:Gem::Version
59
+ version: '0.24'
60
+ type: :runtime
61
+ prerelease: false
62
+ version_requirements: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - "~>"
65
+ - !ruby/object:Gem::Version
66
+ version: '0.24'
53
67
  - !ruby/object:Gem::Dependency
54
68
  name: eac_ruby_utils
55
69
  requirement: !ruby/object:Gem::Requirement
56
70
  requirements:
57
71
  - - "~>"
58
72
  - !ruby/object:Gem::Version
59
- version: '0.121'
73
+ version: '0.122'
60
74
  type: :runtime
61
75
  prerelease: false
62
76
  version_requirements: !ruby/object:Gem::Requirement
63
77
  requirements:
64
78
  - - "~>"
65
79
  - !ruby/object:Gem::Version
66
- version: '0.121'
80
+ version: '0.122'
67
81
  - !ruby/object:Gem::Dependency
68
82
  name: eac_rails_gem_support
69
83
  requirement: !ruby/object:Gem::Requirement