jekyll-assets 1.0.0 → 2.0.0.pre.beta1

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.
Files changed (90) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +10 -10
  3. data/LICENSE +16 -18
  4. data/README.md +94 -554
  5. data/Rakefile +2 -8
  6. data/lib/jekyll/assets.rb +18 -12
  7. data/lib/jekyll/assets/cached.rb +12 -0
  8. data/lib/jekyll/assets/configuration.rb +43 -87
  9. data/lib/jekyll/assets/context.rb +23 -0
  10. data/lib/jekyll/assets/env.rb +181 -0
  11. data/lib/jekyll/assets/extras/es6.rb +5 -0
  12. data/lib/jekyll/assets/extras/font-awesome.rb +1 -0
  13. data/lib/jekyll/assets/extras/helpers.rb +6 -0
  14. data/lib/jekyll/assets/extras/prefix.rb +5 -0
  15. data/lib/jekyll/assets/filters.rb +9 -11
  16. data/lib/jekyll/assets/helpers.rb +37 -0
  17. data/lib/jekyll/assets/hook.rb +45 -0
  18. data/lib/jekyll/assets/hooks/post_read.rb +3 -0
  19. data/lib/jekyll/assets/hooks/post_write.rb +3 -0
  20. data/lib/jekyll/assets/logger.rb +25 -0
  21. data/lib/jekyll/assets/patches/jekyll/cleaner.rb +11 -0
  22. data/lib/jekyll/assets/patches/jekyll/site.rb +5 -0
  23. data/lib/jekyll/assets/patches/sprockets/asset.rb +13 -0
  24. data/lib/jekyll/assets/tag.rb +136 -9
  25. data/lib/jekyll/assets/tag/parser.rb +129 -0
  26. data/lib/jekyll/assets/tag/proxied_asset.rb +84 -0
  27. data/lib/jekyll/assets/tag/proxies.rb +86 -0
  28. data/lib/jekyll/assets/tag/proxies/magick.rb +101 -0
  29. data/lib/jekyll/assets/version.rb +1 -1
  30. metadata +59 -149
  31. data/.gitignore +0 -27
  32. data/.rspec +0 -1
  33. data/.rubocop.yml +0 -43
  34. data/.rubocop_todo.yml +0 -10
  35. data/.travis.yml +0 -16
  36. data/.yardopts +0 -1
  37. data/Appraisals +0 -7
  38. data/Guardfile +0 -7
  39. data/HISTORY.md +0 -297
  40. data/gemfiles/jekyll_2.gemfile +0 -17
  41. data/gemfiles/jekyll_3.gemfile +0 -17
  42. data/jekyll-assets.gemspec +0 -34
  43. data/lib/jekyll-assets.rb +0 -2
  44. data/lib/jekyll/assets/asset_path.rb +0 -39
  45. data/lib/jekyll/assets/environment.rb +0 -62
  46. data/lib/jekyll/assets/patches.rb +0 -1
  47. data/lib/jekyll/assets/patches/asset_patch.rb +0 -102
  48. data/lib/jekyll/assets/patches/bundled_asset_patch.rb +0 -16
  49. data/lib/jekyll/assets/patches/context_patch.rb +0 -31
  50. data/lib/jekyll/assets/patches/index_patch.rb +0 -25
  51. data/lib/jekyll/assets/patches/processed_asset_patch.rb +0 -59
  52. data/lib/jekyll/assets/patches/site_patch.rb +0 -62
  53. data/lib/jekyll/assets/renderer.rb +0 -122
  54. data/spec/fixtures/.gitignore +0 -2
  55. data/spec/fixtures/.jekyll-metadata +0 -0
  56. data/spec/fixtures/_assets/alert.js +0 -1
  57. data/spec/fixtures/_assets/app.css.erb +0 -5
  58. data/spec/fixtures/_assets/app.js +0 -1
  59. data/spec/fixtures/_assets/app.min.css +0 -0
  60. data/spec/fixtures/_assets/app.min.js +0 -0
  61. data/spec/fixtures/_assets/fonts/vapor.eot +0 -0
  62. data/spec/fixtures/_assets/fonts/vapor.svg +0 -0
  63. data/spec/fixtures/_assets/fonts/vapor.ttf +0 -0
  64. data/spec/fixtures/_assets/fonts/vapor.woff +0 -0
  65. data/spec/fixtures/_assets/lib/relative.css.scss +0 -12
  66. data/spec/fixtures/_assets/noise.png +0 -0
  67. data/spec/fixtures/_assets/noize.png +0 -0
  68. data/spec/fixtures/_assets/should_be_blank.css.erb +0 -1
  69. data/spec/fixtures/_assets/should_fail.css.erb +0 -1
  70. data/spec/fixtures/_assets/vapor.css.scss +0 -13
  71. data/spec/fixtures/_assets/vapor.js +0 -2
  72. data/spec/fixtures/_assets/vendor/with_bootstrap.css.sass +0 -1
  73. data/spec/fixtures/_assets/vendor/with_bourbon.css.sass +0 -4
  74. data/spec/fixtures/_assets/vendor/with_compass.css.sass +0 -4
  75. data/spec/fixtures/_assets/vendor/with_neat.css.sass +0 -5
  76. data/spec/fixtures/_assets/wowscript.js +0 -0
  77. data/spec/fixtures/_assets/wowstyle.css +0 -0
  78. data/spec/fixtures/_config.yml +0 -2
  79. data/spec/fixtures/_layouts/default.html +0 -9
  80. data/spec/fixtures/_posts/2012-10-19-hello-world.md +0 -6
  81. data/spec/fixtures/_posts/2015-02-02-duplicates.md +0 -8
  82. data/spec/fixtures/index.html +0 -0
  83. data/spec/lib/jekyll/assets/configuration_spec.rb +0 -172
  84. data/spec/lib/jekyll/assets/environment_spec.rb +0 -18
  85. data/spec/lib/jekyll/assets/filters_spec.rb +0 -112
  86. data/spec/lib/jekyll/assets/patches/site_patch_spec.rb +0 -176
  87. data/spec/lib/jekyll/assets/renderer_spec.rb +0 -286
  88. data/spec/lib/jekyll/assets/tag_spec.rb +0 -139
  89. data/spec/spec_helper.rb +0 -58
  90. data/spec/support/fixtures_helpers.rb +0 -7
@@ -1,139 +0,0 @@
1
- require "spec_helper"
2
-
3
- RSpec.describe Jekyll::Assets::Tag do
4
- let(:context) { { :registers => { :site => @site } } }
5
-
6
- def render(content)
7
- ::Liquid::Template.parse(content).render({}, context)
8
- end
9
-
10
- def not_found_error(file)
11
- "Liquid error: Couldn't find file '#{file}'"
12
- end
13
-
14
- def render_tag(template, path, attrs = "")
15
- template = Jekyll::Assets::Renderer.const_get template
16
- attrs = " #{attrs}" unless attrs.empty?
17
-
18
- format template, :path => path, :attrs => attrs
19
- end
20
-
21
- context "{% image <file> %}" do
22
- def tag_re(name, attrs = "")
23
- file = "/assets/#{name}-[a-f0-9]{32}\.png"
24
- Regexp.new "^#{render_tag :IMAGE, file, attrs}$"
25
- end
26
-
27
- context "when <file> exists" do
28
- subject { render("{% image noise.png %}") }
29
- it { is_expected.to match tag_re("noise") }
30
- end
31
-
32
- context "when <file> has an attribute" do
33
- subject { render("{% image noise.png alt=\"Foobar\" %}") }
34
- it { is_expected.to match tag_re("noise", "alt=\"Foobar\"") }
35
- end
36
-
37
- context "when <file> does not exists" do
38
- subject { render("{% image not-found.png %}") }
39
- it { is_expected.to match not_found_error "not-found.png" }
40
- end
41
- end
42
-
43
- context "{% stylesheet <file> %}" do
44
- def tag_re(name, attrs = "")
45
- file = "/assets/#{name}-[a-f0-9]{32}\.css"
46
- Regexp.new "^#{render_tag :STYLESHEET, file, attrs}$"
47
- end
48
-
49
- context "when <file> exists" do
50
- subject { render("{% stylesheet app.css %}") }
51
- it { is_expected.to match tag_re("app") }
52
- end
53
-
54
- context "when <file> has an attribute" do
55
- subject { render("{% stylesheet app.css type=\"text/css\" %}") }
56
- it { is_expected.to match tag_re("app", "type=\"text/css\"") }
57
- end
58
-
59
- context "when <file> name has multiple dots" do
60
- subject { render("{% stylesheet app.min %}") }
61
- it { is_expected.to match tag_re("app.min") }
62
- end
63
-
64
- context "when <file> extension is omited" do
65
- subject { render("{% stylesheet app %}") }
66
- it { is_expected.to match tag_re("app") }
67
- end
68
-
69
- context "when <file> does not exists" do
70
- subject { render("{% stylesheet not-found.css %}") }
71
- it { is_expected.to match not_found_error "not-found.css" }
72
- end
73
- end
74
-
75
- context "{% javascript <file> %}" do
76
- def tag_re(name, attrs = "")
77
- file = "/assets/#{name}-[a-f0-9]{32}\.js"
78
- Regexp.new "^#{render_tag :JAVASCRIPT, file, attrs}$"
79
- end
80
-
81
- context "when <file> exists" do
82
- subject { render("{% javascript app.js %}") }
83
- it { is_expected.to match tag_re("app") }
84
- end
85
-
86
- context "when <file> has an attribute" do
87
- subject { render("{% javascript app.js type=\"text/javascript\" %}") }
88
- it { is_expected.to match tag_re("app", "type=\"text/javascript\"") }
89
- end
90
-
91
- context "when <file> name has multiple dots" do
92
- subject { render("{% javascript app.min %}") }
93
- it { is_expected.to match tag_re("app.min") }
94
- end
95
-
96
- context "when <file> extension omited" do
97
- subject { render("{% javascript app %}") }
98
- it { is_expected.to match tag_re("app") }
99
- end
100
-
101
- context "when <file> does not exists" do
102
- subject { render("{% javascript not-found.js %}") }
103
- it { is_expected.to match not_found_error "not-found.js" }
104
- end
105
- end
106
-
107
- context "{% asset_path <file.ext> %}" do
108
- context "when <file> exists" do
109
- subject { render("{% asset_path app.css %}") }
110
- it { is_expected.to match(%r{^/assets/app-[a-f0-9]{32}\.css$}) }
111
- end
112
-
113
- context "when <file> does not exists" do
114
- subject { render("{% asset_path not-found.js %}") }
115
- it { is_expected.to match not_found_error "not-found.js" }
116
- end
117
-
118
- context "with baseurl given as /foobar/" do
119
- before do
120
- context[:registers][:site].assets_config.baseurl = "/foobar/"
121
- end
122
-
123
- subject { render("{% asset_path app.css %}") }
124
- it { is_expected.to match(%r{^/foobar/app-[a-f0-9]{32}\.css$}) }
125
- end
126
- end
127
-
128
- context "{% asset <file.ext> %}" do
129
- context "when <file> exists" do
130
- subject { render("{% asset app.css %}") }
131
- it { is_expected.to match(/body \{ background-image: url\(.+?\) \}/) }
132
- end
133
-
134
- context "when <file> does not exists" do
135
- subject { render("{% asset_path not-found.js %}") }
136
- it { is_expected.to match not_found_error "not-found.js" }
137
- end
138
- end
139
- end
data/spec/spec_helper.rb DELETED
@@ -1,58 +0,0 @@
1
- require "rubygems"
2
-
3
- require "simplecov"
4
- require "coveralls"
5
-
6
- SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
7
- SimpleCov::Formatter::HTMLFormatter, Coveralls::SimpleCov::Formatter
8
- ]
9
-
10
- SimpleCov.start
11
-
12
- require_relative "../lib/jekyll/assets"
13
-
14
- require "jekyll"
15
- require "liquid"
16
- require "sprockets"
17
-
18
- # Requires supporting ruby files with custom matchers and macros, etc,
19
- # in spec/support/ and its subdirectories.
20
- Dir[File.expand_path("../support", __FILE__) + "/**/*.rb"]
21
- .each { |f| require f }
22
-
23
- # rubocop:disable Metrics/AbcSize
24
- def start_site
25
- if Gem::Version.new("2") <= Gem::Version.new(Jekyll::VERSION)
26
- Jekyll.logger.log_level = :warn
27
- else
28
- Jekyll.logger.log_level = Jekyll::Stevenson::WARN
29
- end
30
-
31
- @dest = fixtures_path.join("_site")
32
- @site = Jekyll::Site.new(Jekyll.configuration({
33
- "source" => fixtures_path.to_s,
34
- "destination" => @dest.to_s
35
- }))
36
-
37
- @dest.rmtree if @dest.exist?
38
- @site.process
39
- end
40
- # rubocop:enable Metrics/AbcSize
41
-
42
- RSpec.configure do |config|
43
- config.include FixturesHelpers
44
- config.extend FixturesHelpers
45
- config.filter_run :focus => true
46
- config.run_all_when_everything_filtered = true
47
-
48
- config.disable_monkey_patching!
49
-
50
- config.before(:all) do
51
- Jekyll::Assets::HOOKS.clear
52
- start_site
53
- end
54
-
55
- config.after(:all) do
56
- @dest.rmtree if @dest.exist?
57
- end
58
- end
@@ -1,7 +0,0 @@
1
- require "pathname"
2
-
3
- module FixturesHelpers
4
- def fixtures_path
5
- @fixtures_path ||= Pathname.new(__FILE__).parent.parent.join("fixtures")
6
- end
7
- end