harmonia 0.1.8 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 20a7d4c57e312c17c812acfaa1d4f31234d291265b0da78cfdfc94037dcd6bc4
|
|
4
|
+
data.tar.gz: 93288d73a82f3e86f6e5e9130102beeb5db563c5b192c6d981ea9c2c7e79ac68
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0da52f204c3f7a03af63ad177a81a79e710e2eb4c5f50f47046ab36eca2afbcf9cd26bd3bea03ecf6ff58a0f4e52c82e98e025d777c339d4bb8b03ed4af66cf0
|
|
7
|
+
data.tar.gz: 7b6526bbfafa4a0f732d51bf287313e5ceb7f4f7590e99d115f1f1e48eb0c4691d1a1ad84e6bac5acf5153c59cc57e7fefed665de7e1f2c269c548d22a6af543
|
|
@@ -17,6 +17,57 @@ module Harmonia
|
|
|
17
17
|
migration_template "add_filemaker_id_to_table.rb", "db/migrate/add_filemaker_id_to_#{table_name}.rb"
|
|
18
18
|
end
|
|
19
19
|
|
|
20
|
+
def create_or_update_rake_task
|
|
21
|
+
rake_file = "lib/tasks/sync_data.rake"
|
|
22
|
+
task_name = "sync_#{file_name}_to_filemaker"
|
|
23
|
+
|
|
24
|
+
if File.exist?(rake_file)
|
|
25
|
+
# Read existing file
|
|
26
|
+
content = File.read(rake_file)
|
|
27
|
+
|
|
28
|
+
# Add new task before the final 'end' if it doesn't exist
|
|
29
|
+
unless content.include?("task #{task_name}:")
|
|
30
|
+
# Add the new task before the final 'end'
|
|
31
|
+
new_task = <<~TASK
|
|
32
|
+
|
|
33
|
+
desc 'sync #{table_name} from ActiveRecord to FileMaker'
|
|
34
|
+
task #{task_name}: :environment do
|
|
35
|
+
#{class_name}ToFileMakerSyncer.new.sync
|
|
36
|
+
end
|
|
37
|
+
TASK
|
|
38
|
+
|
|
39
|
+
# Insert before the final 'end'
|
|
40
|
+
content = content.sub(/^end\s*$/, "#{new_task}end")
|
|
41
|
+
|
|
42
|
+
# Add task to the 'all' array
|
|
43
|
+
content = content.sub(/task all: %i\[(.*?)\]/) do
|
|
44
|
+
tasks = $1.split.map(&:to_sym)
|
|
45
|
+
tasks << task_name.to_sym unless tasks.include?(task_name.to_sym)
|
|
46
|
+
"task all: %i[#{tasks.join(' ')}]"
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
File.write(rake_file, content)
|
|
50
|
+
end
|
|
51
|
+
else
|
|
52
|
+
# Create new rake file
|
|
53
|
+
template "sync_data.rake", rake_file
|
|
54
|
+
|
|
55
|
+
# Add the new task
|
|
56
|
+
content = File.read(rake_file)
|
|
57
|
+
new_task = <<~TASK
|
|
58
|
+
|
|
59
|
+
desc 'sync #{table_name} from ActiveRecord to FileMaker'
|
|
60
|
+
task #{task_name}: :environment do
|
|
61
|
+
#{class_name}ToFileMakerSyncer.new.sync
|
|
62
|
+
end
|
|
63
|
+
TASK
|
|
64
|
+
|
|
65
|
+
content = content.sub(/^end\s*$/, "#{new_task}end")
|
|
66
|
+
content = content.sub(/task all: %i\[\]/, "task all: %i[#{task_name}]")
|
|
67
|
+
File.write(rake_file, content)
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
|
|
20
71
|
def show_readme
|
|
21
72
|
readme_content = <<~README
|
|
22
73
|
|
|
@@ -27,6 +78,7 @@ module Harmonia
|
|
|
27
78
|
Files created:
|
|
28
79
|
- app/syncers/#{file_name}_to_filemaker_syncer.rb
|
|
29
80
|
- db/migrate/..._add_filemaker_id_to_#{table_name}.rb
|
|
81
|
+
- lib/tasks/sync_data.rake (updated with sync_#{file_name}_to_filemaker task)
|
|
30
82
|
|
|
31
83
|
Next steps:
|
|
32
84
|
1. Run migrations: rails db:migrate
|
|
@@ -58,6 +110,10 @@ module Harmonia
|
|
|
58
110
|
Note: The total_required count used for sync tracking is automatically calculated
|
|
59
111
|
from @total_create_required + @total_update_required
|
|
60
112
|
|
|
113
|
+
7. Run the sync task:
|
|
114
|
+
- Individual sync: rake sync:sync_#{file_name}_to_filemaker
|
|
115
|
+
- All syncs: rake sync:all
|
|
116
|
+
|
|
61
117
|
README
|
|
62
118
|
|
|
63
119
|
say readme_content, :green if behavior == :invoke
|
|
@@ -17,6 +17,57 @@ module Harmonia
|
|
|
17
17
|
migration_template "add_filemaker_id_to_table.rb", "db/migrate/add_filemaker_id_to_#{table_name}.rb"
|
|
18
18
|
end
|
|
19
19
|
|
|
20
|
+
def create_or_update_rake_task
|
|
21
|
+
rake_file = "lib/tasks/sync_data.rake"
|
|
22
|
+
task_name = "sync_#{file_name}"
|
|
23
|
+
|
|
24
|
+
if File.exist?(rake_file)
|
|
25
|
+
# Read existing file
|
|
26
|
+
content = File.read(rake_file)
|
|
27
|
+
|
|
28
|
+
# Add new task before the final 'end' if it doesn't exist
|
|
29
|
+
unless content.include?("task #{task_name}:")
|
|
30
|
+
# Add the new task before the final 'end'
|
|
31
|
+
new_task = <<~TASK
|
|
32
|
+
|
|
33
|
+
desc 'sync #{table_name} from FileMaker to ActiveRecord'
|
|
34
|
+
task #{task_name}: :environment do
|
|
35
|
+
#{class_name}Syncer.new.sync
|
|
36
|
+
end
|
|
37
|
+
TASK
|
|
38
|
+
|
|
39
|
+
# Insert before the final 'end'
|
|
40
|
+
content = content.sub(/^end\s*$/, "#{new_task}end")
|
|
41
|
+
|
|
42
|
+
# Add task to the 'all' array
|
|
43
|
+
content = content.sub(/task all: %i\[(.*?)\]/) do
|
|
44
|
+
tasks = $1.split.map(&:to_sym)
|
|
45
|
+
tasks << task_name.to_sym unless tasks.include?(task_name.to_sym)
|
|
46
|
+
"task all: %i[#{tasks.join(' ')}]"
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
File.write(rake_file, content)
|
|
50
|
+
end
|
|
51
|
+
else
|
|
52
|
+
# Create new rake file
|
|
53
|
+
template "sync_data.rake", rake_file
|
|
54
|
+
|
|
55
|
+
# Add the new task
|
|
56
|
+
content = File.read(rake_file)
|
|
57
|
+
new_task = <<~TASK
|
|
58
|
+
|
|
59
|
+
desc 'sync #{table_name} from FileMaker to ActiveRecord'
|
|
60
|
+
task #{task_name}: :environment do
|
|
61
|
+
#{class_name}Syncer.new.sync
|
|
62
|
+
end
|
|
63
|
+
TASK
|
|
64
|
+
|
|
65
|
+
content = content.sub(/^end\s*$/, "#{new_task}end")
|
|
66
|
+
content = content.sub(/task all: %i\[\]/, "task all: %i[#{task_name}]")
|
|
67
|
+
File.write(rake_file, content)
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
|
|
20
71
|
def show_readme
|
|
21
72
|
readme_content = <<~README
|
|
22
73
|
|
|
@@ -27,6 +78,7 @@ module Harmonia
|
|
|
27
78
|
Files created:
|
|
28
79
|
- app/syncers/#{file_name}_syncer.rb
|
|
29
80
|
- db/migrate/..._add_filemaker_id_to_#{table_name}.rb
|
|
81
|
+
- lib/tasks/sync_data.rake (updated with sync_#{file_name} task)
|
|
30
82
|
|
|
31
83
|
Next steps:
|
|
32
84
|
1. Run migrations: rails db:migrate
|
|
@@ -45,6 +97,10 @@ module Harmonia
|
|
|
45
97
|
Note: The total_required count used for sync tracking is automatically calculated
|
|
46
98
|
from @total_create_required + @total_update_required
|
|
47
99
|
|
|
100
|
+
5. Run the sync task:
|
|
101
|
+
- Individual sync: rake sync:sync_#{file_name}
|
|
102
|
+
- All syncs: rake sync:all
|
|
103
|
+
|
|
48
104
|
README
|
|
49
105
|
|
|
50
106
|
say readme_content, :green if behavior == :invoke
|
|
@@ -47,8 +47,9 @@ module Harmonia
|
|
|
47
47
|
|
|
48
48
|
# Mark sync as completed
|
|
49
49
|
def finish!(records_synced:, records_required:, failed_fm_ids: [], failed_pg_ids: [])
|
|
50
|
+
status = records_synced == records_required ? 'completed' : 'failed'
|
|
50
51
|
update!(
|
|
51
|
-
status:
|
|
52
|
+
status: status,
|
|
52
53
|
records_synced: records_synced,
|
|
53
54
|
records_required: records_required,
|
|
54
55
|
failed_fm_ids: failed_fm_ids,
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: harmonia
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Kempen Automatisering
|
|
@@ -43,6 +43,7 @@ files:
|
|
|
43
43
|
- lib/generators/harmonia/templates/database_connector.rb
|
|
44
44
|
- lib/generators/harmonia/templates/filemaker_to_activerecord_syncer_template.rb
|
|
45
45
|
- lib/generators/harmonia/templates/harmonia_sync.rb
|
|
46
|
+
- lib/generators/harmonia/templates/sync_data.rake
|
|
46
47
|
- lib/generators/harmonia/templates/trophonius_model_extension.rb
|
|
47
48
|
- lib/harmonia.rb
|
|
48
49
|
- lib/harmonia/railtie.rb
|