Sha256: b7c0c21ad089bd09dcd88a95e857d2bcc1e063db8d15eb3d8e0687c3c4b33fec

Contents?: true

Size: 1.3 KB

Versions: 1

Compression:

Stored size: 1.3 KB

Contents

# external dependencies
require 'rubygems'
require 'json'
require 'sfplanner'
require 'colorize'
require "coderay"
require 'logger'
require 'yaml'

# define main module
module Nuri
	def self.windows?
		RUBY_PLATFORM.downcase.include?("mswin")
	end

	def self.home
		Dir.home + '/.nuri'
	end

	def self.init
		### create home directory
		Dir.mkdir(home) if not File.exist?(home)

		### create main configuration file
		File.open(main, 'w') { |f| f.write('') } if not File.exist?(main)

		### create default configuration if it's not exist
		File.open(config_file, 'w') { |f| f.write(YAML.dump(default_config)) } if not File.exist?(config_file)

		### create link to built-in modules directory
		modules_dir = "#{home}/modules"
		system "ln -sf #{File.expand_path(File.dirname(__FILE__) + '/../modules')} #{modules_dir}" if not File.exist?(modules_dir)
	end

	def self.main
		home + '/main.sfp'
	end

	def self.config
		return default_config if not File.exist?(config_file)
		YAML.load(File.read(config_file))
	end

	def self.config_file
		home + '/config.yml'
	end

	def self.default_config
		{
			"editor" => "vim"
		}
	end
end

# internal dependencies
libdir = File.dirname(__FILE__) << '/nuri'
['constraint_helper.rb', 'helper.rb', 'orchestrator.rb',
 'choreographer.rb', 'master.rb'].each do |file|
	require "#{libdir}/#{file}"
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nuri-0.5.3 lib/nuri.rb