bpm 1.0.0.beta.8 → 1.0.0.beta.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (181) hide show
  1. data/.gitignore +1 -0
  2. data/CHANGELOG.md +9 -0
  3. data/bpm.gemspec +2 -7
  4. data/lib/bpm/pipeline/generated_asset.rb +19 -21
  5. data/lib/bpm/pipeline/plugin_context.rb +7 -7
  6. data/lib/bpm/pipeline/plugin_processor.rb +11 -20
  7. data/lib/bpm/pipeline/transport_processor.rb +8 -13
  8. data/lib/bpm/pipeline.rb +47 -42
  9. data/lib/bpm/project_generator.rb +2 -2
  10. data/lib/bpm/version.rb +1 -1
  11. data/lib/bpm.rb +0 -3
  12. data/spec/cli/init_spec.rb +48 -48
  13. data/spec/cli/rebuild_spec.rb +30 -30
  14. data/spec/fixtures/projects/init_app/assets/bpm_libs.js +1 -1
  15. data/spec/fixtures/projects/init_app/assets/bpm_styles.css +1 -1
  16. data/spec/fixtures/projects/init_default/assets/bpm_libs.js +1 -1
  17. data/spec/fixtures/projects/init_default/assets/bpm_styles.css +1 -1
  18. data/spec/plugins/minifier_spec.rb +8 -8
  19. data/templates/project/index.html +0 -2
  20. data/templates/project/{app → lib}/main.js +0 -0
  21. metadata +24 -209
  22. data/.gitmodules +0 -3
  23. data/vendor/sprockets/.gitignore +0 -7
  24. data/vendor/sprockets/.travis.yml +0 -7
  25. data/vendor/sprockets/Gemfile +0 -2
  26. data/vendor/sprockets/LICENSE +0 -20
  27. data/vendor/sprockets/README.md +0 -22
  28. data/vendor/sprockets/Rakefile +0 -8
  29. data/vendor/sprockets/lib/sprockets/asset.rb +0 -198
  30. data/vendor/sprockets/lib/sprockets/asset_attributes.rb +0 -178
  31. data/vendor/sprockets/lib/sprockets/base.rb +0 -134
  32. data/vendor/sprockets/lib/sprockets/bundled_asset.rb +0 -249
  33. data/vendor/sprockets/lib/sprockets/cache/file_store.rb +0 -41
  34. data/vendor/sprockets/lib/sprockets/caching.rb +0 -126
  35. data/vendor/sprockets/lib/sprockets/charset_normalizer.rb +0 -41
  36. data/vendor/sprockets/lib/sprockets/context.rb +0 -221
  37. data/vendor/sprockets/lib/sprockets/digest.rb +0 -73
  38. data/vendor/sprockets/lib/sprockets/directive_processor.rb +0 -397
  39. data/vendor/sprockets/lib/sprockets/eco_template.rb +0 -38
  40. data/vendor/sprockets/lib/sprockets/ejs_template.rb +0 -37
  41. data/vendor/sprockets/lib/sprockets/engines.rb +0 -117
  42. data/vendor/sprockets/lib/sprockets/environment.rb +0 -94
  43. data/vendor/sprockets/lib/sprockets/errors.rb +0 -17
  44. data/vendor/sprockets/lib/sprockets/index.rb +0 -81
  45. data/vendor/sprockets/lib/sprockets/jst_processor.rb +0 -26
  46. data/vendor/sprockets/lib/sprockets/mime.rb +0 -38
  47. data/vendor/sprockets/lib/sprockets/processing.rb +0 -269
  48. data/vendor/sprockets/lib/sprockets/processor.rb +0 -32
  49. data/vendor/sprockets/lib/sprockets/safety_colons.rb +0 -28
  50. data/vendor/sprockets/lib/sprockets/server.rb +0 -270
  51. data/vendor/sprockets/lib/sprockets/static_asset.rb +0 -86
  52. data/vendor/sprockets/lib/sprockets/static_compilation.rb +0 -74
  53. data/vendor/sprockets/lib/sprockets/trail.rb +0 -123
  54. data/vendor/sprockets/lib/sprockets/utils.rb +0 -67
  55. data/vendor/sprockets/lib/sprockets/version.rb +0 -3
  56. data/vendor/sprockets/lib/sprockets.rb +0 -31
  57. data/vendor/sprockets/sprockets.gemspec +0 -30
  58. data/vendor/sprockets/test/fixtures/asset/POW.png +0 -0
  59. data/vendor/sprockets/test/fixtures/asset/application.js +0 -6
  60. data/vendor/sprockets/test/fixtures/asset/bar-utf8.css +0 -2
  61. data/vendor/sprockets/test/fixtures/asset/charset.css +0 -2
  62. data/vendor/sprockets/test/fixtures/asset/circle/a.js +0 -2
  63. data/vendor/sprockets/test/fixtures/asset/circle/b.js +0 -2
  64. data/vendor/sprockets/test/fixtures/asset/circle/c.js +0 -2
  65. data/vendor/sprockets/test/fixtures/asset/compat.js +0 -4
  66. data/vendor/sprockets/test/fixtures/asset/constants.js +0 -2
  67. data/vendor/sprockets/test/fixtures/asset/constants.yml +0 -1
  68. data/vendor/sprockets/test/fixtures/asset/default_mime_type.js +0 -1
  69. data/vendor/sprockets/test/fixtures/asset/filename.js.erb +0 -1
  70. data/vendor/sprockets/test/fixtures/asset/foo-utf8.css +0 -2
  71. data/vendor/sprockets/test/fixtures/asset/included_header.js +0 -4
  72. data/vendor/sprockets/test/fixtures/asset/jquery.tmpl.min.js +0 -1
  73. data/vendor/sprockets/test/fixtures/asset/mismatch.js +0 -1
  74. data/vendor/sprockets/test/fixtures/asset/multiple.js +0 -2
  75. data/vendor/sprockets/test/fixtures/asset/multipleengine.js +0 -1
  76. data/vendor/sprockets/test/fixtures/asset/noengine.js +0 -1
  77. data/vendor/sprockets/test/fixtures/asset/noformat.coffee +0 -1
  78. data/vendor/sprockets/test/fixtures/asset/one.css +0 -1
  79. data/vendor/sprockets/test/fixtures/asset/oneengine.js +0 -1
  80. data/vendor/sprockets/test/fixtures/asset/project.css +0 -1
  81. data/vendor/sprockets/test/fixtures/asset/project.js.erb +0 -4
  82. data/vendor/sprockets/test/fixtures/asset/relative/include.js +0 -4
  83. data/vendor/sprockets/test/fixtures/asset/relative/require.js +0 -1
  84. data/vendor/sprockets/test/fixtures/asset/relative/require_outside_path.js +0 -1
  85. data/vendor/sprockets/test/fixtures/asset/require_self.css +0 -9
  86. data/vendor/sprockets/test/fixtures/asset/require_self_twice.css +0 -8
  87. data/vendor/sprockets/test/fixtures/asset/semicolons/bar.js +0 -1
  88. data/vendor/sprockets/test/fixtures/asset/semicolons/index.js +0 -5
  89. data/vendor/sprockets/test/fixtures/asset/sprite.css.erb +0 -12
  90. data/vendor/sprockets/test/fixtures/asset/tree/all/b/c/d.js +0 -2
  91. data/vendor/sprockets/test/fixtures/asset/tree/all/b/c/e.js +0 -1
  92. data/vendor/sprockets/test/fixtures/asset/tree/all/b/c.js +0 -1
  93. data/vendor/sprockets/test/fixtures/asset/tree/all/b.css +0 -2
  94. data/vendor/sprockets/test/fixtures/asset/tree/all/b.js.erb +0 -1
  95. data/vendor/sprockets/test/fixtures/asset/tree/all/d/c.js.coffee +0 -1
  96. data/vendor/sprockets/test/fixtures/asset/tree/all/d/e.js +0 -1
  97. data/vendor/sprockets/test/fixtures/asset/tree/all_with_require.js +0 -7
  98. data/vendor/sprockets/test/fixtures/asset/tree/all_with_require_directory.js +0 -1
  99. data/vendor/sprockets/test/fixtures/asset/tree/all_with_require_tree.js +0 -2
  100. data/vendor/sprockets/test/fixtures/asset/tree/directory/application.js +0 -2
  101. data/vendor/sprockets/test/fixtures/asset/tree/directory/bar.js +0 -1
  102. data/vendor/sprockets/test/fixtures/asset/tree/directory/foo.js +0 -1
  103. data/vendor/sprockets/test/fixtures/asset/tree/tree/application.js +0 -2
  104. data/vendor/sprockets/test/fixtures/asset/tree/tree/bar.js +0 -1
  105. data/vendor/sprockets/test/fixtures/asset/tree/tree/foo.js +0 -1
  106. data/vendor/sprockets/test/fixtures/asset/tree/with_logical_path/a/a.js +0 -1
  107. data/vendor/sprockets/test/fixtures/asset/tree/with_logical_path/require_tree_with_logical_path.js +0 -1
  108. data/vendor/sprockets/test/fixtures/asset/tree/without_argument/a.js +0 -1
  109. data/vendor/sprockets/test/fixtures/asset/tree/without_argument/b.js +0 -1
  110. data/vendor/sprockets/test/fixtures/asset/tree/without_argument/require_tree_without_argument.js +0 -1
  111. data/vendor/sprockets/test/fixtures/asset/two.css +0 -1
  112. data/vendor/sprockets/test/fixtures/asset/unicode.js +0 -2
  113. data/vendor/sprockets/test/fixtures/asset/unknownexts.min.js +0 -2
  114. data/vendor/sprockets/test/fixtures/asset/users.js.erb.str +0 -4
  115. data/vendor/sprockets/test/fixtures/context/POW.png +0 -0
  116. data/vendor/sprockets/test/fixtures/context/application.js.yml +0 -3
  117. data/vendor/sprockets/test/fixtures/context/bar.js +0 -1
  118. data/vendor/sprockets/test/fixtures/context/foo.js +0 -2
  119. data/vendor/sprockets/test/fixtures/context/helpers.css.erb +0 -3
  120. data/vendor/sprockets/test/fixtures/context/properties.js.erb +0 -7
  121. data/vendor/sprockets/test/fixtures/context/require_glob.js +0 -1
  122. data/vendor/sprockets/test/fixtures/context/resolve_content_type.js.erb +0 -4
  123. data/vendor/sprockets/test/fixtures/context/sprite.css.embed +0 -3
  124. data/vendor/sprockets/test/fixtures/default/application.js.coffee +0 -4
  125. data/vendor/sprockets/test/fixtures/default/blank.gif +0 -0
  126. data/vendor/sprockets/test/fixtures/default/coffee/foo.coffee +0 -1
  127. data/vendor/sprockets/test/fixtures/default/coffee/index.js +0 -3
  128. data/vendor/sprockets/test/fixtures/default/empty +0 -0
  129. data/vendor/sprockets/test/fixtures/default/gallery.css.erb +0 -3
  130. data/vendor/sprockets/test/fixtures/default/gallery.js +0 -1
  131. data/vendor/sprockets/test/fixtures/default/goodbye.jst.eco +0 -1
  132. data/vendor/sprockets/test/fixtures/default/hello.jst.ejs +0 -1
  133. data/vendor/sprockets/test/fixtures/default/hello.txt +0 -1
  134. data/vendor/sprockets/test/fixtures/default/interpolation.js +0 -1
  135. data/vendor/sprockets/test/fixtures/default/missing_require.js +0 -1
  136. data/vendor/sprockets/test/fixtures/default/mobile/a.js +0 -1
  137. data/vendor/sprockets/test/fixtures/default/mobile/b.js +0 -1
  138. data/vendor/sprockets/test/fixtures/default/mobile/c.css +0 -1
  139. data/vendor/sprockets/test/fixtures/default/mobile/d.css +0 -1
  140. data/vendor/sprockets/test/fixtures/default/mobile/index.css +0 -3
  141. data/vendor/sprockets/test/fixtures/default/mobile/index.js +0 -1
  142. data/vendor/sprockets/test/fixtures/default/noreturn.js +0 -1
  143. data/vendor/sprockets/test/fixtures/default/project.js.coffee.erb +0 -2
  144. data/vendor/sprockets/test/fixtures/default/with_data_uri.css.erb +0 -3
  145. data/vendor/sprockets/test/fixtures/directives/code_before_comment +0 -3
  146. data/vendor/sprockets/test/fixtures/directives/comment_without_directives +0 -6
  147. data/vendor/sprockets/test/fixtures/directives/directive_word_splitting +0 -6
  148. data/vendor/sprockets/test/fixtures/directives/directives_after_header +0 -16
  149. data/vendor/sprockets/test/fixtures/directives/double_slash +0 -9
  150. data/vendor/sprockets/test/fixtures/directives/hash +0 -8
  151. data/vendor/sprockets/test/fixtures/directives/no_header +0 -2
  152. data/vendor/sprockets/test/fixtures/directives/slash_star +0 -10
  153. data/vendor/sprockets/test/fixtures/directives/slash_star_single +0 -4
  154. data/vendor/sprockets/test/fixtures/directives/space_between_directive_word +0 -2
  155. data/vendor/sprockets/test/fixtures/directives/triple_hash +0 -10
  156. data/vendor/sprockets/test/fixtures/encoding/ascii.js +0 -1
  157. data/vendor/sprockets/test/fixtures/encoding/ascii_utf8.js +0 -2
  158. data/vendor/sprockets/test/fixtures/encoding/utf16.js +0 -0
  159. data/vendor/sprockets/test/fixtures/encoding/utf8.js +0 -1
  160. data/vendor/sprockets/test/fixtures/encoding/utf8_bom.js +0 -1
  161. data/vendor/sprockets/test/fixtures/engines/hello.alert +0 -1
  162. data/vendor/sprockets/test/fixtures/engines/moo.js.str +0 -1
  163. data/vendor/sprockets/test/fixtures/public/compiled-digest-0aa2105d29558f3eb790d411d7d8fb66.js +0 -3
  164. data/vendor/sprockets/test/fixtures/public/compiled-digest-1c41eb0cf934a0c76babe875f982f9d1.js +0 -1
  165. data/vendor/sprockets/test/fixtures/server/app/javascripts/application.js +0 -5
  166. data/vendor/sprockets/test/fixtures/server/app/javascripts/bar.js +0 -1
  167. data/vendor/sprockets/test/fixtures/server/app/javascripts/foo.js +0 -1
  168. data/vendor/sprockets/test/fixtures/server/app/javascripts/hello.txt +0 -2
  169. data/vendor/sprockets/test/fixtures/server/app/javascripts/tree.js +0 -1
  170. data/vendor/sprockets/test/fixtures/server/vendor/javascripts/missing_require.js +0 -1
  171. data/vendor/sprockets/test/fixtures/server/vendor/stylesheets/missing_require.css +0 -1
  172. data/vendor/sprockets/test/sprockets_test.rb +0 -56
  173. data/vendor/sprockets/test/test_asset.rb +0 -699
  174. data/vendor/sprockets/test/test_asset_attributes.rb +0 -150
  175. data/vendor/sprockets/test/test_caching.rb +0 -62
  176. data/vendor/sprockets/test/test_context.rb +0 -115
  177. data/vendor/sprockets/test/test_directive_processor.rb +0 -124
  178. data/vendor/sprockets/test/test_encoding.rb +0 -65
  179. data/vendor/sprockets/test/test_engines.rb +0 -73
  180. data/vendor/sprockets/test/test_environment.rb +0 -587
  181. data/vendor/sprockets/test/test_server.rb +0 -227
@@ -1,150 +0,0 @@
1
- require 'sprockets_test'
2
-
3
- class TestAssetAttributes < Sprockets::TestCase
4
- test "expand and relativize root" do
5
- assert_equal __FILE__,
6
- pathname(pathname(__FILE__).relativize_root).expand_root
7
- end
8
-
9
- test "search paths" do
10
- assert_equal ["index"],
11
- pathname("index").search_paths
12
- assert_equal ["index.html"],
13
- pathname("index.html").search_paths
14
- assert_equal ["index.css", "index.less", "index.sass", "index.scss"],
15
- pathname("index.css").search_paths
16
- assert_equal ["index.js", "index.coffee", "index.jst"],
17
- pathname("index.js").search_paths
18
- assert_equal ["index.coffee"], pathname("index.coffee").search_paths
19
- assert_equal ["index.js.coffee"], pathname("index.js.coffee").search_paths
20
-
21
- assert_equal ["foo", "foo/index"],
22
- pathname("foo").search_paths
23
- assert_equal ["foo.html", "foo/index.html"],
24
- pathname("foo.html").search_paths
25
- assert_equal ["foo.js", "foo.coffee", "foo.jst", "foo/index.js", "foo/index.coffee", "foo/index.jst"],
26
- pathname("foo.js").search_paths
27
- assert_equal ["foo.coffee", "foo/index.coffee"],
28
- pathname("foo.coffee").search_paths
29
- assert_equal ["foo.js.coffee", "foo/index.js.coffee"],
30
- pathname("foo.js.coffee").search_paths
31
-
32
- assert_equal ["foo/bar", "foo/bar/index"], pathname("foo/bar").search_paths
33
- assert_equal ["foo/bar.js", "foo/bar.coffee", "foo/bar.jst", "foo/bar/index.js", "foo/bar/index.coffee", "foo/bar/index.jst"],
34
- pathname("foo/bar.js").search_paths
35
- assert_equal ["foo/bar.coffee", "foo/bar/index.coffee"], pathname("foo/bar.coffee").search_paths
36
- assert_equal ["foo/bar.js.coffee", "foo/bar/index.js.coffee"], pathname("foo/bar.js.coffee").search_paths
37
-
38
- assert_equal ["jquery.foo.coffee", "jquery/index.foo.coffee"],
39
- pathname("jquery.foo.coffee").search_paths
40
- assert_equal ["jquery.foo.js.coffee", "jquery/index.foo.js.coffee"],
41
- pathname("jquery.foo.js.coffee").search_paths
42
- assert_equal ["jquery.foo.js", "jquery.foo.coffee", "jquery.foo.jst",
43
- "jquery/index.foo.js", "jquery/index.foo.coffee", "jquery/index.foo.jst"],
44
- pathname("jquery.foo.js").search_paths
45
- end
46
-
47
- test "logical path" do
48
- assert_equal nil, pathname(fixture_path("missing/application.js")).logical_path
49
-
50
- assert_equal "application.js", pathname(fixture_path("default/application.js")).logical_path
51
- assert_equal "application.css", pathname(fixture_path("default/application.css")).logical_path
52
- assert_equal "jquery.foo.min.js", pathname(fixture_path("default/jquery.foo.min.js")).logical_path
53
-
54
- assert_equal "application.js", pathname(fixture_path("default/application.js.erb")).logical_path
55
- assert_equal "application.js", pathname(fixture_path("default/application.js.coffee")).logical_path
56
- assert_equal "application.css", pathname(fixture_path("default/application.css.scss")).logical_path
57
-
58
- assert_equal "application.js", pathname(fixture_path("default/application.coffee")).logical_path
59
- assert_equal "application.css", pathname(fixture_path("default/application.scss")).logical_path
60
- assert_equal "hello.js", pathname(fixture_path("default/hello.jst.ejs")).logical_path
61
- end
62
-
63
- test "extensions" do
64
- assert_equal [],
65
- pathname("empty").extensions
66
- assert_equal [".js"],
67
- pathname("gallery.js").extensions
68
- assert_equal [".js", ".coffee"],
69
- pathname("application.js.coffee").extensions
70
- assert_equal [".js", ".coffee", ".erb"],
71
- pathname("project.js.coffee.erb").extensions
72
- assert_equal [".css", ".erb"],
73
- pathname("gallery.css.erb").extensions
74
- end
75
-
76
- test "format extension" do
77
- assert_equal nil, pathname("empty").format_extension
78
- assert_equal ".js", pathname("gallery.js").format_extension
79
- assert_equal ".js", pathname("application.js.coffee").format_extension
80
- assert_equal ".js", pathname("project.js.coffee.erb").format_extension
81
- assert_equal ".css", pathname("gallery.css.erb").format_extension
82
- assert_equal nil, pathname("gallery.erb").format_extension
83
- assert_equal nil, pathname("gallery.foo").format_extension
84
- assert_equal ".js", pathname("jquery.js").format_extension
85
- assert_equal ".js", pathname("jquery.min.js").format_extension
86
- assert_equal ".js", pathname("jquery.tmpl.js").format_extension
87
- assert_equal ".js", pathname("jquery.tmpl.min.js").format_extension
88
-
89
- env = Sprockets::Environment.new
90
- env.register_engine '.ms', Class.new
91
- assert_equal nil, env.attributes_for("foo.jst.ms").format_extension
92
- end
93
-
94
- test "engine extensions" do
95
- assert_equal [], pathname("empty").engine_extensions
96
- assert_equal [], pathname("gallery.js").engine_extensions
97
- assert_equal [".coffee"], pathname("application.js.coffee").engine_extensions
98
- assert_equal [".coffee", ".erb"], pathname("project.js.coffee.erb").engine_extensions
99
- assert_equal [".erb"], pathname("gallery.css.erb").engine_extensions
100
- assert_equal [".erb"], pathname("gallery.erb").engine_extensions
101
- assert_equal [], pathname("jquery.js").engine_extensions
102
- assert_equal [], pathname("jquery.min.js").engine_extensions
103
- assert_equal [], pathname("jquery.tmpl.min.js").engine_extensions
104
- assert_equal [".erb"], pathname("jquery.js.erb").engine_extensions
105
- assert_equal [".erb"], pathname("jquery.min.js.erb").engine_extensions
106
- assert_equal [".coffee"], pathname("jquery.min.coffee").engine_extensions
107
-
108
- env = Sprockets::Environment.new
109
- env.register_engine '.ms', Class.new
110
- assert_equal [".jst", ".ms"], env.attributes_for("foo.jst.ms").engine_extensions
111
- end
112
-
113
- test "content type" do
114
- assert_equal "application/octet-stream",
115
- pathname("empty").content_type
116
- assert_equal "application/javascript",
117
- pathname("gallery.js").content_type
118
- assert_equal "application/javascript",
119
- pathname("application.js.coffee").content_type
120
- assert_equal "application/javascript",
121
- pathname("project.js.coffee.erb").content_type
122
- assert_equal "text/css",
123
- pathname("gallery.css.erb").content_type
124
- assert_equal "application/javascript",
125
- pathname("jquery.tmpl.min.js").content_type
126
-
127
- if Tilt::CoffeeScriptTemplate.respond_to?(:default_mime_type)
128
- assert_equal "application/javascript",
129
- pathname("application.coffee").content_type
130
- end
131
- end
132
-
133
- test "get path fingerprint" do
134
- assert_equal nil, pathname("foo.js").path_fingerprint
135
- assert_equal "0aa2105d29558f3eb790d411d7d8fb66",
136
- pathname("foo-0aa2105d29558f3eb790d411d7d8fb66.js").path_fingerprint
137
- end
138
-
139
- test "inject path fingerprint" do
140
- assert_equal "foo-0aa2105d29558f3eb790d411d7d8fb66.js",
141
- pathname("foo.js").path_with_fingerprint("0aa2105d29558f3eb790d411d7d8fb66")
142
- end
143
-
144
- private
145
- def pathname(path)
146
- env = Sprockets::Environment.new
147
- env.append_path fixture_path("default")
148
- env.attributes_for(path)
149
- end
150
- end
@@ -1,62 +0,0 @@
1
- require 'sprockets_test'
2
-
3
- class TestCaching < Sprockets::TestCase
4
- def setup
5
- @cache = {}
6
-
7
- @env1 = Sprockets::Environment.new(fixture_path('default')) do |env|
8
- env.append_path(".")
9
- env.cache = @cache
10
- end
11
-
12
- @env2 = Sprockets::Environment.new(fixture_path('symlink')) do |env|
13
- env.append_path(".")
14
- env.cache = @cache
15
- end
16
- end
17
-
18
- test "environment digests are the same for different roots" do
19
- assert_equal @env1.digest, @env2.digest
20
- end
21
-
22
- test "shared cache objects are eql" do
23
- asset1 = @env1['gallery.js']
24
- asset2 = @env2['gallery.js']
25
-
26
- assert asset1
27
- assert asset2
28
-
29
- assert asset1.eql?(asset2)
30
- assert asset2.eql?(asset1)
31
- assert !asset1.equal?(asset2)
32
- end
33
-
34
- test "stale cached asset isn't loaded if file is remove" do
35
- filename = fixture_path("default/tmp.js")
36
-
37
- sandbox filename do
38
- File.open(filename, 'w') { |f| f.puts "foo;" }
39
- assert_equal "foo;\n", @env1["tmp.js"].to_s
40
-
41
- File.unlink(filename)
42
- assert_nil @env2["tmp.js"]
43
- end
44
- end
45
-
46
- test "stale cached asset isn't loaded if depedency is changed and removed" do
47
- foo = fixture_path("default/foo-tmp.js")
48
- bar = fixture_path("default/bar-tmp.js")
49
-
50
- sandbox foo, bar do
51
- File.open(foo, 'w') { |f| f.puts "//= require bar-tmp\nfoo;" }
52
- File.open(bar, 'w') { |f| f.puts "bar;" }
53
- assert_equal "bar;\nfoo;\n", @env1["foo-tmp.js"].to_s
54
- assert_equal "bar;\n", @env1["bar-tmp.js"].to_s
55
-
56
- File.open(foo, 'w') { |f| f.puts "foo;" }
57
- File.unlink(bar)
58
- assert_equal "foo;\n", @env1["foo-tmp.js"].to_s
59
- assert_nil @env2["bar-tmp.js"]
60
- end
61
- end
62
- end
@@ -1,115 +0,0 @@
1
- require 'sprockets_test'
2
- require 'tilt'
3
- require 'yaml'
4
-
5
- class TestContext < Sprockets::TestCase
6
- def setup
7
- @env = Sprockets::Environment.new(".")
8
- @env.append_path(fixture_path('context'))
9
- end
10
-
11
- test "source file properties are exposed in context" do
12
- json = @env["properties.js"].to_s.chomp.chop
13
- assert_equal({
14
- 'pathname' => fixture_path("context/properties.js.erb"),
15
- '__FILE__' => fixture_path("context/properties.js.erb"),
16
- 'root_path' => fixture_path("context"),
17
- 'logical_path' => "properties",
18
- 'content_type' => "application/javascript"
19
- }, YAML.load(json))
20
- end
21
-
22
- test "extend context" do
23
- @env.context_class.class_eval do
24
- def datauri(path)
25
- require 'base64'
26
- Base64.encode64(File.open(path, "rb") { |f| f.read })
27
- end
28
- end
29
-
30
- assert_equal ".pow {\n background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAZoAAAEsCAMAAADNS4U5AAAAGXRFWHRTb2Z0\n",
31
- @env["helpers.css"].to_s.lines.to_a[0..1].join
32
- assert_equal 58240, @env["helpers.css"].length
33
- end
34
- end
35
-
36
- class TestCustomProcessor < Sprockets::TestCase
37
- def setup
38
- @env = Sprockets::Environment.new
39
- @env.append_path(fixture_path('context'))
40
- end
41
-
42
- class YamlProcessor < Tilt::Template
43
- def initialize_engine
44
- require 'yaml'
45
- end
46
-
47
- def prepare
48
- @manifest = YAML.load(data)
49
- end
50
-
51
- def evaluate(context, locals)
52
- @manifest['require'].each do |logical_path|
53
- context.require_asset(logical_path)
54
- end
55
- ""
56
- end
57
- end
58
-
59
- test "custom processor using Context#require" do
60
- @env.register_engine :yml, YamlProcessor
61
-
62
- assert_equal "var Foo = {};\n\nvar Bar = {};\n", @env['application.js'].to_s
63
- end
64
-
65
- class DataUriProcessor < Tilt::Template
66
- def initialize_engine
67
- require 'base64'
68
- end
69
-
70
- def prepare
71
- end
72
-
73
- def evaluate(context, locals)
74
- data.gsub(/url\(\"(.+?)\"\)/) do
75
- path = context.resolve($1)
76
- context.depend_on(path)
77
- data = Base64.encode64(File.open(path, "rb") { |f| f.read })
78
- "url(data:image/png;base64,#{data})"
79
- end
80
- end
81
- end
82
-
83
- test "custom processor using Context#resolve and Context#depend_on" do
84
- @env.register_engine :embed, DataUriProcessor
85
-
86
- assert_equal ".pow {\n background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAZoAAAEsCAMAAADNS4U5AAAAGXRFWHRTb2Z0\n",
87
- @env["sprite.css"].to_s.lines.to_a[0..1].join
88
- assert_equal 58240, @env["sprite.css"].length
89
- end
90
-
91
- test "block custom processor" do
92
- require 'base64'
93
-
94
- @env.register_preprocessor 'text/css', :data_uris do |context, data|
95
- data.gsub(/url\(\"(.+?)\"\)/) do
96
- path = context.resolve($1)
97
- context.depend_on(path)
98
- data = Base64.encode64(File.open(path, "rb") { |f| f.read })
99
- "url(data:image/png;base64,#{data})"
100
- end
101
- end
102
-
103
- assert_equal ".pow {\n background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAZoAAAEsCAMAAADNS4U5AAAAGXRFWHRTb2Z0\n",
104
- @env["sprite.css.embed"].to_s.lines.to_a[0..1].join
105
- assert_equal 58240, @env["sprite.css.embed"].length
106
- end
107
-
108
- test "resolve with content type" do
109
- assert_equal [fixture_path("context/foo.js"),
110
- fixture_path("context/foo.js"),
111
- fixture_path("context/foo.js"),
112
- "foo.js is 'application/javascript', not 'text/css';"
113
- ].join(",\n"), @env["resolve_content_type.js"].to_s.strip
114
- end
115
- end
@@ -1,124 +0,0 @@
1
- require "sprockets_test"
2
-
3
- class DirectiveProcessorTest < Sprockets::TestCase
4
- test "parsing double-slash comments" do
5
- directive_parser("double_slash").tap do |parser|
6
- assert_equal "// Header\n//\n//\n(function() {\n})();\n", parser.processed_source
7
- assert_equal directives, parser.directives
8
- end
9
- end
10
-
11
- test "parsing hash comments" do
12
- directive_parser("hash").tap do |parser|
13
- assert_equal "# Header\n#\n#\n(->)()\n", parser.processed_source
14
- assert_equal directives, parser.directives
15
- end
16
- end
17
-
18
- test "parsing slash-star comments" do
19
- directive_parser("slash_star").tap do |parser|
20
- assert_equal "/* Header\n *\n *\n */\n\n(function() {\n})();\n", parser.processed_source
21
- assert_equal directives, parser.directives
22
- end
23
- end
24
-
25
- test "parsing single line slash-star comments" do
26
- directive_parser("slash_star_single").tap do |parser|
27
- assert_equal "\n\n(function() {\n})();\n", parser.processed_source
28
- assert_equal [[1, "require", "a"]], parser.directives
29
- end
30
- end
31
-
32
- test "parsing triple-hash comments" do
33
- directive_parser("triple_hash").tap do |parser|
34
- assert_equal "###\nHeader\n\n\n###\n\n(->)()\n", parser.processed_source
35
- assert_equal directives(1), parser.directives
36
- end
37
- end
38
-
39
- test "header comment without directives is unmodified" do
40
- directive_parser("comment_without_directives").tap do |parser|
41
- assert_equal "/*\n * Comment\n */\n\n(function() {\n})();\n", parser.processed_source
42
- assert_equal [], parser.directives
43
- end
44
- end
45
-
46
- test "directives in comment after header are not parsed" do
47
- directive_parser("directives_after_header").tap do |parser|
48
- assert_equal "/*\n * Header\n */\n\n\n\n/* Not a directive */\n\n(function() {\n})();\n\n/*= require e */\n", parser.processed_source
49
- assert_equal [
50
- [3, "require", "a"],
51
- [6, "require", "b"],
52
- [7, "require", "c"],
53
- [9, "require", "d"]
54
- ], parser.directives
55
- end
56
- end
57
-
58
- test "headers must occur at the beginning of the file" do
59
- directive_parser("code_before_comment").tap do |parser|
60
- assert_equal "", parser.processed_header
61
- assert_equal directive_fixture("code_before_comment"), parser.processed_source
62
- end
63
- end
64
-
65
- test "no header" do
66
- directive_parser("no_header").tap do |parser|
67
- assert_equal directive_fixture("no_header"), parser.processed_source
68
- assert_equal [], parser.directives
69
- end
70
- end
71
-
72
- test "directive word splitting" do
73
- directive_parser("directive_word_splitting").tap do |parser|
74
- assert_equal [
75
- [1, "one"],
76
- [2, "one", "two"],
77
- [3, "one", "two", "three"],
78
- [4, "one", "two three"],
79
- [6, "six", "seven"]
80
- ], parser.directives
81
- end
82
- end
83
-
84
- test "space between = and directive word" do
85
- directive_parser("space_between_directive_word").tap do |parser|
86
- assert_equal "var foo;\n", parser.processed_source
87
- assert_equal [[1, "require", "foo"]], parser.directives
88
- end
89
- end
90
-
91
- def directive_parser(fixture_name)
92
- Sprockets::DirectiveProcessor.new(fixture_path("directives/#{fixture_name}"))
93
- end
94
-
95
- def directive_fixture(name)
96
- fixture("directives/#{name}")
97
- end
98
-
99
- def directives(offset = 0)
100
- [[3 + offset, "require", "a"], [4 + offset, "require", "b"], [6 + offset, "require", "c"]]
101
- end
102
- end
103
-
104
- class TestCustomDirectiveProcessor < Sprockets::TestCase
105
- def setup
106
- @env = Sprockets::Environment.new
107
- @env.append_path(fixture_path('context'))
108
- end
109
-
110
- class TestDirectiveProcessor < Sprockets::DirectiveProcessor
111
- def process_require_glob_directive(glob)
112
- Dir["#{pathname.dirname}/#{glob}"].sort.each do |filename|
113
- context.require_asset(filename)
114
- end
115
- end
116
- end
117
-
118
- test "custom processor using Context#sprockets_resolve and Context#sprockets_depend" do
119
- @env.unregister_preprocessor('application/javascript', Sprockets::DirectiveProcessor)
120
- @env.register_preprocessor('application/javascript', TestDirectiveProcessor)
121
-
122
- assert_equal "var Foo = {};\n\n", @env["require_glob.js"].to_s
123
- end
124
- end
@@ -1,65 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- require "sprockets_test"
3
-
4
- class EncodingTest < Sprockets::TestCase
5
- def setup
6
- @env = Sprockets::Environment.new
7
- @env.append_path(fixture_path('encoding'))
8
- end
9
-
10
- if "".respond_to?(:encoding)
11
- test "read ASCII asset" do
12
- data = @env['ascii.js'].to_s
13
- assert_equal "var foo = \"bar\";\n", data
14
- assert_equal Encoding.find('ASCII'), data.encoding
15
- end
16
-
17
- test "read UTF-8 asset" do
18
- data = @env['utf8.js'].to_s
19
- assert_equal "var snowman = \"☃\";\n", data
20
- assert_equal Encoding.find('UTF-8'), data.encoding
21
- end
22
-
23
- test "read UTF-8 asset with BOM" do
24
- data = @env['utf8_bom.js'].to_s
25
- assert_equal "var snowman = \"☃\";\n", data.encode("UTF-8")
26
- assert_equal Encoding.find('UTF-8'), data.encoding
27
- end
28
-
29
- test "read UTF-16 asset" do
30
- assert_raise Sprockets::EncodingError do
31
- @env['utf16.js'].to_s
32
- end
33
- end
34
-
35
- test "read ASCII + UTF-8 concatation asset" do
36
- data = @env['ascii_utf8.js'].to_s
37
- assert_equal "var foo = \"bar\";\nvar snowman = \"\342\230\203\";\n",
38
- data
39
- assert_equal Encoding.find('UTF-8'), data.encoding
40
- end
41
- else
42
- test "read ASCII asset" do
43
- assert_equal "var foo = \"bar\";\n", @env['ascii.js'].to_s
44
- end
45
-
46
- test "read UTF-8 asset" do
47
- assert_equal "var snowman = \"\342\230\203\";\n", @env['utf8.js'].to_s
48
- end
49
-
50
- test "read UTF-8 asset with BOM" do
51
- assert_equal "var snowman = \"\342\230\203\";\n", @env['utf8_bom.js'].to_s
52
- end
53
-
54
- test "read UTF-16 asset" do
55
- assert_raise Sprockets::EncodingError do
56
- @env['utf16.js'].to_s
57
- end
58
- end
59
-
60
- test "read ASCII + UTF-8 concatation asset" do
61
- assert_equal "var foo = \"bar\";\nvar snowman = \"\342\230\203\";\n",
62
- @env['ascii_utf8.js'].to_s
63
- end
64
- end
65
- end
@@ -1,73 +0,0 @@
1
- require 'sprockets_test'
2
- require 'sprockets/engines'
3
- require 'tilt'
4
-
5
- class AlertTemplate < Tilt::Template
6
- def self.default_mime_type
7
- 'application/javascript'
8
- end
9
-
10
- def prepare
11
- end
12
-
13
- def evaluate(scope, locals, &block)
14
- "alert(#{data.inspect});"
15
- end
16
- end
17
-
18
- class StringTemplate < Tilt::Template
19
- def prepare
20
- end
21
-
22
- def evaluate(scope, locals, &block)
23
- data.gsub(/#\{.*?\}/, "moo")
24
- end
25
- end
26
-
27
- class TestEngines < Sprockets::TestCase
28
- ORIGINAL_ENGINES = Sprockets.instance_variable_get(:@engines)
29
-
30
- def setup
31
- Sprockets.instance_variable_set(:@engines, ORIGINAL_ENGINES.dup)
32
- end
33
-
34
- def teardown
35
- Sprockets.instance_variable_set(:@engines, ORIGINAL_ENGINES)
36
- end
37
-
38
- test "registering a global engine" do
39
- Sprockets.register_engine ".alert", AlertTemplate
40
- assert_equal AlertTemplate, Sprockets.engines("alert")
41
- assert_equal AlertTemplate, Sprockets.engines(".alert")
42
-
43
- env = new_environment
44
- asset = env["hello.alert"]
45
- assert_equal 'alert("Hello world!\n");', asset.to_s
46
- assert_equal 'application/javascript', asset.content_type
47
- end
48
-
49
- test "overriding an engine globally" do
50
- env1 = new_environment
51
- assert_equal %(console.log("Moo, #{RUBY_VERSION}");\n), env1["moo.js"].to_s
52
-
53
- Sprockets.register_engine ".str", StringTemplate
54
- env2 = new_environment
55
- assert_equal %(console.log("Moo, moo");\n), env2["moo.js"].to_s
56
- end
57
-
58
- test "overriding an engine in an environment" do
59
- env1 = new_environment
60
- env2 = new_environment
61
-
62
- env1.register_engine ".str", StringTemplate
63
- assert_equal %(console.log("Moo, moo");\n), env1["moo.js"].to_s
64
-
65
- assert_equal %(console.log("Moo, #{RUBY_VERSION}");\n), env2["moo.js"].to_s
66
- end
67
-
68
- def new_environment
69
- Sprockets::Environment.new.tap do |env|
70
- env.append_path(fixture_path('engines'))
71
- end
72
- end
73
- end