contentful_bootstrap 1.6.0 → 2.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +26 -0
  3. data/.rubocop_todo.yml +123 -0
  4. data/.travis.yml +6 -0
  5. data/CHANGELOG.md +25 -0
  6. data/Gemfile +1 -0
  7. data/Guardfile +5 -0
  8. data/README.md +40 -14
  9. data/Rakefile +7 -0
  10. data/bin/contentful_bootstrap +33 -22
  11. data/contentful_bootstrap.gemspec +7 -0
  12. data/lib/contentful/bootstrap.rb +7 -5
  13. data/lib/contentful/bootstrap/command_runner.rb +45 -0
  14. data/lib/contentful/bootstrap/commands.rb +3 -168
  15. data/lib/contentful/bootstrap/commands/base.rb +66 -0
  16. data/lib/contentful/bootstrap/commands/create_space.rb +111 -0
  17. data/lib/contentful/bootstrap/commands/generate_json.rb +41 -0
  18. data/lib/contentful/bootstrap/commands/generate_token.rb +52 -0
  19. data/lib/contentful/bootstrap/constants.rb +2 -2
  20. data/lib/contentful/bootstrap/generator.rb +94 -0
  21. data/lib/contentful/bootstrap/server.rb +25 -17
  22. data/lib/contentful/bootstrap/support.rb +3 -2
  23. data/lib/contentful/bootstrap/templates.rb +4 -4
  24. data/lib/contentful/bootstrap/templates/base.rb +51 -30
  25. data/lib/contentful/bootstrap/templates/blog.rb +33 -33
  26. data/lib/contentful/bootstrap/templates/catalogue.rb +103 -103
  27. data/lib/contentful/bootstrap/templates/gallery.rb +55 -56
  28. data/lib/contentful/bootstrap/templates/json_template.rb +22 -16
  29. data/lib/contentful/bootstrap/templates/links.rb +2 -2
  30. data/lib/contentful/bootstrap/templates/links/asset.rb +2 -2
  31. data/lib/contentful/bootstrap/templates/links/base.rb +3 -3
  32. data/lib/contentful/bootstrap/templates/links/entry.rb +2 -2
  33. data/lib/contentful/bootstrap/token.rb +32 -31
  34. data/lib/contentful/bootstrap/version.rb +1 -1
  35. data/spec/contentful/bootstrap/command_runner_spec.rb +111 -0
  36. data/spec/contentful/bootstrap/commands/base_spec.rb +102 -0
  37. data/spec/contentful/bootstrap/commands/create_space_spec.rb +72 -0
  38. data/spec/contentful/bootstrap/commands/generate_json_spec.rb +64 -0
  39. data/spec/contentful/bootstrap/commands/generate_token_spec.rb +82 -0
  40. data/spec/contentful/bootstrap/generator_spec.rb +15 -0
  41. data/spec/contentful/bootstrap/server_spec.rb +154 -0
  42. data/spec/contentful/bootstrap/support_spec.rb +27 -0
  43. data/spec/contentful/bootstrap/templates/base_spec.rb +34 -0
  44. data/spec/contentful/bootstrap/templates/blog_spec.rb +32 -0
  45. data/spec/contentful/bootstrap/templates/catalogue_spec.rb +40 -0
  46. data/spec/contentful/bootstrap/templates/gallery_spec.rb +40 -0
  47. data/spec/contentful/bootstrap/templates/json_template_spec.rb +52 -0
  48. data/spec/contentful/bootstrap/templates/links/asset_spec.rb +23 -0
  49. data/spec/contentful/bootstrap/templates/links/base_spec.rb +31 -0
  50. data/spec/contentful/bootstrap/templates/links/entry_spec.rb +23 -0
  51. data/spec/contentful/bootstrap/token_spec.rb +143 -0
  52. data/spec/fixtures/ini_fixtures/contentfulrc.ini +2 -0
  53. data/spec/fixtures/ini_fixtures/no_global.ini +2 -0
  54. data/spec/fixtures/ini_fixtures/no_token.ini +1 -0
  55. data/spec/fixtures/ini_fixtures/sections.ini +5 -0
  56. data/spec/fixtures/json_fixtures/issue_22.json +77 -0
  57. data/spec/fixtures/json_fixtures/simple.json +34 -0
  58. data/spec/fixtures/json_fixtures/wl1z0pal05vy.json +437 -0
  59. data/spec/fixtures/vcr_fixtures/generate_json.yml +384 -0
  60. data/spec/fixtures/vcr_fixtures/issue_22.yml +2488 -0
  61. data/spec/spec_helper.rb +51 -0
  62. metadata +167 -4
@@ -1,5 +1,5 @@
1
- require "contentful/bootstrap/templates/base"
2
- require "contentful/bootstrap/templates/links"
1
+ require 'contentful/bootstrap/templates/base'
2
+ require 'contentful/bootstrap/templates/links'
3
3
 
4
4
  module Contentful
5
5
  module Bootstrap
@@ -8,88 +8,88 @@ module Contentful
8
8
  def content_types
9
9
  [
10
10
  {
11
- "id" => 'brand',
12
- "name" => 'Brand',
13
- "display_field" => 'name',
14
- "fields" => [
11
+ 'id' => 'brand',
12
+ 'name' => 'Brand',
13
+ 'display_field' => 'name',
14
+ 'fields' => [
15
15
  {
16
- "id" => 'name',
17
- "name" => "Company Name",
18
- "type" => "Symbol"
16
+ 'id' => 'name',
17
+ 'name' => 'Company Name',
18
+ 'type' => 'Symbol'
19
19
  },
20
20
  {
21
- "id" => 'website',
22
- "name" => "Website",
23
- "type" => "Symbol"
21
+ 'id' => 'website',
22
+ 'name' => 'Website',
23
+ 'type' => 'Symbol'
24
24
  },
25
25
  {
26
- "id" => 'logo',
27
- "name" => "Logo",
28
- "type" => "Link",
29
- "link_type" => "Asset"
26
+ 'id' => 'logo',
27
+ 'name' => 'Logo',
28
+ 'type' => 'Link',
29
+ 'link_type' => 'Asset'
30
30
  }
31
31
  ]
32
32
  },
33
33
  {
34
- "id" => 'category',
35
- "name" => 'Category',
36
- "display_field" => 'title',
37
- "fields" => [
34
+ 'id' => 'category',
35
+ 'name' => 'Category',
36
+ 'display_field' => 'title',
37
+ 'fields' => [
38
38
  {
39
- "id" => 'title',
40
- "name" => "Title",
41
- "type" => "Symbol"
39
+ 'id' => 'title',
40
+ 'name' => 'Title',
41
+ 'type' => 'Symbol'
42
42
  },
43
43
  {
44
- "id" => 'description',
45
- "name" => "Description",
46
- "type" => "Text"
44
+ 'id' => 'description',
45
+ 'name' => 'Description',
46
+ 'type' => 'Text'
47
47
  },
48
48
  {
49
- "id" => 'icon',
50
- "name" => "Icon",
51
- "type" => "Link",
52
- "link_type" => "Asset"
49
+ 'id' => 'icon',
50
+ 'name' => 'Icon',
51
+ 'type' => 'Link',
52
+ 'link_type' => 'Asset'
53
53
  }
54
54
  ]
55
55
  },
56
56
  {
57
- "id" => 'product',
58
- "name" => 'Product',
59
- "display_field" => 'name',
60
- "fields" => [
57
+ 'id' => 'product',
58
+ 'name' => 'Product',
59
+ 'display_field' => 'name',
60
+ 'fields' => [
61
61
  {
62
- "id" => 'name',
63
- "name" => "name",
64
- "type" => "Symbol"
62
+ 'id' => 'name',
63
+ 'name' => 'name',
64
+ 'type' => 'Symbol'
65
65
  },
66
66
  {
67
- "id" => 'description',
68
- "name" => "Description",
69
- "type" => "Text"
67
+ 'id' => 'description',
68
+ 'name' => 'Description',
69
+ 'type' => 'Text'
70
70
  },
71
71
  {
72
- "id" => 'image',
73
- "name" => "Image",
74
- "type" => "Link",
75
- "link_type" => "Asset"
72
+ 'id' => 'image',
73
+ 'name' => 'Image',
74
+ 'type' => 'Link',
75
+ 'link_type' => 'Asset'
76
76
  },
77
77
  {
78
- "id" => 'brand',
79
- "name" => "Brand",
80
- "type" => "Link",
81
- "link_type" => "Entry"
78
+ 'id' => 'brand',
79
+ 'name' => 'Brand',
80
+ 'type' => 'Link',
81
+ 'link_type' => 'Entry'
82
82
  },
83
83
  {
84
- "id" => 'category',
85
- "name" => "Category",
86
- "type" => "Link",
87
- "link_type" => "Entry"
84
+ 'id' => 'category',
85
+ 'name' => 'Category',
86
+ 'type' => 'Link',
87
+ 'link_type' => 'Entry'
88
88
  },
89
89
  {
90
- "id" => 'url',
91
- "name" => "Available at",
92
- "type" => "Symbol"
90
+ 'id' => 'url',
91
+ 'name' => 'Available at',
92
+ 'type' => 'Symbol'
93
93
  }
94
94
  ]
95
95
  }
@@ -99,34 +99,34 @@ module Contentful
99
99
  def assets
100
100
  [
101
101
  {
102
- "id" => 'playsam_image',
103
- "title" => 'Playsam',
104
- "file" => create_image('playsam_image', 'https://images.contentful.com/liicpxzmg1q0/4zj1ZOfHgQ8oqgaSKm4Qo2/3be82d54d45b5297e951aee9baf920da/playsam.jpg?h=250&')
102
+ 'id' => 'playsam_image',
103
+ 'title' => 'Playsam',
104
+ 'file' => create_image('playsam_image', 'https://images.contentful.com/liicpxzmg1q0/4zj1ZOfHgQ8oqgaSKm4Qo2/3be82d54d45b5297e951aee9baf920da/playsam.jpg?h=250&')
105
105
  },
106
106
  {
107
- "id" => 'normann_image',
108
- "title" => 'Normann',
109
- "file" => create_image('normann_image', 'https://images.contentful.com/liicpxzmg1q0/3wtvPBbBjiMKqKKga8I2Cu/75c7c92f38f7953a741591d215ad61d4/zJYzDlGk.jpeg?h=250&')
107
+ 'id' => 'normann_image',
108
+ 'title' => 'Normann',
109
+ 'file' => create_image('normann_image', 'https://images.contentful.com/liicpxzmg1q0/3wtvPBbBjiMKqKKga8I2Cu/75c7c92f38f7953a741591d215ad61d4/zJYzDlGk.jpeg?h=250&')
110
110
  },
111
111
  {
112
- "id" => 'toy_image',
113
- "title" => 'Toys',
114
- "file" => create_image('toy_image', 'https://images.contentful.com/liicpxzmg1q0/6t4HKjytPi0mYgs240wkG/866ef53a11af9c6bf5f3808a8ce1aab2/toys_512pxGREY.png?h=250&')
112
+ 'id' => 'toy_image',
113
+ 'title' => 'Toys',
114
+ 'file' => create_image('toy_image', 'https://images.contentful.com/liicpxzmg1q0/6t4HKjytPi0mYgs240wkG/866ef53a11af9c6bf5f3808a8ce1aab2/toys_512pxGREY.png?h=250&')
115
115
  },
116
116
  {
117
- "id" => 'kitchen_image',
118
- "title" => 'Kitchen and Home',
119
- "file" => create_image('kitchen_image', 'https://images.contentful.com/liicpxzmg1q0/6m5AJ9vMPKc8OUoQeoCS4o/ffc20f5a8f2a71cca4801bc9c51b966a/1418244847_Streamline-18-256.png?h=250&')
117
+ 'id' => 'kitchen_image',
118
+ 'title' => 'Kitchen and Home',
119
+ 'file' => create_image('kitchen_image', 'https://images.contentful.com/liicpxzmg1q0/6m5AJ9vMPKc8OUoQeoCS4o/ffc20f5a8f2a71cca4801bc9c51b966a/1418244847_Streamline-18-256.png?h=250&')
120
120
  },
121
121
  {
122
- "id" => 'toy_car',
123
- "title" => 'Playsam Toy Car',
124
- "file" => create_image('toy_car', 'https://images.contentful.com/liicpxzmg1q0/wtrHxeu3zEoEce2MokCSi/acef70d12fe019228c4238aa791bdd48/quwowooybuqbl6ntboz3.jpg?h=250&')
122
+ 'id' => 'toy_car',
123
+ 'title' => 'Playsam Toy Car',
124
+ 'file' => create_image('toy_car', 'https://images.contentful.com/liicpxzmg1q0/wtrHxeu3zEoEce2MokCSi/acef70d12fe019228c4238aa791bdd48/quwowooybuqbl6ntboz3.jpg?h=250&')
125
125
  },
126
126
  {
127
- "id" => 'whiskers',
128
- "title" => 'Normann Whisk Beaters',
129
- "file" => create_image('whiskers', 'https://images.contentful.com/liicpxzmg1q0/10TkaLheGeQG6qQGqWYqUI/d510dde5e575d40288cf75b42383aa53/ryugj83mqwa1asojwtwb.jpg?h=250&')
127
+ 'id' => 'whiskers',
128
+ 'title' => 'Normann Whisk Beaters',
129
+ 'file' => create_image('whiskers', 'https://images.contentful.com/liicpxzmg1q0/10TkaLheGeQG6qQGqWYqUI/d510dde5e575d40288cf75b42383aa53/ryugj83mqwa1asojwtwb.jpg?h=250&')
130
130
  }
131
131
  ]
132
132
  end
@@ -135,50 +135,50 @@ module Contentful
135
135
  {
136
136
  'brand' => [
137
137
  {
138
- "id" => 'playsam',
139
- "name" => 'Playsam, Inc',
140
- "website" => 'http://www.playsam.com',
141
- "logo" => Links::Asset.new('playsam_image')
138
+ 'id' => 'playsam',
139
+ 'name' => 'Playsam, Inc',
140
+ 'website' => 'http://www.playsam.com',
141
+ 'logo' => Links::Asset.new('playsam_image')
142
142
  },
143
143
  {
144
- "id" => 'normann',
145
- "name" => "Normann Copenhagen, Inc",
146
- "website" => 'http://www.normann-copenhagen.com/',
147
- "logo" => Links::Asset.new('normann_image')
144
+ 'id' => 'normann',
145
+ 'name' => 'Normann Copenhagen, Inc',
146
+ 'website' => 'http://www.normann-copenhagen.com/',
147
+ 'logo' => Links::Asset.new('normann_image')
148
148
  }
149
149
  ],
150
150
  'category' => [
151
151
  {
152
- "id" => 'toys',
153
- "title" => 'Toys',
154
- "description" => 'Toys for children',
155
- "icon" => Links::Asset.new('toy_image')
152
+ 'id' => 'toys',
153
+ 'title' => 'Toys',
154
+ 'description' => 'Toys for children',
155
+ 'icon' => Links::Asset.new('toy_image')
156
156
  },
157
157
  {
158
- "id" => 'kitchen',
159
- "title" => 'House and Kitchen',
160
- "description" => 'House and Kitchen accessories',
161
- "icon" => Links::Asset.new('kitchen_image')
158
+ 'id' => 'kitchen',
159
+ 'title' => 'House and Kitchen',
160
+ 'description' => 'House and Kitchen accessories',
161
+ 'icon' => Links::Asset.new('kitchen_image')
162
162
  }
163
163
  ],
164
164
  'product' => [
165
165
  {
166
- "id" => 'playsam_car',
167
- "name" => 'Playsam Streamliner Classic Car, Espresso',
168
- "description" => "A classic Playsam design, the Streamliner Classic Car has been selected as Swedish Design Classic by the Swedish National Museum for its inventive style and sleek surface. It's no wonder that this wooden car has also been a long-standing favorite for children both big and small!",
169
- "image" => Links::Asset.new('toy_car'),
170
- "brand" => Links::Entry.new('playsam'),
171
- "category" => Links::Entry.new('toys'),
172
- "url" => 'http://www.amazon.com/dp/B001R6JUZ2/'
166
+ 'id' => 'playsam_car',
167
+ 'name' => 'Playsam Streamliner Classic Car, Espresso',
168
+ 'description' => 'A classic Playsam design, the Streamliner Classic Car has been selected as Swedish Design Classic by the Swedish National Museum for its inventive style and sleek surface. It\'s no wonder that this wooden car has also been a long-standing favorite for children both big and small!',
169
+ 'image' => Links::Asset.new('toy_car'),
170
+ 'brand' => Links::Entry.new('playsam'),
171
+ 'category' => Links::Entry.new('toys'),
172
+ 'url' => 'http://www.amazon.com/dp/B001R6JUZ2/'
173
173
  },
174
174
  {
175
- "id" => 'whisk_beater',
176
- "name" => 'Whisk Beater',
177
- "description" => "A creative little whisk that comes in 8 different colors. Handy and easy to clean after use. A great gift idea.",
178
- "image" => Links::Asset.new('whiskers'),
179
- "brand" => Links::Entry.new('normann'),
180
- "category" => Links::Entry.new('kitchen'),
181
- "url" => 'http://www.amazon.com/dp/B0081F2CCK/'
175
+ 'id' => 'whisk_beater',
176
+ 'name' => 'Whisk Beater',
177
+ 'description' => 'A creative little whisk that comes in 8 different colors. Handy and easy to clean after use. A great gift idea.',
178
+ 'image' => Links::Asset.new('whiskers'),
179
+ 'brand' => Links::Entry.new('normann'),
180
+ 'category' => Links::Entry.new('kitchen'),
181
+ 'url' => 'http://www.amazon.com/dp/B0081F2CCK/'
182
182
  }
183
183
  ]
184
184
  }
@@ -1,5 +1,5 @@
1
- require "contentful/bootstrap/templates/base"
2
- require "contentful/bootstrap/templates/links"
1
+ require 'contentful/bootstrap/templates/base'
2
+ require 'contentful/bootstrap/templates/links'
3
3
 
4
4
  module Contentful
5
5
  module Bootstrap
@@ -8,58 +8,58 @@ module Contentful
8
8
  def content_types
9
9
  [
10
10
  {
11
- "id" => 'author',
12
- "name" => "Author",
13
- "display_field" => "name",
14
- "fields" => [
11
+ 'id' => 'author',
12
+ 'name' => 'Author',
13
+ 'display_field' => 'name',
14
+ 'fields' => [
15
15
  {
16
- "name" => "Name",
17
- "id" => "name",
18
- "type" => "Symbol"
16
+ 'name' => 'Name',
17
+ 'id' => 'name',
18
+ 'type' => 'Symbol'
19
19
  }
20
20
  ]
21
21
  },
22
22
  {
23
- "id" => 'image',
24
- "name" => 'Image',
25
- "display_field" => 'title',
26
- "fields" => [
23
+ 'id' => 'image',
24
+ 'name' => 'Image',
25
+ 'display_field' => 'title',
26
+ 'fields' => [
27
27
  {
28
- "id" => 'title',
29
- "name" => 'Title',
30
- "type" => 'Symbol'
28
+ 'id' => 'title',
29
+ 'name' => 'Title',
30
+ 'type' => 'Symbol'
31
31
  },
32
32
  {
33
- "id" => 'photo',
34
- "name" => 'Photo',
35
- "type" => 'Link',
36
- "link_type" => 'Asset'
33
+ 'id' => 'photo',
34
+ 'name' => 'Photo',
35
+ 'type' => 'Link',
36
+ 'link_type' => 'Asset'
37
37
  }
38
38
  ]
39
39
  },
40
40
  {
41
- "id" => 'gallery',
42
- "name" => 'Gallery',
43
- "display_field" => 'title',
44
- "fields" => [
41
+ 'id' => 'gallery',
42
+ 'name' => 'Gallery',
43
+ 'display_field' => 'title',
44
+ 'fields' => [
45
45
  {
46
- "id" => 'title',
47
- "name" => 'Title',
48
- "type" => 'Symbol'
46
+ 'id' => 'title',
47
+ 'name' => 'Title',
48
+ 'type' => 'Symbol'
49
49
  },
50
50
  {
51
- "id" => 'author',
52
- "name" => 'Author',
53
- "type" => 'Link',
54
- "link_type" => 'Entry'
51
+ 'id' => 'author',
52
+ 'name' => 'Author',
53
+ 'type' => 'Link',
54
+ 'link_type' => 'Entry'
55
55
  },
56
56
  {
57
- "id" => 'images',
58
- "name" => 'Images',
59
- "type" => 'Array',
60
- "items" => {
61
- "type" => 'Link',
62
- "link_type" => 'Entry'
57
+ 'id' => 'images',
58
+ 'name' => 'Images',
59
+ 'type' => 'Array',
60
+ 'items' => {
61
+ 'type' => 'Link',
62
+ 'link_type' => 'Entry'
63
63
  }
64
64
  }
65
65
  ]
@@ -70,14 +70,14 @@ module Contentful
70
70
  def assets
71
71
  [
72
72
  {
73
- "id" => 'pie',
74
- "title" => 'Pie in the Sky',
75
- "file" => create_image('pie', 'https://c2.staticflickr.com/6/5245/5335909339_d307a7cbcf_b.jpg')
73
+ 'id' => 'pie',
74
+ 'title' => 'Pie in the Sky',
75
+ 'file' => create_image('pie', 'https://c2.staticflickr.com/6/5245/5335909339_d307a7cbcf_b.jpg')
76
76
  },
77
77
  {
78
- "id" => 'flower',
79
- "title" => 'The Flower',
80
- "file" => create_image('flower', 'http://c2.staticflickr.com/4/3922/15045568809_b24591e318_b.jpg')
78
+ 'id' => 'flower',
79
+ 'title' => 'The Flower',
80
+ 'file' => create_image('flower', 'http://c2.staticflickr.com/4/3922/15045568809_b24591e318_b.jpg')
81
81
  }
82
82
  ]
83
83
  end
@@ -86,28 +86,28 @@ module Contentful
86
86
  {
87
87
  'author' => [
88
88
  {
89
- "id" => 'dave',
90
- "name" => 'Dave'
89
+ 'id' => 'dave',
90
+ 'name' => 'Dave'
91
91
  }
92
92
  ],
93
93
  'image' => [
94
94
  {
95
- "id" => 'pie_entry',
96
- "title" => 'A Pie in the Sky',
97
- "photo" => Links::Asset.new('pie')
95
+ 'id' => 'pie_entry',
96
+ 'title' => 'A Pie in the Sky',
97
+ 'photo' => Links::Asset.new('pie')
98
98
  },
99
99
  {
100
- "id" => 'flower_entry',
101
- "title" => 'The Flower',
102
- "photo" => Links::Asset.new('flower')
100
+ 'id' => 'flower_entry',
101
+ 'title' => 'The Flower',
102
+ 'photo' => Links::Asset.new('flower')
103
103
  }
104
104
  ],
105
105
  'gallery' => [
106
106
  {
107
- "id" => 'gallery',
108
- "title" => 'Photo Gallery',
109
- "author" => Links::Entry.new('dave'),
110
- "images" => [Links::Entry.new('pie_entry'), Links::Entry.new('flower_entry')]
107
+ 'id' => 'gallery',
108
+ 'title' => 'Photo Gallery',
109
+ 'author' => Links::Entry.new('dave'),
110
+ 'images' => [Links::Entry.new('pie_entry'), Links::Entry.new('flower_entry')]
111
111
  }
112
112
  ]
113
113
  }
@@ -116,4 +116,3 @@ module Contentful
116
116
  end
117
117
  end
118
118
  end
119
-
@@ -1,6 +1,6 @@
1
- require "json"
2
- require "contentful/bootstrap/templates/base"
3
- require "contentful/bootstrap/templates/links"
1
+ require 'json'
2
+ require 'contentful/bootstrap/templates/base'
3
+ require 'contentful/bootstrap/templates/links'
4
4
 
5
5
  module Contentful
6
6
  module Bootstrap
@@ -15,7 +15,7 @@ module Contentful
15
15
  end
16
16
 
17
17
  def content_types
18
- json.fetch("content_types", [])
18
+ json.fetch('content_types', [])
19
19
  end
20
20
 
21
21
  def assets
@@ -27,16 +27,17 @@ module Contentful
27
27
  end
28
28
 
29
29
  private
30
+
30
31
  def json
31
- @json ||= JSON.parse(File.read(@file))
32
+ @json ||= ::JSON.parse(::File.read(@file))
32
33
  end
33
34
 
34
35
  def process_assets
35
- unprocessed_assets = json.fetch("assets", [])
36
+ unprocessed_assets = json.fetch('assets', [])
36
37
  unprocessed_assets.map do |asset|
37
- asset["file"] = create_image(
38
- asset["file"]["filename"],
39
- asset["file"]["url"]
38
+ asset['file'] = create_image(
39
+ asset['file']['filename'],
40
+ asset['file']['url']
40
41
  )
41
42
  asset
42
43
  end
@@ -44,7 +45,7 @@ module Contentful
44
45
 
45
46
  def process_entries
46
47
  processed_entries = {}
47
- unprocessed_entries = json.fetch("entries", {})
48
+ unprocessed_entries = json.fetch('entries', {})
48
49
  unprocessed_entries.each do |content_type_id, entry_list|
49
50
  entries_for_content_type = []
50
51
  entry_list.each do |entry|
@@ -52,8 +53,8 @@ module Contentful
52
53
  link_fields = []
53
54
 
54
55
  entry.each do |field, value|
55
- link_fields << field if value.is_a? Hash
56
- array_fields << field if value.is_a? Array
56
+ link_fields << field if value.is_a? ::Hash
57
+ array_fields << field if value.is_a? ::Array
57
58
  end
58
59
 
59
60
  link_fields.each do |lf|
@@ -62,7 +63,7 @@ module Contentful
62
63
 
63
64
  array_fields.each do |af|
64
65
  entry[af].map! do |item|
65
- if item.is_a? Hash
66
+ if item.is_a? ::Hash
66
67
  create_link(item)
67
68
  else
68
69
  item
@@ -80,9 +81,14 @@ module Contentful
80
81
  end
81
82
 
82
83
  def create_link(link_properties)
83
- link_type = link_properties["link_type"].capitalize
84
- id = link_properties["id"]
85
- Object.const_get("Contentful::Bootstrap::Templates::Links::#{link_type}").new(id)
84
+ link_type = link_properties['link_type'].capitalize
85
+ id = link_properties['id']
86
+ case link_type
87
+ when 'Entry'
88
+ Contentful::Bootstrap::Templates::Links::Entry.new(id)
89
+ when 'Asset'
90
+ Contentful::Bootstrap::Templates::Links::Asset.new(id)
91
+ end
86
92
  end
87
93
  end
88
94
  end