Class: Xing::SpecDoc::ApiDoccer
- Inherits:
-
Object
- Object
- Xing::SpecDoc::ApiDoccer
- Defined in:
- lib/xing/specdoc/api-doccer.rb
Instance Attribute Summary collapse
-
#example ⇒ Object
readonly
Returns the value of attribute example.
-
#patterner ⇒ Object
readonly
Returns the value of attribute patterner.
-
#request ⇒ Object
readonly
Returns the value of attribute request.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Class Method Summary collapse
Instance Method Summary collapse
- #base_filename ⇒ Object
- #document ⇒ Object
- #example_passed? ⇒ Boolean
- #existing_body ⇒ Object
- #filename ⇒ Object
-
#initialize(example, request, response, patterner = nil) ⇒ ApiDoccer
constructor
A new instance of ApiDoccer.
- #output_path ⇒ Object
- #significant_change? ⇒ Boolean
- #store ⇒ Object
Constructor Details
#initialize(example, request, response, patterner = nil) ⇒ ApiDoccer
Returns a new instance of ApiDoccer.
11 12 13 14 15 16 |
# File 'lib/xing/specdoc/api-doccer.rb', line 11 def initialize(example, request, response, patterner=nil) @example = example @request = request @response = response @patterner = patterner || ApiDoccer.patterner end |
Instance Attribute Details
#example ⇒ Object (readonly)
Returns the value of attribute example.
18 19 20 |
# File 'lib/xing/specdoc/api-doccer.rb', line 18 def example @example end |
#patterner ⇒ Object (readonly)
Returns the value of attribute patterner.
18 19 20 |
# File 'lib/xing/specdoc/api-doccer.rb', line 18 def patterner @patterner end |
#request ⇒ Object (readonly)
Returns the value of attribute request.
18 19 20 |
# File 'lib/xing/specdoc/api-doccer.rb', line 18 def request @request end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
18 19 20 |
# File 'lib/xing/specdoc/api-doccer.rb', line 18 def response @response end |
Class Method Details
Instance Method Details
#base_filename ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/xing/specdoc/api-doccer.rb', line 24 def base_filename @base_filename ||= begin pattern = patterner.build(request).sub(%r{^/},"").gsub(%{/:},":").gsub(%r{/},"-") File::join(example.[:doc_path], "#{request.method}+#{response.status}@#{pattern}") end end |
#document ⇒ Object
45 46 47 |
# File 'lib/xing/specdoc/api-doccer.rb', line 45 def document @document ||= Document.new(output_path, response.body) end |
#example_passed? ⇒ Boolean
41 42 43 |
# File 'lib/xing/specdoc/api-doccer.rb', line 41 def example_passed? example.exception.nil? end |
#existing_body ⇒ Object
37 38 39 |
# File 'lib/xing/specdoc/api-doccer.rb', line 37 def existing_body JSON.parse(File.read(output_path)) end |
#filename ⇒ Object
33 34 35 |
# File 'lib/xing/specdoc/api-doccer.rb', line 33 def filename base_filename + ".json" end |
#output_path ⇒ Object
20 21 22 |
# File 'lib/xing/specdoc/api-doccer.rb', line 20 def output_path @output_path ||= File::join( SpecDoc.response_target_dir, filename ) end |
#significant_change? ⇒ Boolean
49 50 51 52 53 |
# File 'lib/xing/specdoc/api-doccer.rb', line 49 def significant_change? document.different_from?(existing_body) rescue Errno::ENOENT true end |