sinatra-docdsl 0.7.0 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +8 -8
  2. data/lib/docdsl.rb +8 -22
  3. metadata +3 -3
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  SHA1:
3
3
  metadata.gz: !binary |-
4
- Y2FiZDQ3OGRlY2VhYTBjNDBmODQ1ZTUzYWI2MTNkZTc1ZDUyYjNjMA==
4
+ MWY4NjBmZDg4ZGEzODliNTdlNmNlNzMxNTVkNDI1YTg2OThkYmQ1ZA==
5
5
  data.tar.gz: !binary |-
6
- NGZmODVlYjdmN2Q2ZmUwNWU2Nzg3MTYyMTMwZTNiNDBkMjdiNDE1NA==
6
+ OWNlYzA5OGYzZDkzNGQ5MDVhZmYxZGYyMDEyYjM5MDQ1NWVmY2JkMA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZjRkZTE1Yzk0YWQyOGFmNTRiZWMxMzgyZDM2ZDQwNDliODMxYzM1MWRjZTBm
10
- MTIwMDRkNTgzYjY5M2FiNGEzZmE2YWE0YmJjNWFkOGJkNjJmNmMxMWJkNzQw
11
- NDExYzVmOGY0ZjVmZmI2NjAxZTQyMzU2ODNjZTU2YmM4ZDNjYzY=
9
+ YjQ4MmExYWM3ZDExZTZjMWFkNGEyYTU3N2MxZmRjYjQ1MGJiMTI0YTM0MzJi
10
+ ZTRlMGU0ZDA0M2ZmNWYyODA0M2NhN2QwZTU5OGQ2NmRjZmEyMTkxODljYzI2
11
+ YzkwYzA5M2I4Mjc1ODRhZWNhZmVmZDQ2NTlhZjUzNTNkYjRhYzQ=
12
12
  data.tar.gz: !binary |-
13
- OTQ4ZDJlODczOGZkNWU1NDU4ZjJmYTA1NzY1OWUyMmIzNjMzMmE3MDZmODRh
14
- ODZmY2I2YTFhMTgyNzIzNzVhZTg0YTljMmI5YjA5NDNiMDRhMTYzMmFjMWM0
15
- YzQ4OTIxZWQ5ZDM4NGJmNzA1NjhmODE3ZTgxZTNjZmNjMzZhMjY=
13
+ YTllMmM0MGIxYzY1ZDhkMThkMTRjMzFhNTc2MmI1NGE0OGZkZDRjMTZmYTlk
14
+ NDg4ZmI4ZThmZjQ1MzYwNzUxYzQzMTI0NzQ1Y2I0NGRiZGRjNjUxNjE2NDg5
15
+ M2U1YjIxYzFkMDJkY2IyNDlkYzNmZmRjZTdkOTU1ZDRhN2IzNDY=
data/lib/docdsl.rb CHANGED
@@ -113,16 +113,6 @@ HTML
113
113
  #{@the_introduction}
114
114
 
115
115
  "
116
- # :description=>@desc,
117
- # :url_parameters=>@params,
118
- # :paths=>@paths,
119
- # :query_parameters=>@query_params,
120
- # :headers=>@headers,
121
- # :payload=>@the_payload,
122
- # :sample_request=>@sample_request,
123
- # :response=>@the_response,
124
- # :status_codes=>@status_codes,
125
- # :sample_response=>@sample_response
126
116
  markdown = @entries.inject(markdown) do | md, entry |
127
117
  path = entry.paths.join(', ')
128
118
  params = definition_list("Url Parameters", entry.params)
@@ -410,23 +400,21 @@ HTML
410
400
  }
411
401
  end
412
402
  end
413
-
414
- def self.registered(app)
415
- app.get '/doc' do
403
+
404
+ def doc_endpoint(path)
405
+ page_doc=@page_doc
406
+ get path do
416
407
  begin
417
- app.instance_eval {
418
- @page_doc ||= PageDoc.new
419
- @page_doc.render
420
- }
408
+ page_doc.render
421
409
  rescue Exception=>e
422
410
  puts e.message, e.backtrace.inspect
423
411
  [500,@page_doc.render]
424
412
  end
425
413
  end
426
414
  end
427
-
415
+
428
416
  def page(&block)
429
- @page_doc ||= PageDoc.new(&block)
417
+ @page_doc = PageDoc.new(&block)
430
418
  end
431
419
 
432
420
  def documentation(description,&block)
@@ -436,10 +424,8 @@ HTML
436
424
  end
437
425
 
438
426
  def method_added(method)
439
- # don't document /doc
440
- return if method.to_s =~ /(^(GET|HEAD) \/doc\z)/
441
427
  # document the method and nullify last_doc so that a new one gets created for the next method
442
- if method.to_s =~ /(GET|POST|PUT|DELETE|UPDATE|HEAD)/ && @last_doc
428
+ if @last_doc
443
429
  @last_doc << method
444
430
  @last_doc = nil
445
431
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sinatra-docdsl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jilles van Gurp
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-08-30 00:00:00.000000000 Z
11
+ date: 2013-09-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: kramdown
@@ -24,7 +24,7 @@ dependencies:
24
24
  version: '0'
25
25
  prerelease: false
26
26
  type: :runtime
27
- description: A simple DSL for documenting Sinatra apps and generating a /doc endpoint in a sinatra resource
27
+ description: A simple DSL for generating documentation for Sinatra REST applications
28
28
  email: incoming@jillesvangurp.xom
29
29
  executables: []
30
30
  extensions: []