Class: Contentful::Bootstrap::CommandRunner
- Inherits:
-
Object
- Object
- Contentful::Bootstrap::CommandRunner
- Defined in:
- lib/contentful/bootstrap/command_runner.rb
Instance Attribute Summary collapse
-
#config_path ⇒ Object
readonly
Returns the value of attribute config_path.
-
#token ⇒ Object
readonly
Returns the value of attribute token.
Instance Method Summary collapse
- #create_space(space_name, options = {}) ⇒ Object
- #generate_json(space_id, options = {}) ⇒ Object
- #generate_token(space, options = {}) ⇒ Object
-
#initialize(config_path = '') ⇒ CommandRunner
constructor
A new instance of CommandRunner.
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_path ⇒ Object (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 |
#token ⇒ Object (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, = {}) template_name = .fetch(:template, nil) json_template = .fetch(:json_template, nil) trigger_oauth = .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, = {}) filename = .fetch(:filename, nil) access_token = .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, = {}) token_name = .fetch(:name, 'Bootstrap Token') trigger_oauth = .fetch(:trigger_oauth, true) Contentful::Bootstrap::Commands::GenerateToken.new( @token, space, token_name, trigger_oauth ).run end |