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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/sutty_migration/data.rb +17 -12
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5486653e0e1eb13f5c4c4f85235c875c782fee7be37a1bee9e4cdd84d5879d0a
4
- data.tar.gz: '096ab9a992ad5b4cf36bb765a4eb99bd4ac9f2fc35ec25737906eb7c3abc8fdf'
3
+ metadata.gz: e94ad861c92188564cbac8821283cd8d6229ae2c85f44ebc24dbc235228de794
4
+ data.tar.gz: e2ae77d06641891aeb6572693536fcfb2e436e2691abf8994cdc540e92104780
5
5
  SHA512:
6
- metadata.gz: e94245fd5af90a7411b842e13c44a5f85bbbe2544449de98eaa9c52dbb70f095938754bb65dea382f5275df26b6753c37c5cea24c564ff8f98ad6a0f29406e0e
7
- data.tar.gz: f415da3e9c4ebee1ec8a6101676ae17a319d05ee248c8360d834d7f321190e791eb8274eb6fa0c5fcc74be5c1d2e1b77195894cb9179c3e33626bd090636327b
6
+ metadata.gz: 9b3382a28169ae769d3993ef5fa7c01421fb8eb951b27e383ec084e22951242a110e11704f8f38ec198740d1673b096044d7f2bf00e63daa72294feffab04cc9
7
+ data.tar.gz: 661841af686da59fa2ebc08be9c0d992e5fb3965e25a6c4751e0ff192ddd65dde2cc426c0fcd610ae1a19fd494b0e1c5d245459848ab6c768052480a6a96af0f
@@ -26,27 +26,32 @@ Jekyll::Hooks.register :site, :post_read, priority: :low do |site|
26
26
  end
27
27
  end
28
28
 
29
- document ||= Jekyll::Document.create(site: site, collection: 'posts',
30
- **row.slice(*%w[date slug title]).transform_keys(&:to_sym))
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 unless value.blank?
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.0
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-10 00:00:00.000000000 Z
11
+ date: 2021-08-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll