class Object

Constants

CONFIG_DIR

Public Instance Methods

create_new_config(module_root_dir) click to toggle source
# File lib/vipera/config.rb, line 6
def create_new_config(module_root_dir)

    if File.exists? CONFIG_DIR then raise "Already initialized!" end
    unless File.exists? "#{Dir.pwd}/#{module_root_dir}" then raise "Module root directory not exists!" end

    config_object = {"module-root": module_root_dir}
    File.write CONFIG_DIR, JSON.generate(config_object)
end
main() click to toggle source
# File lib/vipera/main.rb, line 4
def main
    if ARGV.count < 1 then raise "Invalid arguments!" end

    module_name = ARGV[0]

    config = read_config
    xcodeproj = read_xcodeproj config

    source_map = Sources::create_sources_map module_name
    Sources::generate_sources module_name, xcodeproj, read_config, source_map

    xcodeproj.save

    puts "Module #{module_name} generated!"
end
read_config() click to toggle source
# File lib/vipera/config.rb, line 15
def read_config
    unless File.exists? CONFIG_DIR then raise "Config file required!" end
    JSON.parse File.read CONFIG_DIR
end
read_xcodeproj(config) click to toggle source
# File lib/vipera/config.rb, line 20
def read_xcodeproj(config)
    xcodeproj_file = config["xcodeproj"]
    unless File.exists? "#{Dir.pwd}/#{xcodeproj_file}" then raise "xcodeproj file not found!" end

    Xcodeproj::Project.open("#{Dir.pwd}/#{xcodeproj_file}")
end
run_main() click to toggle source
# File lib/vipera/main.rb, line 20
def run_main
    begin
        main
    rescue StandardError => e
        puts e.message
    end
end