Class: PostmanMarkdoc
- Inherits:
-
Object
- Object
- PostmanMarkdoc
- Defined in:
- lib/postman_markdoc.rb
Defined Under Namespace
Classes: CollectionParser, MarkdownGenerator, RequestParser
Instance Attribute Summary collapse
-
#collections ⇒ Object
readonly
Returns the value of attribute collections.
-
#markdown ⇒ Object
readonly
Returns the value of attribute markdown.
Class Method Summary collapse
-
.files_to_markdown(*file_names) ⇒ Object
accepts filenames as arguments returns markdown string.
-
.raw_json_to_markdown(raw_json) ⇒ Object
accepts raw json collection string as argument returns markdown string.
Instance Method Summary collapse
- #generate_markdown ⇒ Object
-
#initialize(*args) ⇒ PostmanMarkdoc
constructor
accepts hash representations of postman json collections.
Constructor Details
#initialize(*args) ⇒ PostmanMarkdoc
accepts hash representations of postman json collections
23 24 25 26 |
# File 'lib/postman_markdoc.rb', line 23 def initialize(*args) @collections = args generate_markdown end |
Instance Attribute Details
#collections ⇒ Object (readonly)
Returns the value of attribute collections.
20 21 22 |
# File 'lib/postman_markdoc.rb', line 20 def collections @collections end |
#markdown ⇒ Object (readonly)
Returns the value of attribute markdown.
20 21 22 |
# File 'lib/postman_markdoc.rb', line 20 def markdown @markdown end |
Class Method Details
.files_to_markdown(*file_names) ⇒ Object
accepts filenames as arguments returns markdown string
7 8 9 10 11 |
# File 'lib/postman_markdoc.rb', line 7 def self.files_to_markdown(*file_names) raw_json = file_names.map{|f| IO.read(f)} collections = raw_json.map{|json| JSON.parse(json)} self.new(*collections).markdown end |
.raw_json_to_markdown(raw_json) ⇒ Object
accepts raw json collection string as argument returns markdown string
15 16 17 18 |
# File 'lib/postman_markdoc.rb', line 15 def self.raw_json_to_markdown(raw_json) collection = JSON.parse(raw_json) self.new(collection).markdown end |
Instance Method Details
#generate_markdown ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'lib/postman_markdoc.rb', line 28 def generate_markdown @markdown = "" collections.each do |collection| @markdown << PostmanMarkdoc::MarkdownGenerator.generate( data: collection ).content end end |