Class: Contentful::Bootstrap::CommandRunner

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config_path = '') ⇒ CommandRunner

Returns a new instance of CommandRunner.



9
10
11
12
# File 'lib/contentful/bootstrap/command_runner.rb', line 9

def initialize(config_path = '')
  @config_path = config_path
  @token = Token.new(config_path)
end

Instance Attribute Details

#config_pathObject (readonly)

Returns the value of attribute config_path.



7
8
9
# File 'lib/contentful/bootstrap/command_runner.rb', line 7

def config_path
  @config_path
end

#tokenObject (readonly)

Returns the value of attribute token.



7
8
9
# File 'lib/contentful/bootstrap/command_runner.rb', line 7

def token
  @token
end

Instance Method Details

#create_space(space_name, options = {}) ⇒ Object



14
15
16
17
18
19
20
21
22
# File 'lib/contentful/bootstrap/command_runner.rb', line 14

def create_space(space_name, options = {})
  template_name = options.fetch(:template, nil)
  json_template = options.fetch(:json_template, nil)
  trigger_oauth = options.fetch(:trigger_oauth, true)

  Contentful::Bootstrap::Commands::CreateSpace.new(
    @token, space_name, template_name, json_template, trigger_oauth
  ).run
end

#generate_json(space_id, options = {}) ⇒ Object



33
34
35
36
37
38
39
40
41
42
# File 'lib/contentful/bootstrap/command_runner.rb', line 33

def generate_json(space_id, options = {})
  filename = options.fetch(:filename, nil)
  access_token = options.fetch(:access_token, nil)

  fail 'Access Token required' if access_token.nil?

  Contentful::Bootstrap::Commands::GenerateJson.new(
    space_id, access_token, filename
  ).run
end

#generate_token(space, options = {}) ⇒ Object



24
25
26
27
28
29
30
31
# File 'lib/contentful/bootstrap/command_runner.rb', line 24

def generate_token(space, options = {})
  token_name = options.fetch(:name, 'Bootstrap Token')
  trigger_oauth = options.fetch(:trigger_oauth, true)

  Contentful::Bootstrap::Commands::GenerateToken.new(
    @token, space, token_name, trigger_oauth
  ).run
end