diff --git a/.idea/apple-knowledge.iml b/.idea/apple-knowledge.iml index 75328247..966974ca 100644 --- a/.idea/apple-knowledge.iml +++ b/.idea/apple-knowledge.iml @@ -28,7 +28,7 @@ - + diff --git a/.idea/runConfigurations/AppleData_Specs.xml b/.idea/runConfigurations/AppleData_Specs.xml index dd1ea645..ff1cf8d5 100644 --- a/.idea/runConfigurations/AppleData_Specs.xml +++ b/.idea/runConfigurations/AppleData_Specs.xml @@ -3,7 +3,7 @@ - + diff --git a/_packages/ruby/Rakefile b/_packages/ruby/Rakefile index 4e494d69..9c82ae35 100644 --- a/_packages/ruby/Rakefile +++ b/_packages/ruby/Rakefile @@ -14,7 +14,7 @@ OUTPUT_PATH = Pathutil.new OUTPUT_ROOT desc 'set the version patch to the git main height' task :version do - repo_height = `git rev-list --count HEAD` + repo_height = `git rev-list --count main` repo_height = '0' if repo_height.empty? version_file = %(# frozen_string_literal: true diff --git a/_packages/ruby/lib/apple_data/dsl/data_file_definition.rb b/_packages/ruby/lib/apple_data/dsl/data_file_definition.rb index 66e50877..6842736b 100644 --- a/_packages/ruby/lib/apple_data/dsl/data_file_definition.rb +++ b/_packages/ruby/lib/apple_data/dsl/data_file_definition.rb @@ -6,6 +6,7 @@ module DSL class DataFileDefinition def initialize @collections = {} + @methods = {} end def collection(name, mapper = nil, &) @@ -17,6 +18,10 @@ def collection(name, mapper = nil, &) @collections[name] end + def define_method(name, &proc) + @methods[name] = proc + end + attr_writer :default_filename def build! @@ -29,6 +34,10 @@ def build! collection_definition.build!(klass) end + @methods.each do |name, proc| + klass.define_method(name, &proc) + end + klass end end diff --git a/_packages/ruby/lib/apple_data/schemas/img4.rb b/_packages/ruby/lib/apple_data/schemas/img4.rb index 2db58a2e..6f0db354 100644 --- a/_packages/ruby/lib/apple_data/schemas/img4.rb +++ b/_packages/ruby/lib/apple_data/schemas/img4.rb @@ -16,4 +16,9 @@ collection :types do attribute :description, :string end + + define_method :all do + [img4_tags, manifest_properties, objects, lpol_properties, core, types, + cryptex_properties].reduce(&:merge).with_indifferent_access + end end diff --git a/spec/apple_data/schemas/img4_spec.rb b/spec/apple_data/schemas/img4_spec.rb index 5c4d02fa..1b6b1ee7 100644 --- a/spec/apple_data/schemas/img4_spec.rb +++ b/spec/apple_data/schemas/img4_spec.rb @@ -44,4 +44,11 @@ expect(instance.lpol_properties.values.compact).to all(be_a(AppleData::Models::IMG4::Property)) end end + + it 'has #all' do + aggregate_failures do + expect(instance.all).to be_a(Hash) + expect(instance.all).not_to be_empty + end + end end