ninjs 0.10.1 → 0.10.2

Sign up to get free protection for your applications and to get access to all the features.
data/bin/ninjs CHANGED
@@ -42,11 +42,11 @@ class NinjsConsole < Rubikon::Application::Base
42
42
  Ninjs::Command.import
43
43
  end
44
44
 
45
- option :directory, [:dir] do
45
+ option :directory, :dir do
46
46
  @directory = dir
47
47
  end
48
48
  option :p => :directory
49
- command :create, [:app_name] do
49
+ command :create, :app_name do
50
50
  Ninjs::Command.create(app_name, @directory)
51
51
  end
52
52
  end
@@ -3,7 +3,7 @@ end
3
3
 
4
4
  module Ninjs
5
5
  def version
6
- '0.9.4'
6
+ '0.10.1'
7
7
  end
8
8
 
9
9
  def base_directory
@@ -9,7 +9,9 @@ module Ninjs
9
9
  :dependencies,
10
10
  :autoload,
11
11
  :config_path,
12
- :asset_root
12
+ :asset_root,
13
+ :base_url,
14
+ :tests_path
13
15
 
14
16
  def initialize(project_path, name = 'NinjsApplication')
15
17
  @defaults = {
@@ -18,7 +20,9 @@ module Ninjs
18
20
  :asset_root => project_path,
19
21
  :output => 'expanded',
20
22
  :dependencies => ['<jquery/latest>'],
21
- :autoload => ['<ninjs/utilities/all>']
23
+ :autoload => ['<ninjs/utilities/all>'],
24
+ :base_url => 'http://www.example.com/',
25
+ :tests_path => 'tests/'
22
26
  }
23
27
 
24
28
  @defaults.each do |label, setting|
@@ -39,6 +43,8 @@ asset_root: #{options[:project_path]}
39
43
  output: #{options[:output]}
40
44
  dependencies: [#{options[:dependencies].join(', ')}]
41
45
  autoload: [#{options[:autoload].join(', ')}]
46
+ base_url: #{options[:base_url]}
47
+ tests_path: #{options[:tests_path]}
42
48
  CONF
43
49
  end
44
50
 
@@ -57,7 +63,9 @@ autoload: [#{options[:autoload].join(', ')}]
57
63
  :asset_root => @project_path,
58
64
  :output => @output,
59
65
  :dependencies => @dependencies,
60
- :autoload => @autoload
66
+ :autoload => @autoload,
67
+ :base_url => @base_url,
68
+ :tests_path => @tests_path
61
69
  })
62
70
  create_conf_file content
63
71
  end
@@ -74,6 +82,8 @@ autoload: [#{options[:autoload].join(', ')}]
74
82
  @output = config['output']
75
83
  @dependencies = config['dependencies'] || Array.new
76
84
  @autoload = config['autoload'] || Array.new
85
+ @base_url = config['base_url'] || 'http://www.example.com/'
86
+ @tests_path = config['tests_path'] || 'tests/'
77
87
  rescue IOError => e
78
88
  puts e.message
79
89
  puts e.backtrace.inspect
File without changes
@@ -1,6 +1,5 @@
1
1
  module Ninjs
2
- class Project
3
-
2
+ class Project
4
3
  attr_reader :app_filename,
5
4
  :project_path,
6
5
  :config
@@ -19,15 +18,13 @@ module Ninjs
19
18
  project
20
19
  end
21
20
 
22
- def initialize(name = 'NinjsApplication', project_dir = '/')
23
- name.gsub!(/\s|\-|\./)
21
+ def initialize(name = 'NinjsApplication', project_dir = '/')
22
+ app_name = name.gsub(/\s|\-|\./, '')
24
23
  proj_dir = clean_project_path project_dir
25
24
  @modules = Array.new
26
-
27
25
  @color_start = "\e[32m"
28
26
  @color_end = "\e[0m"
29
-
30
- @app_filename = name.downcase
27
+ @app_filename = app_name.downcase
31
28
  @project_path = "#{Ninjs.root_directory}#{proj_dir}"
32
29
  @config = Ninjs::Configuration.new @project_path, name
33
30
  end
@@ -89,16 +86,16 @@ module Ninjs
89
86
  File.open(filename, "w+") do |file|
90
87
  file << "//-- Ninjs #{Time.now.to_s} --//\n"
91
88
  file << File.open("#{@project_path}lib/nin.js", 'r').readlines.join('')
92
- file << "\nvar #{@config.name} = new NinjsApplication();"
89
+ file << "\nvar #{@config.name} = new NinjsApplication('#{@config.base_url}', '#{@config.tests_path}');"
93
90
  end
94
91
  end
95
92
 
96
93
  def import_test_files
97
- Fileutils.cp "#{Ninjs.base_directory}/repository/ninjs/tests/index.html", "#{@project_path}tests"
98
- Fileutils.cp "#{Ninjs.base_directory}/repository/ninjs/tests/ninjs.test.js", "#{@project_path}tests"
99
- Fileutils.cp "#{Ninjs.base_directory}/repository/ninjs/tests/ninjs.utilities.test.js", "#{@project_path}tests"
100
- Fileutils.cp "#{Ninjs.base_directory}/repository/ninjs/tests/qunit/qunit.js", "#{@project_path}tests/qunit"
101
- Fileutils.cp "#{Ninjs.base_directory}/repository/ninjs/tests/qunit/qunit.css", "#{@project_path}tests/qunit"
94
+ FileUtils.cp "#{Ninjs.base_directory}/repository/ninjs/tests/index.html", "#{@project_path}tests"
95
+ FileUtils.cp "#{Ninjs.base_directory}/repository/ninjs/tests/ninjs.test.js", "#{@project_path}tests"
96
+ FileUtils.cp "#{Ninjs.base_directory}/repository/ninjs/tests/ninjs.utilities.test.js", "#{@project_path}tests"
97
+ FileUtils.cp "#{Ninjs.base_directory}/repository/ninjs/tests/qunit/qunit.js", "#{@project_path}tests/qunit"
98
+ FileUtils.cp "#{Ninjs.base_directory}/repository/ninjs/tests/qunit/qunit.css", "#{@project_path}tests/qunit"
102
99
  end
103
100
 
104
101
  def update
@@ -187,7 +184,7 @@ module Ninjs
187
184
  def write_core(file)
188
185
  file << "/*---------- Ninjs core ../lib/nin.js ----------*/\n"
189
186
  file << "//= require \"../lib/nin.js\"\n\n"
190
- file << "\nvar #{@config.name} = new NinjsApplication();\n\n"
187
+ file << "\nvar #{@config.name} = new NinjsApplication('#{@config.base_url}', '#{@config.tests_path}');\n\n"
191
188
  end
192
189
 
193
190
  def write_autoload(file)
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{ninjs}
8
- s.version = "0.10.1"
8
+ s.version = "0.10.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Dayton Nolan"]
12
- s.date = %q{2011-01-25}
12
+ s.date = %q{2011-01-29}
13
13
  s.default_executable = %q{ninjs}
14
14
  s.description = %q{Ninjs is a ruby application and small javascript framework that helps you build clean, modular javascript applications. Ninjs encourages "Good Parts" best practices and the Crockford school Module pattern (http://www.crockford.com/). The ninjs command line application is an automatic compiler, written in ruby, and based on the Sprockets library (http://getsprockets.org/).}
15
15
  s.email = %q{daytonn@gmail.com}
@@ -7,13 +7,20 @@
7
7
  See Also:
8
8
  <NinjsModule>
9
9
  */
10
- var NinjsApplication = function() {
10
+ var NinjsApplication = function(base_url, tests_path) {
11
11
  if (is_undefined(window._)) {
12
12
  window._ = this;
13
13
  }
14
-
15
- if (is_undefined(window.app)) {
16
- window.app = this;
14
+
15
+ if(is_defined(tests_path)) {
16
+ this.tests_path = tests_path;
17
+ }
18
+
19
+ if(is_defined(base_url)) {
20
+ this.site_url = function(path) {
21
+ var path = path || '';
22
+ return base_url + path;
23
+ }
17
24
  }
18
25
  };
19
26
 
@@ -190,10 +190,10 @@ NinjsModule.method('add_test', function(test_file) {
190
190
  });
191
191
 
192
192
  /*
193
- Method: run_tests
193
+ Method: _run_tests
194
194
  Runs the test files in the test array. This method is automatically called by the execute method if run_tests === true
195
195
  */
196
- NinjsModule.method('run_tests', function() {
196
+ NinjsModule.method('_run_tests', function() {
197
197
  var test_template = [];
198
198
  test_template.push('<div class="test-results" title="Test Results">');
199
199
  test_template.push('<h1 id="qunit-header">' + this.name + ' module tests</h1>');
@@ -202,25 +202,31 @@ NinjsModule.method('run_tests', function() {
202
202
  test_template.push('<ol id="qunit-tests"></ol>');
203
203
  test_template.push('</div>');
204
204
 
205
+ var qunit_dependencies = '<script src="' + _.tests_path +'qunit/qunit.js"></script>';
206
+ $.getScript(_.tests_path + 'qunit/qunit.js');
207
+ var qunit_styles = '<link rel="stylesheet" href="' + _.tests_path + 'qunit/qunit.css">';
208
+ $('body').append(qunit_styles);
205
209
  $('body').append(test_template.join("\n"));
206
210
 
207
211
  this.tests.each(function(test) {
208
- $.getScript('tests/' + some + '.test.js', function() {
212
+ $.getScript(_.tests_path + test + '.test.js', function() {
209
213
  var test_results_dialog = $('.test-results');
210
- var height = test_results_dialog.height() + 130;
214
+ var height = $(window).height() - 200;
211
215
  var width = $(window).width() - 300;
212
- var maxHeight = $(window).height() - 200;
213
216
  try {
214
217
  test_results_dialog.dialog({
215
218
  width: width,
216
219
  height: height,
217
- maxHeight: maxHeight,
220
+ autoOpen: false,
218
221
  buttons: {
219
222
  "Thanks buddy": function() {
220
223
  test_results_dialog.dialog('close');
221
224
  }
222
225
  }
223
226
  });
227
+ var failed = $('.failed');
228
+ console.log(failed.html());
229
+ test_results_dialog.dialog('open');
224
230
  }
225
231
  catch(error) {
226
232
  alert("Test harness requires jQueryUI");
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 10
8
- - 1
9
- version: 0.10.1
8
+ - 2
9
+ version: 0.10.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Dayton Nolan
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-01-25 00:00:00 -06:00
17
+ date: 2011-01-29 00:00:00 -06:00
18
18
  default_executable: ninjs
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -459,7 +459,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
459
459
  requirements:
460
460
  - - ">="
461
461
  - !ruby/object:Gem::Version
462
- hash: -3748990397520062791
462
+ hash: 3572589723604572302
463
463
  segments:
464
464
  - 0
465
465
  version: "0"