middleman-sprockets 4.0.0.rc.1 → 4.0.0.rc.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (169) hide show
  1. checksums.yaml +4 -4
  2. data/.editorconfig +13 -0
  3. data/.gitignore +2 -0
  4. data/.rubocop.yml +57 -0
  5. data/.simplecov +1 -1
  6. data/.travis.yml +26 -15
  7. data/CHANGELOG.md +15 -0
  8. data/Gemfile +25 -21
  9. data/README.md +60 -6
  10. data/Rakefile +31 -11
  11. data/docs/upgrade-3-to-4.md +118 -0
  12. data/features/asset_gems.feature +63 -0
  13. data/features/basic_usage.feature +97 -0
  14. data/features/bower.feature +90 -30
  15. data/features/linked_assets.feature +123 -0
  16. data/features/middleman_helpers.feature +154 -0
  17. data/features/step_definitions/builder_steps.rb +8 -0
  18. data/features/step_definitions/server_steps.rb +20 -0
  19. data/features/support/env.rb +0 -1
  20. data/features/{asset_hash.feature → test_cases/asset_hash.feature} +28 -22
  21. data/features/test_cases/exception_response.feature +31 -0
  22. data/features/test_cases/excluded_file_extensions.feature +39 -0
  23. data/features/test_cases/file_not_found.feature +31 -0
  24. data/features/test_cases/ignore_directive_is_respected.feature +90 -0
  25. data/features/test_cases/imported_asset_extensions.feature +77 -0
  26. data/features/test_cases/jst.feature +36 -0
  27. data/features/test_cases/long_filenames.feature +40 -0
  28. data/features/test_cases/path_helpers.feature +106 -0
  29. data/features/test_cases/processible_outside_asset_dir.feature +49 -0
  30. data/features/test_cases/sass_globs.feature +76 -0
  31. data/features/test_cases/sass_partials.feature +49 -0
  32. data/features/test_cases/sassc.feature +27 -0
  33. data/features/test_cases/use_from_templates.feature +21 -0
  34. data/features/test_cases/using_assets_gem_assets.feature +88 -0
  35. data/fixtures/asset-hash-app/config.rb +2 -0
  36. data/fixtures/asset-hash-app/source/stylesheets/jquery-mobile.css.scss +1 -0
  37. data/fixtures/asset-hash-host-app/config.rb +4 -4
  38. data/fixtures/base-app/config.rb +1 -0
  39. data/fixtures/{bower-multiple-assets-app/source/index.html → base-app/source/index.html.erb} +0 -0
  40. data/fixtures/gems/assets_gem/assets_gem.gemspec +16 -0
  41. data/fixtures/gems/assets_gem/lib/assets_gem.rb +7 -0
  42. data/fixtures/gems/assets_gem/vendor/assets/css/_imports/_import.scss +1 -0
  43. data/fixtures/{sprockets-imported-assets-match-multiple-paths-app/vendor/assets/css/test.css → gems/assets_gem/vendor/assets/css/test.scss} +1 -1
  44. data/fixtures/gems/assets_gem/vendor/assets/fonts/font.ttf +0 -0
  45. data/fixtures/gems/assets_gem/vendor/assets/images/logo.png +0 -0
  46. data/fixtures/gems/assets_gem/vendor/assets/javascripts/_imports/import.js +1 -0
  47. data/gemfiles/middleman-4.0.gemfile +7 -0
  48. data/gemfiles/middleman-4.1.gemfile +7 -0
  49. data/gemfiles/middleman-head.gemfile +7 -0
  50. data/gemfiles/sprockets-4.0.gemfile +6 -0
  51. data/lib/middleman-sprockets.rb +5 -5
  52. data/lib/middleman-sprockets/extension.rb +174 -215
  53. data/lib/middleman-sprockets/interface.rb +64 -0
  54. data/lib/middleman-sprockets/resource.rb +97 -0
  55. data/lib/middleman-sprockets/version.rb +1 -1
  56. data/middleman-sprockets.gemspec +16 -15
  57. data/tasks/matrix.rake +46 -0
  58. metadata +77 -237
  59. data/features/jst.feature +0 -14
  60. data/features/long_filenames.feature +0 -17
  61. data/features/sass_globs.feature +0 -9
  62. data/features/sass_partials.feature +0 -36
  63. data/features/sprockets.feature +0 -108
  64. data/features/sprockets_gems.feature +0 -48
  65. data/fixtures/asset-paths-app/config.rb +0 -1
  66. data/fixtures/asset-paths-app/derp/javascripts/vendored_js.js +0 -1
  67. data/fixtures/asset-paths-app/source/javascripts/vendored_include.js +0 -1
  68. data/fixtures/bower-app/bower.json +0 -7
  69. data/fixtures/bower-app/bower_components/underscore/bower.json +0 -8
  70. data/fixtures/bower-app/bower_components/underscore/underscore.js +0 -1343
  71. data/fixtures/bower-app/config.rb +0 -1
  72. data/fixtures/bower-app/source/javascripts/application.js +0 -1
  73. data/fixtures/bower-app/source/javascripts/import.js +0 -1
  74. data/fixtures/bower-individual-outputdir-app/bower.json +0 -7
  75. data/fixtures/bower-individual-outputdir-app/bower_components/underscore/bower.json +0 -8
  76. data/fixtures/bower-individual-outputdir-app/bower_components/underscore/underscore.js +0 -1343
  77. data/fixtures/bower-individual-outputdir-app/config.rb +0 -2
  78. data/fixtures/bower-individual-outputdir-app/source/javascripts/application.js +0 -4
  79. data/fixtures/bower-individual-outputdir-app/vendor/assets/components/lightbox2/.bower.json +0 -34
  80. data/fixtures/bower-individual-outputdir-app/vendor/assets/components/lightbox2/bower.json +0 -26
  81. data/fixtures/bower-individual-outputdir-app/vendor/assets/components/lightbox2/img/close.png +0 -0
  82. data/fixtures/bower-individual-outputdir-app/vendor/assets/components/lightbox2/js/lightbox.js +0 -2
  83. data/fixtures/bower-individual-outputdir-app/vendor/assets/components/lightbox2/package.json +0 -37
  84. data/fixtures/bower-json-app/config.rb +0 -1
  85. data/fixtures/bower-json-app/source/javascripts/application.js.coffee +0 -1
  86. data/fixtures/bower-json-app/source/javascripts/bower.json +0 -5
  87. data/fixtures/bower-multiple-assets-app/.bowerrc +0 -4
  88. data/fixtures/bower-multiple-assets-app/bower.json +0 -7
  89. data/fixtures/bower-multiple-assets-app/config.rb +0 -1
  90. data/fixtures/bower-multiple-assets-app/source/javascripts/core.js +0 -2
  91. data/fixtures/bower-multiple-assets-app/vendor/assets/components/lightbox2/.bower.json +0 -34
  92. data/fixtures/bower-multiple-assets-app/vendor/assets/components/lightbox2/bower.json +0 -26
  93. data/fixtures/bower-multiple-assets-app/vendor/assets/components/lightbox2/img/close.png +0 -0
  94. data/fixtures/bower-multiple-assets-app/vendor/assets/components/lightbox2/img/open.png +0 -0
  95. data/fixtures/bower-multiple-assets-app/vendor/assets/components/lightbox2/js/lightbox.js +0 -2
  96. data/fixtures/bower-multiple-assets-app/vendor/assets/components/lightbox2/package.json +0 -37
  97. data/fixtures/glob-app/config.rb +0 -0
  98. data/fixtures/glob-app/source/stylesheets/main.css.scss +0 -1
  99. data/fixtures/glob-app/source/stylesheets/module1/_i-am-mod.scss +0 -3
  100. data/fixtures/glob-app/source/stylesheets/module2/_derp.sass +0 -2
  101. data/fixtures/glob-app/source/stylesheets/shared/3rd-party/bootstrap.sass +0 -2
  102. data/fixtures/glob-app/source/stylesheets/shared/shared.scss +0 -3
  103. data/fixtures/jquery-mobile-app/config.rb +0 -0
  104. data/fixtures/jquery-mobile-app/source/javascripts/app.js +0 -1
  105. data/fixtures/jquery-mobile-app/source/stylesheets/base.css.scss +0 -2
  106. data/fixtures/long-filenames-app/config.rb +0 -0
  107. data/fixtures/long-filenames-app/source/images/00000000-0000-0000-0000-000000.svg +0 -3
  108. data/fixtures/long-filenames-app/source/images/00000000-0000-0000-0000-0000001.svg +0 -3
  109. data/fixtures/preview-app/config.rb +0 -0
  110. data/fixtures/preview-app/source/content.html.erb +0 -1
  111. data/fixtures/preview-app/source/layout.erb +0 -1
  112. data/fixtures/preview-app/source/stylesheets/_partial.sass +0 -2
  113. data/fixtures/preview-app/source/stylesheets/_partial2.css.sass +0 -2
  114. data/fixtures/preview-app/source/stylesheets/main.css.sass +0 -4
  115. data/fixtures/preview-app/source/stylesheets/main2.css.sass +0 -4
  116. data/fixtures/preview-app/source/stylesheets/plain.css.sass +0 -2
  117. data/fixtures/sprockets-app/config.rb +0 -2
  118. data/fixtures/sprockets-app/source/index.html.erb +0 -6
  119. data/fixtures/sprockets-app/source/library/css/bootstrap_include.css.scss +0 -1
  120. data/fixtures/sprockets-app/source/library/css/plain.css +0 -5
  121. data/fixtures/sprockets-app/source/library/css/sprockets_base1.css.scss +0 -1
  122. data/fixtures/sprockets-app/source/library/css/sprockets_base2.css.scss +0 -1
  123. data/fixtures/sprockets-app/source/library/css/sprockets_sub.css.scss +0 -1
  124. data/fixtures/sprockets-app/source/library/js/jquery_include.js +0 -1
  125. data/fixtures/sprockets-app/source/library/js/plain.js +0 -6
  126. data/fixtures/sprockets-app/source/library/js/sprockets_base.js +0 -5
  127. data/fixtures/sprockets-app/source/library/js/sprockets_sub.js +0 -3
  128. data/fixtures/sprockets-app/source/library/js/vendored_include.js +0 -1
  129. data/fixtures/sprockets-app/vendor/assets/javascripts/coffee.js.coffee +0 -2
  130. data/fixtures/sprockets-app/vendor/assets/javascripts/vendored_js.js +0 -1
  131. data/fixtures/sprockets-app/vendor/assets/stylesheets/vendored.css.scss +0 -4
  132. data/fixtures/sprockets-app2/config.rb +0 -0
  133. data/fixtures/sprockets-app2/data/test.yml +0 -4
  134. data/fixtures/sprockets-app2/data/test2.json +0 -4
  135. data/fixtures/sprockets-app2/source/javascripts/_templates/test.jst.ejs +0 -1
  136. data/fixtures/sprockets-app2/source/javascripts/_templates/test2.jst.eco +0 -1
  137. data/fixtures/sprockets-app2/source/javascripts/asset_path.js.erb +0 -3
  138. data/fixtures/sprockets-app2/source/javascripts/multiple_engines.js.coffee.erb +0 -1
  139. data/fixtures/sprockets-app2/source/javascripts/sprockets_base.js +0 -5
  140. data/fixtures/sprockets-app2/source/javascripts/sprockets_sub.js +0 -3
  141. data/fixtures/sprockets-app2/source/javascripts/templates.js +0 -1
  142. data/fixtures/sprockets-app2/source/stylesheets/sprockets_base1.css.scss +0 -1
  143. data/fixtures/sprockets-app2/source/stylesheets/sprockets_base2.css.scss +0 -1
  144. data/fixtures/sprockets-app2/source/stylesheets/sprockets_sub.css.scss +0 -1
  145. data/fixtures/sprockets-images-app/config.rb +0 -1
  146. data/fixtures/sprockets-images-app/source/index.html.erb +0 -10
  147. data/fixtures/sprockets-images-app/source/library/images/cat.jpg +0 -0
  148. data/fixtures/sprockets-images-app/vendor/assets/images/cat-2.jpg +0 -0
  149. data/fixtures/sprockets-imported-asset-path-conflicts-app/config.rb +0 -4
  150. data/fixtures/sprockets-imported-asset-path-conflicts-app/resources/assets/stylesheets/test.css +0 -3
  151. data/fixtures/sprockets-imported-assets-match-multiple-paths-app/config.rb +0 -4
  152. data/fixtures/sprockets-multiple-extensions-app/bower.json +0 -8
  153. data/fixtures/sprockets-multiple-extensions-app/config.rb +0 -1
  154. data/fixtures/sprockets-multiple-extensions-app/source/fonts/fontawesome-webfont-source.svg.gz +0 -0
  155. data/fixtures/sprockets-multiple-extensions-app/source/images/drawing-source.svg +0 -76
  156. data/fixtures/sprockets-multiple-extensions-app/source/stylesheets/app.css.scss +0 -3
  157. data/fixtures/sprockets-multiple-extensions-app/vendor/assets/components/font-awesome/fonts/fontawesome-webfont-bower.svg.gz +0 -0
  158. data/fixtures/sprockets-multiple-extensions-app/vendor/assets/components/jquery/jquery.asdf.asdf.js.min.asdf +0 -4
  159. data/fixtures/sprockets-multiple-extensions-app/vendor/assets/components/jquery/jquery.min.js +0 -4
  160. data/fixtures/sprockets-svg-font-app/bower.json +0 -8
  161. data/fixtures/sprockets-svg-font-app/config.rb +0 -1
  162. data/fixtures/sprockets-svg-font-app/source/fonts/fontawesome-webfont-source.svg +0 -504
  163. data/fixtures/sprockets-svg-font-app/source/fonts/fontawesome-webfont-source.svg.gz +0 -0
  164. data/fixtures/sprockets-svg-font-app/source/images/drawing-source.svg +0 -76
  165. data/fixtures/sprockets-svg-font-app/source/stylesheets/app.css.scss +0 -4
  166. data/fixtures/sprockets-svg-font-app/vendor/assets/components/blub/images/drawing-bower.svg +0 -76
  167. data/fixtures/sprockets-svg-font-app/vendor/assets/components/font-awesome/fonts/fontawesome-webfont-bower.svg +0 -504
  168. data/fixtures/sprockets-svg-font-app/vendor/assets/components/font-awesome/fonts/fontawesome-webfont-bower.svg.gz +0 -0
  169. data/fixtures/sprockets-svg-font-app/vendor/assets/components/font-awesome/fonts/fontawesome-webfont-bower.ttf.gz +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 29e65d83fd264d3f669643e448e574c58bdb9094
4
- data.tar.gz: b4e9eb5247e49d154ffb882a4e35a09a6f06062f
3
+ metadata.gz: f1b6566a77765245f48a875bab984183266a5b33
4
+ data.tar.gz: 9554a8e748dd6b8df43f2866340bf755063525c9
5
5
  SHA512:
6
- metadata.gz: 5ffc84a66db9426edab185bc9d2058545e9c76214ce2b6f4ff9cdd5bd47ba86a7f2130d36e09ee0b1ae859f020081bc7f7c3e9ec274811db0a19790c4985c5ba
7
- data.tar.gz: bcc58588ae01b813edf13e9290949a16c50b664ce8689b2f91b5a4170bafc1f0f56c1461f6cd6d54a9e07030833a8cb9ce7e43e74242b1f78c5a6e544bfe046c
6
+ metadata.gz: 78525a45da92cb3f549b564f10be63a3ef9f839eba7104f31acbc5cdc3737e16d2bb11b15e4b397d7051c526c33d6979f50e1544004031203c3179c631bd22db
7
+ data.tar.gz: a4080d4ee9f99792c966516f2c76461699ca44b37cca3466d32620c7d2bd778fb791a052844b37ff77dbb59cbf73a83debfee6e096d2837f2a8a1bde494bd813
@@ -0,0 +1,13 @@
1
+ # editorconfig.org
2
+ root = true
3
+
4
+ [*]
5
+ indent_style = space
6
+ indent_size = 2
7
+ end_of_line = lf
8
+ charset = utf-8
9
+ trim_trailing_whitespace = true
10
+ insert_final_newline = true
11
+
12
+ [*.md]
13
+ trim_trailing_whitespace = false
data/.gitignore CHANGED
@@ -8,4 +8,6 @@ tmp
8
8
  pkg
9
9
  build
10
10
  .ruby-version
11
+ .ruby-gemset
11
12
  .cache
13
+ gemfiles/*.lock
@@ -0,0 +1,57 @@
1
+ AllCops:
2
+ DisplayCopNames: true
3
+
4
+
5
+ # Style ------------------------------------
6
+
7
+ Style/FileName:
8
+ Exclude:
9
+ - lib/middleman-sprockets.rb
10
+
11
+ Style/MultilineOperationIndentation:
12
+ EnforcedStyle: aligned
13
+
14
+ Style/MultilineMethodCallIndentation:
15
+ EnforcedStyle: aligned
16
+
17
+ Style/MethodDefParentheses:
18
+ EnforcedStyle: require_no_parentheses_except_multiline
19
+
20
+ Style/SpaceAroundEqualsInParameterDefault:
21
+ EnforcedStyle: no_space
22
+
23
+ Style/IndentationConsistency:
24
+ EnforcedStyle: rails
25
+
26
+ Style/MultilineOperationIndentation:
27
+ Enabled: false
28
+
29
+ Style/Documentation:
30
+ Enabled: false
31
+
32
+ Style/EmptyLinesAroundClassBody:
33
+ Enabled: false
34
+
35
+ Style/RegexpLiteral:
36
+ Enabled: false
37
+
38
+ Style/SignalException:
39
+ Enabled: false
40
+
41
+
42
+ # Metrics ----------------------------------
43
+
44
+ Metrics/LineLength:
45
+ Max: 128
46
+
47
+ Metrics/AbcSize:
48
+ Enabled: false
49
+
50
+ Metrics/MethodLength:
51
+ Enabled: false
52
+
53
+
54
+ # Lint -------------------------------------
55
+
56
+ Lint/EndAlignment:
57
+ AlignWith: variable
data/.simplecov CHANGED
@@ -4,6 +4,6 @@ SimpleCov.start do
4
4
  add_filter "/spec/"
5
5
  add_filter "/tmp"
6
6
  add_filter "/vendor"
7
-
7
+
8
8
  add_group "lib", "lib"
9
9
  end
@@ -1,23 +1,34 @@
1
+ language: ruby
2
+ cache: bundler
3
+ sudo: false
4
+ env: TEST=true
5
+
1
6
  rvm:
7
+ - 2.0.0
8
+ - 2.1
9
+ - 2.2
10
+ - 2.3.0
2
11
  - ruby-head
3
- - jruby-head
4
12
  - jruby-19mode
5
- - 2.2.2
6
- - 2.1
7
- - 2.0
8
- os:
9
- - linux
10
- - osx
11
- sudo: false
13
+ - jruby-head
14
+
15
+ gemfile:
16
+ - gemfiles/middleman-4.1.gemfile
17
+
12
18
  matrix:
13
- fast_finish: true
19
+ include:
20
+ - rvm: 2.2
21
+ gemfile: gemfiles/middleman-head.gemfile
22
+ - rvm: 2.2
23
+ gemfile: gemfiles/middleman-4.0.gemfile
24
+ env: SKIP_ASSET_HASH=true
25
+ - rvm: 2.2
26
+ gemfile: gemfiles/sprockets-4.0.gemfile
27
+ env: SKIP_ASSET_HASH=true
28
+
14
29
  allow_failures:
15
30
  - rvm: ruby-head
16
31
  - rvm: jruby-19mode
17
32
  - rvm: jruby-head
18
- gemfile:
19
- - Gemfile
20
-
21
- script: "bundle exec rake test"
22
-
23
- env: TEST=true
33
+ - rvm: 2.2
34
+ gemfile: gemfiles/sprockets-4.0.gemfile
@@ -1,3 +1,18 @@
1
+ 4.0.0
2
+ =====
3
+
4
+ This is a major rewrite focussed on adding support for Sprockets 3+ & Middleman 4+. With this come a lot of changes, please read the [upgrade guide](docs/upgrade-3-to-4.md) for more information:
5
+
6
+ **tl;dr;**
7
+
8
+ * Requires Middleman 4.0+ & Sprockets 3.0+
9
+ * Remove auto-activation
10
+ * Remove the `import_asset` helper, assets should be linked via a manifest file
11
+ * Remove "automagical" asset placement, linked assets all go in the `imported_asset_path` option
12
+ * Add option to expose middleman helpers to sprockets assets
13
+ * Add compatability for SassC if using Sprockets 4+
14
+
15
+
1
16
  3.4.2
2
17
  ===
3
18
 
data/Gemfile CHANGED
@@ -1,36 +1,40 @@
1
- source "https://rubygems.org"
1
+ source 'https://rubygems.org'
2
2
 
3
- # Specify your gem's dependencies in middleman-sprockets.gemspec
4
3
  gemspec
5
4
 
6
- gem "middleman-cli", github: "middleman/middleman", branch: "master"
7
- gem "middleman-core", github: "middleman/middleman", branch: "master"
5
+ gem 'middleman'
8
6
 
9
7
  # Build and doc tools
10
- gem 'rake', '~> 10.3', require: false
11
- gem 'yard', '~> 0.8', require: false
8
+ gem 'rake', '~> 10.3', require: false
9
+ gem 'yard', '~> 0.8', require: false
12
10
 
13
11
  # Test tools
14
- gem 'pry', '~> 0.10', group: :development, require: false
15
12
  gem 'pry-byebug'
16
- gem 'aruba', '~> 0.7.4', require: false
17
- gem 'rspec', '~> 3.0', require: false
18
- gem 'cucumber', '~> 2.0', require: false
13
+ gem 'aruba', '~> 0.7.4', require: false
14
+ gem 'rspec', '~> 3.0', require: false
15
+ gem 'cucumber', '~> 2.0', require: false
19
16
 
20
17
  # For actual tests
21
18
  # Make sure to lock down the versions of the asset gems
22
19
  # so they don't cause asset hashes to change.
23
- gem "railties", "~> 4.2.0"
24
- gem "jquery-rails", "3.1.0", :require => false
25
- gem "bootstrap-sass", "3.1.1.0", :require => false
26
- gem "jquery_mobile_rails", "1.4.1", :require => false
20
+ gem 'railties', '~> 4.2.0'
21
+ gem 'jquery-rails', '3.1.0', require: false
22
+ gem 'bootstrap-sass', '3.1.1.0', require: false
23
+ gem 'jquery_mobile_rails', '1.4.1', require: false
24
+ gem 'sass-globbing', '1.1.1', require: false
25
+ gem 'assets_gem', path: 'fixtures/gems/assets_gem',
26
+ require: false
27
27
 
28
- gem "ejs", "~> 1.1.1"
29
- gem "eco", "~> 1.0.0"
30
- gem "erubis", "~> 2.7.0"
28
+ gem 'ejs', '~> 1.1.1'
29
+ gem 'eco', '~> 1.0.0'
30
+ gem 'erubis', '~> 2.7.0'
31
+ gem 'haml', '~> 4.0', require: false
32
+ gem 'sassc', require: false
31
33
 
32
34
  # Code Quality
33
- gem 'rubocop', '~> 0.24', require: false
34
- gem 'simplecov', '~> 0.9', require: false
35
- gem 'coveralls', '~> 0.8', require: false
36
- gem 'codeclimate-test-reporter', '~> 0.3', require: false, group: :test
35
+ group :test do
36
+ gem 'rubocop', '~> 0.37.2', require: false
37
+ gem 'simplecov', '~> 0.9', require: false
38
+ gem 'coveralls', '~> 0.8', require: false
39
+ gem 'codeclimate-test-reporter', '~> 0.3', require: false
40
+ end
data/README.md CHANGED
@@ -1,7 +1,12 @@
1
+ > The master branch is for a pre-released 4.x version of Middleman-Sprockets.
2
+ > - For upgrading help please [read the upgrading guide](docs/upgrade-3-to-4.md)
3
+ > - For 3.x stable usage please see the [`v3-stable-real` branch](https://github.com/middleman/middleman-sprockets/tree/v3-stable-real)
4
+
1
5
  # Middleman-Sprockets
2
6
 
3
7
  `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
8
 
9
+
5
10
  ## Installation
6
11
 
7
12
  If you're just getting started, install the `middleman` gem and generate a new project:
@@ -11,25 +16,72 @@ gem install middleman
11
16
  middleman init MY_PROJECT
12
17
  ```
13
18
 
14
- If you already have a Middleman project: Add `gem "middleman-sprockets"` to your `Gemfile` and run `bundle install`
19
+ Then add `gem "middleman-sprockets"` to your `Gemfile` and run `bundle install`
20
+
21
+ To activate the extension, in your `config.rb` add:
22
+
23
+ ```ruby
24
+ activate :sprockets
25
+ ```
26
+
27
+ ### Usage
28
+
29
+ - [Basic Usage](features/basic_usage.feature)
30
+ - [With Asset Gems](features/asset_gems.feature)
31
+ - [With Bower](features/bower.feature)
32
+ - [Linked Assets](features/linked_assets.feature)
33
+ - [Helpers](features/middleman_helpers.feature)
34
+
35
+ ### Configuration
36
+
37
+ There are currently two options for configuration, `imported_asset_path` and `expose_middleman_helpers`.
38
+
39
+ **`imported_asset_path` [default: 'assets']**
40
+
41
+ This is the path imported/linked assets will be added to the sitemap. For example, in the bower fixture app, the `/javascripts/core.js` file has `//= link "lightbox2/img/close.png"`. This linked asset will be added to the sitemap at `/assets/lightbox2/img/close.png`.
42
+
43
+ To configure, in `config.rb`:
44
+
45
+ ```ruby
46
+ activate :sprockets do |c|
47
+ c.imported_asset_path = YOUR_PATH
48
+ end
49
+ ```
50
+
51
+
52
+ **`expose_middleman_helpers` [default: false]**
53
+
54
+ Sometimes you might need sprockets to have access helpers (for example using different keys depending on deployment environment). Getting this to happen is bound to be full of edge cases, so for now it's behind a configuration option.
55
+
56
+ If you need [Middleman helpers in your Sprockets](http://i.imgur.com/fINMSsz.jpg), in `config.rb`:
57
+
58
+ ```ruby
59
+ activate :sprockets do |c|
60
+ c.expose_middleman_helpers = true
61
+ end
62
+ ```
63
+
15
64
 
16
65
  ## Build & Dependency Status
17
66
 
18
- [![Gem Version](https://badge.fury.io/rb/middleman-sprockets.png)][gem]
19
- [![Build Status](https://travis-ci.org/middleman/middleman-sprockets.png)][travis]
20
- [![Dependency Status](https://gemnasium.com/middleman/middleman-sprockets.png?travis)][gemnasium]
21
- [![Code Quality](https://codeclimate.com/github/middleman/middleman-sprockets.png)][codeclimate]
67
+ [![Gem Version](https://badge.fury.io/rb/middleman-sprockets.svg)][gem]
68
+ [![Build Status](https://travis-ci.org/middleman/middleman-sprockets.svg)][travis]
69
+ [![Dependency Status](https://gemnasium.com/middleman/middleman-sprockets.svg?travis)][gemnasium]
70
+ [![Code Quality](https://codeclimate.com/github/middleman/middleman-sprockets.svg)][codeclimate]
71
+
22
72
 
23
73
  ## Community
24
74
 
25
75
  The official community forum is available at: http://forum.middlemanapp.com
26
76
 
77
+
27
78
  ## Bug Reports
28
79
 
29
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
30
81
 
31
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.
32
83
 
84
+
33
85
  ## How to Run Cucumber Tests
34
86
 
35
87
  1. Checkout Repository: `git clone https://github.com/middleman/middleman-sprockets.git`
@@ -37,13 +89,15 @@ The best way to get quick responses to your issues and swift fixes to your bugs
37
89
  3. Run `bundle install` inside the project root to install the gem dependencies.
38
90
  4. Run test cases: `bundle exec rake test`
39
91
 
92
+
40
93
  ## Donate
41
94
 
42
95
  [Click here to lend your support to Middleman](https://spacebox.io/s/4dXbHBorC3)
43
96
 
97
+
44
98
  ## License
45
99
 
46
- Copyright (c) 2012-2014 Thomas Reynolds. MIT Licensed, see [LICENSE] for details.
100
+ Copyright (c) 2012-2016 Thomas Reynolds. MIT Licensed, see [LICENSE] for details.
47
101
 
48
102
  [middleman]: http://middlemanapp.com
49
103
  [gem]: https://rubygems.org/gems/middleman-sprockets
data/Rakefile CHANGED
@@ -1,34 +1,54 @@
1
1
  require 'bundler'
2
2
  Bundler::GemHelper.install_tasks
3
3
 
4
+ require 'rake/clean'
4
5
  require 'cucumber/rake/task'
5
6
  require 'rspec/core/rake_task'
7
+ require 'rubocop/rake_task'
6
8
 
7
9
  require 'middleman-core/version'
10
+ require 'sprockets/version'
11
+
12
+ Dir['./tasks/*.rake'].each { |f| load f }
8
13
 
9
14
  Cucumber::Rake::Task.new(:cucumber, 'Run features that should pass') do |t|
10
- exempt_tags = ["--tags ~@wip"]
11
- t.cucumber_opts = "--color #{exempt_tags.join(" ")} --strict"
12
- end
15
+ exempt_tags = ['--tags ~@wip']
13
16
 
14
- RSpec::Core::RakeTask.new(:spec) do |t|
15
- if RUBY_VERSION < '2.0'
16
- t.rspec_opts = '--tag ~@skip:one-nine'
17
+ if ::Sprockets::VERSION >= '4.0'
18
+ exempt_tags.push '--tags ~@sprockets3'
19
+ else
20
+ exempt_tags.push '--tags ~@sprockets4'
17
21
  end
22
+
23
+ exempt_tags.push '--tags ~@asset_hash' if ENV['SKIP_ASSET_HASH'] == 'true'
24
+ t.cucumber_opts = "--color #{exempt_tags.join(' ')} --strict"
18
25
  end
19
26
 
20
- require 'rake/clean'
27
+ RSpec::Core::RakeTask.new(:spec)
28
+
29
+ desc 'Run RuboCop on the lib & spec directory'
30
+ RuboCop::RakeTask.new(:rubocop) do |task|
31
+ task.patterns = ['lib/**/*.rb',
32
+ 'spec/**/*.rb',
33
+ 'Gemfile',
34
+ 'Rakefile']
35
+ task.fail_on_error = false
36
+ end
37
+
38
+ task test: [:destroy_sass_cache, :rubocop, :cucumber, :spec]
39
+ task default: :test
21
40
 
22
- task :test => [:destroy_sass_cache, "cucumber", "spec"]
41
+ ## removal candidates
42
+ ## ------------------------------------
23
43
 
24
- desc "Build HTML documentation"
44
+ desc 'Build HTML documentation'
25
45
  task :doc do
26
46
  sh 'bundle exec yard'
27
47
  end
28
48
 
29
- desc "Destroy the sass cache from fixtures in case it messes with results"
49
+ desc 'Destroy the sass cache from fixtures in case it messes with results'
30
50
  task :destroy_sass_cache do
31
- Dir["fixtures/*/.sass-cache"].each do |dir|
51
+ Dir['fixtures/*/.sass-cache'].each do |dir|
32
52
  rm_rf dir
33
53
  end
34
54
  end
@@ -0,0 +1,118 @@
1
+ Version 4 represents a major rewrite of Middleman-Sprockets to maintain support for Middleman 4+ & gain support of Sprockets 3+. With this come a lot of changes, some you'll make in your code and others in your expectations.
2
+
3
+
4
+ ## Activation
5
+
6
+ The biggest change to start with is the removal of auto-activation. Since some configuration options have been added, this makes configuring them follow the norm for other extensions. To activate, in your `config.rb`:
7
+
8
+ ```ruby
9
+ activate :sprockets
10
+ ```
11
+
12
+ After activation you can still access the sprockets environment to append paths
13
+
14
+ ```ruby
15
+ activate :sprockets
16
+ sprockets.append_path File.join(root, 'bower_components')
17
+ ```
18
+
19
+
20
+ ## Importing Assets
21
+
22
+ For adding assets from a gem or bower you may have been used to using `sprockets.import_asset ASSET_PATH` and having it added to the sitemap based on it's type. The process for this is considerably different now.
23
+
24
+ First, the `#import_asset` method has been removed, instead you should add a [link directive](https://github.com/rails/sprockets#the-link-directive) to reference the file you want imported. To follow along with the rails convension and import files that aren't necessarily linked from other assets -- add a manifest file. For example lets say we want to import fonts from [Font-Awesome](https://github.com/FortAwesome/Font-Awesome).
25
+
26
+ Assuming Font-Awesome has been installed with bower:
27
+
28
+ ```ruby
29
+ # config.rb
30
+ activate :sprockets
31
+ sprockets.append_path File.join(root, 'bower_components')
32
+ ```
33
+
34
+ ```javascript
35
+ // source/javascripts/manifest.js
36
+ //
37
+ //= link font-awesome-webfont.eot
38
+ //= link font-awesome-webfont.svg
39
+ //= link font-awesome-webfont.ttf
40
+ //= link font-awesome-webfont.wof
41
+ //= link font-awesome-webfont.wof2
42
+ ```
43
+
44
+ This will import the fonts into the sitemap under the configured `imported_asset_path`. So on build it would look like:
45
+
46
+ ```
47
+ build/
48
+ +-- assets/
49
+ +-- font-awesome-webfont.eot
50
+ +-- font-awesome-webfont.svg
51
+ +-- font-awesome-webfont.ttf
52
+ +-- font-awesome-webfont.wof
53
+ +-- font-awesome-webfont.wof2
54
+ ```
55
+
56
+ You may have noticed that second difference from 3.x -- the fonts weren't placed into `:font_dir`. Instead of trying to determine file type & using that path -- with 4.x all imported assets are placed under the `imported_asset_path`.
57
+
58
+ This path defaults to `assets` and is configurable:
59
+
60
+ ```ruby
61
+ # config.rb
62
+ activate :sprockets do |c|
63
+ c.imported_asset_path = 'imported'
64
+ end
65
+ sprockets.append_path File.join(root, 'bower_components')
66
+ ```
67
+
68
+ ```javascripts
69
+ // source/javascripts/manifest.js
70
+ //
71
+ //= link font-awesome-webfont.eot
72
+ ```
73
+
74
+ ```
75
+ build/
76
+ +-- imported/
77
+ +-- font-awesome-webfont.eot
78
+ ```
79
+
80
+
81
+ In addition to importing assets through link directives, assets can also be linked via any of the path helper methods. Again, looking at font-awesome instead of using a manifest file -- lets link it directly from our css that will use it:
82
+
83
+ ```css
84
+ /* source/stylesheets/fonts.css.scss */
85
+
86
+ @font-face {
87
+ font-family: "Font Awesome";
88
+ src: font-url('font-awesome-webfont.eot');
89
+ }
90
+ ```
91
+
92
+ ```
93
+ build/
94
+ +-- assets/
95
+ +-- font-awesome-webfont.eot
96
+ ```
97
+
98
+ Check out the [feature test](../features/linked_assets.feature) for more specifics.
99
+
100
+
101
+ ## Middleman Helpers
102
+
103
+ Helpers are no longer included in the sprockets rendering context by default. To expose them, configure `expose_middleman_helpers` to true:
104
+
105
+ ```ruby
106
+ # config.rb
107
+ activate :sprockets do |c|
108
+ c.expose_middleman_helpers = true
109
+ end
110
+ ```
111
+
112
+
113
+ ## Less Support
114
+
115
+ With 3.x Sprockets has [dropped support for Less](https://github.com/sstephenson/sprockets/pull/547), so be aware that your `.less` files are handled by Middleman directly. As a concequence, sprockets directives or importing of assets won't work.
116
+
117
+
118
+ > Run into an issue or think something is missing? [Let us know](https://github.com/middleman/middleman-sprockets/issues/new) or submit a pull request to help us improve.