api_yard_parser 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +15 -0
 - data/MIT-LICENSE +20 -0
 - data/README.rdoc +14 -0
 - data/Rakefile +38 -0
 - data/app/controllers/api_yard_parser/api_docs_controller.rb +20 -0
 - data/app/views/api_yard_parser/api_docs/index.html.erb +150 -0
 - data/config/routes.rb +5 -0
 - data/lib/api_yard_parser/api_comment.rb +81 -0
 - data/lib/api_yard_parser/api_controllers.rb +14 -0
 - data/lib/api_yard_parser/api_docs.rb +100 -0
 - data/lib/api_yard_parser/engine.rb +3 -0
 - data/lib/api_yard_parser/version.rb +3 -0
 - data/lib/api_yard_parser.rb +18 -0
 - data/test/api_yard_parser_test.rb +7 -0
 - data/test/dummy/README.rdoc +261 -0
 - data/test/dummy/Rakefile +7 -0
 - data/test/dummy/app/assets/javascripts/application.js +15 -0
 - data/test/dummy/app/assets/stylesheets/application.css +13 -0
 - data/test/dummy/app/controllers/application_controller.rb +3 -0
 - data/test/dummy/app/helpers/application_helper.rb +2 -0
 - data/test/dummy/app/views/layouts/application.html.erb +14 -0
 - data/test/dummy/config/application.rb +59 -0
 - data/test/dummy/config/boot.rb +10 -0
 - data/test/dummy/config/database.yml +25 -0
 - data/test/dummy/config/environment.rb +5 -0
 - data/test/dummy/config/environments/development.rb +37 -0
 - data/test/dummy/config/environments/production.rb +67 -0
 - data/test/dummy/config/environments/test.rb +37 -0
 - data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
 - data/test/dummy/config/initializers/inflections.rb +15 -0
 - data/test/dummy/config/initializers/mime_types.rb +5 -0
 - data/test/dummy/config/initializers/secret_token.rb +7 -0
 - data/test/dummy/config/initializers/session_store.rb +8 -0
 - data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
 - data/test/dummy/config/locales/en.yml +5 -0
 - data/test/dummy/config/routes.rb +58 -0
 - data/test/dummy/config.ru +4 -0
 - data/test/dummy/public/404.html +26 -0
 - data/test/dummy/public/422.html +26 -0
 - data/test/dummy/public/500.html +25 -0
 - data/test/dummy/public/favicon.ico +0 -0
 - data/test/dummy/script/rails +6 -0
 - data/test/test_helper.rb +15 -0
 - metadata +130 -0
 
    
        checksums.yaml
    ADDED
    
    | 
         @@ -0,0 +1,15 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            ---
         
     | 
| 
      
 2 
     | 
    
         
            +
            !binary "U0hBMQ==":
         
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: !binary |-
         
     | 
| 
      
 4 
     | 
    
         
            +
                YzRkZmIwNjZkOWI3MWYzYTM4MjgyYjVhNTFmNjFlYzcwZTE0MDdmZQ==
         
     | 
| 
      
 5 
     | 
    
         
            +
              data.tar.gz: !binary |-
         
     | 
| 
      
 6 
     | 
    
         
            +
                YzcxNTI5NDFhZDczZTI5YTRkZjdhNWRiMTY4N2Q4NjI3OGE4N2QyOQ==
         
     | 
| 
      
 7 
     | 
    
         
            +
            SHA512:
         
     | 
| 
      
 8 
     | 
    
         
            +
              metadata.gz: !binary |-
         
     | 
| 
      
 9 
     | 
    
         
            +
                YzA2OGYwMGI0YTc5MjhjMzgwNWVhMDk2YjM3ZWMxY2IyMTUyYjQ3ZDQxN2M3
         
     | 
| 
      
 10 
     | 
    
         
            +
                ODA0ZDIxMzNiM2M5NDEzZjBmNzkyZjQ1MzVmNmI0M2JjZGQxOWViM2M5MzM2
         
     | 
| 
      
 11 
     | 
    
         
            +
                NWQyZTQzOGQ1NGVjMWQwMDA2ZjBlMDdkYjlkMDZmYzk1MTU4Nzg=
         
     | 
| 
      
 12 
     | 
    
         
            +
              data.tar.gz: !binary |-
         
     | 
| 
      
 13 
     | 
    
         
            +
                Y2Q1MmEwZjA1OTUwMWRiYzI2ZmE2MWI3ZmM4YmY1MTI2YWZhZDMyNjYyNTM0
         
     | 
| 
      
 14 
     | 
    
         
            +
                MGIwN2JhZTczZmY5M2RhNTU4MTJjMWJlMWY5ZmQ2ZGE2MjZhMmIwNjEyYWUy
         
     | 
| 
      
 15 
     | 
    
         
            +
                YTA5MjkwYWEzNjk1NGNkZjE5OTEwZDhiYTc2ODA2MjUwYmRhZDI=
         
     | 
    
        data/MIT-LICENSE
    ADDED
    
    | 
         @@ -0,0 +1,20 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            Copyright 2014 Thiago Coutinho
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            Permission is hereby granted, free of charge, to any person obtaining
         
     | 
| 
      
 4 
     | 
    
         
            +
            a copy of this software and associated documentation files (the
         
     | 
| 
      
 5 
     | 
    
         
            +
            "Software"), to deal in the Software without restriction, including
         
     | 
| 
      
 6 
     | 
    
         
            +
            without limitation the rights to use, copy, modify, merge, publish,
         
     | 
| 
      
 7 
     | 
    
         
            +
            distribute, sublicense, and/or sell copies of the Software, and to
         
     | 
| 
      
 8 
     | 
    
         
            +
            permit persons to whom the Software is furnished to do so, subject to
         
     | 
| 
      
 9 
     | 
    
         
            +
            the following conditions:
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
            The above copyright notice and this permission notice shall be
         
     | 
| 
      
 12 
     | 
    
         
            +
            included in all copies or substantial portions of the Software.
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
            THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
         
     | 
| 
      
 15 
     | 
    
         
            +
            EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
         
     | 
| 
      
 16 
     | 
    
         
            +
            MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
         
     | 
| 
      
 17 
     | 
    
         
            +
            NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
         
     | 
| 
      
 18 
     | 
    
         
            +
            LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
         
     | 
| 
      
 19 
     | 
    
         
            +
            OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
         
     | 
| 
      
 20 
     | 
    
         
            +
            WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
         
     | 
    
        data/README.rdoc
    ADDED
    
    | 
         @@ -0,0 +1,14 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            = ApiYardParser
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            This project rocks and uses MIT-LICENSE.
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            1. REQUIREMENTS
         
     | 
| 
      
 6 
     | 
    
         
            +
            ===============
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
            Ruby/ApiYardParser requires Ruby version 1.9.1 or newer and Rails ~> 3.2.16.
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
            2. INSTALLATION
         
     | 
| 
      
 11 
     | 
    
         
            +
            ===============
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
            gem install api_yard_parser
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
    
        data/Rakefile
    ADDED
    
    | 
         @@ -0,0 +1,38 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            #!/usr/bin/env rake
         
     | 
| 
      
 2 
     | 
    
         
            +
            begin
         
     | 
| 
      
 3 
     | 
    
         
            +
              require 'bundler/setup'
         
     | 
| 
      
 4 
     | 
    
         
            +
            rescue LoadError
         
     | 
| 
      
 5 
     | 
    
         
            +
              puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
         
     | 
| 
      
 6 
     | 
    
         
            +
            end
         
     | 
| 
      
 7 
     | 
    
         
            +
            begin
         
     | 
| 
      
 8 
     | 
    
         
            +
              require 'rdoc/task'
         
     | 
| 
      
 9 
     | 
    
         
            +
            rescue LoadError
         
     | 
| 
      
 10 
     | 
    
         
            +
              require 'rdoc/rdoc'
         
     | 
| 
      
 11 
     | 
    
         
            +
              require 'rake/rdoctask'
         
     | 
| 
      
 12 
     | 
    
         
            +
              RDoc::Task = Rake::RDocTask
         
     | 
| 
      
 13 
     | 
    
         
            +
            end
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
            RDoc::Task.new(:rdoc) do |rdoc|
         
     | 
| 
      
 16 
     | 
    
         
            +
              rdoc.rdoc_dir = 'rdoc'
         
     | 
| 
      
 17 
     | 
    
         
            +
              rdoc.title    = 'ApiYardParser'
         
     | 
| 
      
 18 
     | 
    
         
            +
              rdoc.options << '--line-numbers'
         
     | 
| 
      
 19 
     | 
    
         
            +
              rdoc.rdoc_files.include('README.rdoc')
         
     | 
| 
      
 20 
     | 
    
         
            +
              rdoc.rdoc_files.include('lib/**/*.rb')
         
     | 
| 
      
 21 
     | 
    
         
            +
            end
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
            Bundler::GemHelper.install_tasks
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
            require 'rake/testtask'
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
            Rake::TestTask.new(:test) do |t|
         
     | 
| 
      
 31 
     | 
    
         
            +
              t.libs << 'lib'
         
     | 
| 
      
 32 
     | 
    
         
            +
              t.libs << 'test'
         
     | 
| 
      
 33 
     | 
    
         
            +
              t.pattern = 'test/**/*_test.rb'
         
     | 
| 
      
 34 
     | 
    
         
            +
              t.verbose = false
         
     | 
| 
      
 35 
     | 
    
         
            +
            end
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
      
 38 
     | 
    
         
            +
            task :default => :test
         
     | 
| 
         @@ -0,0 +1,20 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module ApiYardParser
         
     | 
| 
      
 2 
     | 
    
         
            +
              class ApiDocsController < ::ApplicationController
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
                def index
         
     | 
| 
      
 5 
     | 
    
         
            +
                  if Rails.env == "production" && ApiYardParser.force_no_docs_production
         
     | 
| 
      
 6 
     | 
    
         
            +
                    render :text => "dont have docs in production"
         
     | 
| 
      
 7 
     | 
    
         
            +
                    return true
         
     | 
| 
      
 8 
     | 
    
         
            +
                  end
         
     | 
| 
      
 9 
     | 
    
         
            +
                  @list_apis = ApiDocs.get_all
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
                  @without = params[:without].split(",") if !params[:without].nil?
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
                  if !@without.nil?
         
     | 
| 
      
 14 
     | 
    
         
            +
                    @list_apis.select!{|api| @without.index(api.name) == nil }
         
     | 
| 
      
 15 
     | 
    
         
            +
                  end
         
     | 
| 
      
 16 
     | 
    
         
            +
                  render "index", :layout => false
         
     | 
| 
      
 17 
     | 
    
         
            +
                end
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
              end
         
     | 
| 
      
 20 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,150 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            <%
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            def class_by_verb(verb)
         
     | 
| 
      
 4 
     | 
    
         
            +
              items ={
         
     | 
| 
      
 5 
     | 
    
         
            +
                "GET"=>"label-success",
         
     | 
| 
      
 6 
     | 
    
         
            +
                "POST" => "label-info",
         
     | 
| 
      
 7 
     | 
    
         
            +
                "PUT" => "label-warning",
         
     | 
| 
      
 8 
     | 
    
         
            +
                "DELETE" => "label-important",
         
     | 
| 
      
 9 
     | 
    
         
            +
              }
         
     | 
| 
      
 10 
     | 
    
         
            +
              items[verb]
         
     | 
| 
      
 11 
     | 
    
         
            +
            end
         
     | 
| 
      
 12 
     | 
    
         
            +
            %>
         
     | 
| 
      
 13 
     | 
    
         
            +
            <!DOCTYPE html>
         
     | 
| 
      
 14 
     | 
    
         
            +
            <html class="colorNavyBlue">
         
     | 
| 
      
 15 
     | 
    
         
            +
            <head>
         
     | 
| 
      
 16 
     | 
    
         
            +
              <title>ApiDocs - <%=Rails.application.class.to_s.split("::").first%></title>
         
     | 
| 
      
 17 
     | 
    
         
            +
              <link rel="stylesheet" type="text/css" href="https://assets.locaweb.com.br/locastyle/1.1.9/locastyle.css">
         
     | 
| 
      
 18 
     | 
    
         
            +
              <script type="text/javascript" src="https://assets.locaweb.com.br/locastyle/1.1.9/locastyle.js"></script>
         
     | 
| 
      
 19 
     | 
    
         
            +
              <link rel="stylesheet" type="text/css" href="https://assets.locaweb.com.br/locastyle/1.1.9/bootstrap.css">
         
     | 
| 
      
 20 
     | 
    
         
            +
              <script type="text/javascript" src="https://assets.locaweb.com.br/locastyle/1.1.9/bootstrap.js"></script>
         
     | 
| 
      
 21 
     | 
    
         
            +
            </head>
         
     | 
| 
      
 22 
     | 
    
         
            +
            <body>
         
     | 
| 
      
 23 
     | 
    
         
            +
              <header class="headerPrincipal">
         
     | 
| 
      
 24 
     | 
    
         
            +
                <div class="limite">
         
     | 
| 
      
 25 
     | 
    
         
            +
                  <h1 class="serviceName"><a href="/">ApiDocs - <%=Rails.application.class.to_s.split("::").first%></a></h1>
         
     | 
| 
      
 26 
     | 
    
         
            +
                </div>
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
                <menu id="menuPrincipal">
         
     | 
| 
      
 29 
     | 
    
         
            +
                  <ul>
         
     | 
| 
      
 30 
     | 
    
         
            +
                    <li class=''>
         
     | 
| 
      
 31 
     | 
    
         
            +
                      <a href="#">Docs by Controllers</a>
         
     | 
| 
      
 32 
     | 
    
         
            +
                    </li>
         
     | 
| 
      
 33 
     | 
    
         
            +
                  </ul>
         
     | 
| 
      
 34 
     | 
    
         
            +
                </menu>
         
     | 
| 
      
 35 
     | 
    
         
            +
              </header>
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
              <div id="main">
         
     | 
| 
      
 38 
     | 
    
         
            +
                <div class="limite">
         
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
      
 40 
     | 
    
         
            +
             
     | 
| 
      
 41 
     | 
    
         
            +
                  <% @list_apis.each do |api| %>
         
     | 
| 
      
 42 
     | 
    
         
            +
                  <% if api.routes.count > 0  %>
         
     | 
| 
      
 43 
     | 
    
         
            +
                  <!--  init ###<%= api.name %>####   -->
         
     | 
| 
      
 44 
     | 
    
         
            +
                  <div class="row">
         
     | 
| 
      
 45 
     | 
    
         
            +
                    <div class="span12">
         
     | 
| 
      
 46 
     | 
    
         
            +
                      <div class="alert alert-warning" style="display:none">
         
     | 
| 
      
 47 
     | 
    
         
            +
                        <a class="close" data-dismiss="alert">×</a>
         
     | 
| 
      
 48 
     | 
    
         
            +
                        <strong>Informação!</strong> Uma informação qualquer do seu sistema. <a href="#">Um link qualquer</a>.
         
     | 
| 
      
 49 
     | 
    
         
            +
                      </div>
         
     | 
| 
      
 50 
     | 
    
         
            +
             
     | 
| 
      
 51 
     | 
    
         
            +
                      <div class="">
         
     | 
| 
      
 52 
     | 
    
         
            +
                        <h2><%= api.name %></h2>
         
     | 
| 
      
 53 
     | 
    
         
            +
                        <% api.routes.each do |route| %>
         
     | 
| 
      
 54 
     | 
    
         
            +
                        <div class="boxCollapse">
         
     | 
| 
      
 55 
     | 
    
         
            +
                          <header data-target="#api_routes_<%=route.object_id%>" data-toggle="collapse">
         
     | 
| 
      
 56 
     | 
    
         
            +
                            <h4><span class="label <%=class_by_verb(route.type)%>" style="color:white;"><%=route.type%></span>
         
     | 
| 
      
 57 
     | 
    
         
            +
                              <strong>   <%=route.url%> </strong> - <%=route.description%></h4>
         
     | 
| 
      
 58 
     | 
    
         
            +
                            </header>
         
     | 
| 
      
 59 
     | 
    
         
            +
                            <div class="collapse" id="api_routes_<%=route.object_id%>">
         
     | 
| 
      
 60 
     | 
    
         
            +
                              <% if !route.params.nil? && route.params.count>0%>
         
     | 
| 
      
 61 
     | 
    
         
            +
                                <p> 
         
     | 
| 
      
 62 
     | 
    
         
            +
                                  <div class="alert alert-success">
         
     | 
| 
      
 63 
     | 
    
         
            +
                                    <h3> Params </h3>
         
     | 
| 
      
 64 
     | 
    
         
            +
                                    <div>
         
     | 
| 
      
 65 
     | 
    
         
            +
                                      <% route.params.each do |param| %>
         
     | 
| 
      
 66 
     | 
    
         
            +
                                      <p>
         
     | 
| 
      
 67 
     | 
    
         
            +
                                        <span><b>  <%=param[:name]%> </b> </span> - 
         
     | 
| 
      
 68 
     | 
    
         
            +
                                        <span ><%=param[:type]%></span> - 
         
     | 
| 
      
 69 
     | 
    
         
            +
                                        <span><%=param[:description]%></span> 
         
     | 
| 
      
 70 
     | 
    
         
            +
                                      </p>
         
     | 
| 
      
 71 
     | 
    
         
            +
                                      <%end%>
         
     | 
| 
      
 72 
     | 
    
         
            +
                                    </div>
         
     | 
| 
      
 73 
     | 
    
         
            +
                                  </div>
         
     | 
| 
      
 74 
     | 
    
         
            +
                                </p>
         
     | 
| 
      
 75 
     | 
    
         
            +
                              <%end%>
         
     | 
| 
      
 76 
     | 
    
         
            +
                              <% if !route.returns.nil? && route.returns.count>0%>
         
     | 
| 
      
 77 
     | 
    
         
            +
                                <% route.returns.each do |myreturn| %>
         
     | 
| 
      
 78 
     | 
    
         
            +
                                  <p> 
         
     | 
| 
      
 79 
     | 
    
         
            +
                                    <div class="alert alert-info">
         
     | 
| 
      
 80 
     | 
    
         
            +
                                      <h4> Return </h4>
         
     | 
| 
      
 81 
     | 
    
         
            +
                                      <div>
         
     | 
| 
      
 82 
     | 
    
         
            +
                                       
         
     | 
| 
      
 83 
     | 
    
         
            +
                                        <%=myreturn[:name]%> - <%=myreturn[:description]%>
         
     | 
| 
      
 84 
     | 
    
         
            +
                                        <br>
         
     | 
| 
      
 85 
     | 
    
         
            +
                                        <%=myreturn[:type]%>:
         
     | 
| 
      
 86 
     | 
    
         
            +
                                          <%if !myreturn[:body].nil? %>
         
     | 
| 
      
 87 
     | 
    
         
            +
                                            <pre class="lang-json prettyprint linenums"><%=myreturn[:body]%></pre>
         
     | 
| 
      
 88 
     | 
    
         
            +
                                          <%end%>
         
     | 
| 
      
 89 
     | 
    
         
            +
                                        
         
     | 
| 
      
 90 
     | 
    
         
            +
                                      </div>
         
     | 
| 
      
 91 
     | 
    
         
            +
                                    </div>
         
     | 
| 
      
 92 
     | 
    
         
            +
                                  </p>
         
     | 
| 
      
 93 
     | 
    
         
            +
                                <%end%>
         
     | 
| 
      
 94 
     | 
    
         
            +
                              <%end%>
         
     | 
| 
      
 95 
     | 
    
         
            +
                              <% if !route.example.nil? %>
         
     | 
| 
      
 96 
     | 
    
         
            +
                              <p> 
         
     | 
| 
      
 97 
     | 
    
         
            +
                                <div class="alert">
         
     | 
| 
      
 98 
     | 
    
         
            +
                                  <h3> Example </h3>
         
     | 
| 
      
 99 
     | 
    
         
            +
                                  <div>
         
     | 
| 
      
 100 
     | 
    
         
            +
                                    <%= route.example%>
         
     | 
| 
      
 101 
     | 
    
         
            +
                                  </div>
         
     | 
| 
      
 102 
     | 
    
         
            +
                                </div>
         
     | 
| 
      
 103 
     | 
    
         
            +
                              </p>
         
     | 
| 
      
 104 
     | 
    
         
            +
                              <%end%>
         
     | 
| 
      
 105 
     | 
    
         
            +
                              <% if !route.notes.nil? && route.notes.count>0%>
         
     | 
| 
      
 106 
     | 
    
         
            +
                              <p> 
         
     | 
| 
      
 107 
     | 
    
         
            +
                                <div class="alert">
         
     | 
| 
      
 108 
     | 
    
         
            +
                                  <h3> Notes </h3>
         
     | 
| 
      
 109 
     | 
    
         
            +
                                  <div>
         
     | 
| 
      
 110 
     | 
    
         
            +
                                    <% route.notes.each do |note|%>
         
     | 
| 
      
 111 
     | 
    
         
            +
                                    <p><%=note%></p>
         
     | 
| 
      
 112 
     | 
    
         
            +
                                    <%end%>
         
     | 
| 
      
 113 
     | 
    
         
            +
                                  </div>
         
     | 
| 
      
 114 
     | 
    
         
            +
                                </div>
         
     | 
| 
      
 115 
     | 
    
         
            +
                              </p>
         
     | 
| 
      
 116 
     | 
    
         
            +
                              <%end%>
         
     | 
| 
      
 117 
     | 
    
         
            +
                            </div>
         
     | 
| 
      
 118 
     | 
    
         
            +
                          </div>
         
     | 
| 
      
 119 
     | 
    
         
            +
                          <% end #end collapse%>
         
     | 
| 
      
 120 
     | 
    
         
            +
                        </div>
         
     | 
| 
      
 121 
     | 
    
         
            +
             
     | 
| 
      
 122 
     | 
    
         
            +
                      </div>
         
     | 
| 
      
 123 
     | 
    
         
            +
             
     | 
| 
      
 124 
     | 
    
         
            +
                    </div><!-- FIM ROW -->
         
     | 
| 
      
 125 
     | 
    
         
            +
                    <!--  end ###<%= api.name %>####   -->
         
     | 
| 
      
 126 
     | 
    
         
            +
                    <% end
         
     | 
| 
      
 127 
     | 
    
         
            +
                    end # end list_apis.each %>
         
     | 
| 
      
 128 
     | 
    
         
            +
             
     | 
| 
      
 129 
     | 
    
         
            +
                </div><!-- FIM LIMITE -->
         
     | 
| 
      
 130 
     | 
    
         
            +
             
     | 
| 
      
 131 
     | 
    
         
            +
             
     | 
| 
      
 132 
     | 
    
         
            +
             
     | 
| 
      
 133 
     | 
    
         
            +
                    <footer id="rodape">
         
     | 
| 
      
 134 
     | 
    
         
            +
                      <div class="footerTop">
         
     | 
| 
      
 135 
     | 
    
         
            +
                        <div class="limite">
         
     | 
| 
      
 136 
     | 
    
         
            +
             
     | 
| 
      
 137 
     | 
    
         
            +
                        </div>
         
     | 
| 
      
 138 
     | 
    
         
            +
                      </div>
         
     | 
| 
      
 139 
     | 
    
         
            +
                      <div class="subfooter">
         
     | 
| 
      
 140 
     | 
    
         
            +
                        <div class="limite">
         
     | 
| 
      
 141 
     | 
    
         
            +
                          <p class="copyRight fright">Copyright © 2014 Thiago Coutinho thiago+@+osfeio.com</p>
         
     | 
| 
      
 142 
     | 
    
         
            +
                        </div>
         
     | 
| 
      
 143 
     | 
    
         
            +
                      </div>
         
     | 
| 
      
 144 
     | 
    
         
            +
                    </footer>
         
     | 
| 
      
 145 
     | 
    
         
            +
             
     | 
| 
      
 146 
     | 
    
         
            +
                  </div>
         
     | 
| 
      
 147 
     | 
    
         
            +
                </div>
         
     | 
| 
      
 148 
     | 
    
         
            +
             
     | 
| 
      
 149 
     | 
    
         
            +
              </body>
         
     | 
| 
      
 150 
     | 
    
         
            +
              </html>
         
     | 
    
        data/config/routes.rb
    ADDED
    
    
| 
         @@ -0,0 +1,81 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module ApiYardParser
         
     | 
| 
      
 2 
     | 
    
         
            +
              class ApiComment
         
     | 
| 
      
 3 
     | 
    
         
            +
                attr_reader :url, :type, :params, :returns, :description, :example, :notes
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
                def initialize(text)
         
     | 
| 
      
 6 
     | 
    
         
            +
                  @text = text
         
     | 
| 
      
 7 
     | 
    
         
            +
                  @params = []
         
     | 
| 
      
 8 
     | 
    
         
            +
                  @returns = []
         
     | 
| 
      
 9 
     | 
    
         
            +
                  parse
         
     | 
| 
      
 10 
     | 
    
         
            +
                end
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
                def parse
         
     | 
| 
      
 13 
     | 
    
         
            +
                  items = @text.split("# @")
         
     | 
| 
      
 14 
     | 
    
         
            +
                  parse_text(items[0])
         
     | 
| 
      
 15 
     | 
    
         
            +
                  items.each do |item|
         
     | 
| 
      
 16 
     | 
    
         
            +
                    res = item.scan(/^(\S+)\s/)
         
     | 
| 
      
 17 
     | 
    
         
            +
                    if res.count > 0
         
     | 
| 
      
 18 
     | 
    
         
            +
                      type = res[0][0]
         
     | 
| 
      
 19 
     | 
    
         
            +
                      send("parse_#{type}",item) if ["url","type","param","return","note"].index(type)
         
     | 
| 
      
 20 
     | 
    
         
            +
                      parse_auto_example if type == "auto-example"
         
     | 
| 
      
 21 
     | 
    
         
            +
                    end
         
     | 
| 
      
 22 
     | 
    
         
            +
                  end
         
     | 
| 
      
 23 
     | 
    
         
            +
                end
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
                def parse_text(text)
         
     | 
| 
      
 26 
     | 
    
         
            +
                  lines = ""
         
     | 
| 
      
 27 
     | 
    
         
            +
                  text.split("\n").each{|line| lines += line.sub(/^\s+#/,"")}
         
     | 
| 
      
 28 
     | 
    
         
            +
                  @description = lines.strip
         
     | 
| 
      
 29 
     | 
    
         
            +
                end
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
                def parse_url(text)
         
     | 
| 
      
 32 
     | 
    
         
            +
                  @url = text.split[1]
         
     | 
| 
      
 33 
     | 
    
         
            +
                end
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
                def parse_type(text)
         
     | 
| 
      
 36 
     | 
    
         
            +
                  @type = text.split[1]
         
     | 
| 
      
 37 
     | 
    
         
            +
                end
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
      
 39 
     | 
    
         
            +
                def parse_param(text)
         
     | 
| 
      
 40 
     | 
    
         
            +
                  res = text.scan(/^\S+\s+\[(\S+)\]\s+(\S+)(\s+->|\s+)(.+)/)[0]
         
     | 
| 
      
 41 
     | 
    
         
            +
                  if !res.nil?
         
     | 
| 
      
 42 
     | 
    
         
            +
                    @params += [{:type => res[0], :name=>res[1], :description=>res[3] } ]
         
     | 
| 
      
 43 
     | 
    
         
            +
                    return true
         
     | 
| 
      
 44 
     | 
    
         
            +
                  end
         
     | 
| 
      
 45 
     | 
    
         
            +
             
     | 
| 
      
 46 
     | 
    
         
            +
                  res = text.scan(/^\S+\s+\[(\S+)\]/)[0]
         
     | 
| 
      
 47 
     | 
    
         
            +
                  if !res.nil?
         
     | 
| 
      
 48 
     | 
    
         
            +
                    @params += [{:type => res[0], :name=>" ", :description=>" " } ]
         
     | 
| 
      
 49 
     | 
    
         
            +
                  end
         
     | 
| 
      
 50 
     | 
    
         
            +
                end
         
     | 
| 
      
 51 
     | 
    
         
            +
             
     | 
| 
      
 52 
     | 
    
         
            +
                def parse_return(text)
         
     | 
| 
      
 53 
     | 
    
         
            +
                  lines = ""
         
     | 
| 
      
 54 
     | 
    
         
            +
                  text.split("\n").each{|line| lines += line.sub(/^\s+#/,"") + "\n"}
         
     | 
| 
      
 55 
     | 
    
         
            +
                  res = lines.scan(/^\S+\s+\[(\S+)\]\s+([a-zA-Z\s\d]+)-(.+)\n([\s\{:\S\}]*)/)
         
     | 
| 
      
 56 
     | 
    
         
            +
                  if !res.nil? && !res[0].nil? && res[0][3].strip != ""
         
     | 
| 
      
 57 
     | 
    
         
            +
                    @returns += [{:type => res[0][0], :name=>res[0][1], :description=>res[0][2], :body => res[0][3] } ]
         
     | 
| 
      
 58 
     | 
    
         
            +
                    return
         
     | 
| 
      
 59 
     | 
    
         
            +
                  end
         
     | 
| 
      
 60 
     | 
    
         
            +
             
     | 
| 
      
 61 
     | 
    
         
            +
                  res = lines.scan(/^\S+\s+\[(\S+)\]\s+([a-zA-Z\s\d]+)-(.+)/)
         
     | 
| 
      
 62 
     | 
    
         
            +
                  if !res.nil? && res.count > 0
         
     | 
| 
      
 63 
     | 
    
         
            +
                    @returns += [{:type => res[0][0], :name=>res[0][1], :description=>res[0][2],:body => nil} ] if !res.nil?
         
     | 
| 
      
 64 
     | 
    
         
            +
                  end
         
     | 
| 
      
 65 
     | 
    
         
            +
                end
         
     | 
| 
      
 66 
     | 
    
         
            +
             
     | 
| 
      
 67 
     | 
    
         
            +
                def parse_note(text)
         
     | 
| 
      
 68 
     | 
    
         
            +
                  lines = ""
         
     | 
| 
      
 69 
     | 
    
         
            +
                  text.split("\n").each{|line| lines += line.sub(/^\s+#/,"") + "\n"}
         
     | 
| 
      
 70 
     | 
    
         
            +
                  res = lines.scan(/(GET|POST|PUT|DELETE).+\n+\s+(http.+)/)[0]
         
     | 
| 
      
 71 
     | 
    
         
            +
                  if !res.nil? 
         
     | 
| 
      
 72 
     | 
    
         
            +
                    @type = res[0]
         
     | 
| 
      
 73 
     | 
    
         
            +
                    @url = res[1]
         
     | 
| 
      
 74 
     | 
    
         
            +
                  end
         
     | 
| 
      
 75 
     | 
    
         
            +
                end
         
     | 
| 
      
 76 
     | 
    
         
            +
             
     | 
| 
      
 77 
     | 
    
         
            +
                def parse_auto_example
         
     | 
| 
      
 78 
     | 
    
         
            +
                end
         
     | 
| 
      
 79 
     | 
    
         
            +
             
     | 
| 
      
 80 
     | 
    
         
            +
              end
         
     | 
| 
      
 81 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,100 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module ApiYardParser
         
     | 
| 
      
 2 
     | 
    
         
            +
              class ApiDocs
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
                attr_accessor :controller_dirs
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
                def self.get_all
         
     | 
| 
      
 7 
     | 
    
         
            +
                  @controller_dirs = ["#{Rails.root}/app/controllers"]
         
     | 
| 
      
 8 
     | 
    
         
            +
                  files = []
         
     | 
| 
      
 9 
     | 
    
         
            +
                  @controller_dirs.each do |dir|
         
     | 
| 
      
 10 
     | 
    
         
            +
                    files += Dir["#{dir}/**/*.rb"]
         
     | 
| 
      
 11 
     | 
    
         
            +
                  end
         
     | 
| 
      
 12 
     | 
    
         
            +
                  content = []
         
     | 
| 
      
 13 
     | 
    
         
            +
                  #files = ["#{Rails.root}/app/controllers/clients_controller.rb"] #TEMP!!!!!!!!
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
                  files.each do |file|
         
     | 
| 
      
 16 
     | 
    
         
            +
                    content += [ApiDocs.new(file).contents]
         
     | 
| 
      
 17 
     | 
    
         
            +
                  end
         
     | 
| 
      
 18 
     | 
    
         
            +
                  content
         
     | 
| 
      
 19 
     | 
    
         
            +
                end
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
                def initialize(file)
         
     | 
| 
      
 22 
     | 
    
         
            +
                  @file = file
         
     | 
| 
      
 23 
     | 
    
         
            +
                end
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
                def contents
         
     | 
| 
      
 26 
     | 
    
         
            +
                  @file_content = File.new(@file).read
         
     | 
| 
      
 27 
     | 
    
         
            +
                  name = @file_content.scan(/class\s(\S+)Controller/ )
         
     | 
| 
      
 28 
     | 
    
         
            +
                  name = (name.count > 0) ? name[0][0] : ""
         
     | 
| 
      
 29 
     | 
    
         
            +
                  controller = ApiControllers.new(name)
         
     | 
| 
      
 30 
     | 
    
         
            +
                  comments.each do |my_method|
         
     | 
| 
      
 31 
     | 
    
         
            +
                    controller.add_route ApiComment.new(my_method) unless my_method =~ /^# -\*- coding: UTF-8 -\*-/ 
         
     | 
| 
      
 32 
     | 
    
         
            +
                  end
         
     | 
| 
      
 33 
     | 
    
         
            +
                  controller
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
                  # [
         
     | 
| 
      
 36 
     | 
    
         
            +
                  #   {
         
     | 
| 
      
 37 
     | 
    
         
            +
                  #     :name => "clients",
         
     | 
| 
      
 38 
     | 
    
         
            +
                  #     :routes => [
         
     | 
| 
      
 39 
     | 
    
         
            +
                  #       {
         
     | 
| 
      
 40 
     | 
    
         
            +
                  #         :description => "Show information about client by :id",
         
     | 
| 
      
 41 
     | 
    
         
            +
                  #         :url => "/clients/:id",
         
     | 
| 
      
 42 
     | 
    
         
            +
                  #         :params => [
         
     | 
| 
      
 43 
     | 
    
         
            +
                  #           {
         
     | 
| 
      
 44 
     | 
    
         
            +
                  #             :name => "id",
         
     | 
| 
      
 45 
     | 
    
         
            +
                  #             :type => "String",
         
     | 
| 
      
 46 
     | 
    
         
            +
                  #             :description => "",
         
     | 
| 
      
 47 
     | 
    
         
            +
                  #           },
         
     | 
| 
      
 48 
     | 
    
         
            +
                  #         ],
         
     | 
| 
      
 49 
     | 
    
         
            +
                  #         :returns => [
         
     | 
| 
      
 50 
     | 
    
         
            +
                  #           '{json { :id => x , :name => "John", :email => "john@teste.com"}'
         
     | 
| 
      
 51 
     | 
    
         
            +
                  #         ],
         
     | 
| 
      
 52 
     | 
    
         
            +
                  #         :example => 'curl -l -X GET "http://api.com.br/clients/1" ',
         
     | 
| 
      
 53 
     | 
    
         
            +
                  #         :notes=>[],
         
     | 
| 
      
 54 
     | 
    
         
            +
                  #       }
         
     | 
| 
      
 55 
     | 
    
         
            +
                  #     ]
         
     | 
| 
      
 56 
     | 
    
         
            +
                  #   }
         
     | 
| 
      
 57 
     | 
    
         
            +
                  # ]
         
     | 
| 
      
 58 
     | 
    
         
            +
                end
         
     | 
| 
      
 59 
     | 
    
         
            +
             
     | 
| 
      
 60 
     | 
    
         
            +
                private
         
     | 
| 
      
 61 
     | 
    
         
            +
             
     | 
| 
      
 62 
     | 
    
         
            +
                def comments
         
     | 
| 
      
 63 
     | 
    
         
            +
                  my_methods = []
         
     | 
| 
      
 64 
     | 
    
         
            +
                  same = false
         
     | 
| 
      
 65 
     | 
    
         
            +
                  method = ""
         
     | 
| 
      
 66 
     | 
    
         
            +
                  inside_def = false
         
     | 
| 
      
 67 
     | 
    
         
            +
                  inside_count = 0
         
     | 
| 
      
 68 
     | 
    
         
            +
                  
         
     | 
| 
      
 69 
     | 
    
         
            +
                  @file_content.split("\n").each do |line|
         
     | 
| 
      
 70 
     | 
    
         
            +
                    next if line =~ /# TODO:/
         
     | 
| 
      
 71 
     | 
    
         
            +
             
     | 
| 
      
 72 
     | 
    
         
            +
                    if line=~/^(\s+#|#\s)(.+|)/ && inside_def == false
         
     | 
| 
      
 73 
     | 
    
         
            +
                      if same==false
         
     | 
| 
      
 74 
     | 
    
         
            +
                        same = true
         
     | 
| 
      
 75 
     | 
    
         
            +
                      end
         
     | 
| 
      
 76 
     | 
    
         
            +
                      method += line + "\n" if same == true
         
     | 
| 
      
 77 
     | 
    
         
            +
                    else
         
     | 
| 
      
 78 
     | 
    
         
            +
                      if same == true
         
     | 
| 
      
 79 
     | 
    
         
            +
                        my_methods.append(method)
         
     | 
| 
      
 80 
     | 
    
         
            +
                        method = ""
         
     | 
| 
      
 81 
     | 
    
         
            +
                        same =false
         
     | 
| 
      
 82 
     | 
    
         
            +
                      end
         
     | 
| 
      
 83 
     | 
    
         
            +
                    end
         
     | 
| 
      
 84 
     | 
    
         
            +
             
     | 
| 
      
 85 
     | 
    
         
            +
                    if line.scan(/(^\s+def)/).count > 0
         
     | 
| 
      
 86 
     | 
    
         
            +
                      inside_def = true
         
     | 
| 
      
 87 
     | 
    
         
            +
                      inside_count = line.scan(/(^\s+def)/)[0][0].length
         
     | 
| 
      
 88 
     | 
    
         
            +
                    end
         
     | 
| 
      
 89 
     | 
    
         
            +
                    if line.scan(/(^\s+end)/).count > 0 && inside_count == line.scan(/(^\s+end)/)[0][0].length && inside_def ==  true
         
     | 
| 
      
 90 
     | 
    
         
            +
                      inside_def = false
         
     | 
| 
      
 91 
     | 
    
         
            +
                    end
         
     | 
| 
      
 92 
     | 
    
         
            +
             
     | 
| 
      
 93 
     | 
    
         
            +
                  end
         
     | 
| 
      
 94 
     | 
    
         
            +
                  my_methods
         
     | 
| 
      
 95 
     | 
    
         
            +
                end
         
     | 
| 
      
 96 
     | 
    
         
            +
             
     | 
| 
      
 97 
     | 
    
         
            +
             
     | 
| 
      
 98 
     | 
    
         
            +
             
     | 
| 
      
 99 
     | 
    
         
            +
              end
         
     | 
| 
      
 100 
     | 
    
         
            +
            end
         
     |