middleman-sprockets-cj 3.3.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (154) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +11 -0
  3. data/.rspec +2 -0
  4. data/.simplecov +9 -0
  5. data/.travis.yml +15 -0
  6. data/CHANGELOG.md +71 -0
  7. data/CONTRIBUTING.md +43 -0
  8. data/Gemfile +32 -0
  9. data/LICENSE.md +20 -0
  10. data/README.md +104 -0
  11. data/Rakefile +45 -0
  12. data/features/asset_hash-3.0.feature +105 -0
  13. data/features/asset_hash.feature +107 -0
  14. data/features/bower.feature +37 -0
  15. data/features/jst.feature +14 -0
  16. data/features/long_filenames.feature +17 -0
  17. data/features/sass_globs.feature +9 -0
  18. data/features/sass_partials.feature +36 -0
  19. data/features/sprockets.feature +129 -0
  20. data/features/sprockets_gems.feature +67 -0
  21. data/features/step_definitions/server_steps.rb +7 -0
  22. data/features/support/env.rb +18 -0
  23. data/fixtures/asset-hash-app/config.rb +7 -0
  24. data/fixtures/asset-hash-app/source/images/100px.gif +0 -0
  25. data/fixtures/asset-hash-app/source/images/100px.jpg +0 -0
  26. data/fixtures/asset-hash-app/source/images/100px.png +0 -0
  27. data/fixtures/asset-hash-app/source/index.html.erb +308 -0
  28. data/fixtures/asset-hash-app/source/javascripts/application.js +8 -0
  29. data/fixtures/asset-hash-app/source/javascripts/sprockets_base.js +5 -0
  30. data/fixtures/asset-hash-app/source/javascripts/sprockets_sub.js +3 -0
  31. data/fixtures/asset-hash-app/source/layout.erb +19 -0
  32. data/fixtures/asset-hash-app/source/other.html.erb +2 -0
  33. data/fixtures/asset-hash-app/source/partials.html.erb +2 -0
  34. data/fixtures/asset-hash-app/source/stylesheets/_partial.sass +2 -0
  35. data/fixtures/asset-hash-app/source/stylesheets/jquery-mobile.css.scss +1 -0
  36. data/fixtures/asset-hash-app/source/stylesheets/site.css.scss +4 -0
  37. data/fixtures/asset-hash-app/source/stylesheets/uses_partials.css.sass +4 -0
  38. data/fixtures/asset-hash-app/source/subdir/index.html.erb +308 -0
  39. data/fixtures/asset-hash-host-app/config.rb +6 -0
  40. data/fixtures/asset-hash-host-app/source/images/100px.gif +0 -0
  41. data/fixtures/asset-hash-host-app/source/images/100px.jpg +0 -0
  42. data/fixtures/asset-hash-host-app/source/images/100px.png +0 -0
  43. data/fixtures/asset-hash-host-app/source/index.html.erb +6 -0
  44. data/fixtures/asset-hash-host-app/source/layout.erb +17 -0
  45. data/fixtures/asset-hash-host-app/source/other.html.erb +2 -0
  46. data/fixtures/asset-hash-host-app/source/stylesheets/site.css.scss +4 -0
  47. data/fixtures/asset-hash-host-app/source/subdir/index.html.erb +6 -0
  48. data/fixtures/asset-paths-app/config.rb +4 -0
  49. data/fixtures/asset-paths-app/derp/javascripts/vendored_js.js +1 -0
  50. data/fixtures/asset-paths-app/source/javascripts/vendored_include.js +1 -0
  51. data/fixtures/bower-app/bower.json +7 -0
  52. data/fixtures/bower-app/bower_components/underscore/bower.json +8 -0
  53. data/fixtures/bower-app/bower_components/underscore/underscore.js +1343 -0
  54. data/fixtures/bower-app/config.rb +3 -0
  55. data/fixtures/bower-app/source/javascripts/application.js +1 -0
  56. data/fixtures/bower-individual-outputdir-app/bower.json +7 -0
  57. data/fixtures/bower-individual-outputdir-app/bower_components/underscore/bower.json +8 -0
  58. data/fixtures/bower-individual-outputdir-app/bower_components/underscore/underscore.js +1343 -0
  59. data/fixtures/bower-individual-outputdir-app/config.rb +6 -0
  60. data/fixtures/bower-individual-outputdir-app/source/javascripts/application.js +1 -0
  61. data/fixtures/bower-individual-outputdir-app/vendor/assets/components/lightbox2/.bower.json +34 -0
  62. data/fixtures/bower-individual-outputdir-app/vendor/assets/components/lightbox2/bower.json +26 -0
  63. data/fixtures/bower-individual-outputdir-app/vendor/assets/components/lightbox2/img/close.png +0 -0
  64. data/fixtures/bower-individual-outputdir-app/vendor/assets/components/lightbox2/js/lightbox.js +2 -0
  65. data/fixtures/bower-individual-outputdir-app/vendor/assets/components/lightbox2/package.json +37 -0
  66. data/fixtures/bower-json-app/config.rb +1 -0
  67. data/fixtures/bower-json-app/source/javascripts/application.js.coffee +1 -0
  68. data/fixtures/bower-json-app/source/javascripts/bower.json +5 -0
  69. data/fixtures/bower-multiple-assets-app/.bowerrc +4 -0
  70. data/fixtures/bower-multiple-assets-app/bower.json +7 -0
  71. data/fixtures/bower-multiple-assets-app/config.rb +7 -0
  72. data/fixtures/bower-multiple-assets-app/vendor/assets/components/lightbox2/.bower.json +34 -0
  73. data/fixtures/bower-multiple-assets-app/vendor/assets/components/lightbox2/bower.json +26 -0
  74. data/fixtures/bower-multiple-assets-app/vendor/assets/components/lightbox2/img/close.png +0 -0
  75. data/fixtures/bower-multiple-assets-app/vendor/assets/components/lightbox2/js/lightbox.js +2 -0
  76. data/fixtures/bower-multiple-assets-app/vendor/assets/components/lightbox2/package.json +37 -0
  77. data/fixtures/glob-app/config.rb +0 -0
  78. data/fixtures/glob-app/source/stylesheets/main.css.scss +1 -0
  79. data/fixtures/glob-app/source/stylesheets/module1/_i-am-mod.scss +3 -0
  80. data/fixtures/glob-app/source/stylesheets/module2/_derp.sass +2 -0
  81. data/fixtures/glob-app/source/stylesheets/shared/3rd-party/bootstrap.sass +2 -0
  82. data/fixtures/glob-app/source/stylesheets/shared/shared.scss +3 -0
  83. data/fixtures/jquery-mobile-app/config.rb +0 -0
  84. data/fixtures/jquery-mobile-app/source/stylesheets/base.css.scss +2 -0
  85. data/fixtures/long-filenames-app/config.rb +0 -0
  86. data/fixtures/long-filenames-app/source/images/00000000-0000-0000-0000-000000.svg +3 -0
  87. data/fixtures/long-filenames-app/source/images/00000000-0000-0000-0000-0000001.svg +3 -0
  88. data/fixtures/preview-app/config.rb +0 -0
  89. data/fixtures/preview-app/source/content.html.erb +1 -0
  90. data/fixtures/preview-app/source/layout.erb +1 -0
  91. data/fixtures/preview-app/source/stylesheets/_partial.sass +2 -0
  92. data/fixtures/preview-app/source/stylesheets/_partial2.css.sass +2 -0
  93. data/fixtures/preview-app/source/stylesheets/main.css.sass +4 -0
  94. data/fixtures/preview-app/source/stylesheets/main2.css.sass +4 -0
  95. data/fixtures/preview-app/source/stylesheets/plain.css.sass +2 -0
  96. data/fixtures/sprockets-app-debug-assets/config.rb +1 -0
  97. data/fixtures/sprockets-app-debug-assets/source/index.html.erb +8 -0
  98. data/fixtures/sprockets-app-debug-assets/source/javascripts/dependency1.js +3 -0
  99. data/fixtures/sprockets-app-debug-assets/source/javascripts/dependency2.js +1 -0
  100. data/fixtures/sprockets-app-debug-assets/source/javascripts/main.js +4 -0
  101. data/fixtures/sprockets-app-debug-assets/source/stylesheets/app.css.scss +4 -0
  102. data/fixtures/sprockets-app-debug-assets/source/stylesheets/dependency1.css +0 -0
  103. data/fixtures/sprockets-app-debug-assets/source/stylesheets/dependency2.css.scss +0 -0
  104. data/fixtures/sprockets-app/config.rb +7 -0
  105. data/fixtures/sprockets-app/source/index.html.erb +6 -0
  106. data/fixtures/sprockets-app/source/library/css/bootstrap_include.css.scss +1 -0
  107. data/fixtures/sprockets-app/source/library/css/plain.css +3 -0
  108. data/fixtures/sprockets-app/source/library/css/sprockets_base1.css.scss +1 -0
  109. data/fixtures/sprockets-app/source/library/css/sprockets_base2.css.scss +1 -0
  110. data/fixtures/sprockets-app/source/library/css/sprockets_sub.css.scss +1 -0
  111. data/fixtures/sprockets-app/source/library/js/jquery_include.js +1 -0
  112. data/fixtures/sprockets-app/source/library/js/plain.js +3 -0
  113. data/fixtures/sprockets-app/source/library/js/sprockets_base.js +5 -0
  114. data/fixtures/sprockets-app/source/library/js/sprockets_sub.js +3 -0
  115. data/fixtures/sprockets-app/source/library/js/vendored_include.js +1 -0
  116. data/fixtures/sprockets-app/vendor/assets/javascripts/coffee.js.coffee +2 -0
  117. data/fixtures/sprockets-app/vendor/assets/javascripts/vendored_js.js +1 -0
  118. data/fixtures/sprockets-app/vendor/assets/stylesheets/vendored.css.scss +4 -0
  119. data/fixtures/sprockets-app2/config.rb +0 -0
  120. data/fixtures/sprockets-app2/data/test.yml +4 -0
  121. data/fixtures/sprockets-app2/data/test2.json +4 -0
  122. data/fixtures/sprockets-app2/source/javascripts/_templates/test.jst.ejs +1 -0
  123. data/fixtures/sprockets-app2/source/javascripts/_templates/test2.jst.eco +1 -0
  124. data/fixtures/sprockets-app2/source/javascripts/asset_path.js.erb +3 -0
  125. data/fixtures/sprockets-app2/source/javascripts/multiple_engines.js.coffee.erb +1 -0
  126. data/fixtures/sprockets-app2/source/javascripts/sprockets_base.js +5 -0
  127. data/fixtures/sprockets-app2/source/javascripts/sprockets_sub.js +3 -0
  128. data/fixtures/sprockets-app2/source/javascripts/templates.js +1 -0
  129. data/fixtures/sprockets-app2/source/stylesheets/sprockets_base1.css.scss +1 -0
  130. data/fixtures/sprockets-app2/source/stylesheets/sprockets_base2.css.scss +1 -0
  131. data/fixtures/sprockets-app2/source/stylesheets/sprockets_sub.css.scss +1 -0
  132. data/fixtures/sprockets-images-app/config.rb +1 -0
  133. data/fixtures/sprockets-images-app/source/index.html.erb +10 -0
  134. data/fixtures/sprockets-images-app/source/library/images/cat.jpg +0 -0
  135. data/fixtures/sprockets-images-app/vendor/assets/images/cat-2.jpg +0 -0
  136. data/lib/middleman-sprockets.rb +6 -0
  137. data/lib/middleman-sprockets/asset.rb +185 -0
  138. data/lib/middleman-sprockets/asset_list.rb +41 -0
  139. data/lib/middleman-sprockets/asset_tag_helpers.rb +54 -0
  140. data/lib/middleman-sprockets/config_only_environment.rb +50 -0
  141. data/lib/middleman-sprockets/environment.rb +228 -0
  142. data/lib/middleman-sprockets/extension.rb +145 -0
  143. data/lib/middleman-sprockets/imported_asset.rb +57 -0
  144. data/lib/middleman-sprockets/pathname_extensions.rb +10 -0
  145. data/lib/middleman-sprockets/sass_function_hack.rb +9 -0
  146. data/lib/middleman-sprockets/version.rb +5 -0
  147. data/middleman-sprockets.gemspec +22 -0
  148. data/spec/asset_list_spec.rb +38 -0
  149. data/spec/asset_spec.rb +116 -0
  150. data/spec/imported_asset_spec.rb +72 -0
  151. data/spec/spec_helper.rb +16 -0
  152. data/spec/support/aruba.rb +18 -0
  153. data/spec/support/rspec.rb +17 -0
  154. metadata +257 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d30ad274a33a6d1a2308c53aed94688ec6bcf6b5
4
+ data.tar.gz: a6e777dd6ca0ce5c723999ea61e2667e38c08f43
5
+ SHA512:
6
+ metadata.gz: f80d7d19c651abafe4165575b9594d3c0cfb22ca82976b07b9bf7ca1dc9d7ccdfbd997be7cda2444f11f70a2bc757ea4a48312eb8b122179984053423ad1e145
7
+ data.tar.gz: 8c22338890deeed0cd59bf0a8d32491a943214a30f94f6909c4394a2fa37ccbfd243813fe1e3e4c01922d323d96efe9250da868f08d60accc3e5519952a8880d
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ coverage/
2
+ .DS_Store
3
+ Gemfile.lock
4
+ Gemfile-v4.lock
5
+ tmp
6
+ .rbenv-*
7
+ .sass-cache
8
+ pkg
9
+ build
10
+ .ruby-version
11
+ .cache
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
data/.simplecov ADDED
@@ -0,0 +1,9 @@
1
+ SimpleCov.start do
2
+ add_filter "/features/"
3
+ add_filter "/fixtures/"
4
+ add_filter "/spec/"
5
+ add_filter "/tmp"
6
+ add_filter "/vendor"
7
+
8
+ add_group "lib", "lib"
9
+ end
data/.travis.yml ADDED
@@ -0,0 +1,15 @@
1
+ rvm:
2
+ - 1.9.3
3
+ - 2.0.0
4
+ - 2.1.1
5
+ - jruby-19mode
6
+
7
+ gemfile:
8
+ - Gemfile
9
+
10
+ script: "bundle exec rake test"
11
+
12
+ env: TEST=true
13
+
14
+ matrix:
15
+ fast_finish: true
data/CHANGELOG.md ADDED
@@ -0,0 +1,71 @@
1
+ 3.3.2
2
+ ===
3
+
4
+ * Remove file-based cache (`.cache` folder), which did not invalidate correctly and led to a lot of problems with assets not updating.
5
+ * It is now possible to configure Sprockets via `sprockets.append_path` and `sprockets.import_asset` without having to wrap it in a `ready` block.
6
+
7
+ 3.3.1
8
+ ===
9
+
10
+ * Fix import_asset for Bower and other import paths that don't end in /javascripts, /stylesheets, etc.
11
+
12
+ 3.3.0
13
+ ===
14
+
15
+ * Prep work for Middleman v4.
16
+ * Work around sstephenson/sprockets#533 by serving bower.json directly, skipping Sprockets.
17
+ * Only attempt to patch up Sass if Sass is present.
18
+ * :bower_dir is deprecated in favor of just adding your bower_components folder to the sprockets load path.
19
+ * Convert to a new-style Middleman extension. #48
20
+ * Use a file-based cache to persist compiled assets between sessions #47
21
+
22
+ 3.2.0
23
+ ===
24
+
25
+ * Require Middleman 3.2 or later.
26
+ * No longer require 'middleman-more'
27
+ * Fix import_asset. #38
28
+
29
+ 3.1.3
30
+ ===
31
+
32
+ * Fix files names like guids, which Sprockets thinks are asset hashes.
33
+
34
+ 3.1.2
35
+ ===
36
+
37
+ * Fix debug_assets for CSS
38
+
39
+ 3.1.1
40
+ ===
41
+
42
+ * Add sprockets-helpers to the list of dependencies to fix various path-related bugs. #34
43
+ * Patch generated_image_url so that Compass sprites work. middleman/middleman#890.
44
+ * Output .jst, .eco, and .ejs files with a .js extension. middleman/middleman#888.
45
+ * Fix :debug_assets for files that include scripts from gems. #29.
46
+ * :debug_assets will now expand CSS included via Sprockets requires as well as JavaScript. #30
47
+
48
+ 3.1.0
49
+ ===
50
+
51
+ * Hack around infinite recursion between bootstrap-sass and sprockets-sass. middleman/middleman#864
52
+ * Fix for fonts in Sass files having ".font" appended to them. middleman/middleman#866.
53
+ * Enable in-memory caching in Sprockets, so unchanged assets don't get recompiled when other assets change. #25
54
+ * Refuse to serve gem-assets that haven't been added to the Middleman sitemap. #23
55
+ * Allow importing JS/CSS assets from gems by their logical path, using `sprockets.import_asset`. #23
56
+ * Fix a bug where, when `:debug_assets` was enabled, refreshing the page would produce the wrong JavaScript include path. #26
57
+
58
+ 3.0.11
59
+ ===
60
+
61
+ * Fonts are now included in the Sprockets load path.
62
+ * When `:debug_assets` is on, do not add `?body=1` multiple times. #24
63
+ * :js_assets_paths configuration is deprecated in favor of just calling sprockets.append_path. #22
64
+ * Sprockets integration, especially with regard to helper methods, is significantly improved. #22
65
+ * Images and fonts from gems added to the Sprockets load path will now be copied to the build output. #22
66
+ * Compatibility with newer Sprockets versions.
67
+
68
+ 3.0.10
69
+ ===
70
+
71
+ * No longer expire Sprockets index in development mode. #18
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,43 @@
1
+ # Contributing
2
+ In the spirit of [free software][free-sw], **everyone** is encouraged to help
3
+ improve this project.
4
+
5
+ [free-sw]: http://www.fsf.org/licensing/essays/free-sw.html
6
+
7
+ Here are some ways *you* can contribute:
8
+
9
+ * by using alpha, beta, and prerelease versions
10
+ * by reporting bugs
11
+ * by suggesting new features
12
+ * by writing or editing documentation
13
+ * by writing specifications
14
+ * by writing code ( **no patch is too small** : fix typos, add comments, clean up inconsistent whitespace )
15
+ * by refactoring code
16
+ * by closing [issues][]
17
+ * by reviewing patches
18
+
19
+ [issues]: https://github.com/middleman/middleman-sprockets/issues
20
+
21
+ ## Submitting an Issue
22
+ We use the [GitHub issue tracker][issues] to track bugs and features. Before
23
+ submitting a bug report or feature request, check to make sure it hasn't
24
+ already been submitted. When submitting a bug report, please include a [Gist][]
25
+ that includes a stack trace and any details that may be necessary to reproduce
26
+ the bug, including your gem version, Ruby version, and operating system.
27
+ Ideally, a bug report should include a pull request with failing specs.
28
+
29
+ [gist]: https://gist.github.com/
30
+
31
+ ## Submitting a Pull Request
32
+ 1. [Fork the repository.][fork]
33
+ 2. [Create a topic branch.][branch]
34
+ 3. Add specs for your unimplemented feature or bug fix.
35
+ 4. Run `bundle exec rake test`. If your specs pass, return to step 3.
36
+ 5. Implement your feature or bug fix.
37
+ 6. Run `bundle exec rake test`. If your specs fail, return to step 5.
38
+ 7. Add, commit, and push your changes.
39
+ 8. [Submit a pull request.][pr]
40
+
41
+ [fork]: http://help.github.com/fork-a-repo/
42
+ [branch]: http://learn.github.com/p/branching.html
43
+ [pr]: http://help.github.com/send-pull-requests/
data/Gemfile ADDED
@@ -0,0 +1,32 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem "middleman-core", :github => "middleman/middleman", :branch => "v3-stable"
4
+
5
+ # Specify your gem's dependencies in middleman-sprockets.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 10.0.3", :require => false
9
+ gem "yard", "~> 0.8.0", :require => false
10
+
11
+ # Test tools
12
+ gem "cucumber"
13
+ gem "fivemat", "~> 1.2.1"
14
+ gem "aruba"
15
+ gem "rspec"
16
+ gem "builder", "~> 3.0"
17
+ gem "simplecov"
18
+
19
+ # For actual tests
20
+ # Make sure to lock down the versions of the asset gems
21
+ # so they don't cause asset hashes to change.
22
+ gem "railties", "~> 4.1.0"
23
+ gem "jquery-rails", "3.1.0", :require => false
24
+ gem "bootstrap-sass", "3.1.1.0", :require => false
25
+ gem "jquery_mobile_rails", "1.4.1", :require => false
26
+
27
+ gem "ejs", "~> 1.1.1"
28
+ gem "eco", "~> 1.0.0"
29
+ gem "erubis", "~> 2.7.0"
30
+
31
+ # Code Quality
32
+ gem "cane", :platforms => [:mri_19, :mri_20], :require => false
data/LICENSE.md ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2012-2013 Thomas Reynolds
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.
data/README.md ADDED
@@ -0,0 +1,104 @@
1
+ # Middleman-Sprockets
2
+
3
+ `middleman-sprockets` is an extension for the [Middleman] static site generator that allows support for [Sprockets](https://github.com/sstephenson/sprockets) in your assets.
4
+
5
+ ## Installation
6
+
7
+ If you're just getting started, install the `middleman` gem and generate a new project:
8
+
9
+ ```
10
+ gem install middleman
11
+ middleman init MY_PROJECT
12
+ ```
13
+
14
+ If you already have a Middleman project: Add `gem "middleman-sprockets"` to your `Gemfile` and run `bundle install`
15
+
16
+ ## Configuration
17
+ <a name="configuration"></a>
18
+
19
+ ```
20
+ activate :sprockets
21
+ ```
22
+
23
+ ## Usage
24
+
25
+ If you want to use, `middleman-sprockets` you need to configure it first - See
26
+ [Configuration](#configuration). If you want to use `middleman-sprockets` with
27
+ bower, you need to import assets first. The path is relative to your
28
+ `bower`-directory.
29
+
30
+ ```
31
+ sprockets.import_asset <path>
32
+ ```
33
+
34
+ Given `vendor/assets/components` as `bower`-directory and `jquery` as
35
+ component-name, you would import the `jquery` production version with:
36
+
37
+ ```
38
+ sprockets.append_path 'vendor/assets/components'
39
+ sprockets.import_asset 'jquery/dist/jquery'
40
+ ```
41
+
42
+ If you tell `sprockets` just about the name of the component, it will make thos
43
+ files available which are given in the `main`-section of the `bower.json`-file.
44
+
45
+ ```
46
+ sprockets.append_path 'vendor/assets/components'
47
+ sprockets.import_asset 'jquery'
48
+ ```
49
+
50
+ If you need to tell `sprockets` to use an individual output path for your
51
+ asset, you can pass `#import_asset` a block. This block gets the logical path
52
+ as
53
+ [`Pathname`](http://rdoc.info/stdlib/pathname/frames)
54
+ and needs to return the relative output path for the asset as `String` or
55
+ `Pathname`.
56
+
57
+ ```
58
+ sprockets.append_path 'vendor/assets/components'
59
+
60
+ # return logical path
61
+ sprockets.import_asset 'jquery/dist/jquery' do |logical_path|
62
+ # => prefix/jquery/dist/jquery
63
+ Pathname.new('prefix') + logical_path
64
+ end
65
+ ```
66
+
67
+ ## Build & Dependency Status
68
+
69
+ [![Gem Version](https://badge.fury.io/rb/middleman-sprockets.png)][gem]
70
+ [![Build Status](https://travis-ci.org/middleman/middleman-sprockets.png)][travis]
71
+ [![Dependency Status](https://gemnasium.com/middleman/middleman-sprockets.png?travis)][gemnasium]
72
+ [![Code Quality](https://codeclimate.com/github/middleman/middleman-sprockets.png)][codeclimate]
73
+
74
+ ## Community
75
+
76
+ The official community forum is available at: http://forum.middlemanapp.com
77
+
78
+ ## Bug Reports
79
+
80
+ Github Issues are used for managing bug reports and feature requests. If you run into issues, please search the issues and submit new problems: https://github.com/middleman/middleman-sprockets/issues
81
+
82
+ The best way to get quick responses to your issues and swift fixes to your bugs is to submit detailed bug reports, include test cases and respond to developer questions in a timely manner. Even better, if you know Ruby, you can submit [Pull Requests](https://help.github.com/articles/using-pull-requests) containing Cucumber Features which describe how your feature should work or exploit the bug you are submitting.
83
+
84
+ ## How to Run Cucumber Tests
85
+
86
+ 1. Checkout Repository: `git clone https://github.com/middleman/middleman-sprockets.git`
87
+ 2. Install Bundler: `gem install bundler`
88
+ 3. Run `bundle install` inside the project root to install the gem dependencies.
89
+ 4. Run test cases: `bundle exec rake test`
90
+
91
+ ## Donate
92
+
93
+ [Click here to lend your support to Middleman](https://spacebox.io/s/4dXbHBorC3)
94
+
95
+ ## License
96
+
97
+ Copyright (c) 2012-2014 Thomas Reynolds. MIT Licensed, see [LICENSE] for details.
98
+
99
+ [middleman]: http://middlemanapp.com
100
+ [gem]: https://rubygems.org/gems/middleman-sprockets
101
+ [travis]: http://travis-ci.org/middleman/middleman-sprockets
102
+ [gemnasium]: https://gemnasium.com/middleman/middleman-sprockets
103
+ [codeclimate]: https://codeclimate.com/github/middleman/middleman-sprockets
104
+ [LICENSE]: https://github.com/middleman/middleman-sprockets/blob/master/LICENSE.md
data/Rakefile ADDED
@@ -0,0 +1,45 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
3
+
4
+ require 'cucumber/rake/task'
5
+ require 'rspec/core/rake_task'
6
+
7
+ require 'middleman-core/version'
8
+
9
+ Cucumber::Rake::Task.new(:cucumber, 'Run features that should pass') do |t|
10
+ exempt_tags = ["--tags ~@wip"]
11
+ exempt_tags << "--tags ~@new " unless Middleman::VERSION.start_with?("3.1")
12
+ exempt_tags << "--tags ~@old " unless Middleman::VERSION.start_with?("3.0")
13
+ t.cucumber_opts = "--color #{exempt_tags.join(" ")} --strict --format #{ENV['CUCUMBER_FORMAT'] || 'Fivemat'}"
14
+ end
15
+
16
+ RSpec::Core::RakeTask.new(:spec)
17
+
18
+ require 'rake/clean'
19
+
20
+ task :test => [:destroy_sass_cache, "cucumber", "spec"]
21
+
22
+ desc "Build HTML documentation"
23
+ task :doc do
24
+ sh 'bundle exec yard'
25
+ end
26
+
27
+ begin
28
+ require 'cane/rake_task'
29
+
30
+ desc "Run cane to check quality metrics"
31
+ Cane::RakeTask.new(:quality) do |cane|
32
+ cane.no_style = true
33
+ cane.no_doc = true
34
+ cane.abc_glob = "lib/middleman-sprockets/**/*.rb"
35
+ end
36
+ rescue LoadError
37
+ # warn "cane not available, quality task not provided."
38
+ end
39
+
40
+ desc "Destroy the sass cache from fixtures in case it messes with results"
41
+ task :destroy_sass_cache do
42
+ Dir["fixtures/*/.sass-cache"].each do |dir|
43
+ rm_rf dir
44
+ end
45
+ end
@@ -0,0 +1,105 @@
1
+ @old
2
+ Feature: Assets get a file hash appended to their URL and references to them are updated
3
+ Scenario: Hashed-asset files are produced, and HTML, CSS, and JavaScript gets rewritten to reference the new files
4
+ Given a successfully built app at "asset-hash-app"
5
+ When I cd to "build"
6
+ Then the following files should exist:
7
+ | index.html |
8
+ | images/100px-1242c368.png |
9
+ | images/100px-5fd6fb90.jpg |
10
+ | images/100px-5fd6fb90.gif |
11
+ | javascripts/application-df677242.js |
12
+ | stylesheets/site-570b0b7d.css |
13
+ | index.html |
14
+ | subdir/index.html |
15
+ | other/index.html |
16
+ And the following files should not exist:
17
+ | images/100px.png |
18
+ | images/100px.jpg |
19
+ | images/100px.gif |
20
+ | javascripts/application.js |
21
+ | stylesheets/site.css |
22
+
23
+ And the file "javascripts/application-df677242.js" should contain "img.src = '/images/100px-5fd6fb90.jpg'"
24
+ And the file "stylesheets/site-570b0b7d.css" should contain 'background-image: url("../images/100px-5fd6fb90.jpg")'
25
+ And the file "index.html" should contain 'href="stylesheets/site-570b0b7d.css"'
26
+ And the file "index.html" should contain 'src="javascripts/application-df677242.js"'
27
+ And the file "index.html" should contain 'src="images/100px-5fd6fb90.jpg"'
28
+ And the file "subdir/index.html" should contain 'href="../stylesheets/site-570b0b7d.css"'
29
+ And the file "subdir/index.html" should contain 'src="../javascripts/application-df677242.js"'
30
+ And the file "subdir/index.html" should contain 'src="../images/100px-5fd6fb90.jpg"'
31
+ And the file "other/index.html" should contain 'href="../stylesheets/site-570b0b7d.css"'
32
+ And the file "other/index.html" should contain 'src="../javascripts/application-df677242.js"'
33
+ And the file "other/index.html" should contain 'src="../images/100px-5fd6fb90.jpg"'
34
+
35
+ Scenario: Hashed assets work in preview server
36
+ Given the Server is running at "asset-hash-app"
37
+ When I go to "/"
38
+ Then I should see 'href="stylesheets/site-570b0b7d.css"'
39
+ Then I should see 'href="stylesheets/jquery-mobile-044da59f.css"'
40
+ And I should see 'src="javascripts/application-df677242.js"'
41
+ And I should see 'src="images/100px-5fd6fb90.jpg"'
42
+ When I go to "/subdir/"
43
+ Then I should see 'href="../stylesheets/site-570b0b7d.css"'
44
+ And I should see 'src="../javascripts/application-df677242.js"'
45
+ And I should see 'src="../images/100px-5fd6fb90.jpg"'
46
+ When I go to "/other/"
47
+ Then I should see 'href="../stylesheets/site-570b0b7d.css"'
48
+ And I should see 'src="../javascripts/application-df677242.js"'
49
+ And I should see 'src="../images/100px-5fd6fb90.jpg"'
50
+ When I go to "/javascripts/application-df677242.js"
51
+ Then I should see "img.src = '/images/100px-5fd6fb90.jpg'"
52
+ When I go to "/stylesheets/site-570b0b7d.css"
53
+ Then I should see 'background-image: url("../images/100px-5fd6fb90.jpg")'
54
+ When I go to "/stylesheets/jquery-mobile-044da59f.css"
55
+ Then I should see 'background-image: url("../images/jquery-mobile/icons-18-white-1681b2cc.png")'
56
+
57
+ Scenario: Enabling an asset host still produces hashed files and references
58
+ Given the Server is running at "asset-hash-host-app"
59
+ When I go to "/"
60
+ Then I should see 'href="http://middlemanapp.com/stylesheets/site-72c69c91.css"'
61
+ And I should see 'src="http://middlemanapp.com/images/100px-5fd6fb90.jpg"'
62
+ When I go to "/subdir/"
63
+ Then I should see 'href="http://middlemanapp.com/stylesheets/site-72c69c91.css"'
64
+ And I should see 'src="http://middlemanapp.com/images/100px-5fd6fb90.jpg"'
65
+ When I go to "/other/"
66
+ Then I should see 'href="http://middlemanapp.com/stylesheets/site-72c69c91.css"'
67
+ And I should see 'src="http://middlemanapp.com/images/100px-5fd6fb90.jpg"'
68
+
69
+ Scenario: The asset hash should change when a SASS partial changes
70
+ Given the Server is running at "asset-hash-app"
71
+ And the file "source/stylesheets/_partial.sass" has the contents
72
+ """
73
+ body
74
+ font-size: 14px
75
+ """
76
+ When I go to "/partials/"
77
+ Then I should see 'href="../stylesheets/uses_partials-423a00f7.css'
78
+ And wait a second
79
+ And the file "source/stylesheets/_partial.sass" has the contents
80
+ """
81
+ body
82
+ font-size: 18px !important
83
+ """
84
+ When I go to "/partials/"
85
+ Then I should see 'href="../stylesheets/uses_partials-e8c3d4eb.css'
86
+
87
+ Scenario: The asset hash should change when a Javascript partial changes
88
+ Given the Server is running at "asset-hash-app"
89
+ And the file "source/javascripts/sprockets_sub.js" has the contents
90
+ """
91
+ function sprockets_sub_function() { }
92
+ """
93
+ When I go to "/partials/"
94
+ Then I should see 'src="../javascripts/sprockets_base-0252a861.js'
95
+ When I go to "/javascripts/sprockets_base-0252a861.js"
96
+ Then I should see "sprockets_sub_function"
97
+ And wait a second
98
+ And the file "source/javascripts/sprockets_sub.js" has the contents
99
+ """
100
+ function sprockets_sub2_function() { }
101
+ """
102
+ When I go to "/partials/"
103
+ Then I should see 'src="../javascripts/sprockets_base-5121d891.js'
104
+ When I go to "/javascripts/sprockets_base-5121d891.js"
105
+ Then I should see "sprockets_sub2_function"