contentful-importer 0.0.1 → 0.0.2

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: 5b4cb5b28ec76176d942746f1e3d0c1062acbb39
4
- data.tar.gz: e214eff208d733e53483a1397d5f12cbadbdb5a9
3
+ metadata.gz: b73728474014c30ccd464ed1d5cf924709ab305c
4
+ data.tar.gz: 09ce5c3def7d50dd13817c754f0e5e8819ca10a5
5
5
  SHA512:
6
- metadata.gz: c045429597f9113ee8dc58678b8d8fdea072fe9f17447d2d49ef28c1ead138c2f393294d542874dd80e418f764b40a0c419ebeae2729c11f09daea19aecfef79
7
- data.tar.gz: 8f889a25905fa8e8903aad4961793e1f16ae17de1f82f028ed70bd8042d0b0f6d811e5fc3f694ad6da95b2d4a232e1d15e8bed7d2d96bfdc7c1a55232f5b6bd7
6
+ metadata.gz: 1c863bfd32bec39e6c64b437bf84053fa0bd6505e20f42d39a7777a997a7ac575c6ebccf3b7988da8b2b58d692cb4b770af3346c822bdb4222cae2183c9ffed2
7
+ data.tar.gz: a76e0c297f18bd96796e859470412a08dbd041f006725c7da4146ceee43cb89d0023c09ac36a109d5d31e6d240b5f9c9937b99249d2b123b1b977ef9e127c135
data/CHANGELOG.md CHANGED
@@ -1,4 +1,9 @@
1
1
  # Change Log
2
+
3
+ ## 0.0.2
4
+ ### Added
5
+ * Read contentType and description from asset JSON files, falling back to contentType inference from the asset URL.
6
+
2
7
  ## 0.0.1
3
8
  ### Other
4
9
  * Initial release
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- contentful-importer (0.0.1)
4
+ contentful-importer (0.0.2)
5
5
  activesupport (~> 4.1)
6
6
  api_cache (~> 0.3.0)
7
7
  contentful-management (~> 0.5.0)
@@ -14,7 +14,7 @@ PATH
14
14
  GEM
15
15
  remote: https://rubygems.org/
16
16
  specs:
17
- activesupport (4.2.0)
17
+ activesupport (4.2.1)
18
18
  i18n (~> 0.7)
19
19
  json (~> 1.7, >= 1.7.7)
20
20
  minitest (~> 5.1)
@@ -31,10 +31,10 @@ GEM
31
31
  docile (1.1.5)
32
32
  escort (0.4.0)
33
33
  nesty
34
- form_data (0.1.0)
35
- http (0.7.1)
36
- form_data (~> 0.1.0)
34
+ http (0.7.3)
35
+ http-form_data (~> 1.0.0)
37
36
  http_parser.rb (~> 0.6.0)
37
+ http-form_data (1.0.0)
38
38
  http_parser.rb (0.6.0)
39
39
  i18n (0.7.0)
40
40
  json (1.8.2)
@@ -65,7 +65,7 @@ GEM
65
65
  multi_json (~> 1.0)
66
66
  simplecov-html (~> 0.8.0)
67
67
  simplecov-html (0.8.0)
68
- thread_safe (0.3.4)
68
+ thread_safe (0.3.5)
69
69
  tzinfo (1.2.2)
70
70
  thread_safe (~> 0.1)
71
71
  vcr (2.9.3)
data/README.md CHANGED
@@ -9,9 +9,9 @@ You can use one of the following tools to extract your content and make it ready
9
9
 
10
10
  #### Available exporters
11
11
 
12
- - [Database](https://github.com/contentful/database-adapter)
13
- - [Wordpress](https://github.com/contentful/wordpress-adapter)
14
- - [Drupal](https://github.com/contentful/drupal-adapter)
12
+ - [Database](https://github.com/contentful/database-exporter.rb)
13
+ - [Wordpress](https://github.com/contentful/wordpress-exporter.rb)
14
+ - [Drupal](https://github.com/contentful/drupal-exporter.rb)
15
15
 
16
16
 
17
17
  ## Installation
@@ -85,9 +85,10 @@ module Contentful
85
85
  def import_asset(asset_attributes)
86
86
  logger.info "Import asset - #{asset_attributes['id']} "
87
87
  asset_title = asset_attributes['name'].present? ? asset_attributes['name'] : asset_attributes['id']
88
+ asset_description = asset_attributes['description'].present? ? asset_attributes['description'] : ''
88
89
  asset_file = create_asset_file(asset_title, asset_attributes)
89
90
  space = Contentful::Management::Space.find(config.config['space_id'])
90
- asset = space.assets.create(id: "#{asset_attributes['id']}", title: "#{asset_title}", description: '', file: asset_file)
91
+ asset = space.assets.create(id: "#{asset_attributes['id']}", title: "#{asset_title}", description: asset_description, file: asset_file)
91
92
  asset_status(asset, asset_attributes)
92
93
  end
93
94
 
@@ -376,7 +377,7 @@ module Contentful
376
377
  end
377
378
 
378
379
  def file_content_type(params)
379
- MimeContentType::EXTENSION_LIST[File.extname(params['url'])]
380
+ params['contentType'].present? ? params['contentType'] : MimeContentType::EXTENSION_LIST[File.extname(params['url'])]
380
381
  end
381
382
 
382
383
  def format_json(item)
data/lib/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Version
2
- VERSION = '0.0.1'
2
+ VERSION = '0.0.2'
3
3
  end
@@ -22,6 +22,16 @@ module Contentful
22
22
  expect(file).to be_a Contentful::Management::File
23
23
  end
24
24
 
25
+ it 'gets asset content type from params' do
26
+ file = @importer.create_asset_file('title', {'url' => 'www.example.com/image.jpg?withoutextension', 'contentType' => 'image/jpeg'})
27
+ expect(file.properties[:contentType]).to eq'image/jpeg'
28
+ end
29
+
30
+ it 'gets asset content type from params' do
31
+ file = @importer.create_asset_file('title', {'url' => 'www.example.com/image.jpg'})
32
+ expect(file.properties[:contentType]).to eq'image/jpeg'
33
+ end
34
+
25
35
  it 'get_id' do
26
36
  id = @importer.send(:get_id, {'id' => 'name.png'})
27
37
  expect(id).to eq 'name.png'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: contentful-importer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Contentful GmbH (Andreas Tiefenthaler)
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-28 00:00:00.000000000 Z
11
+ date: 2015-03-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: http