Class: ContentfulBootstrap::Commands

Inherits:
Object
  • Object
show all
Includes:
Support
Defined in:
lib/contentful_bootstrap/commands.rb

Instance Method Summary collapse

Methods included from Support

#silence_stderr

Instance Method Details

#create_space(space_name, template_name = nil) ⇒ Object



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

def create_space(space_name, template_name = nil)
  management_client_init

  puts "Creating Space '#{space_name}'"
  space = Contentful::Management::Space.create(name: space_name)
  puts "Space '#{space_name}' created!"

  return if template_name.nil?

  if templates.has_key? template_name.to_sym
    puts "Creating Template '#{template_name}'"

    templates[template_name.to_sym].new(space).run
    puts "Template '#{template_name}' created!"
  else
    puts "Template '#{template_name}' not found. Valid templates are '#{templates.keys.map(&:to_s).join('\', \'')}'"
  end
end

#init(space_name, template_name = nil) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/contentful_bootstrap/commands.rb', line 13

def init(space_name, template_name = nil)
  if !Token.present?
    puts "A new tab on your browser will open for requesting OAuth permissions"
    get_token
    puts "OAuth permissions successfully saved, your OAuth token is present in '.contentful_token'"
  else
    puts "OAuth token found, moving on!"
  end

  create_space(space_name, template_name)
end