Class: Contentful::Bootstrap::Templates::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/contentful/bootstrap/templates/base.rb

Direct Known Subclasses

Blog, Catalogue, Gallery, JsonTemplate

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(space, environment_id = 'master', quiet = false, skip_content_types = false, no_publish = false) ⇒ Base

Returns a new instance of Base.



11
12
13
14
15
16
# File 'lib/contentful/bootstrap/templates/base.rb', line 11

def initialize(space, environment_id = 'master', quiet = false, skip_content_types = false, no_publish = false)
  @environment = space.environments.find(environment_id)
  @quiet = quiet
  @skip_content_types = skip_content_types
  @no_publish = no_publish
end

Instance Attribute Details

#environmentObject (readonly)

Returns the value of attribute environment.



9
10
11
# File 'lib/contentful/bootstrap/templates/base.rb', line 9

def environment
  @environment
end

#skip_content_typesObject (readonly)

Returns the value of attribute skip_content_types.



9
10
11
# File 'lib/contentful/bootstrap/templates/base.rb', line 9

def skip_content_types
  @skip_content_types
end

Instance Method Details

#after_runObject



45
# File 'lib/contentful/bootstrap/templates/base.rb', line 45

def after_run; end

#assetsObject



41
42
43
# File 'lib/contentful/bootstrap/templates/base.rb', line 41

def assets
  []
end

#content_typesObject



33
34
35
# File 'lib/contentful/bootstrap/templates/base.rb', line 33

def content_types
  []
end

#entriesObject



37
38
39
# File 'lib/contentful/bootstrap/templates/base.rb', line 37

def entries
  {}
end

#runObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/contentful/bootstrap/templates/base.rb', line 18

def run
  create_content_types unless skip_content_types
  create_assets
  create_entries

  after_run
rescue Contentful::Management::Error => e
  error = e.error
  output "Error at: #{error[:url]}"
  output "Message: #{error[:message]}"
  output "Details: #{error[:details]}"

  raise e
end