jekyll-js-converter 0.0.6 → 1.1.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8f975186d3b4d088fb3ee18595c6b6f43b1226defb8f44d06e2683663c60a611
4
- data.tar.gz: fd7abf2439a6a69133cdd2c0e55ed3f30fa8d8e2dc95698d1b1314cb934e4a60
3
+ metadata.gz: 46e4f09c7076cad7fb5dfc7c811e826cce1ad8358db66f3bb3e99a85577ca4ab
4
+ data.tar.gz: cc313145326fd00006785f91df5f3fd7277c5f97b5fba35e2fe8e66edc50ce97
5
5
  SHA512:
6
- metadata.gz: '086d6cef9f35f63debb0ff5a0bfead0c11cc69e45f1e543ba3191cd6a619a7d3f7a45b8ebe465348de2ee2bec04b3d2d1155f7f52645fbca394ce589f91f1941'
7
- data.tar.gz: ee944a5a249415e7308a67488a6d2e0bc44a7f2a71153301444da9dd18265c03d0529be0b2d02125acc751dd06c08b3973c1aa39a2df0ea0b1888ccd51636a82
6
+ metadata.gz: f3c7dfac1fd68634f4e0a6ade3a6429127e9e183a752e2f06a0cec311c989fecb82d14c6d4c0a3df5840131000e4ca68b51f672d2acbe5f082e66cc51aeb66ef
7
+ data.tar.gz: fe2e8bd2d8a2b7cbccfbd7d2f03d3ed38951268fafc5131d18a4688f284cdce9e87e030920660fb23ff2722788e888443a0f0aca42eb4e39ec21dccaee26f20a
@@ -1,5 +1,6 @@
1
1
  require 'uglifier'
2
2
  require 'jekyll/js_source_map_page'
3
+ require 'jekyll/core_ext/hash'
3
4
 
4
5
  module Jekyll
5
6
  module Converters
@@ -11,7 +12,6 @@ module Jekyll
11
12
 
12
13
  def associate_page(page)
13
14
  @page = page
14
- @site = @page.site
15
15
  @source_map_page = JsSourceMapPage.new(@page)
16
16
  end
17
17
 
@@ -22,28 +22,28 @@ module Jekyll
22
22
  end
23
23
 
24
24
  def javascript_config
25
- @javascript_config ||= @config['javascript'] || {}
25
+ @javascript_config ||= @config['javascript'].deep_symbolize_keys || {}
26
26
  end
27
27
 
28
28
  def javascript_dir
29
- javascript_config['javascript_dir'].to_s.empty? ? '_javascript' : javascript_config['javascript_dir']
29
+ javascript_config[:javascript_dir].to_s.empty? ? '_javascript' : javascript_config[:javascript_dir]
30
30
  end
31
31
 
32
32
  def load_paths
33
33
  @load_paths ||= begin
34
- paths = [Jekyll.sanitized_path(@site.source, javascript_dir)]
35
- paths += javascript_config['load_paths'].map { |load_path| File.expand_path(load_path) } rescue []
34
+ paths = [Jekyll.sanitized_path(site.source, javascript_dir)]
35
+ paths += javascript_config[:load_paths].map { |load_path| File.expand_path(load_path, site.source) } rescue []
36
36
 
37
37
  if safe?
38
- paths.map! { |path| Jekyll.sanitized_path(@site.source, path) }
38
+ paths.map! { |path| Jekyll.sanitized_path(site.source, path) }
39
39
  end
40
40
 
41
- Dir.chdir(@site.source) do
41
+ Dir.chdir(site.source) do
42
42
  paths = paths.flat_map { |path| Dir.glob(path) }
43
43
 
44
44
  paths.map! do |path|
45
45
  if safe?
46
- Jekyll.sanitized_path(site_source, path)
46
+ Jekyll.sanitized_path(site.source, path)
47
47
  else
48
48
  File.expand_path(path)
49
49
  end
@@ -51,7 +51,7 @@ module Jekyll
51
51
  end
52
52
 
53
53
  paths.uniq!
54
- paths << @site.theme.javascript_path
54
+ paths << site.theme.javascript_path if site.theme&.javascript_path
55
55
  paths.select { |path| File.directory?(path) }
56
56
  end
57
57
  end
@@ -60,7 +60,7 @@ module Jekyll
60
60
  ext =~ /^\.js$/i
61
61
  end
62
62
 
63
- def output_ext(ext)
63
+ def output_ext(ext = '')
64
64
  '.js'
65
65
  end
66
66
 
@@ -72,7 +72,7 @@ module Jekyll
72
72
  if generate_source_map?
73
73
  config = Jekyll::Utils.symbolize_hash_keys(
74
74
  Jekyll::Utils.deep_merge_hashes(
75
- { :uglifer => {
75
+ { :uglifier => {
76
76
  :source_map => {
77
77
  :map_url => @source_map_page.name,
78
78
  :sources_content => true,
@@ -84,21 +84,21 @@ module Jekyll
84
84
  )
85
85
  )
86
86
 
87
- uglified, source_map = Uglifier.new(config[:uglifer]).compile_with_map(insert_imports(content))
87
+ uglified, source_map = Uglifier.new(config[:uglifier]).compile_with_map(insert_imports(content))
88
88
 
89
89
  @source_map_page.source_map(source_map)
90
- @site.pages << @source_map_page
90
+ site.pages << @source_map_page
91
91
 
92
92
  uglified
93
93
  else
94
94
  config = Jekyll::Utils.symbolize_hash_keys(
95
95
  Jekyll::Utils.deep_merge_hashes(
96
- { :uglifer => {} },
96
+ { :uglifier => {} },
97
97
  javascript_config
98
98
  )
99
99
  )
100
100
 
101
- Uglifier.new(config[:uglifer]).compile(insert_imports(content))
101
+ Uglifier.new(config[:uglifier]).compile(insert_imports(content))
102
102
  end
103
103
  end
104
104
 
@@ -110,7 +110,7 @@ module Jekyll
110
110
  elsif source_map_option.eql?(:always)
111
111
  true
112
112
  else
113
- :development == source_map_option == Jekyll.env.to_sym
113
+ :development == source_map_option && source_map_option == Jekyll.env.to_sym
114
114
  end
115
115
  end
116
116
 
@@ -151,8 +151,12 @@ module Jekyll
151
151
  content
152
152
  end
153
153
 
154
+ def site
155
+ @site ||= @page.nil? ? Jekyll.sites.last : @page.site
156
+ end
157
+
154
158
  def source_map_option
155
- javascript_config.fetch('source_map', :always).to_sym
159
+ javascript_config.fetch(:source_map, :always).to_sym
156
160
  end
157
161
  end
158
162
  end
@@ -0,0 +1,12 @@
1
+ class Hash
2
+ def deep_symbolize_keys(object = self)
3
+ case object
4
+ when Hash
5
+ object.each_with_object(Hash.new) do |(key, value), result|
6
+ result[key.to_sym] = deep_symbolize_keys(value)
7
+ end
8
+ else
9
+ object
10
+ end
11
+ end
12
+ end
@@ -1,3 +1,3 @@
1
1
  module JekyllJsConverter
2
- VERSION = '0.0.6'
2
+ VERSION = '1.1.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-js-converter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Susco
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-23 00:00:00.000000000 Z
11
+ date: 2022-05-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: uglifier
@@ -89,6 +89,7 @@ files:
89
89
  - lib/jekyll-js-converter.rb
90
90
  - lib/jekyll-js-converter/version.rb
91
91
  - lib/jekyll/converters/js.rb
92
+ - lib/jekyll/core_ext/hash.rb
92
93
  - lib/jekyll/js_source_map_page.rb
93
94
  homepage: https://github.com/dsusco/jekyll-js-converter
94
95
  licenses:
@@ -102,7 +103,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
102
103
  requirements:
103
104
  - - ">="
104
105
  - !ruby/object:Gem::Version
105
- version: 2.4.0
106
+ version: 2.5.0
106
107
  required_rubygems_version: !ruby/object:Gem::Requirement
107
108
  requirements:
108
109
  - - ">="