contentful-database-importer 0.3.2 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -0
- data/CHANGELOG.md +8 -0
- data/README.md +6 -0
- data/lib/contentful/database_importer/json_generator.rb +6 -4
- data/lib/contentful/database_importer/resource_bootstrap_class_methods.rb +2 -2
- data/lib/contentful/database_importer/resource_class_methods.rb +7 -1
- data/lib/contentful/database_importer/resource_relationships.rb +1 -1
- data/lib/contentful/database_importer/support.rb +25 -0
- data/lib/contentful/database_importer/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9abdc777c01f879523c6f4aa2bb1d395e2d42eaf
|
4
|
+
data.tar.gz: 179fc5d6250c71c34baf4ec663d3281ef6802d46
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bdd7697218f80a8a164de2382b381cfffb4d3411cbbf9c2b4dc284f6e57df414e46555935a3bc7608859224043899cf76a3f47027b348632e9bc6434075b569b
|
7
|
+
data.tar.gz: c867fe2cc5f53b8a2a573dfd1a48dc85ae548e0977111467cb6904a3033ff0773d5c0f7809602ce6ebb76dc5c6fdd9b49781e9321185aec94811015571c30a6f
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,14 @@
|
|
2
2
|
|
3
3
|
## Unreleased
|
4
4
|
|
5
|
+
## 0.3.3
|
6
|
+
|
7
|
+
### Added
|
8
|
+
* Added notice on using Sequel `v5` when requiring string literals on queries or namespaces. [#12](https://github.com/contentful/contentful-database-importer.rb/issues/12)
|
9
|
+
|
10
|
+
### Fixed
|
11
|
+
* Fixed Merge tables not properly working.
|
12
|
+
|
5
13
|
## 0.3.2
|
6
14
|
|
7
15
|
### Fixed
|
data/README.md
CHANGED
@@ -98,6 +98,10 @@ class MyTable
|
|
98
98
|
end
|
99
99
|
```
|
100
100
|
|
101
|
+
For specifying namespaces for your tables, use `self.table_name = :namespace__table_name`.
|
102
|
+
|
103
|
+
If planning to upgrade to Sequel `v5`, and require namespaces, at the beggining of your file add: `Sequel.split_symbols = true`. This will allow to properly handle the namespaces.
|
104
|
+
|
101
105
|
#### Overriding Table and Content Type ID
|
102
106
|
|
103
107
|
The methods `::table_name=` and `::content_type_id=` allow you to override the IDs for either the table or content type.
|
@@ -242,6 +246,8 @@ class MyResource
|
|
242
246
|
end
|
243
247
|
```
|
244
248
|
|
249
|
+
If planning to upgrade to Sequel `v5`, use `self.query = Sequel.lit("foo = 'bar' AND baz > 2")`. Sequel is deprecating string literals and allowing only this new method.
|
250
|
+
|
245
251
|
### Configuration
|
246
252
|
|
247
253
|
```ruby
|
@@ -30,7 +30,9 @@ module Contentful
|
|
30
30
|
|
31
31
|
if prev_ct_definition
|
32
32
|
result[:contentTypes].delete(prev_ct_definition)
|
33
|
-
content_type_definition.merge
|
33
|
+
content_type_definition = Support.merge(
|
34
|
+
prev_ct_definition, content_type_definition
|
35
|
+
)
|
34
36
|
end
|
35
37
|
|
36
38
|
result[:contentTypes] << content_type_definition
|
@@ -56,16 +58,16 @@ module Contentful
|
|
56
58
|
result
|
57
59
|
)
|
58
60
|
|
59
|
-
return unless prev_entry
|
61
|
+
return entry_definition unless prev_entry
|
60
62
|
|
61
63
|
result[:entries][content_type_definition[:id]].delete(prev_entry)
|
62
|
-
|
64
|
+
Support.merge(prev_entry, entry_definition)
|
63
65
|
end
|
64
66
|
|
65
67
|
def self.create_entry(entry, content_type_definition, result)
|
66
68
|
entry_definition = entry.to_bootstrap
|
67
69
|
|
68
|
-
merge_entries(entry_definition, content_type_definition, result)
|
70
|
+
entry_definition = merge_entries(entry_definition, content_type_definition, result)
|
69
71
|
|
70
72
|
result[:assets].concat(entry.associated_assets) unless entry.associated_assets.empty?
|
71
73
|
|
@@ -46,7 +46,7 @@ module Contentful
|
|
46
46
|
def array_link?(field_data)
|
47
47
|
(field_data[:type] == :array && field_data[:item_type] == :asset) ||
|
48
48
|
(resource?(field_data[:type]) &&
|
49
|
-
[
|
49
|
+
%i[many through].include?(field_data[:relationship]))
|
50
50
|
end
|
51
51
|
|
52
52
|
def array_link_type(field_data)
|
@@ -61,7 +61,7 @@ module Contentful
|
|
61
61
|
def array?(field_data)
|
62
62
|
field_data[:type] == :array ||
|
63
63
|
(resource?(field_data[:type]) &&
|
64
|
-
[
|
64
|
+
%i[many through].include?(field_data[:relationship]))
|
65
65
|
end
|
66
66
|
|
67
67
|
def resource?(other)
|
@@ -70,10 +70,16 @@ module Contentful
|
|
70
70
|
|
71
71
|
def all
|
72
72
|
entries = []
|
73
|
-
rows =
|
73
|
+
rows = if query.nil?
|
74
|
+
table.all
|
75
|
+
else
|
76
|
+
table.where(query).all
|
77
|
+
end
|
78
|
+
|
74
79
|
rows.each_with_index do |row, index|
|
75
80
|
entries << new(row, index)
|
76
81
|
end
|
82
|
+
|
77
83
|
entries
|
78
84
|
end
|
79
85
|
end
|
@@ -3,7 +3,7 @@ module Contentful
|
|
3
3
|
# Relationship methods for Resource
|
4
4
|
module ResourceRelationships
|
5
5
|
def fetch_relations(relationship_field_definition)
|
6
|
-
relations = [
|
6
|
+
relations = %i[many one through]
|
7
7
|
if relations.include?(relationship_field_definition[:relationship])
|
8
8
|
return send(
|
9
9
|
"fetch_#{relationship_field_definition[:relationship]}".to_sym,
|
@@ -9,6 +9,31 @@ module Contentful
|
|
9
9
|
.tr('-', '_')
|
10
10
|
.downcase
|
11
11
|
end
|
12
|
+
|
13
|
+
def self.deep_hash_merge(hash1, hash2)
|
14
|
+
result = {}
|
15
|
+
hash1.each do |key, value|
|
16
|
+
value2 = hash2[key]
|
17
|
+
result[key] = merge(value, value2)
|
18
|
+
end
|
19
|
+
|
20
|
+
hash2.each do |key, value|
|
21
|
+
next if hash1.keys.include?(key)
|
22
|
+
result[key] = value
|
23
|
+
end
|
24
|
+
|
25
|
+
result
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.merge(value, value2)
|
29
|
+
if value.is_a?(::Hash) && value2.is_a?(::Hash)
|
30
|
+
deep_hash_merge(value, value2)
|
31
|
+
elsif value.is_a?(::Array) && value2.is_a?(::Array)
|
32
|
+
value + value2
|
33
|
+
else
|
34
|
+
value || value2
|
35
|
+
end
|
36
|
+
end
|
12
37
|
end
|
13
38
|
end
|
14
39
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: contentful-database-importer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Contentful GmbH (David Litvak Bruno)
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-08-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: contentful_bootstrap
|
@@ -247,7 +247,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
247
247
|
version: '0'
|
248
248
|
requirements: []
|
249
249
|
rubyforge_project:
|
250
|
-
rubygems_version: 2.
|
250
|
+
rubygems_version: 2.6.11
|
251
251
|
signing_key:
|
252
252
|
specification_version: 4
|
253
253
|
summary: Tool to import content from a Database to Contentful
|