lib/ninjs/project.rb in ninjs-0.10.1 vs lib/ninjs/project.rb in ninjs-0.10.2
- old
+ new
@@ -1,8 +1,7 @@
module Ninjs
- class Project
-
+ class Project
attr_reader :app_filename,
:project_path,
:config
attr_writer :config,
:project_path,
@@ -17,19 +16,17 @@
project.project_path = config.project_path
project.app_filename = config.name.downcase
project
end
- def initialize(name = 'NinjsApplication', project_dir = '/')
- name.gsub!(/\s|\-|\./)
+ def initialize(name = 'NinjsApplication', project_dir = '/')
+ app_name = name.gsub(/\s|\-|\./, '')
proj_dir = clean_project_path project_dir
@modules = Array.new
-
@color_start = "\e[32m"
@color_end = "\e[0m"
-
- @app_filename = name.downcase
+ @app_filename = app_name.downcase
@project_path = "#{Ninjs.root_directory}#{proj_dir}"
@config = Ninjs::Configuration.new @project_path, name
end
def clean_project_path(dir)
@@ -87,20 +84,20 @@
filename = "#{@project_path}application/#{@app_filename}.js"
File.open(filename, "w+") do |file|
file << "//-- Ninjs #{Time.now.to_s} --//\n"
file << File.open("#{@project_path}lib/nin.js", 'r').readlines.join('')
- file << "\nvar #{@config.name} = new NinjsApplication();"
+ file << "\nvar #{@config.name} = new NinjsApplication('#{@config.base_url}', '#{@config.tests_path}');"
end
end
def import_test_files
- Fileutils.cp "#{Ninjs.base_directory}/repository/ninjs/tests/index.html", "#{@project_path}tests"
- Fileutils.cp "#{Ninjs.base_directory}/repository/ninjs/tests/ninjs.test.js", "#{@project_path}tests"
- Fileutils.cp "#{Ninjs.base_directory}/repository/ninjs/tests/ninjs.utilities.test.js", "#{@project_path}tests"
- Fileutils.cp "#{Ninjs.base_directory}/repository/ninjs/tests/qunit/qunit.js", "#{@project_path}tests/qunit"
- Fileutils.cp "#{Ninjs.base_directory}/repository/ninjs/tests/qunit/qunit.css", "#{@project_path}tests/qunit"
+ FileUtils.cp "#{Ninjs.base_directory}/repository/ninjs/tests/index.html", "#{@project_path}tests"
+ FileUtils.cp "#{Ninjs.base_directory}/repository/ninjs/tests/ninjs.test.js", "#{@project_path}tests"
+ FileUtils.cp "#{Ninjs.base_directory}/repository/ninjs/tests/ninjs.utilities.test.js", "#{@project_path}tests"
+ FileUtils.cp "#{Ninjs.base_directory}/repository/ninjs/tests/qunit/qunit.js", "#{@project_path}tests/qunit"
+ FileUtils.cp "#{Ninjs.base_directory}/repository/ninjs/tests/qunit/qunit.css", "#{@project_path}tests/qunit"
end
def update
get_updated_modules
compile_modules
@@ -185,10 +182,10 @@
end
def write_core(file)
file << "/*---------- Ninjs core ../lib/nin.js ----------*/\n"
file << "//= require \"../lib/nin.js\"\n\n"
- file << "\nvar #{@config.name} = new NinjsApplication();\n\n"
+ file << "\nvar #{@config.name} = new NinjsApplication('#{@config.base_url}', '#{@config.tests_path}');\n\n"
end
def write_autoload(file)
@config.autoload.each do |auto_file|
file << "/*---------- Ninjs autoload #{auto_file} ----------*/"
\ No newline at end of file