Class: Contentful::Bootstrap::Commands::Base

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

Direct Known Subclasses

CreateSpace, GenerateToken, UpdateSpace

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Base.



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

def initialize(token, space, options = {})
  trigger_oauth = options.fetch(:trigger_oauth, true)

  @token = token
  @options = options
  @quiet = options.fetch(:quiet, false)
  @no_input = options.fetch(:no_input, false)

  configuration if trigger_oauth
  client if trigger_oauth
  @space = space
end

Instance Attribute Details

#no_inputObject (readonly)

Returns the value of attribute no_input.



10
11
12
# File 'lib/contentful/bootstrap/commands/base.rb', line 10

def no_input
  @no_input
end

#optionsObject (readonly)

Returns the value of attribute options.



10
11
12
# File 'lib/contentful/bootstrap/commands/base.rb', line 10

def options
  @options
end

#quietObject (readonly)

Returns the value of attribute quiet.



10
11
12
# File 'lib/contentful/bootstrap/commands/base.rb', line 10

def quiet
  @quiet
end

#spaceObject (readonly)

Returns the value of attribute space.



10
11
12
# File 'lib/contentful/bootstrap/commands/base.rb', line 10

def space
  @space
end

#tokenObject (readonly)

Returns the value of attribute token.



10
11
12
# File 'lib/contentful/bootstrap/commands/base.rb', line 10

def token
  @token
end

Instance Method Details

#clientObject



29
30
31
32
33
34
35
36
37
# File 'lib/contentful/bootstrap/commands/base.rb', line 29

def client
  @client ||= ::Contentful::Management::Client.new(
    @token.read,
    default_locale: options.fetch(:locale, 'en-US'),
    raise_errors: true,
    application_name: 'bootstrap',
    application_version: ::Contentful::Bootstrap::VERSION
  )
end

#runObject



25
26
27
# File 'lib/contentful/bootstrap/commands/base.rb', line 25

def run
  raise 'must implement'
end