Class: Contentful::Bootstrap::Generator
- Inherits:
- 
      Object
      
        - Object
- Contentful::Bootstrap::Generator
 
- Defined in:
- lib/contentful/bootstrap/generator.rb
Constant Summary collapse
- DELIVERY_API_URL =
- 'cdn.contentful.com'.freeze 
- PREVIEW_API_URL =
- 'preview.contentful.com'.freeze 
Instance Attribute Summary collapse
- 
  
    
      #client  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    Returns the value of attribute client. 
- 
  
    
      #content_types_only  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    Returns the value of attribute content_types_only. 
Instance Method Summary collapse
- #generate_json ⇒ Object
- 
  
    
      #initialize(space_id, access_token, content_types_only, use_preview)  ⇒ Generator 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    A new instance of Generator. 
Constructor Details
#initialize(space_id, access_token, content_types_only, use_preview) ⇒ Generator
Returns a new instance of Generator.
| 15 16 17 18 19 20 21 22 23 24 | # File 'lib/contentful/bootstrap/generator.rb', line 15 def initialize(space_id, access_token, content_types_only, use_preview) @client = Contentful::Client.new( access_token: access_token, space: space_id, application_name: 'bootstrap', application_version: ::Contentful::Bootstrap::VERSION, api_url: use_preview ? PREVIEW_API_URL : DELIVERY_API_URL ) @content_types_only = content_types_only end | 
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
| 13 14 15 | # File 'lib/contentful/bootstrap/generator.rb', line 13 def client @client end | 
#content_types_only ⇒ Object (readonly)
Returns the value of attribute content_types_only.
| 13 14 15 | # File 'lib/contentful/bootstrap/generator.rb', line 13 def content_types_only @content_types_only end | 
Instance Method Details
#generate_json ⇒ Object
| 26 27 28 29 30 31 32 33 | # File 'lib/contentful/bootstrap/generator.rb', line 26 def generate_json template = {} template['version'] = Contentful::Bootstrap.major_version template['contentTypes'] = content_types template['assets'] = assets template['entries'] = entries JSON.pretty_generate(template) end |