Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Naming/FileName:

Metrics/AbcSize:
CountRepeatedAttributes: false
Max: 25
Max: 30

Metrics/ClassLength:
Max: 150
Expand Down
2 changes: 1 addition & 1 deletion _packages/ruby/lib/apple_data/data_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def construct_hash(collection_definition, value)
[key, instance]
end

result.to_h
result.to_h.with_indifferent_access
end
end
end
20 changes: 14 additions & 6 deletions _packages/ruby/lib/apple_data/dsl/data_file_definition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,21 @@ def initialize
@methods = {}
end

def collection(name, mapper = nil, &)
@collections[name] = AppleData::DSL::CollectionDefinition.new(name, mapper)
if block_given? && @collections[name].mapper.nil?
@collections[name].mapper = Class.new(AppleData::SchemaBase)
@collections[name].mapper.class_eval(&)
def collection(collection_name, mapper = nil, &)
data_collection_name = self.class.name
@collections[collection_name] = AppleData::DSL::CollectionDefinition.new(collection_name, mapper)
if block_given? && @collections[collection_name].mapper.nil?
@collections[collection_name].mapper = Class.new(AppleData::SchemaBase)
@collections[collection_name].mapper.const_set(:DATA_COLLECTION_NAME, data_collection_name)
@collections[collection_name].mapper.const_set(:COLLECTION_NAME, collection_name)
@collections[collection_name].mapper.instance_eval do
def name
"#{self.class.const_get(:DATA_COLLECTION_NAME)}:#{self.class.const_get(:COLLECTION_NAME)}"
end
end
Comment on lines +12 to +23
@collections[collection_name].mapper.class_eval(&)
end
@collections[name]
@collections[collection_name]
end

def define_method(name, &proc)
Expand Down
7 changes: 7 additions & 0 deletions _packages/ruby/lib/apple_data/schemas/pki.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,19 @@
end

collection :oids do
attr_accessor :key

attribute :name, :string
Comment on lines +18 to +20
attribute :title, :string
attribute :type, :string
attribute :description, :string
attribute :apple_description, :string
attribute :found_in, :string, collection: true
attribute :issuers, :string, collection: true
attribute :ous, :string, collection: true

define_method :to_s do
[name, title, description, key].reject(&:blank?).first
end
Comment on lines +29 to +31
end
end
19 changes: 19 additions & 0 deletions spec/apple_data/schemas/pki_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# frozen_string_literal: true

RSpec.describe AppleData::Schemas::PKI do
let(:instance) { described_class.new }

it 'has entries' do
aggregate_failures do
expect(instance.oids).to be_a(Hash)
expect(instance.oids).not_to be_empty
end
end

it 'has entries that respond to #to_s' do
aggregate_failures do
expect(instance.oids[:'1.2.840.113635.100.6.1.15'].to_s).to be_a(String)
expect(instance.oids[:'1.2.840.113635.100.6.1.15'].to_s).to eq 'appleImg4Manifest'
end
end
Comment on lines +13 to +18
end
Loading