bpm 0.1.0 → 0.1.2
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/.gitmodules +3 -0
- data/Gemfile +0 -13
- data/TODO.md +1 -0
- data/bpm.gemspec +8 -3
- data/lib/bpm/cli/base.rb +22 -20
- data/lib/bpm/generator.rb +3 -3
- data/lib/bpm/libgems_ext/dependency_installer.rb +4 -4
- data/lib/bpm/libgems_ext/installer.rb +1 -1
- data/lib/bpm/package.rb +13 -9
- data/lib/bpm/pipeline/generated_asset.rb +30 -3
- data/lib/bpm/pipeline/transport_processor.rb +20 -12
- data/lib/bpm/pipeline.rb +17 -9
- data/lib/bpm/project.rb +42 -10
- data/lib/bpm/server.rb +5 -0
- data/lib/bpm/version.rb +1 -1
- data/lib/bpm.rb +2 -0
- data/lib/vendored_sprockets.rb +7 -0
- data/spec/cli/add_spec.rb +40 -37
- data/spec/cli/build_spec.rb +5 -5
- data/spec/cli/new_spec.rb +49 -23
- data/spec/cli/push_spec.rb +5 -5
- data/spec/cli/unpack_spec.rb +14 -14
- data/spec/fixtures/{badrake-0.8.7.spd → badrake-0.8.7.bpkg} +0 -0
- data/spec/fixtures/{builder-3.0.0.spd → builder-3.0.0.bpkg} +0 -0
- data/spec/fixtures/{bundler-1.1.pre.spd → bundler-1.1.pre.bpkg} +0 -0
- data/spec/fixtures/{coffee-1.0.1.pre.spd → coffee-1.0.1.pre.bpkg} +0 -0
- data/spec/fixtures/{core-test-0.4.9.spd → core-test-0.4.9.bpkg} +0 -0
- data/spec/fixtures/{custom_generator-1.0.spd → custom_generator-1.0.bpkg} +0 -0
- data/spec/fixtures/custom_name/MyProject.json +4 -0
- data/spec/fixtures/hello_world/css/dummy.css +3 -0
- data/spec/fixtures/{highline-1.6.1.spd → highline-1.6.1.bpkg} +0 -0
- data/spec/fixtures/{ivory-0.0.1.spd → ivory-0.0.1.bpkg} +0 -0
- data/spec/fixtures/{jquery-1.4.3.spd → jquery-1.4.3.bpkg} +0 -0
- data/spec/fixtures/minitest/assets/bpm_packages.js +1 -0
- data/spec/fixtures/minitest/assets/bpm_styles.css +0 -0
- data/spec/fixtures/minitest/assets/minitest/app_package.js +1 -0
- data/spec/fixtures/minitest/lib/main.js +1 -0
- data/spec/fixtures/minitest/minitest.json +22 -0
- data/spec/fixtures/minitest/packages/uglyduck/lib/main.js +1 -0
- data/spec/fixtures/minitest/packages/uglyduck/minifier/main.js +4 -0
- data/spec/fixtures/minitest/packages/uglyduck/package.json +21 -0
- data/spec/fixtures/{optparse-1.0.1.spd → optparse-1.0.1.bpkg} +0 -0
- data/spec/fixtures/{rake-0.8.6.spd → rake-0.8.6.bpkg} +0 -0
- data/spec/fixtures/{rake-0.8.7.spd → rake-0.8.7.bpkg} +0 -0
- data/spec/fixtures/{spade-0.5.0.spd → spade-0.5.0.bpkg} +0 -0
- data/spec/fixtures/transporter/packages/transport/lib/main.js +1 -0
- data/spec/fixtures/transporter/packages/transport/package.json +1 -1
- data/spec/fixtures/transporter/packages/transport/transports/wrapper.js +5 -0
- data/spec/gauntlet_spec.rb +2 -2
- data/spec/package_spec.rb +3 -3
- data/spec/pipeline_spec.rb +175 -54
- data/spec/project_spec.rb +19 -3
- data/spec/support/fake_gem_server.rb +4 -4
- data/templates/init/project.json +3 -1
- data/templates/project/index.html +1 -1
- data/vendor/sprockets/.gitignore +7 -0
- data/vendor/sprockets/.travis.yml +6 -0
- data/vendor/sprockets/Gemfile +8 -0
- data/vendor/sprockets/LICENSE +20 -0
- data/vendor/sprockets/README.md +22 -0
- data/vendor/sprockets/Rakefile +8 -0
- data/vendor/sprockets/lib/sprockets/asset.rb +203 -0
- data/vendor/sprockets/lib/sprockets/asset_attributes.rb +161 -0
- data/vendor/sprockets/lib/sprockets/base.rb +147 -0
- data/vendor/sprockets/lib/sprockets/bundled_asset.rb +222 -0
- data/vendor/sprockets/lib/sprockets/cache/file_store.rb +41 -0
- data/vendor/sprockets/lib/sprockets/caching.rb +121 -0
- data/vendor/sprockets/lib/sprockets/charset_normalizer.rb +41 -0
- data/vendor/sprockets/lib/sprockets/context.rb +191 -0
- data/vendor/sprockets/lib/sprockets/digest.rb +73 -0
- data/vendor/sprockets/lib/sprockets/directive_processor.rb +380 -0
- data/vendor/sprockets/lib/sprockets/eco_template.rb +39 -0
- data/vendor/sprockets/lib/sprockets/ejs_template.rb +38 -0
- data/vendor/sprockets/lib/sprockets/engines.rb +92 -0
- data/vendor/sprockets/lib/sprockets/environment.rb +93 -0
- data/vendor/sprockets/lib/sprockets/errors.rb +17 -0
- data/vendor/sprockets/lib/sprockets/index.rb +80 -0
- data/vendor/sprockets/lib/sprockets/jst_processor.rb +26 -0
- data/vendor/sprockets/lib/sprockets/processing.rb +310 -0
- data/vendor/sprockets/lib/sprockets/processor.rb +32 -0
- data/vendor/sprockets/lib/sprockets/safety_colons.rb +28 -0
- data/vendor/sprockets/lib/sprockets/server.rb +270 -0
- data/vendor/sprockets/lib/sprockets/static_asset.rb +87 -0
- data/vendor/sprockets/lib/sprockets/static_compilation.rb +82 -0
- data/vendor/sprockets/lib/sprockets/trail.rb +122 -0
- data/vendor/sprockets/lib/sprockets/utils.rb +67 -0
- data/vendor/sprockets/lib/sprockets/version.rb +3 -0
- data/vendor/sprockets/lib/sprockets.rb +31 -0
- data/vendor/sprockets/sprockets.gemspec +30 -0
- data/vendor/sprockets/test/fixtures/asset/POW.png +0 -0
- data/vendor/sprockets/test/fixtures/asset/application.js +6 -0
- data/vendor/sprockets/test/fixtures/asset/bar-utf8.css +2 -0
- data/vendor/sprockets/test/fixtures/asset/charset.css +2 -0
- data/vendor/sprockets/test/fixtures/asset/circle/a.js +2 -0
- data/vendor/sprockets/test/fixtures/asset/circle/b.js +2 -0
- data/vendor/sprockets/test/fixtures/asset/circle/c.js +2 -0
- data/vendor/sprockets/test/fixtures/asset/compat.js +4 -0
- data/vendor/sprockets/test/fixtures/asset/constants.js +2 -0
- data/vendor/sprockets/test/fixtures/asset/constants.yml +1 -0
- data/vendor/sprockets/test/fixtures/asset/default_mime_type.js +1 -0
- data/vendor/sprockets/test/fixtures/asset/filename.js.erb +1 -0
- data/vendor/sprockets/test/fixtures/asset/foo-utf8.css +2 -0
- data/vendor/sprockets/test/fixtures/asset/included_header.js +4 -0
- data/vendor/sprockets/test/fixtures/asset/jquery.tmpl.min.js +1 -0
- data/vendor/sprockets/test/fixtures/asset/mismatch.js +1 -0
- data/vendor/sprockets/test/fixtures/asset/multiple.js +2 -0
- data/vendor/sprockets/test/fixtures/asset/multipleengine.js +1 -0
- data/vendor/sprockets/test/fixtures/asset/noengine.js +1 -0
- data/vendor/sprockets/test/fixtures/asset/noformat.coffee +1 -0
- data/vendor/sprockets/test/fixtures/asset/one.css +1 -0
- data/vendor/sprockets/test/fixtures/asset/oneengine.js +1 -0
- data/vendor/sprockets/test/fixtures/asset/project.css +1 -0
- data/vendor/sprockets/test/fixtures/asset/project.js.erb +4 -0
- data/vendor/sprockets/test/fixtures/asset/relative/include.js +4 -0
- data/vendor/sprockets/test/fixtures/asset/relative/require.js +1 -0
- data/vendor/sprockets/test/fixtures/asset/relative/require_outside_path.js +1 -0
- data/vendor/sprockets/test/fixtures/asset/require_self.css +9 -0
- data/vendor/sprockets/test/fixtures/asset/require_self_twice.css +8 -0
- data/vendor/sprockets/test/fixtures/asset/semicolons/bar.js +1 -0
- data/vendor/sprockets/test/fixtures/asset/semicolons/index.js +5 -0
- data/vendor/sprockets/test/fixtures/asset/sprite.css.erb +12 -0
- data/vendor/sprockets/test/fixtures/asset/tree/all/b/c/d.js +2 -0
- data/vendor/sprockets/test/fixtures/asset/tree/all/b/c/e.js +1 -0
- data/vendor/sprockets/test/fixtures/asset/tree/all/b/c.js +1 -0
- data/vendor/sprockets/test/fixtures/asset/tree/all/b.css +2 -0
- data/vendor/sprockets/test/fixtures/asset/tree/all/b.js.erb +1 -0
- data/vendor/sprockets/test/fixtures/asset/tree/all/d/c.js.coffee +1 -0
- data/vendor/sprockets/test/fixtures/asset/tree/all/d/e.js +1 -0
- data/vendor/sprockets/test/fixtures/asset/tree/all_with_require.js +7 -0
- data/vendor/sprockets/test/fixtures/asset/tree/all_with_require_directory.js +1 -0
- data/vendor/sprockets/test/fixtures/asset/tree/all_with_require_tree.js +2 -0
- data/vendor/sprockets/test/fixtures/asset/tree/directory/application.js +2 -0
- data/vendor/sprockets/test/fixtures/asset/tree/directory/bar.js +1 -0
- data/vendor/sprockets/test/fixtures/asset/tree/directory/foo.js +1 -0
- data/vendor/sprockets/test/fixtures/asset/tree/tree/application.js +2 -0
- data/vendor/sprockets/test/fixtures/asset/tree/tree/bar.js +1 -0
- data/vendor/sprockets/test/fixtures/asset/tree/tree/foo.js +1 -0
- data/vendor/sprockets/test/fixtures/asset/tree/with_logical_path/a/a.js +1 -0
- data/vendor/sprockets/test/fixtures/asset/tree/with_logical_path/require_tree_with_logical_path.js +1 -0
- data/vendor/sprockets/test/fixtures/asset/tree/without_argument/a.js +1 -0
- data/vendor/sprockets/test/fixtures/asset/tree/without_argument/b.js +1 -0
- data/vendor/sprockets/test/fixtures/asset/tree/without_argument/require_tree_without_argument.js +1 -0
- data/vendor/sprockets/test/fixtures/asset/two.css +1 -0
- data/vendor/sprockets/test/fixtures/asset/unicode.js +2 -0
- data/vendor/sprockets/test/fixtures/asset/unknownexts.min.js +2 -0
- data/vendor/sprockets/test/fixtures/asset/users.js.erb.str +4 -0
- data/vendor/sprockets/test/fixtures/context/POW.png +0 -0
- data/vendor/sprockets/test/fixtures/context/application.js.yml +3 -0
- data/vendor/sprockets/test/fixtures/context/bar.js +1 -0
- data/vendor/sprockets/test/fixtures/context/foo.js +2 -0
- data/vendor/sprockets/test/fixtures/context/helpers.css.erb +3 -0
- data/vendor/sprockets/test/fixtures/context/properties.js.erb +7 -0
- data/vendor/sprockets/test/fixtures/context/require_glob.js +1 -0
- data/vendor/sprockets/test/fixtures/context/resolve_content_type.js.erb +4 -0
- data/vendor/sprockets/test/fixtures/context/sprite.css.embed +3 -0
- data/vendor/sprockets/test/fixtures/default/application.js.coffee +4 -0
- data/vendor/sprockets/test/fixtures/default/coffee/foo.coffee +1 -0
- data/vendor/sprockets/test/fixtures/default/coffee/index.js +3 -0
- data/vendor/sprockets/test/fixtures/default/empty +0 -0
- data/vendor/sprockets/test/fixtures/default/gallery.css.erb +3 -0
- data/vendor/sprockets/test/fixtures/default/gallery.js +1 -0
- data/vendor/sprockets/test/fixtures/default/goodbye.jst.eco +1 -0
- data/vendor/sprockets/test/fixtures/default/hello.jst.ejs +1 -0
- data/vendor/sprockets/test/fixtures/default/hello.txt +1 -0
- data/vendor/sprockets/test/fixtures/default/interpolation.js +1 -0
- data/vendor/sprockets/test/fixtures/default/missing_require.js +1 -0
- data/vendor/sprockets/test/fixtures/default/mobile/a.js +1 -0
- data/vendor/sprockets/test/fixtures/default/mobile/b.js +1 -0
- data/vendor/sprockets/test/fixtures/default/mobile/c.css +1 -0
- data/vendor/sprockets/test/fixtures/default/mobile/d.css +1 -0
- data/vendor/sprockets/test/fixtures/default/mobile/index.css +3 -0
- data/vendor/sprockets/test/fixtures/default/mobile/index.js +1 -0
- data/vendor/sprockets/test/fixtures/default/noreturn.js +1 -0
- data/vendor/sprockets/test/fixtures/default/project.js.coffee.erb +2 -0
- data/vendor/sprockets/test/fixtures/directives/code_before_comment +3 -0
- data/vendor/sprockets/test/fixtures/directives/comment_without_directives +6 -0
- data/vendor/sprockets/test/fixtures/directives/directive_word_splitting +6 -0
- data/vendor/sprockets/test/fixtures/directives/directives_after_header +16 -0
- data/vendor/sprockets/test/fixtures/directives/double_slash +9 -0
- data/vendor/sprockets/test/fixtures/directives/hash +8 -0
- data/vendor/sprockets/test/fixtures/directives/no_header +2 -0
- data/vendor/sprockets/test/fixtures/directives/slash_star +10 -0
- data/vendor/sprockets/test/fixtures/directives/slash_star_single +4 -0
- data/vendor/sprockets/test/fixtures/directives/space_between_directive_word +2 -0
- data/vendor/sprockets/test/fixtures/directives/triple_hash +10 -0
- data/vendor/sprockets/test/fixtures/encoding/ascii.js +1 -0
- data/vendor/sprockets/test/fixtures/encoding/ascii_utf8.js +2 -0
- data/vendor/sprockets/test/fixtures/encoding/utf16.js +0 -0
- data/vendor/sprockets/test/fixtures/encoding/utf8.js +1 -0
- data/vendor/sprockets/test/fixtures/encoding/utf8_bom.js +1 -0
- data/vendor/sprockets/test/fixtures/engines/hello.alert +1 -0
- data/vendor/sprockets/test/fixtures/engines/moo.js.str +1 -0
- data/vendor/sprockets/test/fixtures/public/compiled-digest-0aa2105d29558f3eb790d411d7d8fb66.js +3 -0
- data/vendor/sprockets/test/fixtures/public/compiled-digest-1c41eb0cf934a0c76babe875f982f9d1.js +1 -0
- data/vendor/sprockets/test/fixtures/server/app/javascripts/application.js +5 -0
- data/vendor/sprockets/test/fixtures/server/app/javascripts/bar.js +1 -0
- data/vendor/sprockets/test/fixtures/server/app/javascripts/foo.js +1 -0
- data/vendor/sprockets/test/fixtures/server/app/javascripts/hello.txt +2 -0
- data/vendor/sprockets/test/fixtures/server/app/javascripts/tree.js +1 -0
- data/vendor/sprockets/test/fixtures/server/vendor/javascripts/missing_require.js +1 -0
- data/vendor/sprockets/test/fixtures/server/vendor/stylesheets/missing_require.css +1 -0
- data/vendor/sprockets/test/sprockets_test.rb +56 -0
- data/vendor/sprockets/test/test_asset.rb +593 -0
- data/vendor/sprockets/test/test_asset_attributes.rb +86 -0
- data/vendor/sprockets/test/test_caching.rb +62 -0
- data/vendor/sprockets/test/test_context.rb +115 -0
- data/vendor/sprockets/test/test_directive_processor.rb +124 -0
- data/vendor/sprockets/test/test_encoding.rb +65 -0
- data/vendor/sprockets/test/test_engines.rb +73 -0
- data/vendor/sprockets/test/test_environment.rb +610 -0
- data/vendor/sprockets/test/test_server.rb +227 -0
- metadata +258 -54
- data/spec/fixtures/transporter/packages/transport/lib/wrapper.js +0 -5
data/spec/pipeline_spec.rb
CHANGED
|
@@ -43,81 +43,139 @@ describe BPM::Pipeline, "asset_path" do
|
|
|
43
43
|
asset.pathname.should == home('hello_world', '.bpm', 'packages', 'core-test', 'resources', 'runner.css')
|
|
44
44
|
end
|
|
45
45
|
|
|
46
|
-
describe "
|
|
47
|
-
|
|
46
|
+
describe "generated assets" do
|
|
47
|
+
|
|
48
48
|
before do
|
|
49
49
|
goto_home
|
|
50
50
|
set_host
|
|
51
51
|
start_fake(FakeGemServer.new)
|
|
52
52
|
cd home('hello_world')
|
|
53
|
-
|
|
53
|
+
|
|
54
54
|
bpm 'add', 'custom_package'
|
|
55
55
|
wait
|
|
56
|
-
|
|
56
|
+
|
|
57
57
|
@project = BPM::Project.new home('hello_world')
|
|
58
58
|
end
|
|
59
|
+
|
|
60
|
+
describe "bpm_packages.js" do
|
|
61
|
+
|
|
62
|
+
subject do
|
|
63
|
+
BPM::Pipeline.new(@project).find_asset 'bpm_packages.js'
|
|
64
|
+
end
|
|
59
65
|
|
|
66
|
+
it "should return an asset of type BPM::GeneratedAsset" do
|
|
67
|
+
subject.class.should == BPM::GeneratedAsset
|
|
68
|
+
end
|
|
60
69
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
it "should return an asset of type BPM::GeneratedAsset" do
|
|
66
|
-
subject.class.should == BPM::GeneratedAsset
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
it "should find the bpm_packages.js" do
|
|
70
|
-
subject.pathname.should == home('hello_world', 'assets', 'bpm_packages.js')
|
|
71
|
-
end
|
|
70
|
+
it "should find the bpm_packages.js" do
|
|
71
|
+
subject.pathname.should == home('hello_world', 'assets', 'bpm_packages.js')
|
|
72
|
+
end
|
|
72
73
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
74
|
+
it "should find bpm_packages as well" do
|
|
75
|
+
BPM::Pipeline.new(@project).find_asset('bpm_packages').should == subject
|
|
76
|
+
end
|
|
76
77
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
78
|
+
it "should have a manifest line" do
|
|
79
|
+
subject.to_s.should include('MANIFEST: core-test (0.4.9) custom_package (2.0.0) ivory (0.0.1) optparse (1.0.1) rake (0.8.6) spade (0.5.0)')
|
|
80
|
+
end
|
|
80
81
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
82
|
+
it "should include any required modules in the bpm_package.js" do
|
|
83
|
+
subject.to_s.should include(File.read(home('hello_world', 'packages', 'custom_package', 'lib', 'main.js')))
|
|
84
|
+
end
|
|
84
85
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
86
|
+
it "should reference package.json directories when resolving modules" do
|
|
87
|
+
subject.to_s.should include(File.read(home('hello_world', 'packages', 'custom_package', 'custom_dir', 'basic-module.js')))
|
|
88
|
+
end
|
|
88
89
|
|
|
89
|
-
|
|
90
|
+
end
|
|
90
91
|
|
|
91
|
-
|
|
92
|
+
describe "bpm_styles.css" do
|
|
92
93
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
94
|
+
subject do
|
|
95
|
+
BPM::Pipeline.new(@project).find_asset 'bpm_styles.css'
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
it "should find bpm_styles.css" do
|
|
99
|
+
subject.pathname.should == home('hello_world', 'assets', 'bpm_styles.css')
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
it "should include any required modules in the bpm_styles.css" do
|
|
103
|
+
subject.to_s.should include(File.read(home('hello_world', 'packages', 'custom_package', 'css', 'sample_styles.css')))
|
|
104
|
+
end
|
|
98
105
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
106
|
+
it "should reference installed package styles as well" do
|
|
107
|
+
subject.to_s.should include(File.read(home('hello_world', '.bpm', 'packages', 'core-test', 'resources', 'runner.css')))
|
|
108
|
+
end
|
|
102
109
|
|
|
103
|
-
subject do
|
|
104
|
-
project = BPM::Project.new home('hello_world')
|
|
105
|
-
BPM::Pipeline.new(project).find_asset 'bpm_styles.css'
|
|
106
110
|
end
|
|
111
|
+
|
|
112
|
+
describe "hello_world/app_package.js" do
|
|
113
|
+
|
|
114
|
+
before do
|
|
115
|
+
FileUtils.mkdir_p home('hello_world', 'assets', 'hello_world')
|
|
116
|
+
FileUtils.touch home('hello_world', 'assets', 'hello_world', 'app_package.js')
|
|
117
|
+
end
|
|
107
118
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
119
|
+
subject do
|
|
120
|
+
BPM::Pipeline.new(@project).find_asset 'hello_world/app_package.js'
|
|
121
|
+
end
|
|
111
122
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
123
|
+
it "should return an asset of type BPM::GeneratedAsset" do
|
|
124
|
+
subject.class.should == BPM::GeneratedAsset
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
it "should find the app_package.js" do
|
|
128
|
+
subject.pathname.should == home('hello_world', 'assets', 'hello_world', 'app_package.js')
|
|
129
|
+
end
|
|
115
130
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
131
|
+
it "should find app_package as well" do
|
|
132
|
+
BPM::Pipeline.new(@project).find_asset('hello_world/app_package').should == subject
|
|
133
|
+
end
|
|
119
134
|
|
|
135
|
+
it "should have a manifest line" do
|
|
136
|
+
subject.to_s.should include('MANIFEST: hello_world (2.0.0)')
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
it "should include any required modules in the app_package" do
|
|
140
|
+
subject.to_s.should include(File.read(home('hello_world', 'lib', 'main.js')))
|
|
141
|
+
end
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
describe "hello_world/app_styles.css" do
|
|
145
|
+
|
|
146
|
+
before do
|
|
147
|
+
FileUtils.mkdir_p home('hello_world', 'assets', 'hello_world')
|
|
148
|
+
FileUtils.touch home('hello_world', 'assets', 'hello_world', 'app_styles.css')
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
subject do
|
|
152
|
+
BPM::Pipeline.new(@project).find_asset 'hello_world/app_styles.css'
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
it "should return an asset of type BPM::GeneratedAsset" do
|
|
156
|
+
subject.class.should == BPM::GeneratedAsset
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
it "should find the app_styles.css" do
|
|
160
|
+
subject.pathname.should == home('hello_world', 'assets', 'hello_world', 'app_styles.css')
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
it "should find app_styles as well" do
|
|
164
|
+
BPM::Pipeline.new(@project).find_asset('hello_world/app_styles').should == subject
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
it "should have a manifest line" do
|
|
168
|
+
subject.to_s.should include('MANIFEST: hello_world (2.0.0)')
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
it "should include any required modules in the app_package" do
|
|
172
|
+
subject.to_s.should include(File.read(home('hello_world', 'css', 'dummy.css')))
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
end
|
|
176
|
+
|
|
120
177
|
end
|
|
178
|
+
|
|
121
179
|
end
|
|
122
180
|
|
|
123
181
|
|
|
@@ -192,8 +250,8 @@ describe BPM::Pipeline, 'transport processor' do
|
|
|
192
250
|
FileUtils.cp_r fixtures('transporter'), '.'
|
|
193
251
|
cd home('transporter')
|
|
194
252
|
|
|
195
|
-
|
|
196
|
-
|
|
253
|
+
bpm 'compile'
|
|
254
|
+
wait
|
|
197
255
|
end
|
|
198
256
|
|
|
199
257
|
subject do
|
|
@@ -201,13 +259,76 @@ describe BPM::Pipeline, 'transport processor' do
|
|
|
201
259
|
BPM::Pipeline.new project
|
|
202
260
|
end
|
|
203
261
|
|
|
204
|
-
it "should wrap main.js" do
|
|
262
|
+
it "should wrap the project's main.js" do
|
|
205
263
|
asset = subject.find_asset 'transporter/lib/main.js'
|
|
206
|
-
asset.to_s.should
|
|
264
|
+
asset.to_s.should == "define_transport(function() {\n//TRANSPORT\ntransporter();\n//TRANSPORT\n\n}), 'transporter', 'main', 'lib/main.js');\n\n"
|
|
207
265
|
asset.pathname.to_s.should == File.join(Dir.pwd, 'lib', 'main.js')
|
|
208
266
|
end
|
|
267
|
+
|
|
268
|
+
it "should not wrap transport/main.js" do
|
|
269
|
+
asset = subject.find_asset 'transport/lib/main.js'
|
|
270
|
+
asset.to_s.should == "// TRANSPORT DEMO\n"
|
|
271
|
+
end
|
|
272
|
+
|
|
273
|
+
end
|
|
274
|
+
|
|
275
|
+
describe BPM::Pipeline, 'minifier' do
|
|
276
|
+
|
|
277
|
+
before do
|
|
278
|
+
goto_home
|
|
279
|
+
set_host
|
|
280
|
+
reset_libgems bpm_dir.to_s
|
|
281
|
+
start_fake(FakeGemServer.new)
|
|
282
|
+
|
|
283
|
+
FileUtils.cp_r fixtures('minitest'), '.'
|
|
284
|
+
cd home('minitest')
|
|
285
|
+
|
|
286
|
+
bpm 'compile'
|
|
287
|
+
wait
|
|
288
|
+
end
|
|
209
289
|
|
|
290
|
+
subject do
|
|
291
|
+
project = BPM::Project.new home('minitest')
|
|
292
|
+
BPM::Pipeline.new project
|
|
293
|
+
end
|
|
210
294
|
|
|
295
|
+
it "should wrap bpm_packages.js" do
|
|
296
|
+
asset = subject.find_asset 'bpm_packages.js'
|
|
297
|
+
file_path = home('minitest', 'packages', 'uglyduck', 'lib', 'main.js')
|
|
298
|
+
expected = <<EOF
|
|
299
|
+
//MINIFIED START
|
|
300
|
+
/* ===========================================================================
|
|
301
|
+
BPM Static Dependencies
|
|
302
|
+
MANIFEST: uglyduck (1.0.0)
|
|
303
|
+
This file is generated automatically by the bpm (http://www.bpmjs.org)
|
|
304
|
+
To use this file, load this file in your HTML head.
|
|
305
|
+
=========================================================================*/
|
|
306
|
+
|
|
307
|
+
#{File.read file_path}
|
|
308
|
+
//MINIFIED END
|
|
309
|
+
EOF
|
|
310
|
+
|
|
311
|
+
asset.to_s.should == expected
|
|
312
|
+
end
|
|
313
|
+
|
|
314
|
+
it "should wrap app_package.js" do
|
|
315
|
+
asset = subject.find_asset 'minitest/app_package.js'
|
|
316
|
+
file_path = home('minitest', 'lib', 'main.js')
|
|
317
|
+
expected = <<EOF
|
|
318
|
+
//MINIFIED START
|
|
319
|
+
/* ===========================================================================
|
|
320
|
+
BPM Static Dependencies
|
|
321
|
+
MANIFEST: minitest (2.0.0)
|
|
322
|
+
This file is generated automatically by the bpm (http://www.bpmjs.org)
|
|
323
|
+
To use this file, load this file in your HTML head.
|
|
324
|
+
=========================================================================*/
|
|
325
|
+
|
|
326
|
+
#{File.read(file_path)}
|
|
327
|
+
//MINIFIED END
|
|
328
|
+
EOF
|
|
329
|
+
asset.to_s.should == expected
|
|
330
|
+
end
|
|
331
|
+
|
|
211
332
|
end
|
|
212
333
|
|
|
213
|
-
|
|
334
|
+
|
data/spec/project_spec.rb
CHANGED
|
@@ -2,22 +2,28 @@ require "spec_helper"
|
|
|
2
2
|
|
|
3
3
|
describe BPM::Project, "project_file_path" do
|
|
4
4
|
|
|
5
|
-
it "should return
|
|
5
|
+
it "should return project file path" do
|
|
6
6
|
path = fixtures('hello_world')
|
|
7
7
|
expected = File.join(path, 'hello_world.json')
|
|
8
8
|
BPM::Project.project_file_path(path).should == expected
|
|
9
9
|
end
|
|
10
10
|
|
|
11
|
-
it "should return
|
|
11
|
+
it "should return nil on a package" do
|
|
12
12
|
path = fixtures('core-test')
|
|
13
13
|
BPM::Project.project_file_path(path).should == nil
|
|
14
14
|
end
|
|
15
15
|
|
|
16
|
-
it "should return
|
|
16
|
+
it "should return nil on a project with no file" do
|
|
17
17
|
path = fixtures('simple_hello')
|
|
18
18
|
BPM::Project.project_file_path(path).should == nil
|
|
19
19
|
end
|
|
20
20
|
|
|
21
|
+
it "should return project path with different name" do
|
|
22
|
+
path = fixtures('custom_name')
|
|
23
|
+
expected = File.join(path, 'MyProject.json')
|
|
24
|
+
BPM::Project.project_file_path(path).should == expected
|
|
25
|
+
end
|
|
26
|
+
|
|
21
27
|
end
|
|
22
28
|
|
|
23
29
|
describe BPM::Project, "is_project_root?" do
|
|
@@ -128,3 +134,13 @@ describe BPM::Project, "project metadata" do
|
|
|
128
134
|
end
|
|
129
135
|
|
|
130
136
|
end
|
|
137
|
+
|
|
138
|
+
describe BPM::Project, "converting" do
|
|
139
|
+
subject do
|
|
140
|
+
BPM::Project.nearest_project(fixtures("hello_world")).as_json
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
it "should have bpm set to current version" do
|
|
144
|
+
subject["bpm"].should == BPM::VERSION
|
|
145
|
+
end
|
|
146
|
+
end
|
|
@@ -41,12 +41,12 @@ class FakeGemServer
|
|
|
41
41
|
[200, {"Content-Type" => "application/octet-stream"}, compress(big_index)]
|
|
42
42
|
elsif request.path =~ /\/quick\/Marshal\.4\.8\/(.*)\.gemspec\.rz$/
|
|
43
43
|
|
|
44
|
-
spec = LibGems::Format.from_file_by_path(
|
|
44
|
+
spec = LibGems::Format.from_file_by_path(gem_or_bpkg($1).to_s).spec
|
|
45
45
|
value = LibGems.deflate(Marshal.dump(spec))
|
|
46
46
|
|
|
47
47
|
[200, {"Content-Type" => "application/octet-stream"}, value]
|
|
48
48
|
elsif request.path =~ /\/gems\/(.*)\.gem$/
|
|
49
|
-
[200, {"Content-Type" => "application/octet-stream"}, File.read(
|
|
49
|
+
[200, {"Content-Type" => "application/octet-stream"}, File.read(gem_or_bpkg($1))]
|
|
50
50
|
else
|
|
51
51
|
[200, {"Content-Type" => "text/plain"}, "fake gem server"]
|
|
52
52
|
end
|
|
@@ -62,9 +62,9 @@ class FakeGemServer
|
|
|
62
62
|
|
|
63
63
|
private
|
|
64
64
|
|
|
65
|
-
def
|
|
65
|
+
def gem_or_bpkg(name)
|
|
66
66
|
fixture = fixtures("#{name}.gem")
|
|
67
|
-
fixture = fixtures("#{name}.
|
|
67
|
+
fixture = fixtures("#{name}.bpkg") unless File.exist?(fixture)
|
|
68
68
|
fixture
|
|
69
69
|
end
|
|
70
70
|
|
data/templates/init/project.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<html>
|
|
2
2
|
<head>
|
|
3
|
-
<script type="text/javascript" src="assets/bpm_packages.
|
|
3
|
+
<script type="text/javascript" src="assets/bpm_packages.js"></script>
|
|
4
4
|
<script type="text/javascript" src="app.js"></script>
|
|
5
5
|
|
|
6
6
|
<link rel="stylesheet" href="assets/bpm_styles.css" type="text/css" media="screen" charset="utf-8" />
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Copyright (c) 2010 Sam Stephenson
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
+
a copy of this software and associated documentation files (the
|
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
+
the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be
|
|
12
|
+
included in all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<div style="border: 1px solid #c00; background: #fff; padding: 5px 10px"><strong>This is an in-progress rewrite of Sprockets</strong> to be released as version 2.0. Please see the <a href="https://github.com/sstephenson/sprockets/tree/1.0.x">1.0.x branch</a> for information on the current release.</div>
|
|
2
|
+
|
|
3
|
+
Sprockets 2
|
|
4
|
+
===========
|
|
5
|
+
|
|
6
|
+
Sprockets 2 is a Rack-based asset packaging system that concatenates
|
|
7
|
+
and serves JavaScript, CoffeeScript, CSS, LESS, Sass, and SCSS.
|
|
8
|
+
|
|
9
|
+
This version is a rewrite of Sprockets that addresses a number of issues
|
|
10
|
+
with the original version's design.
|
|
11
|
+
|
|
12
|
+
* Emphasis on serving, not generating.
|
|
13
|
+
* Support for multiple concatenations.
|
|
14
|
+
* Support for CSS concatenations.
|
|
15
|
+
* Support for CoffeeScript, LESS, Sass and SCSS preprocessing.
|
|
16
|
+
* Simplified, header-comment-based dependency declarations.
|
|
17
|
+
* Opt-in interpolation with ERB support.
|
|
18
|
+
* Serve images and other assets from anywhere in the load path.
|
|
19
|
+
|
|
20
|
+
More coming soon.
|
|
21
|
+
|
|
22
|
+
[](http://travis-ci.org/sstephenson/sprockets)
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
require 'time'
|
|
2
|
+
|
|
3
|
+
module Sprockets
|
|
4
|
+
# `Asset` is the base class for `BundledAsset` and `StaticAsset`.
|
|
5
|
+
class Asset
|
|
6
|
+
# Internal initializer to load `Asset` from serialized `Hash`.
|
|
7
|
+
def self.from_hash(environment, hash)
|
|
8
|
+
asset = allocate
|
|
9
|
+
asset.init_with(environment, hash)
|
|
10
|
+
asset
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
# Define base set of attributes to be serialized.
|
|
14
|
+
def self.serialized_attributes
|
|
15
|
+
%w( environment_hexdigest
|
|
16
|
+
logical_path pathname
|
|
17
|
+
content_type mtime length digest )
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
attr_reader :environment
|
|
21
|
+
attr_reader :logical_path, :pathname
|
|
22
|
+
|
|
23
|
+
def initialize(environment, logical_path, pathname)
|
|
24
|
+
@environment = environment
|
|
25
|
+
@logical_path = logical_path.to_s
|
|
26
|
+
@pathname = Pathname.new(pathname)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# Initialize `Asset` from serialized `Hash`.
|
|
30
|
+
def init_with(environment, coder)
|
|
31
|
+
@environment = environment
|
|
32
|
+
|
|
33
|
+
self.class.serialized_attributes.each do |attr|
|
|
34
|
+
instance_variable_set("@#{attr}", coder[attr].to_s) if coder[attr]
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
if @pathname
|
|
38
|
+
# Expand `$root` placeholder and wrapper string in a `Pathname`
|
|
39
|
+
@pathname = Pathname.new(expand_root_path(@pathname))
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
if @mtime
|
|
43
|
+
# Parse time string
|
|
44
|
+
@mtime = Time.parse(@mtime)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
if @length
|
|
48
|
+
# Convert length to an `Integer`
|
|
49
|
+
@length = Integer(@length)
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
# Copy serialized attributes to the coder object
|
|
54
|
+
def encode_with(coder)
|
|
55
|
+
coder['class'] = self.class.name.sub(/Sprockets::/, '')
|
|
56
|
+
|
|
57
|
+
self.class.serialized_attributes.each do |attr|
|
|
58
|
+
coder[attr] = send(attr).to_s
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
coder['pathname'] = relativize_root_path(coder['pathname'])
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
# Returns `Content-Type` from pathname.
|
|
65
|
+
def content_type
|
|
66
|
+
@content_type ||= environment.content_type_of(pathname)
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
# Get mtime at the time the `Asset` is built.
|
|
70
|
+
def mtime
|
|
71
|
+
@mtime ||= environment.stat(pathname).mtime
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
# Get length at the time the `Asset` is built.
|
|
75
|
+
def length
|
|
76
|
+
@length ||= environment.stat(pathname).size
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
# Get content digest at the time the `Asset` is built.
|
|
80
|
+
def digest
|
|
81
|
+
@digest ||= environment.file_digest(pathname).hexdigest
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
# Return an `Array` of `Asset` files that are declared dependencies.
|
|
85
|
+
def dependencies
|
|
86
|
+
[]
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
# Expand asset into an `Array` of parts.
|
|
90
|
+
#
|
|
91
|
+
# Appending all of an assets body parts together should give you
|
|
92
|
+
# the asset's contents as a whole.
|
|
93
|
+
#
|
|
94
|
+
# This allows you to link to individual files for debugging
|
|
95
|
+
# purposes.
|
|
96
|
+
def to_a
|
|
97
|
+
[self]
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
# Add enumerator to allow `Asset` instances to be used as Rack
|
|
101
|
+
# compatible body objects.
|
|
102
|
+
def each
|
|
103
|
+
yield to_s
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
# Checks if Asset is fresh by comparing the actual mtime and
|
|
107
|
+
# digest to the inmemory model.
|
|
108
|
+
#
|
|
109
|
+
# Used to test if cached models need to be rebuilt.
|
|
110
|
+
#
|
|
111
|
+
# Subclass must override `fresh?` or `stale?`.
|
|
112
|
+
def fresh?
|
|
113
|
+
!stale?
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
# Checks if Asset is stale by comparing the actual mtime and
|
|
117
|
+
# digest to the inmemory model.
|
|
118
|
+
#
|
|
119
|
+
# Subclass must override `fresh?` or `stale?`.
|
|
120
|
+
def stale?
|
|
121
|
+
!fresh?
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
# Pretty inspect
|
|
125
|
+
def inspect
|
|
126
|
+
"#<#{self.class}:0x#{object_id.to_s(16)} " +
|
|
127
|
+
"pathname=#{pathname.to_s.inspect}, " +
|
|
128
|
+
"mtime=#{mtime.inspect}, " +
|
|
129
|
+
"digest=#{digest.inspect}" +
|
|
130
|
+
">"
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
# Assets are equal if they share the same path, mtime and digest.
|
|
134
|
+
def eql?(other)
|
|
135
|
+
other.class == self.class &&
|
|
136
|
+
other.relative_pathname == self.relative_pathname &&
|
|
137
|
+
other.mtime == self.mtime &&
|
|
138
|
+
other.digest == self.digest
|
|
139
|
+
end
|
|
140
|
+
alias_method :==, :eql?
|
|
141
|
+
|
|
142
|
+
protected
|
|
143
|
+
# Stores the environment digest from when the asset was first created.
|
|
144
|
+
def environment_hexdigest
|
|
145
|
+
@environment_hexdigest ||= environment.digest.hexdigest
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
# Get pathname with its root stripped.
|
|
149
|
+
def relative_pathname
|
|
150
|
+
Pathname.new(relativize_root_path(pathname))
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
# Replace `$root` placeholder with actual environment root.
|
|
154
|
+
def expand_root_path(path)
|
|
155
|
+
environment.attributes_for(path).expand_root
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
# Replace actual environment root with `$root` placeholder.
|
|
159
|
+
def relativize_root_path(path)
|
|
160
|
+
environment.attributes_for(path).relativize_root
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
# Check if dependency is fresh.
|
|
164
|
+
#
|
|
165
|
+
# `dep` is a `Hash` with `path`, `mtime` and `hexdigest` keys.
|
|
166
|
+
#
|
|
167
|
+
# A `Hash` is used rather than other `Asset` object because we
|
|
168
|
+
# want to test non-asset files and directories.
|
|
169
|
+
def dependency_fresh?(dep = {})
|
|
170
|
+
path, mtime, hexdigest = dep.values_at('path', 'mtime', 'hexdigest')
|
|
171
|
+
|
|
172
|
+
stat = environment.stat(path)
|
|
173
|
+
|
|
174
|
+
# If path no longer exists, its definitely stale.
|
|
175
|
+
if stat.nil?
|
|
176
|
+
return false
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
# Compare dependency mime to the actual mtime. If the
|
|
180
|
+
# dependency mtime is newer than the actual mtime, the file
|
|
181
|
+
# hasn't changed since we created this `Asset` instance.
|
|
182
|
+
#
|
|
183
|
+
# However, if the mtime is newer it doesn't mean the asset is
|
|
184
|
+
# stale. Many deployment environments may recopy or recheckout
|
|
185
|
+
# assets on each deploy. In this case the mtime would be the
|
|
186
|
+
# time of deploy rather than modified time.
|
|
187
|
+
if mtime >= stat.mtime
|
|
188
|
+
return true
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
digest = environment.file_digest(path)
|
|
192
|
+
|
|
193
|
+
# If the mtime is newer, do a full digest comparsion. Return
|
|
194
|
+
# fresh if the digests match.
|
|
195
|
+
if hexdigest == digest.hexdigest
|
|
196
|
+
return true
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
# Otherwise, its stale.
|
|
200
|
+
false
|
|
201
|
+
end
|
|
202
|
+
end
|
|
203
|
+
end
|