contentful-database-importer 0.2.0 → 0.3.0

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: 452224245e7a1c58fdb80466f7beef6911546e4d
4
- data.tar.gz: 7f860c92ea18230ecc8a7a50b7a39fc6be06fe32
3
+ metadata.gz: 0302793d39ecf33e81c86cafe39e6125a5851c75
4
+ data.tar.gz: 3a24e01de0daf7d481a2bd13f0c2052bd3b0b880
5
5
  SHA512:
6
- metadata.gz: faa9477146f720378be62b5299ea633e4bec319ac930c181138ff47bf7f9d10e2837736bbd2f0bd4895350cf424ee0c7709a5dfad9613df8ab0db314e5698d62
7
- data.tar.gz: 30589e531b05f151f1b6e66a74f527cdcab762579fd72ef6af03818e307fce78c1aae941fdef7874bd43ef7d6eed2d5f2b931fd43cc698e0e7d78b0542beef6a
6
+ metadata.gz: e042169712b3bd6c3069e2b5f16ab88b58080610f2029bdc52e7b663c37e363c2e72e65be9864448875fcab0fe1d2eaae85f5c12aacdc06dbb9b27459e685550
7
+ data.tar.gz: 9e32f719aaf1337a003a471b2cda2b215d74ad28d2bf297f880124b5242c9deb3069c675bf09841d2d91d75a7da94eba200f045d562e6b280033a8ce90d00cdc
data/.rubocop.yml ADDED
@@ -0,0 +1,13 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2017-01-30 13:40:58 -0300 using RuboCop version 0.47.1.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 6
10
+ # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
11
+ # URISchemes: http, https
12
+ Metrics/LineLength:
13
+ Max: 100
data/CHANGELOG.md CHANGED
@@ -2,6 +2,17 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 0.3.0
6
+
7
+ ### Changed
8
+ * Updated Contentful Bootstrap Version
9
+
10
+ ### Fixed
11
+ * Fix Rubocop Offenses
12
+
13
+ ### Added
14
+ * Support for `:object` field type
15
+
5
16
  ## 0.2.0
6
17
 
7
18
  ### Added
data/README.md CHANGED
@@ -18,6 +18,10 @@ Contentful offers tools for managing editorial teams and enabling cooperation be
18
18
  you to generate a JSON file that's a valid [`contentful_bootstrap`](https://github.com/contentful/contentful-bootstrap.rb) JSON Template,
19
19
  or directly import to Contentful, creating a new space and using your data to populate the content.
20
20
 
21
+ ## Requirements
22
+
23
+ * Ruby
24
+ * A Relational Database
21
25
 
22
26
  ## Installation
23
27
 
@@ -41,6 +45,14 @@ source 'https://rubygems.org'
41
45
  gem 'contentful-database-importer'
42
46
  ```
43
47
 
48
+ * Add to your _`Gemfile`_ the handler specific to your database (e.g.):
49
+
50
+ ```ruby
51
+ gem 'pg' # if using Postgres
52
+ gem 'sqlite3' # if using SQLite
53
+ gem 'mysql' # if using MySQL
54
+ ```
55
+
44
56
  * Create your importer file, for example _`import.rb`_:
45
57
 
46
58
  ```ruby
@@ -143,7 +155,7 @@ The options are:
143
155
  - `:boolean`: Boolean.
144
156
  - `:location`: Geographical Location (can be coerced from a String, Hash or Array.)
145
157
  - `:date`: An ISO8601 Date (can be coerced from a Date/DateTime object or String).
146
- - `:object`: A JSON Object. _Currently not supported_
158
+ - `:object`: A JSON Object.
147
159
  - `:asset`: A File description. A String containing the file URL needs to be provided.
148
160
  - `:array`: An Array of elements.
149
161
 
@@ -19,8 +19,7 @@ Gem::Specification.new do |spec|
19
19
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
20
  spec.require_paths = ["lib"]
21
21
 
22
- spec.add_dependency 'contentful_bootstrap', '~> 3.0'
23
- spec.add_dependency 'contentful-management', '~> 0.9'
22
+ spec.add_dependency 'contentful_bootstrap', '~> 3.5'
24
23
  spec.add_dependency 'sequel', '~> 4.39'
25
24
  spec.add_dependency 'base62-rb'
26
25
  spec.add_dependency 'mimemagic'
@@ -23,11 +23,8 @@ module Contentful
23
23
  end
24
24
 
25
25
  def find_on_entry(entry_data, match)
26
- if entry_data.excluded_fields.key?(match)
27
- return entry_data.excluded_fields[match]
28
- elsif entry_data.bootstrap_fields.key?(match)
29
- return entry_data.bootstrap_fields[match]
30
- end
26
+ return entry_data.excluded_fields[match] if entry_data.excluded_fields.key?(match)
27
+ return entry_data.bootstrap_fields[match] if entry_data.bootstrap_fields.key?(match)
31
28
 
32
29
  raise "Template could not be resolved, #{match} not found."
33
30
  end
@@ -67,9 +67,7 @@ module Contentful
67
67
 
68
68
  merge_entries(entry_definition, content_type_definition, result)
69
69
 
70
- result[:assets].concat(
71
- entry.associated_assets
72
- ) unless entry.associated_assets.empty?
70
+ result[:assets].concat(entry.associated_assets) unless entry.associated_assets.empty?
73
71
 
74
72
  result[:entries][content_type_definition[:id]] << entry_definition
75
73
  end
@@ -79,9 +79,11 @@ module Contentful
79
79
  end
80
80
 
81
81
  def id
82
- self.class.id_generator = IdGenerator::Base.new(
83
- self.class.default_generator_options
84
- ) if self.class.id_generator.nil?
82
+ if self.class.id_generator.nil?
83
+ self.class.id_generator = IdGenerator::Base.new(
84
+ self.class.default_generator_options
85
+ )
86
+ end
85
87
 
86
88
  self.class.id_generator.run(self, index)
87
89
  end
@@ -32,10 +32,7 @@ module Contentful
32
32
  end
33
33
 
34
34
  def items_type(field_data)
35
- return {
36
- type: 'Link',
37
- linkType: array_link_type(field_data)
38
- } if array_link?(field_data)
35
+ return { type: 'Link', linkType: array_link_type(field_data) } if array_link?(field_data)
39
36
 
40
37
  type = definition_type(field_data[:item_type])
41
38
 
@@ -88,9 +85,7 @@ module Contentful
88
85
  definition = basic_field_definition(field_data)
89
86
 
90
87
  definition[:type] = 'Array' if array?(field_data)
91
- definition[:linkType] = link_type(
92
- field_data[:type]
93
- ) if link_type?(field_data)
88
+ definition[:linkType] = link_type(field_data[:type]) if link_type?(field_data)
94
89
  definition[:items] = items_type(field_data) if array?(field_data)
95
90
 
96
91
  definition
@@ -79,8 +79,10 @@ module Contentful
79
79
  end
80
80
  end
81
81
 
82
- def coerce_object(*)
83
- raise 'Not yet supported by Contentful Bootstrap'
82
+ def coerce_object(value)
83
+ return value if value.is_a?(::Hash)
84
+
85
+ raise "Can't coerce #{value} to JSON Object"
84
86
  end
85
87
 
86
88
  def create_associated_asset(name, value)
@@ -29,10 +29,7 @@ module Contentful
29
29
  def prepare_field(database_name, options)
30
30
  field = prepare_standard_field_options(database_name, options)
31
31
  field[:item_type] = options.fetch(:item_type) if field[:type] == :array
32
- fetch_relationship_options(
33
- field,
34
- options
35
- ) if options.fetch(:relationship, false)
32
+ fetch_relationship_options(field, options) if options.fetch(:relationship, false)
36
33
 
37
34
  field
38
35
  end
@@ -4,10 +4,12 @@ module Contentful
4
4
  module ResourceRelationships
5
5
  def fetch_relations(relationship_field_definition)
6
6
  relations = [:many, :one, :through]
7
- return send(
8
- "fetch_#{relationship_field_definition[:relationship]}".to_sym,
9
- relationship_field_definition
10
- ) if relations.include?(relationship_field_definition[:relationship])
7
+ if relations.include?(relationship_field_definition[:relationship])
8
+ return send(
9
+ "fetch_#{relationship_field_definition[:relationship]}".to_sym,
10
+ relationship_field_definition
11
+ )
12
+ end
11
13
 
12
14
  raise 'Invalid Relationship type'
13
15
  end
@@ -1,5 +1,5 @@
1
1
  module Contentful
2
2
  module DatabaseImporter
3
- VERSION = '0.2.0'.freeze
3
+ VERSION = '0.3.0'.freeze
4
4
  end
5
5
  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.2.0
4
+ version: 0.3.0
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: 2016-11-15 00:00:00.000000000 Z
11
+ date: 2017-01-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: contentful_bootstrap
@@ -16,28 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '3.0'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '3.0'
27
- - !ruby/object:Gem::Dependency
28
- name: contentful-management
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '0.9'
19
+ version: '3.5'
34
20
  type: :runtime
35
21
  prerelease: false
36
22
  version_requirements: !ruby/object:Gem::Requirement
37
23
  requirements:
38
24
  - - "~>"
39
25
  - !ruby/object:Gem::Version
40
- version: '0.9'
26
+ version: '3.5'
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: sequel
43
29
  requirement: !ruby/object:Gem::Requirement
@@ -215,6 +201,7 @@ extra_rdoc_files: []
215
201
  files:
216
202
  - ".gitignore"
217
203
  - ".rspec"
204
+ - ".rubocop.yml"
218
205
  - ".travis.yml"
219
206
  - CHANGELOG.md
220
207
  - CODE_OF_CONDUCT.md