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

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +2 -3
  3. data/Gemfile +15 -16
  4. data/README.md +0 -58
  5. data/Rakefile +1 -16
  6. data/features/asset_hash.feature +5 -6
  7. data/features/bower.feature +6 -6
  8. data/features/sprockets.feature +13 -65
  9. data/features/sprockets_gems.feature +7 -26
  10. data/features/step_definitions/server_steps.rb +0 -4
  11. data/fixtures/asset-paths-app/config.rb +1 -4
  12. data/fixtures/bower-app/config.rb +0 -2
  13. data/fixtures/bower-app/source/javascripts/application.js +1 -1
  14. data/fixtures/bower-app/source/javascripts/import.js +1 -0
  15. data/fixtures/bower-individual-outputdir-app/config.rb +0 -4
  16. data/fixtures/bower-individual-outputdir-app/source/javascripts/application.js +3 -0
  17. data/fixtures/bower-multiple-assets-app/config.rb +1 -7
  18. data/fixtures/{sprockets-app-debug-assets/source/stylesheets/dependency1.css → bower-multiple-assets-app/source/index.html} +0 -0
  19. data/fixtures/bower-multiple-assets-app/source/javascripts/core.js +2 -0
  20. data/fixtures/jquery-mobile-app/source/javascripts/app.js +1 -0
  21. data/fixtures/sprockets-app/config.rb +0 -5
  22. data/fixtures/sprockets-app/source/library/css/bootstrap_include.css.scss +1 -1
  23. data/fixtures/sprockets-app/source/library/css/plain.css +2 -0
  24. data/fixtures/sprockets-app/source/library/css/sprockets_base2.css.scss +1 -1
  25. data/fixtures/sprockets-app/source/library/js/jquery_include.js +1 -1
  26. data/fixtures/sprockets-app/source/library/js/plain.js +3 -0
  27. data/fixtures/sprockets-app2/source/stylesheets/sprockets_base2.css.scss +1 -1
  28. data/fixtures/sprockets-imported-asset-path-conflicts-app/config.rb +1 -1
  29. data/fixtures/sprockets-imported-assets-match-multiple-paths-app/config.rb +1 -1
  30. data/fixtures/sprockets-multiple-extensions-app/config.rb +0 -3
  31. data/fixtures/sprockets-multiple-extensions-app/source/stylesheets/app.css.scss +3 -0
  32. data/fixtures/sprockets-svg-font-app/config.rb +0 -4
  33. data/fixtures/sprockets-svg-font-app/source/stylesheets/app.css.scss +4 -0
  34. data/lib/middleman-sprockets.rb +1 -6
  35. data/lib/middleman-sprockets/extension.rb +197 -113
  36. data/lib/middleman-sprockets/version.rb +1 -1
  37. data/middleman-sprockets.gemspec +2 -4
  38. metadata +29 -74
  39. data/Gemfile-Sprockets3 +0 -36
  40. data/Gemfile-v3 +0 -36
  41. data/features/asset_hash-3.0.feature +0 -105
  42. data/fixtures/sprockets-app-debug-assets/config.rb +0 -1
  43. data/fixtures/sprockets-app-debug-assets/source/index.html.erb +0 -8
  44. data/fixtures/sprockets-app-debug-assets/source/javascripts/dependency1.js +0 -3
  45. data/fixtures/sprockets-app-debug-assets/source/javascripts/dependency2.js +0 -1
  46. data/fixtures/sprockets-app-debug-assets/source/javascripts/main.js +0 -4
  47. data/fixtures/sprockets-app-debug-assets/source/stylesheets/app.css.scss +0 -4
  48. data/fixtures/sprockets-app-debug-assets/source/stylesheets/dependency2.css.scss +0 -0
  49. data/lib/middleman-sprockets/asset.rb +0 -142
  50. data/lib/middleman-sprockets/asset_tag_helpers.rb +0 -54
  51. data/lib/middleman-sprockets/config_only_environment.rb +0 -50
  52. data/lib/middleman-sprockets/environment.rb +0 -293
  53. data/lib/middleman-sprockets/imported_asset.rb +0 -30
  54. data/lib/middleman-sprockets/sass_function_hack.rb +0 -9
  55. data/lib/middleman-sprockets/sass_utils.rb +0 -14
  56. data/spec/asset_spec.rb +0 -118
  57. data/spec/imported_asset_spec.rb +0 -42
@@ -1,30 +0,0 @@
1
- # encoding: utf-8
2
- module Middleman
3
- module Sprockets
4
- # ImportedAsset
5
- class ImportedAsset
6
- attr_reader :logical_path, :output_path
7
-
8
- # Create instance
9
- #
10
- # @param [Pathname] logical_path
11
- # The logical path to the asset given in config.rb
12
- #
13
- # @param [proc] output_dir
14
- # An individual output directory for that particular asset
15
- def initialize logical_path, output_path = nil
16
- @logical_path = Pathname.new logical_path
17
-
18
- if output_path.respond_to? :call
19
- if output_path.arity.abs == 1
20
- output_path = output_path.call(@logical_path)
21
- else
22
- output_path = output_path.call
23
- end
24
- end
25
-
26
- @output_path = Pathname.new output_path if output_path
27
- end
28
- end
29
- end
30
- end
@@ -1,9 +0,0 @@
1
- if defined?(Sass)
2
- module Sass::Script::Functions
3
- # Override generated_image_url to use Sprockets
4
- # a la https://github.com/Compass/compass-rails/blob/master/lib/compass-rails/patches/4_0.rb
5
- def generated_image_url(path, only_path = nil)
6
- asset_url(path, Sass::Script::String.new("image"))
7
- end
8
- end
9
- end
@@ -1,14 +0,0 @@
1
- if defined?(Sass)
2
-
3
- module Sass::Script::Functions
4
-
5
- ##
6
- # A reference to the Middleman::Application object.
7
- #
8
- def middleman_app
9
- options[:custom][:sprockets_context].app
10
- end
11
-
12
- end
13
-
14
- end
data/spec/asset_spec.rb DELETED
@@ -1,118 +0,0 @@
1
- # encoding: utf-8
2
- RSpec.describe Middleman::Sprockets::Asset do
3
-
4
- def build_subject_asset logical_path, source_dir
5
- source_path = File.join source_dir, logical_path
6
- @sprockets_double = instance_double("Middleman::Sprockets::Environment")
7
- @app_double = double("Middleman::Application",
8
- sprockets: @sprockets_double,
9
- config: ::Middleman::Util.recursively_enhance(images_dir: 'images'))
10
- @asset_double = instance_double("Sprockets::BundledAsset",
11
- pathname: Pathname.new(source_path),
12
- logical_path: logical_path)
13
- allow( @sprockets_double ).to receive(:resolve).with(source_path)
14
- .and_return("anything")
15
- allow( @sprockets_double ).to receive(:[]).with("anything")
16
- .and_return(@asset_double)
17
-
18
- return described_class.new @app_double, source_path
19
- end
20
-
21
- describe "#initialize" do
22
- it "raises Sprockets::FileNotFound if sprockets can't find the asset" do
23
- source_path = "/path/to/nowhere.jpg"
24
-
25
- @sprockets_double = instance_double("Middleman::Sprockets::Environment")
26
- @app_double = double("Middleman::Application",
27
- sprockets: @sprockets_double)
28
- allow( @sprockets_double ).to receive(:resolve).with(source_path)
29
- .and_return("anything")
30
-
31
- # mimic sprockets unable to find an asset
32
- allow( @sprockets_double ).to receive(:[]).with("anything")
33
- .and_return(nil)
34
-
35
- expect {
36
- described_class.new @app_double, source_path
37
- }.to raise_error Sprockets::FileNotFound
38
- end
39
- end
40
-
41
- describe "#type" do
42
-
43
- it 'finds type by extension' do
44
- image = build_subject_asset 'path/to/image.png', 'source'
45
- expect( image.type ).to eq :image
46
-
47
- stylesheet = build_subject_asset 'path/to/stylesheet.css', 'source'
48
- expect( stylesheet.type ).to eq :stylesheet
49
-
50
- script = build_subject_asset 'path/to/script.js', 'source'
51
- expect( script.type ).to eq :script
52
-
53
- font = build_subject_asset 'path/to/font.ttf', 'source'
54
- expect( font.type ).to eq :font
55
- end
56
-
57
- it 'finds type by path' do
58
- image = build_subject_asset 'path/to/images/image.foo', 'source'
59
- expect( image.type ).to eq :image
60
- image = build_subject_asset 'path/to/image.foo', 'images'
61
- expect( image.type ).to eq :image
62
-
63
- stylesheet = build_subject_asset 'path/to/css/stylesheet.foo', 'source'
64
- expect( stylesheet.type ).to eq :stylesheet
65
- image = build_subject_asset 'path/to/stylesheet.foo', 'css'
66
- expect( image.type ).to eq :stylesheet
67
-
68
- script = build_subject_asset 'path/to/javascripts/script.foo', 'source'
69
- expect( script.type ).to eq :script
70
- image = build_subject_asset 'path/to/script.foo', 'javascripts'
71
- expect( image.type ).to eq :script
72
-
73
- font = build_subject_asset 'path/to/fonts/font.foo', 'source'
74
- expect( font.type ).to eq :font
75
- font = build_subject_asset 'path/to/font.foo', 'fonts'
76
- expect( font.type ).to eq :font
77
- end
78
-
79
- it 'finds type by double extension' do
80
- image = build_subject_asset 'path/to/image.svg.erb', 'source'
81
- expect( image.type ).to eq :image
82
-
83
- stylesheet = build_subject_asset 'path/to/stylesheet.css.scss', 'source'
84
- expect( stylesheet.type ).to eq :stylesheet
85
-
86
- script = build_subject_asset 'path/to/script.js.coffee', 'source'
87
- expect( script.type ).to eq :script
88
- end
89
-
90
- it 'finds type in an unlimited number of extensions' do
91
- asset = script = build_subject_asset 'path/to/image.asdf.png.asdf.xz', 'source'
92
- expect( asset.type ).to eq :image
93
- end
94
- end
95
-
96
- describe "#source_path" do
97
- it "returns pathname from sprockets asset" do
98
- asset = build_subject_asset 'path/to/asset.css', 'source'
99
- expect( @asset_double ).to receive(:pathname)
100
- .and_return("sprockets/pathname")
101
-
102
- expect( asset.source_path ).to eq "sprockets/pathname"
103
- end
104
- end
105
-
106
- describe "#destination_path" do
107
- it "builds path based on asset type" do
108
- asset = build_subject_asset 'path/to/image.png', 'source'
109
- expect( asset.destination_path.to_s ).to eq 'images/path/to/image.png'
110
- end
111
-
112
- it "strips asset type directory from logical path and uses apps asset directory" do
113
- asset = build_subject_asset 'img/path/to/image.png', 'source'
114
- expect( asset.destination_path.to_s ).to eq 'images/path/to/image.png'
115
- end
116
- end
117
-
118
- end
@@ -1,42 +0,0 @@
1
- # encoding: utf-8
2
- RSpec.describe Middleman::Sprockets::ImportedAsset do
3
-
4
- describe "#initialize" do
5
- it "sets #logical_path to a pathname based on given path" do
6
- subject = described_class.new "logical"
7
- expect( subject.logical_path ).to eq Pathname.new("logical")
8
- end
9
-
10
- it "sets #output_path to nil if no block given" do
11
- subject = described_class.new "logical"
12
- expect( subject.output_path ).to be_nil
13
- end
14
-
15
- it "sets #output_path based on return of passed block" do
16
- subject = described_class.new "logical", -> { "hello" }
17
- expect( subject.output_path ).to eq Pathname.new("hello")
18
- end
19
-
20
- it "passes #logical_path to the output_path block if it accepts an argument" do
21
- output_double = proc { |arg| "hello" }
22
- expect( output_double ).to receive(:call).with(Pathname.new("logical"))
23
-
24
- described_class.new "logical", output_double
25
- end
26
-
27
- it "passes #logical_path to the output_path block if it accepts an argument and has a default", skip: '1.9' do
28
- output_double = lambda { |arg=3| "hello" }
29
- expect( output_double ).to receive(:call).with(Pathname.new("logical"))
30
-
31
- described_class.new "logical", output_double
32
- end
33
-
34
- it "calls output_path block with no args it it accepts none" do
35
- output_double = -> { "hello" }
36
- expect( output_double ).to receive(:call).with no_args()
37
-
38
- described_class.new "logical", output_double
39
- end
40
- end
41
-
42
- end