building_sync_bindings 0.1.2 → 0.1.3

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.
@@ -1,3 +1,3 @@
1
1
  module BuildingSyncRails
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
@@ -25,6 +25,7 @@ module BuildingSyncTk
25
25
  def memo_building_sync_for(*args)
26
26
  memo_isomorphism_for(BuildingSyncTk::Inflector.instance, *args, xmlattrs: BuildingSyncTk::Factory.instance.xmlattrs)
27
27
  end
28
+ ruby2_keywords(:memo_building_sync_for) if respond_to?(:ruby2_keywords, true) # Ruby 3: forward keyword options through *args (no-op before 2.7)
28
29
 
29
30
  # Returns the memo-cahe.
30
31
  #
@@ -46,5 +47,6 @@ module BuildingSyncTk
46
47
  def find_all_with_memo_building_sync_for(*args)
47
48
  find_all_with_memo_isomorphism_for(BuildingSyncTk::Inflector.instance, *args, xmlattrs: BuildingSyncTk::Factory.instance.xmlattrs)
48
49
  end
50
+ ruby2_keywords(:find_all_with_memo_building_sync_for) if respond_to?(:ruby2_keywords, true) # Ruby 3: forward keyword options through *args (no-op before 2.7)
49
51
  end
50
52
  end
@@ -32,6 +32,7 @@ module BuildingSyncTk
32
32
  def building_sync_for(*args, &block)
33
33
  isomorphism_for(BuildingSyncTk::Factory.instance, BuildingSyncTk::Inflector.instance, *args, &block)
34
34
  end
35
+ ruby2_keywords(:building_sync_for) if respond_to?(:ruby2_keywords, true) # Ruby 3: forward keyword options through *args (no-op before 2.7)
35
36
  end
36
37
  end
37
38
  end
@@ -120,13 +120,26 @@ namespace :building_sync_rails do
120
120
  # @note Download the BuildingSync XSD file from the remote network and copy to the local disk.
121
121
  download_schema_recursive(uri_xsd_remote, verbose)
122
122
 
123
- # @note Execute the "xsd2ruby.rb" binary that is installed by the "soap4r" gem. The Ruby source files are created in the "/" directory.
124
- ::Bundler.with_clean_env do
125
- `xsd2ruby.rb --xsd #{::File.join("public", uri_xsd_remote.split(::File::SEPARATOR)[-1])} --module_path "BuildingSync" --classdef "BuildingSync" --mapping_registry --mapper --force --quiet`
123
+ # @note Execute the "xsd2ruby.rb" binary that is installed by the "soap4r" gem. The Ruby source files are created in the repository root.
124
+ xsd_path = ::File.join("public", uri_xsd_remote.split(::File::SEPARATOR)[-1])
125
+ generation_succeeded = ::Bundler.with_clean_env do
126
+ ::Kernel.system(
127
+ "xsd2ruby.rb",
128
+ "--xsd", xsd_path,
129
+ "--module_path", "BuildingSync",
130
+ "--classdef", "BuildingSync",
131
+ "--mapping_registry",
132
+ "--mapper",
133
+ "--force",
134
+ "--quiet"
135
+ )
126
136
  end
137
+ raise "xsd2ruby.rb failed; generated files were not sanitized or moved" unless generation_succeeded
127
138
 
128
139
  # @note Sanitize the contents of each Ruby source file.
129
140
  options_by_local_name.each do |local_name, options|
141
+ raise "xsd2ruby.rb did not generate #{local_name}" unless ::File.file?(local_name)
142
+
130
143
  s = ::File.open(local_name, "r") do |file|
131
144
  array = file.read.split($/)
132
145
 
@@ -152,6 +165,8 @@ namespace :building_sync_rails do
152
165
  # @note Move the Ruby source files to the "lib/" directory.
153
166
  options_by_local_name.keys.each do |local_name|
154
167
  ::FileUtils.mv(local_name, ::File.join("lib", local_name)) if ::File.exist?(local_name)
168
+ raise "Generated file was not moved to lib/#{local_name}" unless ::File.file?(::File.join("lib", local_name))
169
+ raise "Stale generated file remains at repository root: #{local_name}" if ::File.exist?(local_name)
155
170
  end
156
171
  end
157
172
  end