ninjs 0.11.0 → 0.11.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.textile CHANGED
@@ -2,7 +2,7 @@ h1. Readme
2
2
 
3
3
  h2. About
4
4
 
5
- Ninjs (No Inheritance Necessary) is a command line application written in ruby that leverages the "Sprockets":http://getsprockets.org JavaScript compiler to create modular javascript applications without having to compile your scripts manually. Ninjs also contains a "'Good Parts'":http://www.amazon.com/JavaScript-Good-Parts-Douglas-Crockford/dp/0596517742/ref=sr_1_1?ie=UTF8&qid=1294628522&sr=8-1 JavaScript framework to encourage best practices like name-spacing and modular separation.
5
+ Ninjs is a command line application written in ruby that leverages the "Sprockets":http://getsprockets.org JavaScript compiler to create modular javascript applications without having to compile your scripts manually. Ninjs also contains a "'Good Parts'":http://www.amazon.com/JavaScript-Good-Parts-Douglas-Crockford/dp/0596517742/ref=sr_1_1?ie=UTF8&qid=1294628522&sr=8-1 JavaScript framework to encourage best practices like name-spacing and modular separation.
6
6
 
7
7
  h2. Installation
8
8
 
@@ -16,7 +16,7 @@ $ export PATH=/path/to/ninjs/bin:$PATH
16
16
 
17
17
  h1. Create a Ninjs application
18
18
 
19
- <pre name="code" class="brush: sh;">$ ninjs create MyApplication</pre>
19
+ <pre name="code" class="brush: sh;">$ ninjs create myapplication</pre>
20
20
 
21
21
  This will create a Ninjs application in the current working directory. Now we can create Ninjs modules by adding them in the modules directory.
22
22
 
@@ -29,23 +29,23 @@ Create a module file in the /modules directory. By convention, we'll name the fi
29
29
  The basic functionality of a module is to encapsulate specific logic into a container. Think of a module as a class in the sense that it allows to name-space properties and methods. A Ninjs module is an extremely lightweight object that contains a very simple api which helps you write clear, concise code. The following is the bare minimum you need to have a working module a.k.a Ninjs' "Hello World":
30
30
 
31
31
  <pre name="code" class="brush: js;">
32
- MyApplication.add_module('hello');
32
+ myapplication.add_module('hello');
33
33
 
34
- MyApplication.hello.actions = function() {
34
+ myapplication.hello.actions = function() {
35
35
  this.say_hello();
36
36
  };
37
37
 
38
- MyApplication.hello.say_hello = function() {
38
+ myapplication.hello.say_hello = function() {
39
39
  alert('Hello World');
40
40
  };
41
41
 
42
- MyApplication.hello.run();
42
+ myapplication.hello.run();
43
43
  </pre>
44
44
 
45
45
  The run method will execute the actions method. Please note that the "run" method will wait for the DOM to be ready before it is executed. If you wish the actions to be executed immediately, you may call the execute method like so:
46
46
 
47
47
  <pre name="code" class="brush: js;">
48
- MyApplication.hello.execute();
48
+ myapplication.hello.execute();
49
49
  </pre>
50
50
 
51
51
  This pattern allows you to write in a literate style while making your intentions clear and methods succinct. However, if you prefer a shorter syntax or make your module completely protable (transplant to any application), Ninjs defines two aliases to work with your application and modules that are more terse. Your application object will be aliased as "_" (underscore). When using either the run or execute methods to call the module's actions, the module will be available through the "__" alias. The previous hello module would look like the following:
@@ -64,33 +64,33 @@ This pattern allows you to write in a literate style while making your intention
64
64
  _.hello.run();
65
65
  </pre>
66
66
 
67
- This not only makes the module less cumbersome to write, it also allows you to copy the code directly to another Ninjs application and run it without any renaming. Remember one underscore is a reference to the application and two underscores is a reference to the current module.
67
+ This not only makes the module less cumbersome to write, it also allows you to port modules directly into other Ninjs application's and run them without any renaming. Remember one underscore is a reference to the application and two underscores is a reference to the current module.
68
68
 
69
- You may ask why we are calling say_hello() in the actions method instead of just alerting the string in actions itself. Let's set aside the fact that this is a trivial example and assume we will be adding many more methods to the module. If we simply added all of our module code inside actions, we'd quickly have a soup of code in there which would be difficult to follow. I prefer my actions method to be a list of methods called in the order they are defined. This let's my module tell a consistent story from top to bottom. The actions method serves as a table of contents. Consider a slightly more sophisticated hello module:
69
+ You may ask why we are calling say_hello() in the actions method instead of just alerting the string in actions itself. Let's set aside the fact that this is a trivial example and assume we will be adding many more methods to the module. If we simply added all of our module code inside actions, we'd quickly have a soup of code in there which would be difficult to follow. The Ninjs javascript framework encourages syntactic clarity. It's preferable for the actions method to be a list of methods called in the module. This let's my module tell a consistent story from top to bottom. The actions method serves as a table of contents. Consider a slightly more sophisticated hello module:
70
70
 
71
71
  <pre name="code" class="brush: js;">
72
- MyApplication.add_module('hello');
72
+ myapplication.add_module('hello');
73
73
 
74
- MyApplication.hello.actions = function() {
74
+ myapplication.hello.actions = function() {
75
75
  this.define_properties();
76
76
  this.say_hello();
77
77
  };
78
78
 
79
- MyApplication.hello.define_properties() = function() {
79
+ myapplication.hello.define_properties() = function() {
80
80
  this.greeting = 'Hello';
81
81
  this.name = 'World';
82
82
  }
83
83
 
84
- MyApplication.hello.say_hello = function() {
84
+ myapplication.hello.say_hello = function() {
85
85
  var message = this.greeting_string();
86
86
  alert(message);
87
87
  };
88
88
 
89
- MyApplication.hello.greeting_string = function() {
89
+ myapplication.hello.greeting_string = function() {
90
90
  return this.greeting + ' ' + this.name + '!';
91
91
  };
92
92
 
93
- MyApplication.hello.run();
93
+ myapplication.hello.run();
94
94
  </pre>
95
95
 
96
96
  We can see what this module does by simply glancing at the actions method. From there, if methods are kept short and follow the "single responsibiliy principle":http://en.wikipedia.org/wiki/Single_responsibility_principle, it will be easy to follow and test.
@@ -117,7 +117,7 @@ The only problem with this is that we tend to manipulate a lot of selections and
117
117
  Elements belong to a module and can be added using the elements method. To add elements to the hello module, let's add a hello.elements.js file in the elements folder. Next add the elements to the module with the elements method:
118
118
 
119
119
  <pre name="code" class="brush: js;">
120
- MyApplication.hello.elements(function() {
120
+ myapplication.hello.elements(function() {
121
121
  this.message_box = $('#message-box');
122
122
  });
123
123
  </pre>
@@ -125,7 +125,7 @@ Elements belong to a module and can be added using the elements method. To add e
125
125
  And that's it for the elements code. We've added a cached element with the id of "message-box" to our module. All there is left is to add the elements to the module using the "Sprockets require directive":http://getsprockets.org/installation_and_usage#specifying_dependencies_with_the_require_directive
126
126
 
127
127
  <pre name="code" class="brush: js;">
128
- MyApplication.add_module('hello');
128
+ myapplication.add_module('hello');
129
129
 
130
130
  //= require '../elements/hello.elements.js'
131
131
 
@@ -137,7 +137,7 @@ Be sure to require the elements file after the "add_module" method is called. No
137
137
  <pre name="code" class="brush: js;">
138
138
  ...
139
139
 
140
- MyApplication.hello.say_hello = function() {
140
+ myapplication.hello.say_hello = function() {
141
141
  var message = this.greeting_string();
142
142
  this.message_box.html(message);
143
143
  };
@@ -151,22 +151,24 @@ Most modules will be exactly like the one we just created, only with more method
151
151
 
152
152
  h2. Create a Ninjs model
153
153
 
154
- Ninjs models are simply files in the models directory that define a data structure. By convention models are simply object literals that are usefull for reusing inside your modules and throughout your application. There is no one way to create or use a model but I'll describe the common use case.
154
+ Ninjs models are simply files in the models directory that define a data structure. By convention models are simply object literals that are useful for reusing inside your modules and throughout your application.
155
155
 
156
156
  Let's suppose I have multiple "jQueryUI dialog windows":http://jqueryui.com/demos/dialog/ that I want to share a certain default configuration. Instead of creating an options object each time I call dialog on an element, I can use a model. Let's see how this might look in our hello example. Let's create the model in /models/hello.model.js:
157
157
 
158
158
  <pre name="code" class="brush: js;">
159
- MyApplication.hello.dialog_settings = {
159
+ myapplication.hello.set_data('dialog_settings', {
160
160
  width: 300,
161
161
  height: 150,
162
162
  autoOpen: false
163
- }
163
+ });
164
164
  </pre>
165
165
 
166
+ The set_data method will add the dialog_settings object to the module's data property (one of the only default module properties). You could add objects directly to the data property, but the set_data method has more syntactic clarity. You can think of this method as setting the modules "instance" variables.
167
+
166
168
  Next we include the model in the module:
167
169
 
168
170
  <pre name="code" class="brush: js;">
169
- MyApplication.add_module('hello');
171
+ myapplication.add_module('hello');
170
172
 
171
173
  //= require '../elements/hello.model.js'
172
174
  //= require '../elements/hello.elements.js'
@@ -174,15 +176,15 @@ Next we include the model in the module:
174
176
  ...
175
177
  </pre>
176
178
 
177
- Now whenever I create a dialog in my module, I can use the MyApplication.hello.dialog_settings object:
179
+ Now whenever I create a dialog in my module, I can use the dialog_settings object like so:
178
180
 
179
181
  <pre name="code" class="brush: js;">
180
182
  // assumes we have elements "error_dialog" and "notice_dialog"
181
183
  // defined in the elements file
182
184
 
183
- MyApplciation.hello.create_dialogs = function() {
184
- this.error_dialog.dialog(this.dialog_settings);
185
- this.notice_dialog.dialog(this.dialog_settings);
185
+ myapplication.hello.create_dialogs = function() {
186
+ this.error_dialog.dialog(this.data.dialog_settings);
187
+ this.notice_dialog.dialog(this.data.dialog_settings);
186
188
  }
187
189
  </pre>
188
190
 
@@ -192,29 +194,27 @@ This way we don't have to keep redefining the same properties each time we call
192
194
  // assumes we have elements "error_dialog" and "notice_dialog"
193
195
  // defined in the elements file
194
196
 
195
- MyApplciation.hello.create_dialogs = function() {
196
- this.error_dialog.dialog(this.dialog_settings);
197
- this.notice_dialog.dialog($.extend(MyApplication.hello.dialog_settings, {
197
+ myapplication.hello.create_dialogs = function() {
198
+ this.error_dialog.dialog(this.data.dialog_settings);
199
+ this.notice_dialog.dialog($.extend(myapplication.hello.data.dialog_settings, {
198
200
  height: 300,
199
201
  autoOpen: true
200
202
  }));
201
203
  }
202
204
  </pre>
203
205
 
204
- The model provides a default base that we can build from, helping use to keep our code DRY. There's also an opportunithy here to illustrate the utility of the "ninja" aliases. Notice that inside the dialog function we are unable to use the this.dialog_settings shorthand. This is because this is refering to the dialog and not the module. That's why Ninjs defines the double underscore variable to refer to the current module. The previous example can be rewritten more succinclty like so:
206
+ The model provides a default base that we can build from, helping use to keep our code DRY. There's also an opportunity here to illustrate the utility of the "ninja" aliases. Notice that inside the dialog function we are unable to use the this.dialog_settings shorthand. Using "this" in Javascript can be a bit tricky. In this case, "this" is referring to the dialog and not the module. That's why Ninjs defines the double underscore ( __ ) variable to refer to the current module. The previous example can be rewritten more succinctly like so:
205
207
 
206
208
  <pre name="code" class="brush: js;">
207
209
  MyApplciation.hello.create_dialogs = function() {
208
- this.error_dialog.dialog(this.dialog_settings);
209
- this.notice_dialog.dialog($.extend(__.dialog_settings, {
210
- height: 300,
211
- autoOpen: true
212
- }));
213
- }
210
+ __.error_dialog.dialog(__.dialog_settings);
211
+ __.notice_dialog.dialog($.extend(__.dialog_settings, {
212
+ height: 300,
213
+ autoOpen: true
214
+ }));
215
+ }
214
216
  </pre>
215
217
 
216
- Using "this" in Javascript can be a bit tricky so if your not sure what "this" refers to in any given context, your safe using the "_" (application alias) and "__" (module alias) aliases in Ninjs.
217
-
218
218
  h1. Compiling the application
219
219
 
220
220
  Now that we have a complete module including elements and a model, we need to compile these files into one coherent file to use in our html. To do so we have 2 options. Open a terminal window (command prompt) and navigate to the root of your Ninjs application. We can compile our application with one of 2 commands. The first choice is the compile command. From the root of your Ninjs application type:
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.11.0
1
+ 0.11.1
data/bin/ninjs CHANGED
@@ -22,9 +22,9 @@ class NinjsConsole < Rubikon::Application::Base
22
22
  if version.given?
23
23
  time = Time.now
24
24
  copyright_year = time.year == 2010 ? '2010' : '2010-' << time.year
25
- puts 'ninjs ' << Ninjs.version
26
- puts "Copyright (c) #{copyright_year} Dayton Nolan"
27
- puts "Released under the MIT License"
25
+ Ninjs::Notification.notice 'ninjs ' + Ninjs::VERSION
26
+ Ninjs::Notification.notice "Copyright (c) #{copyright_year} Dayton Nolan"
27
+ Ninjs::Notification.notice "Released under the MIT License"
28
28
  else
29
29
  Ninjs::Command.help
30
30
  end
data/lib/ninjs.rb CHANGED
@@ -1,31 +1,10 @@
1
1
  module Ninjs
2
- def version
3
- '0.10.1'
4
- end
5
-
6
- def base_directory
7
- File.expand_path(File.join(File.dirname(__FILE__), '..'))
8
- end
9
-
10
- def lib_directory
11
- File.expand_path(File.join(File.dirname(__FILE__)))
12
- end
13
-
14
- def root_directory
15
- Dir.getwd
16
- end
17
-
18
- def repository_root
19
- base_directory + '/repository/'
20
- end
21
-
22
- module_function :version,
23
- :base_directory,
24
- :lib_directory,
25
- :root_directory,
26
- :repository_root
2
+ VERSION = '0.11.0'
3
+ BASE_DIR = File.expand_path(File.join(File.dirname(__FILE__), '..'))
4
+ LIB_DIR = File.expand_path(File.join(File.dirname(__FILE__)))
5
+ ROOT_DIR = Dir.getwd
27
6
  end
28
7
 
29
- %w(dependencies configuration helpers manifest project command).each do |lib|
30
- require "#{Ninjs.lib_directory}/ninjs/#{lib}"
8
+ %w(dependencies configuration helpers manifest project command notification).each do |lib|
9
+ require "#{Ninjs::LIB_DIR}/ninjs/#{lib}"
31
10
  end
data/lib/ninjs/command.rb CHANGED
@@ -4,7 +4,7 @@ module Ninjs
4
4
  require "fssm"
5
5
  project_path = Dir.getwd << '/'
6
6
  raise "ninjs.conf was not located in #{project_path}" unless File.exists? "#{project_path}ninjs.conf"
7
- puts "\e[32m>>>\e[0m Ninjs are watching for changes. Press Ctrl-C to stop."
7
+ Ninjs::Notification.log "Ninjs are watching for changes. Press Ctrl-C to stop."
8
8
  project = Ninjs::Project.new
9
9
  project.update
10
10
 
@@ -16,7 +16,7 @@ module Ninjs
16
16
  end
17
17
 
18
18
  watch_hash[project_path] = "**/*.conf"
19
- watch_hash["#{Ninjs.base_directory}/repository"] = "**/*.js"
19
+ watch_hash["#{Ninjs::BASE_DIR}/repository"] = "**/*.js"
20
20
 
21
21
  FSSM.monitor do
22
22
 
@@ -26,12 +26,12 @@ module Ninjs
26
26
  glob g
27
27
 
28
28
  update do |base, relative|
29
- puts "\e[33m<<<\e[0m change detected in #{relative}"
29
+ Ninjs::Notification.event "change detected in #{relative}"
30
30
  project.update
31
31
  end
32
32
 
33
33
  create do |base, relative|
34
- puts "\e[33m+++\e[0m #{relative} created"
34
+ Ninjs::Notification.event "#{relative} created"
35
35
  project.update
36
36
  end
37
37
  end
@@ -95,17 +95,17 @@ Example:
95
95
  file << '//= require "../models/' + name.downcase + '.model.js"' + "\n\n" if models
96
96
  file << project.config.name + "." + name + ".actions = function() {\n\n}\n\n"
97
97
  file << project.config.name + "." + name + ".run();"
98
- puts "+++ created #{name.downcase}.module.js"
98
+ Ninjs::Notification.added "created #{name.downcase}.module.js"
99
99
  end unless File.exists? "#{project_path}modules/#{name.downcase}.module.js"
100
100
  elsif object === 'elements'
101
101
  File.open("#{project_path}elements/#{name.downcase}" + ".elements.js", "w") do |file|
102
102
  file << project.config.name + "." + name + ".elements(function({\n\n}));"
103
- puts "+++ created #{name.downcase}.elements.js"
103
+ Ninjs::Notification.added "created #{name.downcase}.elements.js"
104
104
  end unless File.exists? "#{project_path}elements/#{name.downcase}.elements.js"
105
105
  elsif object === 'model'
106
106
  File.open "#{project_path}models/#{name.downcase}.model.js", "w" do |file|
107
107
  file << project.config.name + "." + name + ".set_data({});"
108
- puts "+++ created #{name.downcase}.model.js"
108
+ Ninjs::Notification.added "created #{name.downcase}.model.js"
109
109
  end unless File.exists? "#{project_path}models/#{name.downcase}.model.js"
110
110
  end
111
111
  rescue
@@ -53,7 +53,7 @@ module Ninjs
53
53
  conf_file << conf_content(@defaults)
54
54
  end
55
55
 
56
- puts "ninjs.conf created"
56
+ Ninjs::Notification.notice "ninjs.conf created"
57
57
  end
58
58
 
59
59
  def update
@@ -0,0 +1,37 @@
1
+ module Ninjs
2
+ class Notification
3
+ @@growl_support = false
4
+ @@indicators = {
5
+ :none => "",
6
+ :log => "\e[32m>>>\e[0m ",
7
+ :event => "\e[33m<<<\e[0m ",
8
+ :added => "\e[33m+++\e[0m ",
9
+ :error => "\e[0;31m!!!\e[0m "
10
+ }
11
+
12
+ def self.notify(message, style)
13
+ puts @@indicators[style] + message
14
+ end
15
+
16
+ def self.notice(message)
17
+ self.notify(message, :none)
18
+ end
19
+
20
+ def self.log(message)
21
+ self.notify(message, :log)
22
+ end
23
+
24
+ def self.event(message)
25
+ self.notify(message, :event)
26
+ end
27
+
28
+ def self.added(message)
29
+ self.notify(message, :added)
30
+ end
31
+
32
+ def self.error(message)
33
+ self.notify(message, :error)
34
+ end
35
+
36
+ end
37
+ end
data/lib/ninjs/project.rb CHANGED
@@ -21,9 +21,9 @@ module Ninjs
21
21
  end
22
22
 
23
23
  def create
24
- puts "\e[32m>>>\e[0m Creating the #{@config.name} project in #{@project_path}"
24
+ Ninjs::Notification.notice "Creating the #{@config.name} project in #{@project_path}"
25
25
  create_project_structure
26
- puts "created the project structure"
26
+ Ninjs::Notification.notice "created the project structure"
27
27
  @config.create
28
28
  create_ninjs_lib_file
29
29
  create_utility_lib_file
@@ -34,33 +34,33 @@ module Ninjs
34
34
  def create_project_structure
35
35
  Dir.mkdir "#{@project_path}" unless File.exists? "#{@project_path}"
36
36
  Ninjs::Manifest.directories.each do |folder|
37
- puts "#{folder}/ created" unless File.exists? "#{@project_path}#{folder}"
37
+ Ninjs::Notification.added "#{folder}/ created" unless File.exists? "#{@project_path}#{folder}"
38
38
  Dir.mkdir "#{@project_path}#{folder}" unless File.exists? "#{@project_path}#{folder}"
39
39
  end
40
40
  end
41
41
 
42
42
  def create_ninjs_lib_file
43
43
  ninjs_lib_secretary = Sprockets::Secretary.new(
44
- :root => "#{Ninjs.base_directory}",
44
+ :root => "#{Ninjs::BASE_DIR}",
45
45
  :load_path => ["repository"],
46
46
  :source_files => ["repository/ninjs/core/nin.js"]
47
47
  )
48
48
 
49
49
  ninjs_lib_secretary.concatenation.save_to "#{@project_path}lib/nin.js"
50
50
 
51
- puts "lib/nin.js created"
51
+ Ninjs::Notification.added "lib/nin.js created"
52
52
  end
53
53
 
54
54
  def create_utility_lib_file
55
55
  utility_lib_secretary = Sprockets::Secretary.new(
56
- :root => "#{Ninjs.base_directory}",
56
+ :root => "#{Ninjs::BASE_DIR}",
57
57
  :load_path => ["repository"],
58
58
  :source_files => ["repository/ninjs/utilities/all.js"]
59
59
  )
60
60
 
61
61
  utility_lib_secretary.concatenation.save_to "#{@project_path}lib/utilities.js"
62
62
 
63
- puts "lib/utilities.js created"
63
+ Ninjs::Notification.added "lib/utilities.js created"
64
64
  end
65
65
 
66
66
  def create_ninjs_application_file
@@ -74,11 +74,11 @@ module Ninjs
74
74
  end
75
75
 
76
76
  def import_test_files
77
- FileUtils.cp "#{Ninjs.base_directory}/repository/ninjs/tests/index.html", "#{@project_path}tests"
78
- FileUtils.cp "#{Ninjs.base_directory}/repository/ninjs/tests/ninjs.test.js", "#{@project_path}tests"
79
- FileUtils.cp "#{Ninjs.base_directory}/repository/ninjs/tests/ninjs.utilities.test.js", "#{@project_path}tests"
80
- FileUtils.cp "#{Ninjs.base_directory}/repository/ninjs/tests/qunit/qunit.js", "#{@project_path}tests/qunit"
81
- FileUtils.cp "#{Ninjs.base_directory}/repository/ninjs/tests/qunit/qunit.css", "#{@project_path}tests/qunit"
77
+ FileUtils.cp "#{Ninjs::BASE_DIR}/repository/ninjs/tests/index.html", "#{@project_path}tests"
78
+ FileUtils.cp "#{Ninjs::BASE_DIR}/repository/ninjs/tests/ninjs.test.js", "#{@project_path}tests"
79
+ FileUtils.cp "#{Ninjs::BASE_DIR}/repository/ninjs/tests/ninjs.utilities.test.js", "#{@project_path}tests"
80
+ FileUtils.cp "#{Ninjs::BASE_DIR}/repository/ninjs/tests/qunit/qunit.js", "#{@project_path}tests/qunit"
81
+ FileUtils.cp "#{Ninjs::BASE_DIR}/repository/ninjs/tests/qunit/qunit.css", "#{@project_path}tests/qunit"
82
82
  end
83
83
 
84
84
  def update
@@ -86,7 +86,7 @@ module Ninjs
86
86
  compile_modules
87
87
  update_application_file
88
88
  compress_application if @config.output == 'compressed'
89
- puts "\e[32m>>>\e[0m application updated" unless @errors
89
+ Ninjs::Notification.log "application updated" unless @errors
90
90
  @errors = false
91
91
  end
92
92
 
@@ -126,7 +126,7 @@ module Ninjs
126
126
  module_src = "#{@project_path}modules/#{module_file}"
127
127
 
128
128
  ninjs_lib_secretary = Sprockets::Secretary.new(
129
- :root => "#{Ninjs.base_directory}",
129
+ :root => "#{Ninjs::BASE_DIR}",
130
130
  :asset_root => @config.asset_root || @project_path.gsub(/[a-zA-z0-9\.\-\_\s]+\/$/, ''),
131
131
  :load_path => ["repository"],
132
132
  :source_files => ["#{module_src}"]
@@ -137,10 +137,9 @@ module Ninjs
137
137
  module_file.save_to "#{@project_path}application/#{module_name}.js"
138
138
  ninjs_lib_secretary.install_assets
139
139
 
140
- #puts message
141
140
  rescue Exception => error
142
141
  @errors = true
143
- puts "Sprockets error: #{error.message}"
142
+ Ninjs::Notification.error "Sprockets error: #{error.message}"
144
143
  end
145
144
  end
146
145
 
@@ -181,7 +180,7 @@ module Ninjs
181
180
  def compile_application_file(file)
182
181
  begin
183
182
  ninjs_lib_secretary = Sprockets::Secretary.new(
184
- :root => "#{Ninjs.base_directory}",
183
+ :root => "#{Ninjs::BASE_DIR}",
185
184
  :asset_root => @config.asset_root || @project_path.gsub(/[a-zA-z0-9\.\-\_\s]+\/$/, ''),
186
185
  :load_path => ["repository"],
187
186
  :source_files => ["#{file}"]
@@ -192,7 +191,7 @@ module Ninjs
192
191
  application_file.save_to "#{file}"
193
192
  rescue Exception => error
194
193
  @errors = true
195
- puts "\e[0;31m!!!\e[0m Sprockets error: #{error.message}"
194
+ Ninjs::Notification.error "Sprockets error: #{error.message}"
196
195
  end
197
196
  end
198
197
 
data/ninjs.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{ninjs}
8
- s.version = "0.11.0"
8
+ s.version = "0.11.1"
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-03-06}
12
+ s.date = %q{2011-03-24}
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}
@@ -34,6 +34,7 @@ Gem::Specification.new do |s|
34
34
  "lib/ninjs/dependencies.rb",
35
35
  "lib/ninjs/helpers.rb",
36
36
  "lib/ninjs/manifest.rb",
37
+ "lib/ninjs/notification.rb",
37
38
  "lib/ninjs/project.rb",
38
39
  "ninjs.conf",
39
40
  "ninjs.gemspec",
@@ -67,7 +68,6 @@ Gem::Specification.new do |s|
67
68
  "repository/jquery/fancybox/assets/1.3.1/images/fancybox/fancybox-y.png",
68
69
  "repository/jquery/fancybox/assets/1.3.1/images/fancybox/fancybox.png",
69
70
  "repository/jquery/fancybox/assets/1.3.1/images/fancybox/jquery.easing-1.3.pack.js",
70
- "repository/jquery/fancybox/assets/1.3.1/scss/fancybox.scss",
71
71
  "repository/jquery/fancybox/latest.js",
72
72
  "repository/jquery/latest.js",
73
73
  "repository/jquery/mobile/1.0a3.js",
@@ -310,7 +310,7 @@ Gem::Specification.new do |s|
310
310
  s.licenses = ["MIT"]
311
311
  s.require_paths = ["lib"]
312
312
  s.rubyforge_project = %q{nowarning}
313
- s.rubygems_version = %q{1.3.7}
313
+ s.rubygems_version = %q{1.5.2}
314
314
  s.summary = %q{ninjs is a command line application to help you write clean, modular javascript applications.}
315
315
  s.test_files = [
316
316
  "spec/ninjs_spec.rb",
@@ -318,7 +318,6 @@ Gem::Specification.new do |s|
318
318
  ]
319
319
 
320
320
  if s.respond_to? :specification_version then
321
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
322
321
  s.specification_version = 3
323
322
 
324
323
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
@@ -91,19 +91,14 @@ NinjsModule.method('call_on_ready', function(callback) {
91
91
  > MyModule.execute();
92
92
  */
93
93
  NinjsModule.method('execute', function() {
94
- // swap out the __ alias
95
- this.old__ = is_defined(window.__) ? window.__ : undefined;
94
+ // create the __ alias
96
95
  window.__ = this;
97
96
 
98
97
  if (this.run_tests) {
99
98
  this._run_tests();
100
99
  }
101
- this.actions();
102
100
 
103
- // reset the __ alias
104
- if(is_defined(this.old__)) {
105
- window.__ = this.old__;
106
- }
101
+ this.actions();
107
102
  });
108
103
 
109
104
  /*
@@ -117,17 +112,8 @@ NinjsModule.method('execute', function() {
117
112
  > // element definitions go here
118
113
  > });
119
114
  */
120
- NinjsModule.method('elements', function(callback) {
121
- // swap out the __ alias
122
- this.old__ = is_defined(window.__) ? window.__ : undefined;
123
- window.__ = this;
124
-
115
+ NinjsModule.method('elements', function(callback) {
125
116
  this.call_on_ready(callback);
126
-
127
- // reset the __ alias
128
- if(is_defined(this.old__)) {
129
- window.__ = this.old__;
130
- }
131
117
  });
132
118
 
133
119
 
metadata CHANGED
@@ -1,12 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ninjs
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 11
8
- - 0
9
- version: 0.11.0
4
+ prerelease:
5
+ version: 0.11.1
10
6
  platform: ruby
11
7
  authors:
12
8
  - Dayton Nolan
@@ -14,7 +10,7 @@ autorequire:
14
10
  bindir: bin
15
11
  cert_chain: []
16
12
 
17
- date: 2011-03-06 00:00:00 -06:00
13
+ date: 2011-03-24 00:00:00 -05:00
18
14
  default_executable: ninjs
19
15
  dependencies:
20
16
  - !ruby/object:Gem::Dependency
@@ -24,8 +20,6 @@ dependencies:
24
20
  requirements:
25
21
  - - ">="
26
22
  - !ruby/object:Gem::Version
27
- segments:
28
- - 0
29
23
  version: "0"
30
24
  type: :runtime
31
25
  prerelease: false
@@ -37,8 +31,6 @@ dependencies:
37
31
  requirements:
38
32
  - - ">="
39
33
  - !ruby/object:Gem::Version
40
- segments:
41
- - 0
42
34
  version: "0"
43
35
  type: :runtime
44
36
  prerelease: false
@@ -50,8 +42,6 @@ dependencies:
50
42
  requirements:
51
43
  - - ">="
52
44
  - !ruby/object:Gem::Version
53
- segments:
54
- - 0
55
45
  version: "0"
56
46
  type: :runtime
57
47
  prerelease: false
@@ -63,8 +53,6 @@ dependencies:
63
53
  requirements:
64
54
  - - ">="
65
55
  - !ruby/object:Gem::Version
66
- segments:
67
- - 0
68
56
  version: "0"
69
57
  type: :runtime
70
58
  prerelease: false
@@ -76,8 +64,6 @@ dependencies:
76
64
  requirements:
77
65
  - - ">="
78
66
  - !ruby/object:Gem::Version
79
- segments:
80
- - 0
81
67
  version: "0"
82
68
  type: :development
83
69
  prerelease: false
@@ -89,8 +75,6 @@ dependencies:
89
75
  requirements:
90
76
  - - ">="
91
77
  - !ruby/object:Gem::Version
92
- segments:
93
- - 0
94
78
  version: "0"
95
79
  type: :development
96
80
  prerelease: false
@@ -102,10 +86,6 @@ dependencies:
102
86
  requirements:
103
87
  - - ~>
104
88
  - !ruby/object:Gem::Version
105
- segments:
106
- - 1
107
- - 0
108
- - 0
109
89
  version: 1.0.0
110
90
  type: :development
111
91
  prerelease: false
@@ -117,10 +97,6 @@ dependencies:
117
97
  requirements:
118
98
  - - ~>
119
99
  - !ruby/object:Gem::Version
120
- segments:
121
- - 1
122
- - 5
123
- - 2
124
100
  version: 1.5.2
125
101
  type: :development
126
102
  prerelease: false
@@ -132,8 +108,6 @@ dependencies:
132
108
  requirements:
133
109
  - - ">="
134
110
  - !ruby/object:Gem::Version
135
- segments:
136
- - 0
137
111
  version: "0"
138
112
  type: :development
139
113
  prerelease: false
@@ -145,8 +119,6 @@ dependencies:
145
119
  requirements:
146
120
  - - ">="
147
121
  - !ruby/object:Gem::Version
148
- segments:
149
- - 0
150
122
  version: "0"
151
123
  type: :development
152
124
  prerelease: false
@@ -158,8 +130,6 @@ dependencies:
158
130
  requirements:
159
131
  - - ">="
160
132
  - !ruby/object:Gem::Version
161
- segments:
162
- - 0
163
133
  version: "0"
164
134
  type: :runtime
165
135
  prerelease: false
@@ -171,8 +141,6 @@ dependencies:
171
141
  requirements:
172
142
  - - ">="
173
143
  - !ruby/object:Gem::Version
174
- segments:
175
- - 0
176
144
  version: "0"
177
145
  type: :runtime
178
146
  prerelease: false
@@ -184,8 +152,6 @@ dependencies:
184
152
  requirements:
185
153
  - - ">="
186
154
  - !ruby/object:Gem::Version
187
- segments:
188
- - 0
189
155
  version: "0"
190
156
  type: :runtime
191
157
  prerelease: false
@@ -197,8 +163,6 @@ dependencies:
197
163
  requirements:
198
164
  - - ">="
199
165
  - !ruby/object:Gem::Version
200
- segments:
201
- - 0
202
166
  version: "0"
203
167
  type: :runtime
204
168
  prerelease: false
@@ -210,8 +174,6 @@ dependencies:
210
174
  requirements:
211
175
  - - ">="
212
176
  - !ruby/object:Gem::Version
213
- segments:
214
- - 0
215
177
  version: "0"
216
178
  type: :development
217
179
  prerelease: false
@@ -241,6 +203,7 @@ files:
241
203
  - lib/ninjs/dependencies.rb
242
204
  - lib/ninjs/helpers.rb
243
205
  - lib/ninjs/manifest.rb
206
+ - lib/ninjs/notification.rb
244
207
  - lib/ninjs/project.rb
245
208
  - ninjs.conf
246
209
  - ninjs.gemspec
@@ -274,7 +237,6 @@ files:
274
237
  - repository/jquery/fancybox/assets/1.3.1/images/fancybox/fancybox-y.png
275
238
  - repository/jquery/fancybox/assets/1.3.1/images/fancybox/fancybox.png
276
239
  - repository/jquery/fancybox/assets/1.3.1/images/fancybox/jquery.easing-1.3.pack.js
277
- - repository/jquery/fancybox/assets/1.3.1/scss/fancybox.scss
278
240
  - repository/jquery/fancybox/latest.js
279
241
  - repository/jquery/latest.js
280
242
  - repository/jquery/mobile/1.0a3.js
@@ -526,7 +488,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
526
488
  requirements:
527
489
  - - ">="
528
490
  - !ruby/object:Gem::Version
529
- hash: -750760641061794542
491
+ hash: -4377457271539238813
530
492
  segments:
531
493
  - 0
532
494
  version: "0"
@@ -535,13 +497,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
535
497
  requirements:
536
498
  - - ">="
537
499
  - !ruby/object:Gem::Version
538
- segments:
539
- - 0
540
500
  version: "0"
541
501
  requirements: []
542
502
 
543
503
  rubyforge_project: nowarning
544
- rubygems_version: 1.3.7
504
+ rubygems_version: 1.5.2
545
505
  signing_key:
546
506
  specification_version: 3
547
507
  summary: ninjs is a command line application to help you write clean, modular javascript applications.
@@ -1,69 +0,0 @@
1
- html, body {
2
- margin: 0;
3
- padding: 0;
4
- }
5
-
6
- body {
7
- background: #F2F2F2;
8
- font-family: Arial;
9
- font-size: 13px;
10
- line-height: 1.6;
11
- color: #444;
12
- }
13
-
14
- #content {
15
- width: 350px;
16
- margin: 30px auto;
17
- padding: 20px 60px;
18
- border: 1px solid #D2D2D2;
19
- -moz-box-shadow: 0 0 30px #CCC;
20
- -webkit-box-shadow: 0 0 30px #CCC;
21
- box-shadow: 0 0 30px #CCC;
22
- background: #FFF;
23
- background: -webkit-gradient(linear, left top, left 15, from(#FFFFFF), color-stop(4%, #EEEEEE), to(#FFFFFF));
24
- background: -moz-linear-gradient(top, #FFFFFF, #EEEEEE 1px, #FFFFFF 15px);
25
- }
26
-
27
- h1 {
28
- margin: 0;
29
- font-size: 30px;
30
- font-weight: normal;
31
- font-family: "Museo 700", Arial;
32
- }
33
-
34
- h1 em {
35
- font-size: 50%;
36
- letter-spacing: -0.05em;
37
- }
38
-
39
- h2 {
40
- margin: 0;
41
- }
42
-
43
- hr {
44
- border: none;
45
- height: 1px; line-height: 1px;
46
- background: #D8D8D8;
47
- margin-bottom: 20px;
48
- padding: 0;
49
- }
50
-
51
- p {
52
- margin: 0;
53
- padding-bottom: 14px;
54
- }
55
-
56
- a {
57
- outline: none;
58
- }
59
-
60
- a img {
61
- border: 1px solid #BBB;
62
- padding: 2px;
63
- margin: 10px 30px 10px 0;
64
- vertical-align: top;
65
- }
66
-
67
- ul {
68
- margin: -7px 0 24px 0;
69
- }