Class: Contentful::Bootstrap::Commands::CreateSpace

Inherits:
Base
  • Object
show all
Defined in:
lib/contentful/bootstrap/commands/create_space.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#no_input, #options, #quiet, #space, #token

Instance Method Summary collapse

Methods inherited from Base

#client

Constructor Details

#initialize(token, space, options = {}) ⇒ CreateSpace

Returns a new instance of CreateSpace.



12
13
14
15
16
17
18
19
20
21
# File 'lib/contentful/bootstrap/commands/create_space.rb', line 12

def initialize(token, space, options = {})
  @template_name = options.fetch(:template, nil)
  @json_template = options.fetch(:json_template, nil)
  @mark_processed = options.fetch(:mark_processed, false)
  @locale = options.fetch(:locale, 'en-US')
  @no_publish = options.fetch(:no_publish, false)
  @environment = 'master' # Can only add content to a new space through the master environment by default

  super(token, space, options)
end

Instance Attribute Details

#json_templateObject (readonly)

Returns the value of attribute json_template.



11
12
13
# File 'lib/contentful/bootstrap/commands/create_space.rb', line 11

def json_template
  @json_template
end

#template_nameObject (readonly)

Returns the value of attribute template_name.



11
12
13
# File 'lib/contentful/bootstrap/commands/create_space.rb', line 11

def template_name
  @template_name
end

Instance Method Details

#runObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/contentful/bootstrap/commands/create_space.rb', line 23

def run
  output "Creating Space '#{@space}'"

  new_space = fetch_space

  output "Space '#{@space}' created!"
  output

  create_template(new_space) unless @template_name.nil?
  create_json_template(new_space) unless @json_template.nil?

  access_token = generate_token(new_space)
  output
  output "Space ID: '#{new_space.id}'"
  output "Access Token: '#{access_token}'"
  output
  output 'You can now insert those values into your configuration blocks'
  output "Manage your content at https://app.contentful.com/spaces/#{new_space.id}"

  new_space
end