Class: CoreDataMotion::FileWriter
- Inherits:
-
Object
- Object
- CoreDataMotion::FileWriter
- Defined in:
- lib/core_data_motion/file_writer.rb
Instance Method Summary collapse
- #create_model_definition ⇒ Object
- #entity_definition_class_name ⇒ Object
- #file_prefix ⇒ Object
- #model_contents_path ⇒ Object
- #model_xml_content ⇒ Object
- #path_to_model_contents ⇒ Object
Instance Method Details
#create_model_definition ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/core_data_motion/file_writer.rb', line 28 def create_model_definition Dir.glob("./settings/*.rb") { |filename| load filename } FileUtils.mkpath path_to_model_contents File.open(model_contents_path, "w") do |f| f.puts model_xml_content end end |
#entity_definition_class_name ⇒ Object
3 4 5 6 7 |
# File 'lib/core_data_motion/file_writer.rb', line 3 def entity_definition_class_name @entity_definition_class_name ||= begin Object.const_get file_prefix.split("_").map(&:capitalize).join end end |
#file_prefix ⇒ Object
9 10 11 |
# File 'lib/core_data_motion/file_writer.rb', line 9 def file_prefix @file_prefix ||= "model_definition" end |
#model_contents_path ⇒ Object
18 19 20 |
# File 'lib/core_data_motion/file_writer.rb', line 18 def model_contents_path @model_contents_path ||= "#{path_to_model_contents}/contents" end |
#model_xml_content ⇒ Object
22 23 24 25 26 |
# File 'lib/core_data_motion/file_writer.rb', line 22 def model_xml_content tmp_instance = entity_definition_class_name.new tmp_instance.define_model tmp_instance.to_xml end |
#path_to_model_contents ⇒ Object
13 14 15 16 |
# File 'lib/core_data_motion/file_writer.rb', line 13 def path_to_model_contents @path_to_model_contents ||= "./resources/#{file_prefix}.xcdatamodeld/#{file_prefix}.xcdatamodel" end |