module Gyro::Parser::XCDataModel
Parser
for CoreData's xcdatamodel files
Public Class Methods
find_in_dir(dir)
click to toggle source
# File lib/gyro/parser/xcdatamodel/xcdatamodel.rb, line 22 def self.find_in_dir(dir) Dir.chdir(dir) do files = Dir.glob('*.xcdatamodel') files.first.nil? ? nil : File.expand_path(files.first, dir) end end
user_info(xml, key)
click to toggle source
# File lib/gyro/parser/xcdatamodel/xcdatamodel.rb, line 29 def self.user_info(xml, key) XPath.first(xml, "userInfo/entry[@key='#{key}']/@value").to_s end
Public Instance Methods
load_attributes(entity_xml)
click to toggle source
# File lib/gyro/parser/xcdatamodel/entity.rb, line 177 def load_attributes(entity_xml) entity_xml.each_element('attribute') do |node| attribute = Attribute.new(node, @name) if attribute.type != 'Transformable' @attributes[attribute.name] = attribute end end end
load_relationships(entity_xml)
click to toggle source
# File lib/gyro/parser/xcdatamodel/entity.rb, line 186 def load_relationships(entity_xml) entity_xml.each_element('relationship') do |node| relationship = Relationship.new(node, @name) @relationships[relationship.name] = relationship end end
search_for_error()
click to toggle source
# File lib/gyro/parser/xcdatamodel/relationship.rb, line 72 def search_for_error # rubocop:disable Style/GuardClause if inverse_type.empty? && destination.empty? message = %(The relationship "#{@name}" from "#{@entity_name}" is wrong - please fix it) Gyro::Log.fail!(message) end if !destination.empty? && type != :to_many message = %(The relationship "#{@name}" from "#{@entity_name}" is wrong - ) + %(please set a 'No Value' relationship as 'To Many') Gyro::Log.fail!(message) end # rubocop:enable Style/GuardClause end