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
# File 'lib/contentful/bootstrap/command_runner.rb', line 14

def create_space(space_name, options = {})
  Contentful::Bootstrap::Commands::CreateSpace.new(
    @token, space_name, options
  ).run
end

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



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/contentful/bootstrap/command_runner.rb', line 32

def generate_json(space_id, options = {})
  filename = options.fetch(:filename, nil)
  access_token = options.fetch(:access_token, nil)
  environment = options.fetch(:environment, 'master')
  content_types_only = options.fetch(:content_types_only, false)
  quiet = options.fetch(:quiet, false)
  use_preview = options.fetch(:use_preview, false)
  content_type_ids = options.fetch(:content_type_ids, [])

  raise 'Access Token required' if access_token.nil?

  Contentful::Bootstrap::Commands::GenerateJson.new(
    space_id,
    access_token,
    environment,
    filename,
    content_types_only,
    quiet,
    use_preview,
    content_type_ids
  ).run
end

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



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

def generate_token(space, options = {})
  Contentful::Bootstrap::Commands::GenerateToken.new(
    @token, space, options
  ).run
end

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



20
21
22
23
24
# File 'lib/contentful/bootstrap/command_runner.rb', line 20

def update_space(space_id, options = {})
  Contentful::Bootstrap::Commands::UpdateSpace.new(
    @token, space_id, options
  ).run
end