Module: RestKat

Defined in:
lib/rest_kat.rb,
lib/rest_kat.rb,
lib/rest_kat/validator.rb

Defined Under Namespace

Classes: IosMapping, MySugrIphone, ObjCClass, ObjCProperty, Resource, Validator

Class Method Summary collapse

Class Method Details

.generate_api(api_location, schema_location) ⇒ Object



316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
# File 'lib/rest_kat.rb', line 316

def self.generate_api(api_location, schema_location)

    api_src = File.join api_location, "MSRestApiAutoGen"
    m_file_task = generate_item(api_src, schema_location, "h")
    h_file_task = generate_item(api_src, schema_location, "m")

    src_path = File.expand_path "../../src", __FILE__

    src_h = File.join src_path, "MSRestSerializable.h"
    src_m = File.join src_path, "MSRestSerializable.m"

    tgt_h = File.join api_location, "MSRestSerializable.h"
    tgt_m = File.join api_location, "MSRestSerializable.m"


    t0 = file tgt_h, src_h do
        cp src_h, tgt_h, :verbose => true
    end

    t1 = file tgt_m, src_m do
        cp src_m, tgt_m, :verbose => true
    end

    Rake::Task.define_task :type => [m_file_task, h_file_task, t0, t1]
end

.generate_item(api_location, schema_location, ext) ⇒ Object



294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
# File 'lib/rest_kat.rb', line 294

def self.generate_item(api_location, schema_location, ext)
    deps = %w[
        model.h.erb
        model.m.erb
        rest_kat.rb
        validator.rb
    ].collect do |d|
        File.expand_path "../#{d}", __FILE__
    end

    deps << schema_location

    file = "#{api_location}.#{ext}"

    file_task = Rake::FileTask.define_task file => deps do
        File.open file, 'w' do |f|
            puts "Generating #{file}"
            f.write RestKat::IosMapping.new(schema_location).send("to_#{ext}", file)
        end
    end  
end