storageroom-to-contentful 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -2
- data/Gemfile.lock +10 -10
- data/lib/contentful_importer.rb +25 -5
- data/lib/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 79a184621db4c5e848f97f4bc4a6674b0f8425ee
|
4
|
+
data.tar.gz: 555a9a24648e6086260bc32842ef46274a285160
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 38642fd6df22cc4265cf32b380fa787013ba4904f926964d36cc6f195bc38cd1a173f83d681bae504ef68bb9d7e93ff0781a6edcfd4a246d7fddc87dcae389a5
|
7
|
+
data.tar.gz: a46e519ec3598ec7427cddf28486cd3d6b7f20681fdad47f8dac81e7dd22585b6aff6e25f4479e6febacad49a838cc05006c1de919b6b86b898972e5e552a48a
|
data/CHANGELOG.md
CHANGED
@@ -1,14 +1,17 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
-
## 0.0.
|
3
|
+
## 0.0.5 - 2014-10.31
|
4
4
|
### Fixed
|
5
|
-
*
|
5
|
+
* Create content type fields with a single request [#34](https://github.com/contentful/storageroom-to-contentful.rb/pull/24)
|
6
6
|
|
7
|
+
## 0.0.4 - 2014-10-07
|
7
8
|
### Added
|
8
9
|
* Test for StorageRoom and Contentful credentials
|
9
10
|
|
10
11
|
### Fixed
|
11
12
|
* Import StorageRoom Array as Contentful Array
|
13
|
+
* Storage Room export only exporting the first 20 records #19
|
14
|
+
|
12
15
|
|
13
16
|
## 0.0.3 - 2014-09-26
|
14
17
|
### Added
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
storageroom-to-contentful (0.0.
|
4
|
+
storageroom-to-contentful (0.0.5)
|
5
5
|
contentful-management (~> 0.2)
|
6
6
|
http (~> 0.6)
|
7
7
|
i18n (~> 0.6)
|
@@ -14,7 +14,7 @@ GEM
|
|
14
14
|
ast (2.0.0)
|
15
15
|
astrolabe (1.3.0)
|
16
16
|
parser (>= 2.2.0.pre.3, < 3.0)
|
17
|
-
contentful-management (0.
|
17
|
+
contentful-management (0.3.1)
|
18
18
|
http (~> 0.6)
|
19
19
|
multi_json (~> 1)
|
20
20
|
crack (0.4.2)
|
@@ -25,7 +25,7 @@ GEM
|
|
25
25
|
http_parser.rb (0.6.0)
|
26
26
|
i18n (0.6.11)
|
27
27
|
multi_json (1.10.1)
|
28
|
-
parser (2.2.0.pre.
|
28
|
+
parser (2.2.0.pre.6)
|
29
29
|
ast (>= 1.1, < 3.0)
|
30
30
|
slop (~> 3.4, >= 3.4.5)
|
31
31
|
powerpack (0.0.9)
|
@@ -35,25 +35,25 @@ GEM
|
|
35
35
|
rspec-core (~> 3.1.0)
|
36
36
|
rspec-expectations (~> 3.1.0)
|
37
37
|
rspec-mocks (~> 3.1.0)
|
38
|
-
rspec-core (3.1.
|
38
|
+
rspec-core (3.1.7)
|
39
39
|
rspec-support (~> 3.1.0)
|
40
40
|
rspec-expectations (3.1.2)
|
41
41
|
diff-lcs (>= 1.2.0, < 2.0)
|
42
42
|
rspec-support (~> 3.1.0)
|
43
|
-
rspec-mocks (3.1.
|
43
|
+
rspec-mocks (3.1.3)
|
44
44
|
rspec-support (~> 3.1.0)
|
45
|
-
rspec-support (3.1.
|
46
|
-
rubocop (0.
|
45
|
+
rspec-support (3.1.2)
|
46
|
+
rubocop (0.27.0)
|
47
47
|
astrolabe (~> 1.3)
|
48
|
-
parser (>= 2.2.0.pre.
|
48
|
+
parser (>= 2.2.0.pre.6, < 3.0)
|
49
49
|
powerpack (~> 0.0.6)
|
50
50
|
rainbow (>= 1.99.1, < 3.0)
|
51
51
|
ruby-progressbar (~> 1.4)
|
52
|
-
ruby-progressbar (1.6.
|
52
|
+
ruby-progressbar (1.6.1)
|
53
53
|
safe_yaml (1.0.4)
|
54
54
|
slop (3.6.0)
|
55
55
|
vcr (2.9.3)
|
56
|
-
webmock (1.
|
56
|
+
webmock (1.20.0)
|
57
57
|
addressable (>= 2.3.6)
|
58
58
|
crack (>= 0.3.2)
|
59
59
|
|
data/lib/contentful_importer.rb
CHANGED
@@ -42,7 +42,7 @@ class ContentfulImporter
|
|
42
42
|
def import_content_types
|
43
43
|
Dir.glob("#{COLLECTIONS_DATA_DIR}/*json") do |file_path|
|
44
44
|
collection_attributes = JSON.parse(File.read(file_path))
|
45
|
-
content_type =
|
45
|
+
content_type = create_new_content_type(collection_attributes)
|
46
46
|
puts "Importing content_type: #{content_type.name}"
|
47
47
|
create_content_type_fields(collection_attributes, content_type)
|
48
48
|
create_content_type_webhooks(collection_attributes['webhook_definitions'], content_type.space.id)
|
@@ -121,9 +121,11 @@ class ContentfulImporter
|
|
121
121
|
end
|
122
122
|
|
123
123
|
def create_content_type_fields(collection_attributes, content_type)
|
124
|
-
collection_attributes['fields'].
|
125
|
-
create_field(field
|
124
|
+
fields = collection_attributes['fields'].each_with_object([]) do |field, fields|
|
125
|
+
fields << create_field(field)
|
126
126
|
end
|
127
|
+
content_type.fields = fields
|
128
|
+
content_type.save
|
127
129
|
end
|
128
130
|
|
129
131
|
def create_content_type_webhooks(params, space_id)
|
@@ -200,6 +202,13 @@ class ContentfulImporter
|
|
200
202
|
Contentful::Management::ContentType.find(space_id, content_type_id)
|
201
203
|
end
|
202
204
|
|
205
|
+
def create_new_content_type(collection_attributes)
|
206
|
+
space.content_types.new.tap do |content_type|
|
207
|
+
content_type.name = collection_attributes['entry_type']
|
208
|
+
content_type.description = collection_attributes['note']
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
203
212
|
def add_content_type_id_to_file(collection, content_type_id, space_id, file_path)
|
204
213
|
File.open(file_path, 'w') { |file| file.write(format_json(collection.merge(content_type_id: content_type_id, space_id: space_id))) }
|
205
214
|
end
|
@@ -235,11 +244,22 @@ class ContentfulImporter
|
|
235
244
|
end
|
236
245
|
end
|
237
246
|
|
238
|
-
def create_field(field
|
247
|
+
def create_field(field)
|
239
248
|
field_params = {id: field['identifier'], name: field['name'], required: field['required']}
|
240
249
|
field_params.merge!(additional_field_params(field))
|
241
250
|
puts "Creating field: #{field_params[:type]}"
|
242
|
-
|
251
|
+
create_content_type_field(field_params)
|
252
|
+
end
|
253
|
+
|
254
|
+
def create_content_type_field(field_params)
|
255
|
+
Contentful::Management::Field.new.tap do |field|
|
256
|
+
field.id = field_params[:id]
|
257
|
+
field.name = field_params[:name]
|
258
|
+
field.type = field_params[:type]
|
259
|
+
field.link_type = field_params[:link_type]
|
260
|
+
field.required = field_params[:required]
|
261
|
+
field.items = field_params[:items]
|
262
|
+
end
|
243
263
|
end
|
244
264
|
|
245
265
|
def active_status(ct_object)
|
data/lib/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: storageroom-to-contentful
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andreas Tiefenthaler
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-10-
|
11
|
+
date: 2014-10-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: http
|