sutty-migration 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/sutty_migration/data.rb +17 -12
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e94ad861c92188564cbac8821283cd8d6229ae2c85f44ebc24dbc235228de794
|
4
|
+
data.tar.gz: e2ae77d06641891aeb6572693536fcfb2e436e2691abf8994cdc540e92104780
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9b3382a28169ae769d3993ef5fa7c01421fb8eb951b27e383ec084e22951242a110e11704f8f38ec198740d1673b096044d7f2bf00e63daa72294feffab04cc9
|
7
|
+
data.tar.gz: 661841af686da59fa2ebc08be9c0d992e5fb3965e25a6c4751e0ff192ddd65dde2cc426c0fcd610ae1a19fd494b0e1c5d245459848ab6c768052480a6a96af0f
|
data/lib/sutty_migration/data.rb
CHANGED
@@ -26,27 +26,32 @@ Jekyll::Hooks.register :site, :post_read, priority: :low do |site|
|
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
-
document ||=
|
30
|
-
|
29
|
+
document ||= begin
|
30
|
+
data = row.slice(*%w[date slug title]).transform_keys(&:to_sym)
|
31
|
+
Jekyll::Document.find_or_create(site: site, collection: 'posts', **data)
|
32
|
+
end
|
33
|
+
next unless document
|
31
34
|
|
32
35
|
row.each do |attribute, value|
|
33
|
-
next
|
36
|
+
next if value.nil? || value.blank?
|
37
|
+
|
38
|
+
value.strip! if value.is_a? String
|
34
39
|
|
35
40
|
row[attribute] =
|
36
41
|
case layout.dig(attribute, 'type')
|
37
|
-
when 'string' then value
|
38
|
-
when 'text' then value
|
39
|
-
when 'tel' then value
|
42
|
+
when 'string' then value.tr("\n", ' ').squeeze(' ')
|
43
|
+
when 'text' then value.gsub("\n", "\n\n")
|
44
|
+
when 'tel' then value.tr("\n", ' ').squeeze(' ')
|
40
45
|
# TODO: validate
|
41
|
-
when 'color' then value
|
46
|
+
when 'color' then value.tr("\n", ' ').squeeze(' ')
|
42
47
|
when 'date' then Jekyll::Utils.parse_date(value)
|
43
48
|
# TODO: validate
|
44
|
-
when 'email' then value
|
49
|
+
when 'email' then value.tr("\n", ' ').squeeze(' ')
|
45
50
|
# TODO: validate
|
46
|
-
when 'url' then value
|
47
|
-
when 'content' then value
|
48
|
-
when 'markdown_content' then value
|
49
|
-
when 'markdown' then value
|
51
|
+
when 'url' then value.tr("\n", ' ').squeeze(' ')
|
52
|
+
when 'content' then value.gsub("\n", "\n\n")
|
53
|
+
when 'markdown_content' then value.gsub("\n", "\n\n")
|
54
|
+
when 'markdown' then value.gsub("\n", "\n\n")
|
50
55
|
when 'number' then value.to_i
|
51
56
|
when 'order' then value.to_i
|
52
57
|
when 'boolean' then !value.strip.empty?
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sutty-migration
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- f
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-08-
|
11
|
+
date: 2021-08-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|