ninjs 0.16.3 → 0.16.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION +1 -1
- data/lib/sprockets/.gitignore +4 -0
- data/lib/sprockets/CHANGELOG +22 -0
- data/lib/sprockets/LICENSE +20 -0
- data/lib/sprockets/README.markdown +230 -0
- data/lib/sprockets/bin/sprocketize +54 -0
- data/lib/sprockets/ext/nph-sprockets.cgi +127 -0
- data/lib/sprockets/lib/sprockets.rb +42 -0
- data/lib/sprockets/lib/sprockets/concatenation.rb +36 -0
- data/lib/sprockets/lib/sprockets/environment.rb +52 -0
- data/lib/sprockets/lib/sprockets/error.rb +5 -0
- data/lib/sprockets/lib/sprockets/pathname.rb +37 -0
- data/lib/sprockets/lib/sprockets/preprocessor.rb +96 -0
- data/lib/sprockets/lib/sprockets/secretary.rb +110 -0
- data/lib/sprockets/lib/sprockets/source_file.rb +56 -0
- data/lib/sprockets/lib/sprockets/source_line.rb +85 -0
- data/lib/sprockets/lib/sprockets/version.rb +9 -0
- data/lib/sprockets/sprockets.gemspec +15 -0
- data/lib/sprockets/test/fixtures/assets/images/script_with_assets/one.png +1 -0
- data/lib/sprockets/test/fixtures/assets/images/script_with_assets/two.png +1 -0
- data/lib/sprockets/test/fixtures/assets/stylesheets/script_with_assets.css +1 -0
- data/lib/sprockets/test/fixtures/constants.yml +1 -0
- data/lib/sprockets/test/fixtures/double_slash_comments_that_are_not_requires_should_be_ignored_when_strip_comments_is_false.js +8 -0
- data/lib/sprockets/test/fixtures/double_slash_comments_that_are_not_requires_should_be_removed_by_default.js +2 -0
- data/lib/sprockets/test/fixtures/multiline_comments_should_be_removed_by_default.js +4 -0
- data/lib/sprockets/test/fixtures/requiring_a_file_after_it_has_already_been_required_should_do_nothing.js +5 -0
- data/lib/sprockets/test/fixtures/requiring_a_file_that_does_not_exist_should_raise_an_error.js +1 -0
- data/lib/sprockets/test/fixtures/requiring_a_single_file_should_replace_the_require_comment_with_the_file_contents.js +3 -0
- data/lib/sprockets/test/fixtures/requiring_the_current_file_should_do_nothing.js +1 -0
- data/lib/sprockets/test/fixtures/src/constants.yml +3 -0
- data/lib/sprockets/test/fixtures/src/foo.js +1 -0
- data/lib/sprockets/test/fixtures/src/foo/bar.js +4 -0
- data/lib/sprockets/test/fixtures/src/foo/foo.js +1 -0
- data/lib/sprockets/test/fixtures/src/script_with_assets.js +3 -0
- data/lib/sprockets/test/fixtures/src/script_with_comments.js +13 -0
- data/lib/sprockets/test/test_concatenation.rb +28 -0
- data/lib/sprockets/test/test_environment.rb +64 -0
- data/lib/sprockets/test/test_helper.rb +55 -0
- data/lib/sprockets/test/test_pathname.rb +43 -0
- data/lib/sprockets/test/test_preprocessor.rb +107 -0
- data/lib/sprockets/test/test_secretary.rb +89 -0
- data/lib/sprockets/test/test_source_file.rb +34 -0
- data/lib/sprockets/test/test_source_line.rb +89 -0
- data/ninjs.gemspec +55 -13
- metadata +46 -4
@@ -0,0 +1,34 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
require "enumerator"
|
3
|
+
Enumerator = Enumerable::Enumerator unless defined?(Enumerator) # for 1.9.1 compatibility
|
4
|
+
|
5
|
+
class SourceFileTest < Test::Unit::TestCase
|
6
|
+
def setup
|
7
|
+
@environment = environment_for_fixtures
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_each_source_line
|
11
|
+
source_file_lines = Enumerator.new(source_file("src/foo/bar.js"), :each_source_line).to_a
|
12
|
+
assert_equal content_of_fixture("src/foo/bar.js"), source_file_lines.map { |line| line.line }.join
|
13
|
+
assert_equal 4, source_file_lines.length
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_find_should_return_pathname_for_file_relative_to_the_current_pathname
|
17
|
+
assert_absolute_location_ends_with "test/fixtures/src/foo/bar.js", source_file("src/foo/foo.js").find("bar.js")
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_find_should_return_nil_for_nonexistent_file
|
21
|
+
assert_nil source_file("src/foo/foo.js").find("nonexistent.js")
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_equality_of_source_files
|
25
|
+
assert_equal source_file("src/foo/foo.js"), source_file("src/foo/foo.js")
|
26
|
+
assert_equal source_file("src/foo/foo.js"), source_file("src/foo/../foo/foo.js")
|
27
|
+
assert_not_equal source_file("src/foo/foo.js"), source_file("src/foo.js")
|
28
|
+
assert_not_equal source_file("src/foo/foo.js"), source_file("src/foo/bar.js")
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_mtime_should_return_now_if_file_does_not_exist
|
32
|
+
assert source_file("src/foo/nonexistent.js").mtime.instance_of?(Time)
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
class SourceLineTest < Test::Unit::TestCase
|
4
|
+
def test_line_that_begins_with_double_slash_should_be_a_comment
|
5
|
+
assert source_line("//").comment?
|
6
|
+
assert source_line("//test").comment?
|
7
|
+
assert source_line("//= require").comment?
|
8
|
+
assert source_line("//= require <foo>").comment?
|
9
|
+
assert source_line(" //").comment?
|
10
|
+
assert source_line("\t//").comment?
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_line_that_begins_a_multiline_comment
|
14
|
+
assert source_line(" /*").begins_multiline_comment?
|
15
|
+
assert source_line(" /**").begins_multiline_comment?
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_line_that_begins_a_pdoc_comment
|
19
|
+
assert !source_line(" /*").begins_pdoc_comment?
|
20
|
+
assert source_line(" /**").begins_pdoc_comment?
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_line_that_ends_a_multiline_comment
|
24
|
+
assert source_line(" */").ends_multiline_comment?
|
25
|
+
assert source_line(" **/").ends_multiline_comment?
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_line_that_ends_a_pdoc_comment
|
29
|
+
assert !source_line(" */").ends_pdoc_comment?
|
30
|
+
assert source_line(" **/").ends_pdoc_comment?
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_line_that_contains_but_does_not_begin_with_double_slash_should_not_be_a_comment
|
34
|
+
assert !source_line("f //").comment?
|
35
|
+
assert !source_line("f //= require <foo>").comment?
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_comment_should_be_extracted_from_comment_lines
|
39
|
+
assert_equal "test", source_line("//test").comment
|
40
|
+
assert_equal " test", source_line("// test").comment
|
41
|
+
assert_equal nil, source_line("f //test").comment
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_line_that_contains_require_comment_should_be_a_require
|
45
|
+
assert source_line("//= require <foo>").require?
|
46
|
+
assert !source_line("//= require<foo>").require?
|
47
|
+
assert source_line("//= require \"foo\"").require?
|
48
|
+
assert !source_line("//= require <foo> f").require?
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_require_should_be_extracted_from_require_lines
|
52
|
+
assert_nil source_line("//= require").require
|
53
|
+
assert_equal "<foo>", source_line("//= require <foo>").require
|
54
|
+
assert_equal "<foo>", source_line("//= require <foo> ").require
|
55
|
+
assert_equal "\"foo\"", source_line("//= require \"foo\"").require
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_line_that_contains_a_provide_comment_should_be_a_provide
|
59
|
+
assert source_line("//= provide \"../assets\"").provide?
|
60
|
+
assert !source_line("//= provide").provide?
|
61
|
+
assert !source_line("//= provide <../assets>").provide?
|
62
|
+
end
|
63
|
+
|
64
|
+
def test_provide_should_be_extracted_from_provide_lines
|
65
|
+
assert_nil source_line("//= provide").provide
|
66
|
+
assert_equal "../assets", source_line("//= provide \"../assets\"").provide
|
67
|
+
end
|
68
|
+
|
69
|
+
def test_inspect_should_include_source_file_location_and_line_number
|
70
|
+
environment = environment_for_fixtures
|
71
|
+
pathname = Sprockets::Pathname.new(environment, "/a/b/c.js")
|
72
|
+
source_file = Sprockets::SourceFile.new(environment, pathname)
|
73
|
+
assert_equal "line 25 of #{File.expand_path("/a/b/c.js")}", source_line("hello", source_file, 25).inspect
|
74
|
+
end
|
75
|
+
|
76
|
+
def test_interpolation_of_constants
|
77
|
+
assert_equal %(var VERSION = "1.0";\n), source_line('var VERSION = "<%= VERSION %>";').to_s("VERSION" => "1.0")
|
78
|
+
end
|
79
|
+
|
80
|
+
def test_interpolation_of_missing_constant_raises_undefined_constant_error
|
81
|
+
assert_raises(Sprockets::UndefinedConstantError) do
|
82
|
+
source_line('<%= NONEXISTENT %>').to_s("VERSION" => "1.0")
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
def test_to_s_should_strip_trailing_whitespace_before_adding_line_ending
|
87
|
+
assert_equal "hello();\n", source_line("hello(); \t \r\n").to_s({})
|
88
|
+
end
|
89
|
+
end
|
data/ninjs.gemspec
CHANGED
@@ -4,15 +4,15 @@
|
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
|
-
s.name =
|
8
|
-
s.version = "0.16.
|
7
|
+
s.name = "ninjs"
|
8
|
+
s.version = "0.16.4"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
-
s.authors = [
|
12
|
-
s.date =
|
13
|
-
s.description =
|
14
|
-
s.email =
|
15
|
-
s.executables = [
|
11
|
+
s.authors = ["Dayton Nolan"]
|
12
|
+
s.date = "2012-02-15"
|
13
|
+
s.description = "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/)."
|
14
|
+
s.email = "daytonn@gmail.com"
|
15
|
+
s.executables = ["ninjs"]
|
16
16
|
s.extra_rdoc_files = [
|
17
17
|
"LICENSE",
|
18
18
|
"README.md"
|
@@ -37,6 +37,48 @@ Gem::Specification.new do |s|
|
|
37
37
|
"lib/ninjs/manifest.rb",
|
38
38
|
"lib/ninjs/notification.rb",
|
39
39
|
"lib/ninjs/project.rb",
|
40
|
+
"lib/sprockets/.gitignore",
|
41
|
+
"lib/sprockets/CHANGELOG",
|
42
|
+
"lib/sprockets/LICENSE",
|
43
|
+
"lib/sprockets/README.markdown",
|
44
|
+
"lib/sprockets/bin/sprocketize",
|
45
|
+
"lib/sprockets/ext/nph-sprockets.cgi",
|
46
|
+
"lib/sprockets/lib/sprockets.rb",
|
47
|
+
"lib/sprockets/lib/sprockets/concatenation.rb",
|
48
|
+
"lib/sprockets/lib/sprockets/environment.rb",
|
49
|
+
"lib/sprockets/lib/sprockets/error.rb",
|
50
|
+
"lib/sprockets/lib/sprockets/pathname.rb",
|
51
|
+
"lib/sprockets/lib/sprockets/preprocessor.rb",
|
52
|
+
"lib/sprockets/lib/sprockets/secretary.rb",
|
53
|
+
"lib/sprockets/lib/sprockets/source_file.rb",
|
54
|
+
"lib/sprockets/lib/sprockets/source_line.rb",
|
55
|
+
"lib/sprockets/lib/sprockets/version.rb",
|
56
|
+
"lib/sprockets/sprockets.gemspec",
|
57
|
+
"lib/sprockets/test/fixtures/assets/images/script_with_assets/one.png",
|
58
|
+
"lib/sprockets/test/fixtures/assets/images/script_with_assets/two.png",
|
59
|
+
"lib/sprockets/test/fixtures/assets/stylesheets/script_with_assets.css",
|
60
|
+
"lib/sprockets/test/fixtures/constants.yml",
|
61
|
+
"lib/sprockets/test/fixtures/double_slash_comments_that_are_not_requires_should_be_ignored_when_strip_comments_is_false.js",
|
62
|
+
"lib/sprockets/test/fixtures/double_slash_comments_that_are_not_requires_should_be_removed_by_default.js",
|
63
|
+
"lib/sprockets/test/fixtures/multiline_comments_should_be_removed_by_default.js",
|
64
|
+
"lib/sprockets/test/fixtures/requiring_a_file_after_it_has_already_been_required_should_do_nothing.js",
|
65
|
+
"lib/sprockets/test/fixtures/requiring_a_file_that_does_not_exist_should_raise_an_error.js",
|
66
|
+
"lib/sprockets/test/fixtures/requiring_a_single_file_should_replace_the_require_comment_with_the_file_contents.js",
|
67
|
+
"lib/sprockets/test/fixtures/requiring_the_current_file_should_do_nothing.js",
|
68
|
+
"lib/sprockets/test/fixtures/src/constants.yml",
|
69
|
+
"lib/sprockets/test/fixtures/src/foo.js",
|
70
|
+
"lib/sprockets/test/fixtures/src/foo/bar.js",
|
71
|
+
"lib/sprockets/test/fixtures/src/foo/foo.js",
|
72
|
+
"lib/sprockets/test/fixtures/src/script_with_assets.js",
|
73
|
+
"lib/sprockets/test/fixtures/src/script_with_comments.js",
|
74
|
+
"lib/sprockets/test/test_concatenation.rb",
|
75
|
+
"lib/sprockets/test/test_environment.rb",
|
76
|
+
"lib/sprockets/test/test_helper.rb",
|
77
|
+
"lib/sprockets/test/test_pathname.rb",
|
78
|
+
"lib/sprockets/test/test_preprocessor.rb",
|
79
|
+
"lib/sprockets/test/test_secretary.rb",
|
80
|
+
"lib/sprockets/test/test_source_file.rb",
|
81
|
+
"lib/sprockets/test/test_source_line.rb",
|
40
82
|
"ninjs.gemspec",
|
41
83
|
"repository/jquery/1.1.4.js",
|
42
84
|
"repository/jquery/1.2.6.js",
|
@@ -185,12 +227,12 @@ Gem::Specification.new do |s|
|
|
185
227
|
"templates/jasmine.yml",
|
186
228
|
"templates/test-index.html"
|
187
229
|
]
|
188
|
-
s.homepage =
|
189
|
-
s.licenses = [
|
190
|
-
s.require_paths = [
|
191
|
-
s.rubyforge_project =
|
192
|
-
s.rubygems_version =
|
193
|
-
s.summary =
|
230
|
+
s.homepage = "http://github.com/textnotspeech/ninjs"
|
231
|
+
s.licenses = ["MIT"]
|
232
|
+
s.require_paths = ["lib"]
|
233
|
+
s.rubyforge_project = "nowarning"
|
234
|
+
s.rubygems_version = "1.8.15"
|
235
|
+
s.summary = "ninjs is a command line application to help you write clean, modular javascript applications."
|
194
236
|
s.test_files = [
|
195
237
|
"spec/cli_spec.rb",
|
196
238
|
"spec/command_spec.rb",
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: ninjs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.16.
|
5
|
+
version: 0.16.4
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Dayton Nolan
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date:
|
13
|
+
date: 2012-02-15 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: fssm
|
@@ -195,6 +195,48 @@ files:
|
|
195
195
|
- lib/ninjs/manifest.rb
|
196
196
|
- lib/ninjs/notification.rb
|
197
197
|
- lib/ninjs/project.rb
|
198
|
+
- lib/sprockets/.gitignore
|
199
|
+
- lib/sprockets/CHANGELOG
|
200
|
+
- lib/sprockets/LICENSE
|
201
|
+
- lib/sprockets/README.markdown
|
202
|
+
- lib/sprockets/bin/sprocketize
|
203
|
+
- lib/sprockets/ext/nph-sprockets.cgi
|
204
|
+
- lib/sprockets/lib/sprockets.rb
|
205
|
+
- lib/sprockets/lib/sprockets/concatenation.rb
|
206
|
+
- lib/sprockets/lib/sprockets/environment.rb
|
207
|
+
- lib/sprockets/lib/sprockets/error.rb
|
208
|
+
- lib/sprockets/lib/sprockets/pathname.rb
|
209
|
+
- lib/sprockets/lib/sprockets/preprocessor.rb
|
210
|
+
- lib/sprockets/lib/sprockets/secretary.rb
|
211
|
+
- lib/sprockets/lib/sprockets/source_file.rb
|
212
|
+
- lib/sprockets/lib/sprockets/source_line.rb
|
213
|
+
- lib/sprockets/lib/sprockets/version.rb
|
214
|
+
- lib/sprockets/sprockets.gemspec
|
215
|
+
- lib/sprockets/test/fixtures/assets/images/script_with_assets/one.png
|
216
|
+
- lib/sprockets/test/fixtures/assets/images/script_with_assets/two.png
|
217
|
+
- lib/sprockets/test/fixtures/assets/stylesheets/script_with_assets.css
|
218
|
+
- lib/sprockets/test/fixtures/constants.yml
|
219
|
+
- lib/sprockets/test/fixtures/double_slash_comments_that_are_not_requires_should_be_ignored_when_strip_comments_is_false.js
|
220
|
+
- lib/sprockets/test/fixtures/double_slash_comments_that_are_not_requires_should_be_removed_by_default.js
|
221
|
+
- lib/sprockets/test/fixtures/multiline_comments_should_be_removed_by_default.js
|
222
|
+
- lib/sprockets/test/fixtures/requiring_a_file_after_it_has_already_been_required_should_do_nothing.js
|
223
|
+
- lib/sprockets/test/fixtures/requiring_a_file_that_does_not_exist_should_raise_an_error.js
|
224
|
+
- lib/sprockets/test/fixtures/requiring_a_single_file_should_replace_the_require_comment_with_the_file_contents.js
|
225
|
+
- lib/sprockets/test/fixtures/requiring_the_current_file_should_do_nothing.js
|
226
|
+
- lib/sprockets/test/fixtures/src/constants.yml
|
227
|
+
- lib/sprockets/test/fixtures/src/foo.js
|
228
|
+
- lib/sprockets/test/fixtures/src/foo/bar.js
|
229
|
+
- lib/sprockets/test/fixtures/src/foo/foo.js
|
230
|
+
- lib/sprockets/test/fixtures/src/script_with_assets.js
|
231
|
+
- lib/sprockets/test/fixtures/src/script_with_comments.js
|
232
|
+
- lib/sprockets/test/test_concatenation.rb
|
233
|
+
- lib/sprockets/test/test_environment.rb
|
234
|
+
- lib/sprockets/test/test_helper.rb
|
235
|
+
- lib/sprockets/test/test_pathname.rb
|
236
|
+
- lib/sprockets/test/test_preprocessor.rb
|
237
|
+
- lib/sprockets/test/test_secretary.rb
|
238
|
+
- lib/sprockets/test/test_source_file.rb
|
239
|
+
- lib/sprockets/test/test_source_line.rb
|
198
240
|
- ninjs.gemspec
|
199
241
|
- repository/jquery/1.1.4.js
|
200
242
|
- repository/jquery/1.2.6.js
|
@@ -355,7 +397,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
355
397
|
requirements:
|
356
398
|
- - ">="
|
357
399
|
- !ruby/object:Gem::Version
|
358
|
-
hash:
|
400
|
+
hash: 3447029779432945311
|
359
401
|
segments:
|
360
402
|
- 0
|
361
403
|
version: "0"
|
@@ -368,7 +410,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
368
410
|
requirements: []
|
369
411
|
|
370
412
|
rubyforge_project: nowarning
|
371
|
-
rubygems_version: 1.8.
|
413
|
+
rubygems_version: 1.8.15
|
372
414
|
signing_key:
|
373
415
|
specification_version: 3
|
374
416
|
summary: ninjs is a command line application to help you write clean, modular javascript applications.
|