### Home Classes Methods

### In Files

- lib/gherkin/formatter/json_formatter.rb

### Parent

Object

### Methods

- ::new
- #background
- #eof
- #examples
- #feature
- #scenario
- #scenario_outline
- #step

### Included Modules

- Gherkin::Rubify

### Files

- LICENSE
- README.rdoc
- meta.txt
- root.txt
- steps.txt
- README.rdoc

### Class/Module Index

Quicksearch

- Gherkin
- Gherkin::CLexer
- Gherkin::Cli
- Gherkin::Cli::Main
- Gherkin::Formatter
- Gherkin::Formatter::Argument
- Gherkin::Formatter::Colors
- Gherkin::Formatter::Escaping
- Gherkin::Formatter::JSONFormatter
- Gherkin::Formatter::MonochromeFormat
- Gherkin::Formatter::PrettyFormatter
- Gherkin::I18n
- Gherkin::I18nLexer
- Gherkin::JSONLexer
- Gherkin::Parser
- Gherkin::Parser::Event
- Gherkin::Parser::FilterListener
- Gherkin::Parser::FormatterListener
- Gherkin::Parser::ParseError
- Gherkin::Parser::Parser
- Gherkin::Parser::Parser::Machine
- Gherkin::Parser::Parser::Machine::StateMachineReader
- Gherkin::Parser::Row
- Gherkin::Parser::TagExpression
- Gherkin::RbLexer
- Gherkin::Rubify
- Gherkin::Tools
- Gherkin::Tools::Files
- Gherkin::Tools::Reformat
- Gherkin::Tools::Stats
- Gherkin::Tools::StatsListener
- Class

No matching classes.

# Gherkin::Formatter::JSONFormatter

### Public Class Methods

new(io) click to toggle source

    # File lib/gherkin/formatter/json_formatter.rb, line 10
    def initialize(io)
      @io = io
    end

### Public Instance Methods

background(comments, keyword, name, description, line) click to toggle source

    # File lib/gherkin/formatter/json_formatter.rb, line 25
    def background(comments, keyword, name, description, line)
      background = {
        'comments' => comments.to_a,
        'keyword' => keyword,
        'name' => name,
        'description' => description,
        'line' => line,
        'steps' => [],
      }
      @json_hash['background'] = background
      @in_background = true
    end

eof() click to toggle source

    # File lib/gherkin/formatter/json_formatter.rb, line 59
    def eof
      @io.write(@json_hash.to_json)
    end

examples(comments, tags, keyword, name, description, line, table) click to toggle source

    # File lib/gherkin/formatter/json_formatter.rb, line 48
    def examples(comments, tags, keyword, name, description, line, table)
      @table_container = add_examples(comments, tags, keyword, name, description, line)
      @table_container['table'] = to_hash_array(table)
    end

feature(comments, tags, keyword, name, description, uri) click to toggle source

    # File lib/gherkin/formatter/json_formatter.rb, line 14
    def feature(comments, tags, keyword, name, description, uri)
      @json_hash = {
        'comments' => comments.to_a,
        'tags' => tags.to_a,
        'keyword' => keyword,
        'name' => name,
        'description' => description,
        'uri' => uri
      }
    end

scenario(comments, tags, keyword, name, description, line) click to toggle source

    # File lib/gherkin/formatter/json_formatter.rb, line 38
    def scenario(comments, tags, keyword, name, description, line)
      @in_background = false
      add_step_container(comments, tags, keyword, name, description, line, 'scenario')
    end

scenario_outline(comments, tags, keyword, name, description, line) click to toggle source

    # File lib/gherkin/formatter/json_formatter.rb, line 43
    def scenario_outline(comments, tags, keyword, name, description, line)
      @in_background = false
      add_step_container(comments, tags, keyword, name, description, line, 'scenario_outline')
    end

step(comments, keyword, name, line, multiline_arg, status, exception, arguments, stepdef_location) click to toggle source

    # File lib/gherkin/formatter/json_formatter.rb, line 53
    def step(comments, keyword, name, line, multiline_arg, status, exception, arguments, stepdef_location)
      @table_container = {'comments' => comments.to_a, 'keyword' => keyword, 'name' => name, 'line' => line}.merge(step_arg_to_hash(multiline_arg))
      last_element['steps'] ||= []
      last_element['steps'] << @table_container
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.