drupal-exporter 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +39 -0
- data/.rspec +3 -0
- data/.travis.yml +8 -0
- data/CHANGELOG.md +4 -0
- data/Gemfile +7 -0
- data/Gemfile.lock +72 -0
- data/LICENSE +22 -0
- data/README.md +251 -0
- data/Rakefile +9 -0
- data/bin/drupal-exporter +37 -0
- data/drupal_exporter.gemspec +34 -0
- data/drupal_settings/boolean_columns.yml +2 -0
- data/drupal_settings/drupal_content_types.json +47 -0
- data/drupal_settings/drupal_settings.yml +23 -0
- data/lib/cli.rb +13 -0
- data/lib/configuration.rb +46 -0
- data/lib/converters/content_types_structure_creator.rb +60 -0
- data/lib/converters/contentful_model_to_json.rb +109 -0
- data/lib/drupal/content_type.rb +151 -0
- data/lib/drupal/export.rb +69 -0
- data/lib/drupal/file_managed.rb +42 -0
- data/lib/drupal/tag.rb +52 -0
- data/lib/drupal/user.rb +46 -0
- data/lib/drupal/vocabulary.rb +42 -0
- data/lib/migrator.rb +28 -0
- data/lib/version.rb +3 -0
- data/spec/fixtures/database_rows/content_type_article.json +14 -0
- data/spec/fixtures/database_rows/image.json +10 -0
- data/spec/fixtures/database_rows/node_content_type_article.json +15 -0
- data/spec/fixtures/database_rows/node_content_type_blog.json +15 -0
- data/spec/fixtures/database_rows/tag.json +8 -0
- data/spec/fixtures/database_rows/user.json +18 -0
- data/spec/fixtures/database_rows/vocabulary.json +9 -0
- data/spec/fixtures/drupal/assets/file/file_4.json +6 -0
- data/spec/fixtures/drupal/entries/article/article_5.json +24 -0
- data/spec/fixtures/drupal/entries/tag/tag_1.json +9 -0
- data/spec/fixtures/drupal/entries/user/user_1.json +6 -0
- data/spec/fixtures/drupal/entries/vocabulary/vocabulary_3.json +6 -0
- data/spec/fixtures/json_responses/article.json +24 -0
- data/spec/fixtures/json_responses/image.json +6 -0
- data/spec/fixtures/json_responses/tag.json +9 -0
- data/spec/fixtures/json_responses/vocabulary.json +6 -0
- data/spec/fixtures/settings/boolean_columns.yml +2 -0
- data/spec/fixtures/settings/drupal_content_types.json +47 -0
- data/spec/fixtures/settings/drupal_settings.yml +17 -0
- data/spec/lib/configuration_spec.rb +18 -0
- data/spec/lib/drupal/content_type_spec.rb +123 -0
- data/spec/lib/drupal/export_spec.rb +33 -0
- data/spec/lib/drupal/file_managed_spec.rb +52 -0
- data/spec/lib/drupal/tag_spec.rb +60 -0
- data/spec/lib/drupal/user_spec.rb +49 -0
- data/spec/lib/drupal/vocabulary_spec.rb +51 -0
- data/spec/spec_helper.rb +11 -0
- data/spec/support/db_rows_json.rb +15 -0
- data/spec/support/shared_configuration.rb +20 -0
- metadata +297 -0
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require './lib/drupal/vocabulary'
|
3
|
+
require './lib/drupal/export'
|
4
|
+
require './spec/support/shared_configuration.rb'
|
5
|
+
require './spec/support/db_rows_json.rb'
|
6
|
+
|
7
|
+
module Contentful
|
8
|
+
module Exporter
|
9
|
+
module Drupal
|
10
|
+
describe Vocabulary do
|
11
|
+
|
12
|
+
include_context 'shared_configuration'
|
13
|
+
|
14
|
+
before do
|
15
|
+
exporter = Export.new(@config)
|
16
|
+
@vocabulary = Vocabulary.new(exporter, @config)
|
17
|
+
@row = json_fixture('database_rows/vocabulary')
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'initialize' do
|
21
|
+
expect(@vocabulary.config).to be_a Contentful::Configuration
|
22
|
+
expect(@vocabulary.exporter).to be_a Contentful::Exporter::Drupal::Export
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'save_vocabularies_as_json' do
|
26
|
+
expect_any_instance_of(Contentful::Configuration).to receive(:db) { {taxonomy_vocabulary: [json_fixture('database_rows/vocabulary')]} }
|
27
|
+
expect_any_instance_of(Vocabulary).to receive(:extract_data) { json_fixture('json_responses/vocabulary') }
|
28
|
+
@vocabulary.save_vocabularies_as_json
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'extract_data' do
|
32
|
+
expect_any_instance_of(Vocabulary).to receive_message_chain(:map_fields) { json_fixture('json_responses/vocabulary') }
|
33
|
+
@vocabulary.send(:extract_data, @row)
|
34
|
+
tag_fixture = entry_fixture('vocabulary/vocabulary_3')
|
35
|
+
expect(tag_fixture).to include(id: 'vocabulary_3', name: 'tag_name', description: 'Very bad tag', machine_name: 'bad')
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'id' do
|
39
|
+
tag_id = @vocabulary.send(:id, @row[:vid])
|
40
|
+
expect(tag_id).to eq 'vocabulary_3'
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'map_fields' do
|
44
|
+
vocabulary = @vocabulary.send(:map_fields, @row)
|
45
|
+
expect(vocabulary).to include(id: 'vocabulary_3', name: 'tag_name', description: 'Very bad tag', machine_name: 'bad')
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'multi_json'
|
2
|
+
|
3
|
+
def json_fixture(file, _as_json = false)
|
4
|
+
MultiJson.load(
|
5
|
+
File.read(File.dirname(__FILE__) + "/../fixtures/#{file}.json")
|
6
|
+
).with_indifferent_access
|
7
|
+
end
|
8
|
+
|
9
|
+
def entry_fixture(file, _as_json = false)
|
10
|
+
JSON.parse(File.read(File.dirname(__FILE__) + "/../fixtures/drupal/entries/#{file}.json")).with_indifferent_access
|
11
|
+
end
|
12
|
+
|
13
|
+
def asset_fixture(file, _as_json = false)
|
14
|
+
JSON.parse(File.read(File.dirname(__FILE__) + "/../fixtures/drupal/assets/#{file}.json")).with_indifferent_access
|
15
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require './lib/configuration'
|
2
|
+
|
3
|
+
shared_context 'shared_configuration' do
|
4
|
+
before do
|
5
|
+
yaml_text = <<-EOF
|
6
|
+
data_dir: spec/fixtures/drupal
|
7
|
+
adapter: mysql2
|
8
|
+
host: localhost
|
9
|
+
database: drupal
|
10
|
+
user: username
|
11
|
+
password: secret_password
|
12
|
+
|
13
|
+
drupal_content_types_json: spec/fixtures/settings/drupal_content_types.json
|
14
|
+
drupal_boolean_columns: spec/fixtures/settings/boolean_columns.yml
|
15
|
+
drupal_base_url: http://example_hostname.com
|
16
|
+
EOF
|
17
|
+
yaml = YAML.load(yaml_text)
|
18
|
+
@config = Contentful::Configuration.new(yaml)
|
19
|
+
end
|
20
|
+
end
|
metadata
ADDED
@@ -0,0 +1,297 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: drupal-exporter
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Contentful GmbH (Andreas Tiefenthaler)
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-01-28 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: http
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.6'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: multi_json
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: sequel
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '4.15'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '4.15'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: mysql2
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.3'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0.3'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: activesupport
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '4.1'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '4.1'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: pg
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 0.17.0
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 0.17.0
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: escort
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 0.4.0
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 0.4.0
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: i18n
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0.6'
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0.6'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: rspec
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '3'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '3'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: rspec-its
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - "~>"
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: 1.1.0
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - "~>"
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: 1.1.0
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: bundler
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - "~>"
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '1.6'
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - "~>"
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '1.6'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: rake
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - ">="
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
174
|
+
type: :development
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - ">="
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '0'
|
181
|
+
description: Drupal exporter that prepares content to be imported
|
182
|
+
email:
|
183
|
+
- rubygems@contentful.com
|
184
|
+
executables:
|
185
|
+
- drupal-exporter
|
186
|
+
extensions: []
|
187
|
+
extra_rdoc_files: []
|
188
|
+
files:
|
189
|
+
- ".gitignore"
|
190
|
+
- ".rspec"
|
191
|
+
- ".travis.yml"
|
192
|
+
- CHANGELOG.md
|
193
|
+
- Gemfile
|
194
|
+
- Gemfile.lock
|
195
|
+
- LICENSE
|
196
|
+
- README.md
|
197
|
+
- Rakefile
|
198
|
+
- bin/drupal-exporter
|
199
|
+
- drupal_exporter.gemspec
|
200
|
+
- drupal_settings/boolean_columns.yml
|
201
|
+
- drupal_settings/drupal_content_types.json
|
202
|
+
- drupal_settings/drupal_settings.yml
|
203
|
+
- lib/cli.rb
|
204
|
+
- lib/configuration.rb
|
205
|
+
- lib/converters/content_types_structure_creator.rb
|
206
|
+
- lib/converters/contentful_model_to_json.rb
|
207
|
+
- lib/drupal/content_type.rb
|
208
|
+
- lib/drupal/export.rb
|
209
|
+
- lib/drupal/file_managed.rb
|
210
|
+
- lib/drupal/tag.rb
|
211
|
+
- lib/drupal/user.rb
|
212
|
+
- lib/drupal/vocabulary.rb
|
213
|
+
- lib/migrator.rb
|
214
|
+
- lib/version.rb
|
215
|
+
- spec/fixtures/database_rows/content_type_article.json
|
216
|
+
- spec/fixtures/database_rows/image.json
|
217
|
+
- spec/fixtures/database_rows/node_content_type_article.json
|
218
|
+
- spec/fixtures/database_rows/node_content_type_blog.json
|
219
|
+
- spec/fixtures/database_rows/tag.json
|
220
|
+
- spec/fixtures/database_rows/user.json
|
221
|
+
- spec/fixtures/database_rows/vocabulary.json
|
222
|
+
- spec/fixtures/drupal/assets/file/file_4.json
|
223
|
+
- spec/fixtures/drupal/entries/article/article_5.json
|
224
|
+
- spec/fixtures/drupal/entries/tag/tag_1.json
|
225
|
+
- spec/fixtures/drupal/entries/user/user_1.json
|
226
|
+
- spec/fixtures/drupal/entries/vocabulary/vocabulary_3.json
|
227
|
+
- spec/fixtures/json_responses/article.json
|
228
|
+
- spec/fixtures/json_responses/image.json
|
229
|
+
- spec/fixtures/json_responses/tag.json
|
230
|
+
- spec/fixtures/json_responses/vocabulary.json
|
231
|
+
- spec/fixtures/settings/boolean_columns.yml
|
232
|
+
- spec/fixtures/settings/drupal_content_types.json
|
233
|
+
- spec/fixtures/settings/drupal_settings.yml
|
234
|
+
- spec/lib/configuration_spec.rb
|
235
|
+
- spec/lib/drupal/content_type_spec.rb
|
236
|
+
- spec/lib/drupal/export_spec.rb
|
237
|
+
- spec/lib/drupal/file_managed_spec.rb
|
238
|
+
- spec/lib/drupal/tag_spec.rb
|
239
|
+
- spec/lib/drupal/user_spec.rb
|
240
|
+
- spec/lib/drupal/vocabulary_spec.rb
|
241
|
+
- spec/spec_helper.rb
|
242
|
+
- spec/support/db_rows_json.rb
|
243
|
+
- spec/support/shared_configuration.rb
|
244
|
+
homepage: https://github.com/contentful/drupal-exporter.rb
|
245
|
+
licenses:
|
246
|
+
- MIT
|
247
|
+
metadata: {}
|
248
|
+
post_install_message:
|
249
|
+
rdoc_options: []
|
250
|
+
require_paths:
|
251
|
+
- lib
|
252
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
253
|
+
requirements:
|
254
|
+
- - ">="
|
255
|
+
- !ruby/object:Gem::Version
|
256
|
+
version: '0'
|
257
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
258
|
+
requirements:
|
259
|
+
- - ">="
|
260
|
+
- !ruby/object:Gem::Version
|
261
|
+
version: '0'
|
262
|
+
requirements: []
|
263
|
+
rubyforge_project:
|
264
|
+
rubygems_version: 2.2.2
|
265
|
+
signing_key:
|
266
|
+
specification_version: 4
|
267
|
+
summary: Exporter for Drupal 7
|
268
|
+
test_files:
|
269
|
+
- spec/fixtures/database_rows/content_type_article.json
|
270
|
+
- spec/fixtures/database_rows/image.json
|
271
|
+
- spec/fixtures/database_rows/node_content_type_article.json
|
272
|
+
- spec/fixtures/database_rows/node_content_type_blog.json
|
273
|
+
- spec/fixtures/database_rows/tag.json
|
274
|
+
- spec/fixtures/database_rows/user.json
|
275
|
+
- spec/fixtures/database_rows/vocabulary.json
|
276
|
+
- spec/fixtures/drupal/assets/file/file_4.json
|
277
|
+
- spec/fixtures/drupal/entries/article/article_5.json
|
278
|
+
- spec/fixtures/drupal/entries/tag/tag_1.json
|
279
|
+
- spec/fixtures/drupal/entries/user/user_1.json
|
280
|
+
- spec/fixtures/drupal/entries/vocabulary/vocabulary_3.json
|
281
|
+
- spec/fixtures/json_responses/article.json
|
282
|
+
- spec/fixtures/json_responses/image.json
|
283
|
+
- spec/fixtures/json_responses/tag.json
|
284
|
+
- spec/fixtures/json_responses/vocabulary.json
|
285
|
+
- spec/fixtures/settings/boolean_columns.yml
|
286
|
+
- spec/fixtures/settings/drupal_content_types.json
|
287
|
+
- spec/fixtures/settings/drupal_settings.yml
|
288
|
+
- spec/lib/configuration_spec.rb
|
289
|
+
- spec/lib/drupal/content_type_spec.rb
|
290
|
+
- spec/lib/drupal/export_spec.rb
|
291
|
+
- spec/lib/drupal/file_managed_spec.rb
|
292
|
+
- spec/lib/drupal/tag_spec.rb
|
293
|
+
- spec/lib/drupal/user_spec.rb
|
294
|
+
- spec/lib/drupal/vocabulary_spec.rb
|
295
|
+
- spec/spec_helper.rb
|
296
|
+
- spec/support/db_rows_json.rb
|
297
|
+
- spec/support/shared_configuration.rb
|