contentful_middleman 1.0.3 → 1.0.4
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
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e9139679962d383306d6e3bc2ac41003499bad3c
|
4
|
+
data.tar.gz: 7775dbb392e95e021cf9fa8adfb9a97a5e722ad2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f89ab95709e0510226915f0e3991d4561c193b80cb419a2f830206725c1a71c038852eb81d3e56bded678913e99f820b306700e4ddcd842c7ac7e57ff8e5b8fd
|
7
|
+
data.tar.gz: 118262ec63062c0962fce52c1ff643a40376c95668bf7fa219cc5ec8b8aee37313549e66d4cb3e9f4530f667facc2bcce7e041e11ac6d70bc18c12f54523277e
|
data/CHANGELOG.md
CHANGED
@@ -1,9 +1,16 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
-
##
|
3
|
+
## 1.0.4
|
4
|
+
### Fixed
|
5
|
+
* Typo in the require statements
|
6
|
+
* The importing of entries with fields containing a list of elements other that links to entries now works
|
7
|
+
* Handle non included links i.e. when the `include` query parameter is not present or its value doesn't cover a link
|
8
|
+
|
9
|
+
## 1.0.3
|
4
10
|
## Fixed
|
5
11
|
* The importing of entries including `Contentful::Location` fields now works
|
6
12
|
|
13
|
+
|
7
14
|
## 1.0.2
|
8
15
|
### Fixed
|
9
16
|
* Include `middleman-blog` as dependency of the gem.
|
data/README.md
CHANGED
@@ -48,7 +48,7 @@ Parameter | Description
|
|
48
48
|
---------- |------------
|
49
49
|
space | Hash with an user choosen name for the space as key and the space id as value
|
50
50
|
access_token | Contentful Delivery API access token
|
51
|
-
cda_query | Hash describing query configuration. See [contentful.rb](https://github.com/contentful/contentful.rb) for more info
|
51
|
+
cda_query | Hash describing query configuration. See [contentful.rb](https://github.com/contentful/contentful.rb) for more info (look for filter options there)
|
52
52
|
content_types | Hash describing the mapping applied to entries of the imported content types
|
53
53
|
|
54
54
|
You can activate the extension multiple times to import entries from different spaces.
|
@@ -5,7 +5,7 @@ require 'digest'
|
|
5
5
|
require 'contentful_middleman/commands/context'
|
6
6
|
require 'contentful_middleman/tools/backup'
|
7
7
|
require 'contentful_middleman/version_hash'
|
8
|
-
require '
|
8
|
+
require 'contentful_middleman/import_task'
|
9
9
|
require 'contentful_middleman/local_data/store'
|
10
10
|
require 'contentful_middleman/local_data/file'
|
11
11
|
|
@@ -1,14 +1,13 @@
|
|
1
1
|
module ContentfulMiddleman
|
2
2
|
class Context < BasicObject
|
3
3
|
def initialize
|
4
|
-
@variables
|
5
|
-
@nexted_contexts = []
|
4
|
+
@variables = {}
|
6
5
|
end
|
7
6
|
|
8
7
|
def method_missing(symbol, *args, &block)
|
9
8
|
if symbol =~ /\A.+=\z/
|
10
|
-
variable_name
|
11
|
-
variable_value
|
9
|
+
variable_name = symbol.to_s.gsub('=','')
|
10
|
+
variable_value = args.first
|
12
11
|
|
13
12
|
set variable_name, variable_value
|
14
13
|
else
|
@@ -16,25 +15,6 @@ module ContentfulMiddleman
|
|
16
15
|
end
|
17
16
|
end
|
18
17
|
|
19
|
-
def nest(field_name)
|
20
|
-
@nexted_contexts << field_name
|
21
|
-
new_context = Context.new
|
22
|
-
yield new_context
|
23
|
-
|
24
|
-
set field_name, new_context
|
25
|
-
end
|
26
|
-
|
27
|
-
def map(field_name, elements)
|
28
|
-
@nexted_contexts << field_name
|
29
|
-
new_contexts = elements.map do |element|
|
30
|
-
new_context = Context.new
|
31
|
-
yield element, new_context
|
32
|
-
new_context
|
33
|
-
end
|
34
|
-
|
35
|
-
set field_name, new_contexts
|
36
|
-
end
|
37
|
-
|
38
18
|
def set(name, value)
|
39
19
|
@variables[name.to_sym] = value
|
40
20
|
end
|
@@ -47,30 +27,27 @@ module ContentfulMiddleman
|
|
47
27
|
Context == klass
|
48
28
|
end
|
49
29
|
|
50
|
-
def
|
51
|
-
|
30
|
+
def to_yaml
|
31
|
+
hashize.to_yaml
|
52
32
|
end
|
53
33
|
|
54
|
-
def
|
34
|
+
def hashize
|
55
35
|
variables = @variables.dup
|
56
36
|
variables.update(variables) do |variable_name, variable_value|
|
57
|
-
|
58
|
-
hashize_nested_context(variable_value)
|
59
|
-
else
|
60
|
-
variable_value
|
61
|
-
end
|
37
|
+
ensure_primitive_data_types(variable_value)
|
62
38
|
end
|
63
|
-
|
64
|
-
variables.to_yaml
|
65
39
|
end
|
66
40
|
|
67
|
-
def
|
68
|
-
case
|
41
|
+
def ensure_primitive_data_types(value)
|
42
|
+
case value
|
43
|
+
when Context
|
44
|
+
value.hashize
|
69
45
|
when ::Array
|
70
|
-
|
46
|
+
value.map {|element| ensure_primitive_data_types(element)}
|
71
47
|
else
|
72
|
-
|
48
|
+
value
|
73
49
|
end
|
74
50
|
end
|
51
|
+
|
75
52
|
end
|
76
53
|
end
|
@@ -1,44 +1,66 @@
|
|
1
|
+
require_relative '../commands/context'
|
2
|
+
|
1
3
|
module ContentfulMiddleman
|
2
4
|
module Mapper
|
3
5
|
class Base
|
4
6
|
def map(context, entry)
|
5
|
-
map_entry(context, entry)
|
6
|
-
end
|
7
|
-
|
8
|
-
private
|
9
|
-
def map_entry(context, entry)
|
10
7
|
context.id = entry.id
|
11
8
|
entry.fields.each {|k, v| map_field context, k, v}
|
12
9
|
end
|
13
10
|
|
11
|
+
private
|
12
|
+
|
14
13
|
def map_field(context, field_name, field_value)
|
15
|
-
|
14
|
+
value_mapping = map_value(field_value)
|
15
|
+
context.set(field_name, value_mapping)
|
16
|
+
end
|
17
|
+
|
18
|
+
def map_value(value)
|
19
|
+
case value
|
16
20
|
when Contentful::Asset
|
17
|
-
map_asset(
|
21
|
+
map_asset(value)
|
18
22
|
when Contentful::Location
|
19
|
-
map_location(
|
23
|
+
map_location(value)
|
24
|
+
when Contentful::Link
|
25
|
+
map_link(value)
|
26
|
+
when Contentful::DynamicEntry
|
27
|
+
map_entry(value)
|
20
28
|
when Array
|
21
|
-
map_array(
|
29
|
+
map_array(value)
|
22
30
|
else
|
23
|
-
|
31
|
+
value
|
24
32
|
end
|
25
33
|
end
|
26
34
|
|
27
|
-
def map_asset(
|
28
|
-
context.
|
29
|
-
|
30
|
-
|
31
|
-
|
35
|
+
def map_asset(asset)
|
36
|
+
context = Context.new
|
37
|
+
context.title = asset.title
|
38
|
+
context.url = asset.file.url
|
39
|
+
|
40
|
+
context
|
32
41
|
end
|
33
42
|
|
34
|
-
def
|
35
|
-
|
36
|
-
|
37
|
-
|
43
|
+
def map_entry(entry)
|
44
|
+
context = Context.new
|
45
|
+
context.id = entry.id
|
46
|
+
entry.fields.each {|k, v| map_field context, k, v}
|
47
|
+
|
48
|
+
context
|
49
|
+
end
|
50
|
+
|
51
|
+
def map_location(location)
|
52
|
+
location.properties
|
53
|
+
end
|
54
|
+
|
55
|
+
def map_link(link)
|
56
|
+
context = Context.new
|
57
|
+
context.id = link.id
|
58
|
+
|
59
|
+
context
|
38
60
|
end
|
39
61
|
|
40
|
-
def
|
41
|
-
|
62
|
+
def map_array(array)
|
63
|
+
array.map {|element| map_value(element)}
|
42
64
|
end
|
43
65
|
end
|
44
66
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: contentful_middleman
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sascha Konietzke
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-03-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: middleman-core
|