Sha256: 24f3af52c6c28488e3e6de1a358cc209b73fd25f804f47e5795ab37779efbd47

Contents?: true

Size: 1.24 KB

Versions: 2

Compression:

Stored size: 1.24 KB

Contents

require 'xcdm/schema'
require 'xcdm/entity'

if defined?(Motion::Project::Config)

  class Motion::Project::Config
    variable :xcdm

    def xcdm
      @xcdm ||= Struct.new(:name).new(nil)
    end
  end

  if File.directory?(File.join(App.config.project_dir, "schemas"))
    namespace :schema do

      desc "Clear the datamodel outputs"
      task :clean do
        App.config.xcdm.name ||= App.config.name
        files = Dir.glob(File.join(App.config.project_dir, 'resources', App.config.xcdm.name) + ".{momd,xcdatamodeld}")
        files.each do |f|
          rm_rf f
        end
      end

      desc "Generate the xcdatamodel file"
      task :build => :clean do
        App.config.xcdm.name ||= App.config.name
        Dir.chdir App.config.project_dir
        if `xcodebuild -version` =~ /Xcode (\d+.\d+)/
          xcode_version = $1
        else
          raise "could not determine xcode version"
        end
        runner = XCDM::Schema::Runner.new( App.config.xcdm.name, "schemas", "resources", App.config.sdk_version)
        App.info "Generating", "Data Model #{App.config.xcdm.name}"
        runner.load_all { |schema, file| App.info "Loading", file }
        runner.write_all { |schema, file| App.info "Writing", file }
      end
    end
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ruby-xcdm-1.0.0 lib/ruby-xcdm.rb
ruby-xcdm-0.0.11 lib/ruby-xcdm.rb