jekyll-js-converter 1.0.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 01a1eeed7b7f346b0419859c5c4f59cd735c311f4f80ab1571147abf0d82cf66
4
- data.tar.gz: 004070e0d99a326d423b20bf8bb3691c98e05d7e1089f7262304c3740317e297
3
+ metadata.gz: 3266db8f045c5dfc168d25c41ae37cf094c3d6dbe8ffaa4b2ddf90547f486919
4
+ data.tar.gz: 7630aac486970cfea70a9b3f3b721973113ada5c4a2c8ad5c6e3e6c38c050977
5
5
  SHA512:
6
- metadata.gz: 27142c7333b1ba84a3dea919ff2f3614e23b8d4f783f8c7280b97e55e6d9266924e0af3ddc1be79ba0ee6f9368013a2e70918ce18c03a9204d4dc25ca6cd86cb
7
- data.tar.gz: a91ec043fbcc3c279616f47e462f8574dbbcc355962c4534605749653e9f77983bdcd79455424c9a6d8c77a602afa3527eb3b50413510cbf6958b42c620e779a
6
+ metadata.gz: b23f80a19d6ab045ca681cd9ac9037dcab4fae1df175fc2f53e02a24c7be3e0d32a5e770d42cd0955c02f667d7d9254c13ff971a19f970e07471c2f245bf89cf
7
+ data.tar.gz: 1f7897defebc0406b5af04d17c63dd02a2e9535e5195575c9897862bc69004ccc20c908e72b7e4c5fb78418d28fc5ccadce686ecba6150d64afb02a9d6cf87f8
@@ -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
@@ -21,17 +22,17 @@ module Jekyll
21
22
  end
22
23
 
23
24
  def javascript_config
24
- @javascript_config ||= @config['javascript'] || {}
25
+ @javascript_config ||= @config['javascript'].deep_symbolize_keys || {}
25
26
  end
26
27
 
27
28
  def javascript_dir
28
- 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]
29
30
  end
30
31
 
31
32
  def load_paths
32
33
  @load_paths ||= begin
33
34
  paths = [Jekyll.sanitized_path(site.source, javascript_dir)]
34
- paths += javascript_config['load_paths'].map { |load_path| File.expand_path(load_path, site.source) } rescue []
35
+ paths += javascript_config[:load_paths].map { |load_path| File.expand_path(load_path, site.source) } rescue []
35
36
 
36
37
  if safe?
37
38
  paths.map! { |path| Jekyll.sanitized_path(site.source, path) }
@@ -69,35 +70,31 @@ module Jekyll
69
70
 
70
71
  def convert(content)
71
72
  if generate_source_map?
72
- config = Jekyll::Utils.symbolize_hash_keys(
73
- Jekyll::Utils.deep_merge_hashes(
74
- { :uglifer => {
75
- :source_map => {
76
- :map_url => @source_map_page.name,
77
- :sources_content => true,
78
- :filename => @page.name
79
- }
73
+ config = Jekyll::Utils.deep_merge_hashes(
74
+ { :uglifier => {
75
+ :source_map => {
76
+ :map_url => @source_map_page.name,
77
+ :sources_content => true,
78
+ :filename => @page.name
80
79
  }
81
- },
82
- javascript_config
83
- )
80
+ }
81
+ },
82
+ javascript_config
84
83
  )
85
84
 
86
- uglified, source_map = Uglifier.new(config[:uglifer]).compile_with_map(insert_imports(content))
85
+ uglified, source_map = Uglifier.new(config[:uglifier]).compile_with_map(insert_imports(content))
87
86
 
88
87
  @source_map_page.source_map(source_map)
89
88
  site.pages << @source_map_page
90
89
 
91
90
  uglified
92
91
  else
93
- config = Jekyll::Utils.symbolize_hash_keys(
94
- Jekyll::Utils.deep_merge_hashes(
95
- { :uglifer => {} },
96
- javascript_config
97
- )
92
+ config = Jekyll::Utils.deep_merge_hashes(
93
+ { :uglifier => {} },
94
+ javascript_config
98
95
  )
99
96
 
100
- Uglifier.new(config[:uglifer]).compile(insert_imports(content))
97
+ Uglifier.new(config[:uglifier]).compile(insert_imports(content))
101
98
  end
102
99
  end
103
100
 
@@ -155,7 +152,7 @@ module Jekyll
155
152
  end
156
153
 
157
154
  def source_map_option
158
- javascript_config.fetch('source_map', :always).to_sym
155
+ javascript_config.fetch(:source_map, :always).to_sym
159
156
  end
160
157
  end
161
158
  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 = '1.0.0'
2
+ VERSION = '1.1.1'
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: 1.0.0
4
+ version: 1.1.1
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-30 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
  - - ">="