autodoc 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +20 -0
  3. data/Gemfile +9 -0
  4. data/LICENSE.txt +22 -0
  5. data/README.md +59 -0
  6. data/Rakefile +1 -0
  7. data/autodoc.gemspec +26 -0
  8. data/lib/autodoc.rb +28 -0
  9. data/lib/autodoc/collector.rb +11 -0
  10. data/lib/autodoc/document.rb +79 -0
  11. data/lib/autodoc/version.rb +3 -0
  12. data/spec/dummy/Rakefile +7 -0
  13. data/spec/dummy/app/assets/javascripts/application.js +15 -0
  14. data/spec/dummy/app/assets/stylesheets/application.css +13 -0
  15. data/spec/dummy/app/controllers/application_controller.rb +9 -0
  16. data/spec/dummy/app/controllers/recipes_controller.rb +14 -0
  17. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  18. data/spec/dummy/app/mailers/.gitkeep +0 -0
  19. data/spec/dummy/app/models/.gitkeep +0 -0
  20. data/spec/dummy/app/models/recipe.rb +3 -0
  21. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  22. data/spec/dummy/config.ru +4 -0
  23. data/spec/dummy/config/application.rb +65 -0
  24. data/spec/dummy/config/boot.rb +10 -0
  25. data/spec/dummy/config/database.yml +25 -0
  26. data/spec/dummy/config/environment.rb +5 -0
  27. data/spec/dummy/config/environments/development.rb +37 -0
  28. data/spec/dummy/config/environments/production.rb +67 -0
  29. data/spec/dummy/config/environments/test.rb +37 -0
  30. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  31. data/spec/dummy/config/initializers/inflections.rb +15 -0
  32. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  33. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  34. data/spec/dummy/config/initializers/session_store.rb +8 -0
  35. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  36. data/spec/dummy/config/locales/en.yml +5 -0
  37. data/spec/dummy/config/routes.rb +3 -0
  38. data/spec/dummy/db/migrate/20130607075126_create_recipes.rb +10 -0
  39. data/spec/dummy/db/schema.rb +23 -0
  40. data/spec/dummy/doc/recipes.md +25 -0
  41. data/spec/dummy/lib/assets/.gitkeep +0 -0
  42. data/spec/dummy/log/.gitkeep +0 -0
  43. data/spec/dummy/public/404.html +26 -0
  44. data/spec/dummy/public/422.html +26 -0
  45. data/spec/dummy/public/500.html +25 -0
  46. data/spec/dummy/public/favicon.ico +0 -0
  47. data/spec/dummy/script/rails +6 -0
  48. data/spec/requests/recipes_spec.rb +56 -0
  49. data/spec/spec_helper.rb +18 -0
  50. metadata +214 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 48b16f327c311d87c794cb15c8b8d1e80e06ab99
4
+ data.tar.gz: 710522cb6d1e32004813a2c14cebe5c6960a17eb
5
+ SHA512:
6
+ metadata.gz: 4a7eef59bded9b22e2c3900d8004900860d6a328c15a57d573fba518f29da22c64f599c200ce7185f008f7abfc69912cf5951f0253c7d485cc1e46b892d49bde
7
+ data.tar.gz: c0141c63399a45cca283831ebde9a89feb7c45a7fc6197256870a435c51159dd6fc33cd2ca78ba1a4b0a64c7a2a9ac60863fa4967509e447a4eccf736c32afb2
data/.gitignore ADDED
@@ -0,0 +1,20 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle/
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ lib/bundler/man
11
+ log/*.log
12
+ pkg
13
+ pkg/
14
+ rdoc
15
+ spec/dummy/.sass-cache
16
+ spec/dummy/db/*.sqlite3
17
+ spec/dummy/log/*.log
18
+ spec/dummy/tmp/
19
+ spec/reports
20
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,9 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
4
+
5
+ group :test do
6
+ gem "pry-rails"
7
+ gem "rspec-rails"
8
+ gem "weak_parameters"
9
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Ryo Nakamura
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,59 @@
1
+ # Autodoc
2
+ Auto-generate API documents from your request-specs.
3
+
4
+ ## Installation
5
+ ```ruby
6
+ gem "autodoc", group: :test
7
+ ```
8
+
9
+ ## Usage
10
+ All request-specs tagged with `:autodoc` will be auto-documented.
11
+ You must include a HTTP method and request path in the example description.
12
+
13
+ ```
14
+ $ AUTODOC=1 rspec
15
+ ```
16
+
17
+ ```ruby
18
+ # spec/requests/recipes_spec.rb
19
+ describe "Recipes" do
20
+ let(:params) do
21
+ { name: "alice", type: 1 }
22
+ end
23
+
24
+ describe "POST /recipes", autodoc: true do
25
+ it "creates a new recipe" do
26
+ post "/recipes", params
27
+ end
28
+ end
29
+ end
30
+ ```
31
+
32
+ and the following document is generated in [doc/recipes.md](https://github.com/r7kamura/autodoc/blob/master/spec/dummy/doc/recipes.md).
33
+
34
+ <pre>
35
+ ## POST /recipes
36
+ Creates a new recipe
37
+
38
+ ```
39
+ POST /recipes
40
+ ```
41
+
42
+ ### parameters
43
+ * `name` string (required)
44
+ * `type` integer
45
+
46
+
47
+ ### response
48
+ ```
49
+ Status: 201
50
+ location: http://www.example.com/recipes/1
51
+ response:
52
+ {
53
+ "created_at" => "2013-06-07T08:28:35Z",
54
+ "id" => 1,
55
+ "name" => "name",
56
+ "updated_at" => "2013-06-07T08:28:35Z"
57
+ }
58
+ ```
59
+ </pre>
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/autodoc.gemspec ADDED
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "autodoc/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "autodoc"
8
+ spec.version = Autodoc::VERSION
9
+ spec.authors = ["Ryo Nakamura"]
10
+ spec.email = ["r7kamura@gmail.com"]
11
+ spec.summary = "Auto-generate API documents from your request-specs."
12
+ spec.homepage = "https://github.com/r7kamura/autodoc"
13
+ spec.license = "MIT"
14
+
15
+ spec.files = `git ls-files`.split($/)
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_dependency "awesome_print"
21
+ spec.add_dependency "rspec"
22
+ spec.add_development_dependency "bundler", "~> 1.3"
23
+ spec.add_development_dependency "rails", ">= 3.2.11"
24
+ spec.add_development_dependency "rake"
25
+ spec.add_development_dependency "sqlite3"
26
+ end
data/lib/autodoc.rb ADDED
@@ -0,0 +1,28 @@
1
+ require "autodoc/collector"
2
+ require "autodoc/document"
3
+ require "autodoc/version"
4
+
5
+ module Autodoc
6
+ def self.collector
7
+ @collector ||= Autodoc::Collector.new
8
+ end
9
+ end
10
+
11
+ if ENV["AUTODOC"] && defined?(RSpec)
12
+ RSpec.configure do |config|
13
+ config.after(:each, type: :request) do
14
+ if example.metadata[:autodoc]
15
+ Autodoc.collector.collect(example, request, response)
16
+ end
17
+ end
18
+
19
+ config.after(:suite) do
20
+ Autodoc.collector.documents.each do |filepath, documents|
21
+ filepath = filepath.gsub("./spec/requests/", "").gsub("_spec.rb", ".md")
22
+ pathname = Rails.root + "doc/#{filepath}"
23
+ pathname.parent.mkpath
24
+ pathname.open("w") {|file| file << documents.join("\n") }
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,11 @@
1
+ module Autodoc
2
+ class Collector
3
+ def collect(example, request, response)
4
+ documents[example.file_path] << Autodoc::Document.render(example, request, response)
5
+ end
6
+
7
+ def documents
8
+ @documents ||= Hash.new {|hash, key| hash[key] = [] }
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,79 @@
1
+ require "awesome_print"
2
+ require "erb"
3
+
4
+ module Autodoc
5
+ class Document
6
+ def self.render(*args)
7
+ new(*args).render
8
+ end
9
+
10
+ attr_reader :example, :request, :response
11
+
12
+ def initialize(example, request, response)
13
+ @example, @request, @response = example, request, response
14
+ end
15
+
16
+ def render
17
+ ERB.new(template).result(binding)
18
+ end
19
+
20
+ private
21
+
22
+ def template
23
+ File.read(__FILE__).split("__END__\n", 2).last
24
+ end
25
+
26
+ def path
27
+ example.full_description[%r<(GET|POST|PUT|DELETE) ([^ ]+)>, 2]
28
+ end
29
+
30
+ # request.body can be "" (e.g. in PUT and DELETE request)
31
+ def request_body
32
+ "\n" + JSON.parse(response.body).ai(plain: true, indent: 2, index: false)
33
+ rescue JSON::ParserError
34
+ end
35
+
36
+ def parameters_section
37
+ if has_validators?
38
+ "\n### parameters\n#{parameters}\n\n"
39
+ end
40
+ end
41
+
42
+ def parameters
43
+ validators.map do |validator|
44
+ "* `#{validator.key}` #{validator.type}#{' (required)' if validator.required?}"
45
+ end.join("\n")
46
+ end
47
+
48
+ def has_validators?
49
+ !!(defined?(WeakParameters) && validators)
50
+ end
51
+
52
+ def validators
53
+ WeakParameters.stats[request.params[:controller]][request.params[:action]].try(:validators)
54
+ end
55
+
56
+ def link
57
+ "\nLink: #{response.header['Link']}" if response.header["Link"]
58
+ end
59
+
60
+ def location
61
+ "\nlocation: #{response.location}" if response.location
62
+ end
63
+ end
64
+ end
65
+
66
+ __END__
67
+ ## <%= request.method %> <%= path %>
68
+ <%= example.description.camelize %>
69
+
70
+ ```
71
+ <%= request.method %> <%= request.path %>
72
+ ```
73
+ <%= parameters_section %>
74
+ ### response
75
+ ```
76
+ Status: <%= response.status %><%= link %><%= location %>
77
+ response: <%= request_body %>
78
+ ```
79
+
@@ -0,0 +1,3 @@
1
+ module Autodoc
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env rake
2
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
3
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
4
+
5
+ require File.expand_path('../config/application', __FILE__)
6
+
7
+ Dummy::Application.load_tasks
@@ -0,0 +1,15 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // the compiled file.
9
+ //
10
+ // WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
11
+ // GO AFTER THE REQUIRES BELOW.
12
+ //
13
+ //= require jquery
14
+ //= require jquery_ujs
15
+ //= require_tree .
@@ -0,0 +1,13 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the top of the
9
+ * compiled file, but it's generally better to create a new file per style scope.
10
+ *
11
+ *= require_self
12
+ *= require_tree .
13
+ */
@@ -0,0 +1,9 @@
1
+ class ApplicationController < ActionController::Base
2
+ protect_from_forgery
3
+
4
+ respond_to :json
5
+
6
+ rescue_from WeakParameters::ValidationError do
7
+ head 400
8
+ end
9
+ end
@@ -0,0 +1,14 @@
1
+ class RecipesController < ApplicationController
2
+ validates :create do
3
+ string :name, required: true
4
+ integer :type
5
+ end
6
+
7
+ def show
8
+ respond_with Recipe.find(params[:id])
9
+ end
10
+
11
+ def create
12
+ respond_with Recipe.create(params.slice(:name, :type))
13
+ end
14
+ end
@@ -0,0 +1,2 @@
1
+ module ApplicationHelper
2
+ end
File without changes
File without changes
@@ -0,0 +1,3 @@
1
+ class Recipe < ActiveRecord::Base
2
+ attr_accessible :name, :type
3
+ end
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Dummy</title>
5
+ <%= stylesheet_link_tag "application", :media => "all" %>
6
+ <%= javascript_include_tag "application" %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>
@@ -0,0 +1,4 @@
1
+ # This file is used by Rack-based servers to start the application.
2
+
3
+ require ::File.expand_path('../config/environment', __FILE__)
4
+ run Dummy::Application
@@ -0,0 +1,65 @@
1
+ require File.expand_path('../boot', __FILE__)
2
+
3
+ # Pick the frameworks you want:
4
+ require "active_record/railtie"
5
+ require "action_controller/railtie"
6
+ require "action_mailer/railtie"
7
+ require "active_resource/railtie"
8
+ require "sprockets/railtie"
9
+ # require "rails/test_unit/railtie"
10
+
11
+ Bundler.require(*Rails.groups)
12
+ require "autodoc"
13
+
14
+ module Dummy
15
+ class Application < Rails::Application
16
+ # Settings in config/environments/* take precedence over those specified here.
17
+ # Application configuration should go into files in config/initializers
18
+ # -- all .rb files in that directory are automatically loaded.
19
+
20
+ # Custom directories with classes and modules you want to be autoloadable.
21
+ # config.autoload_paths += %W(#{config.root}/extras)
22
+
23
+ # Only load the plugins named here, in the order given (default is alphabetical).
24
+ # :all can be used as a placeholder for all plugins not explicitly named.
25
+ # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
26
+
27
+ # Activate observers that should always be running.
28
+ # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
29
+
30
+ # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
31
+ # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
32
+ # config.time_zone = 'Central Time (US & Canada)'
33
+
34
+ # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
35
+ # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
36
+ # config.i18n.default_locale = :de
37
+
38
+ # Configure the default encoding used in templates for Ruby 1.9.
39
+ config.encoding = "utf-8"
40
+
41
+ # Configure sensitive parameters which will be filtered from the log file.
42
+ config.filter_parameters += [:password]
43
+
44
+ # Enable escaping HTML in JSON.
45
+ config.active_support.escape_html_entities_in_json = true
46
+
47
+ # Use SQL instead of Active Record's schema dumper when creating the database.
48
+ # This is necessary if your schema can't be completely dumped by the schema dumper,
49
+ # like if you have constraints or database-specific column types
50
+ # config.active_record.schema_format = :sql
51
+
52
+ # Enforce whitelist mode for mass assignment.
53
+ # This will create an empty whitelist of attributes available for mass-assignment for all models
54
+ # in your app. As such, your models will need to explicitly whitelist or blacklist accessible
55
+ # parameters by using an attr_accessible or attr_protected declaration.
56
+ config.active_record.whitelist_attributes = true
57
+
58
+ # Enable the asset pipeline
59
+ config.assets.enabled = true
60
+
61
+ # Version of your assets, change this if you want to expire all your assets
62
+ config.assets.version = '1.0'
63
+ end
64
+ end
65
+
@@ -0,0 +1,10 @@
1
+ require 'rubygems'
2
+ gemfile = File.expand_path('../../../../Gemfile', __FILE__)
3
+
4
+ if File.exist?(gemfile)
5
+ ENV['BUNDLE_GEMFILE'] = gemfile
6
+ require 'bundler'
7
+ Bundler.setup
8
+ end
9
+
10
+ $:.unshift File.expand_path('../../../../lib', __FILE__)
@@ -0,0 +1,25 @@
1
+ # SQLite version 3.x
2
+ # gem install sqlite3
3
+ #
4
+ # Ensure the SQLite 3 gem is defined in your Gemfile
5
+ # gem 'sqlite3'
6
+ development:
7
+ adapter: sqlite3
8
+ database: db/development.sqlite3
9
+ pool: 5
10
+ timeout: 5000
11
+
12
+ # Warning: The database defined as "test" will be erased and
13
+ # re-generated from your development database when you run "rake".
14
+ # Do not set this db to the same as development or production.
15
+ test:
16
+ adapter: sqlite3
17
+ database: db/test.sqlite3
18
+ pool: 5
19
+ timeout: 5000
20
+
21
+ production:
22
+ adapter: sqlite3
23
+ database: db/production.sqlite3
24
+ pool: 5
25
+ timeout: 5000
@@ -0,0 +1,5 @@
1
+ # Load the rails application
2
+ require File.expand_path('../application', __FILE__)
3
+
4
+ # Initialize the rails application
5
+ Dummy::Application.initialize!
@@ -0,0 +1,37 @@
1
+ Dummy::Application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb
3
+
4
+ # In the development environment your application's code is reloaded on
5
+ # every request. This slows down response time but is perfect for development
6
+ # since you don't have to restart the web server when you make code changes.
7
+ config.cache_classes = false
8
+
9
+ # Log error messages when you accidentally call methods on nil.
10
+ config.whiny_nils = true
11
+
12
+ # Show full error reports and disable caching
13
+ config.consider_all_requests_local = true
14
+ config.action_controller.perform_caching = false
15
+
16
+ # Don't care if the mailer can't send
17
+ config.action_mailer.raise_delivery_errors = false
18
+
19
+ # Print deprecation notices to the Rails logger
20
+ config.active_support.deprecation = :log
21
+
22
+ # Only use best-standards-support built into browsers
23
+ config.action_dispatch.best_standards_support = :builtin
24
+
25
+ # Raise exception on mass assignment protection for Active Record models
26
+ config.active_record.mass_assignment_sanitizer = :strict
27
+
28
+ # Log the query plan for queries taking more than this (works
29
+ # with SQLite, MySQL, and PostgreSQL)
30
+ config.active_record.auto_explain_threshold_in_seconds = 0.5
31
+
32
+ # Do not compress assets
33
+ config.assets.compress = false
34
+
35
+ # Expands the lines which load the assets
36
+ config.assets.debug = true
37
+ end
@@ -0,0 +1,67 @@
1
+ Dummy::Application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb
3
+
4
+ # Code is not reloaded between requests
5
+ config.cache_classes = true
6
+
7
+ # Full error reports are disabled and caching is turned on
8
+ config.consider_all_requests_local = false
9
+ config.action_controller.perform_caching = true
10
+
11
+ # Disable Rails's static asset server (Apache or nginx will already do this)
12
+ config.serve_static_assets = false
13
+
14
+ # Compress JavaScripts and CSS
15
+ config.assets.compress = true
16
+
17
+ # Don't fallback to assets pipeline if a precompiled asset is missed
18
+ config.assets.compile = false
19
+
20
+ # Generate digests for assets URLs
21
+ config.assets.digest = true
22
+
23
+ # Defaults to nil and saved in location specified by config.assets.prefix
24
+ # config.assets.manifest = YOUR_PATH
25
+
26
+ # Specifies the header that your server uses for sending files
27
+ # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
28
+ # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
29
+
30
+ # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
31
+ # config.force_ssl = true
32
+
33
+ # See everything in the log (default is :info)
34
+ # config.log_level = :debug
35
+
36
+ # Prepend all log lines with the following tags
37
+ # config.log_tags = [ :subdomain, :uuid ]
38
+
39
+ # Use a different logger for distributed setups
40
+ # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
41
+
42
+ # Use a different cache store in production
43
+ # config.cache_store = :mem_cache_store
44
+
45
+ # Enable serving of images, stylesheets, and JavaScripts from an asset server
46
+ # config.action_controller.asset_host = "http://assets.example.com"
47
+
48
+ # Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
49
+ # config.assets.precompile += %w( search.js )
50
+
51
+ # Disable delivery errors, bad email addresses will be ignored
52
+ # config.action_mailer.raise_delivery_errors = false
53
+
54
+ # Enable threaded mode
55
+ # config.threadsafe!
56
+
57
+ # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
58
+ # the I18n.default_locale when a translation can not be found)
59
+ config.i18n.fallbacks = true
60
+
61
+ # Send deprecation notices to registered listeners
62
+ config.active_support.deprecation = :notify
63
+
64
+ # Log the query plan for queries taking more than this (works
65
+ # with SQLite, MySQL, and PostgreSQL)
66
+ # config.active_record.auto_explain_threshold_in_seconds = 0.5
67
+ end
@@ -0,0 +1,37 @@
1
+ Dummy::Application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb
3
+
4
+ # The test environment is used exclusively to run your application's
5
+ # test suite. You never need to work with it otherwise. Remember that
6
+ # your test database is "scratch space" for the test suite and is wiped
7
+ # and recreated between test runs. Don't rely on the data there!
8
+ config.cache_classes = true
9
+
10
+ # Configure static asset server for tests with Cache-Control for performance
11
+ config.serve_static_assets = true
12
+ config.static_cache_control = "public, max-age=3600"
13
+
14
+ # Log error messages when you accidentally call methods on nil
15
+ config.whiny_nils = true
16
+
17
+ # Show full error reports and disable caching
18
+ config.consider_all_requests_local = true
19
+ config.action_controller.perform_caching = false
20
+
21
+ # Raise exceptions instead of rendering exception templates
22
+ config.action_dispatch.show_exceptions = false
23
+
24
+ # Disable request forgery protection in test environment
25
+ config.action_controller.allow_forgery_protection = false
26
+
27
+ # Tell Action Mailer not to deliver emails to the real world.
28
+ # The :test delivery method accumulates sent emails in the
29
+ # ActionMailer::Base.deliveries array.
30
+ config.action_mailer.delivery_method = :test
31
+
32
+ # Raise exception on mass assignment protection for Active Record models
33
+ config.active_record.mass_assignment_sanitizer = :strict
34
+
35
+ # Print deprecation notices to the stderr
36
+ config.active_support.deprecation = :stderr
37
+ end
@@ -0,0 +1,7 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
4
+ # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
5
+
6
+ # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
7
+ # Rails.backtrace_cleaner.remove_silencers!
@@ -0,0 +1,15 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Add new inflection rules using the following format
4
+ # (all these examples are active by default):
5
+ # ActiveSupport::Inflector.inflections do |inflect|
6
+ # inflect.plural /^(ox)$/i, '\1en'
7
+ # inflect.singular /^(ox)en/i, '\1'
8
+ # inflect.irregular 'person', 'people'
9
+ # inflect.uncountable %w( fish sheep )
10
+ # end
11
+ #
12
+ # These inflection rules are supported but not enabled by default:
13
+ # ActiveSupport::Inflector.inflections do |inflect|
14
+ # inflect.acronym 'RESTful'
15
+ # end
@@ -0,0 +1,5 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Add new mime types for use in respond_to blocks:
4
+ # Mime::Type.register "text/richtext", :rtf
5
+ # Mime::Type.register_alias "text/html", :iphone
@@ -0,0 +1,7 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Your secret key for verifying the integrity of signed cookies.
4
+ # If you change this key, all old signed cookies will become invalid!
5
+ # Make sure the secret is at least 30 characters and all random,
6
+ # no regular words or you'll be exposed to dictionary attacks.
7
+ Dummy::Application.config.secret_token = '2da8e59639e7c92b0da46798ed97a45be5834c72cdd9a4ad141dadc5b1175f991b05ef02dde00f9c27cadb3790311e642010b89ed1dad598539980a1ae88be61'
@@ -0,0 +1,8 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ Dummy::Application.config.session_store :cookie_store, key: '_dummy_session'
4
+
5
+ # Use the database for sessions instead of the cookie-based default,
6
+ # which shouldn't be used to store highly confidential information
7
+ # (create the session table with "rails generate session_migration")
8
+ # Dummy::Application.config.session_store :active_record_store
@@ -0,0 +1,14 @@
1
+ # Be sure to restart your server when you modify this file.
2
+ #
3
+ # This file contains settings for ActionController::ParamsWrapper which
4
+ # is enabled by default.
5
+
6
+ # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
7
+ ActiveSupport.on_load(:action_controller) do
8
+ wrap_parameters format: [:json]
9
+ end
10
+
11
+ # Disable root element in JSON by default.
12
+ ActiveSupport.on_load(:active_record) do
13
+ self.include_root_in_json = false
14
+ end
@@ -0,0 +1,5 @@
1
+ # Sample localization file for English. Add more files in this directory for other locales.
2
+ # See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
3
+
4
+ en:
5
+ hello: "Hello world"
@@ -0,0 +1,3 @@
1
+ Dummy::Application.routes.draw do
2
+ resources :recipes, only: [:show, :create]
3
+ end
@@ -0,0 +1,10 @@
1
+ class CreateRecipes < ActiveRecord::Migration
2
+ def change
3
+ create_table :recipes do |t|
4
+ t.string :name
5
+ t.integer :type
6
+
7
+ t.timestamps
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,23 @@
1
+ # encoding: UTF-8
2
+ # This file is auto-generated from the current state of the database. Instead
3
+ # of editing this file, please use the migrations feature of Active Record to
4
+ # incrementally modify your database, and then regenerate this schema definition.
5
+ #
6
+ # Note that this schema.rb definition is the authoritative source for your
7
+ # database schema. If you need to create the application database on another
8
+ # system, you should be using db:schema:load, not running all the migrations
9
+ # from scratch. The latter is a flawed and unsustainable approach (the more migrations
10
+ # you'll amass, the slower it'll run and the greater likelihood for issues).
11
+ #
12
+ # It's strongly recommended to check this file into your version control system.
13
+
14
+ ActiveRecord::Schema.define(:version => 20130607075126) do
15
+
16
+ create_table "recipes", :force => true do |t|
17
+ t.string "name"
18
+ t.integer "type"
19
+ t.datetime "created_at", :null => false
20
+ t.datetime "updated_at", :null => false
21
+ end
22
+
23
+ end
@@ -0,0 +1,25 @@
1
+ ## POST /recipes
2
+ Creates a new recipe
3
+
4
+ ```
5
+ POST /recipes
6
+ ```
7
+
8
+ ### parameters
9
+ * `name` string (required)
10
+ * `type` integer
11
+
12
+
13
+ ### response
14
+ ```
15
+ Status: 201
16
+ location: http://www.example.com/recipes/1
17
+ response:
18
+ {
19
+ "created_at" => "2013-06-07T08:28:35Z",
20
+ "id" => 1,
21
+ "name" => "name",
22
+ "updated_at" => "2013-06-07T08:28:35Z"
23
+ }
24
+ ```
25
+
File without changes
File without changes
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The page you were looking for doesn't exist (404)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/404.html -->
21
+ <div class="dialog">
22
+ <h1>The page you were looking for doesn't exist.</h1>
23
+ <p>You may have mistyped the address or the page may have moved.</p>
24
+ </div>
25
+ </body>
26
+ </html>
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The change you wanted was rejected (422)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/422.html -->
21
+ <div class="dialog">
22
+ <h1>The change you wanted was rejected.</h1>
23
+ <p>Maybe you tried to change something you didn't have access to.</p>
24
+ </div>
25
+ </body>
26
+ </html>
@@ -0,0 +1,25 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>We're sorry, but something went wrong (500)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/500.html -->
21
+ <div class="dialog">
22
+ <h1>We're sorry, but something went wrong.</h1>
23
+ </div>
24
+ </body>
25
+ </html>
File without changes
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3
+
4
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
5
+ require File.expand_path('../../config/boot', __FILE__)
6
+ require 'rails/commands'
@@ -0,0 +1,56 @@
1
+ require "spec_helper"
2
+
3
+ describe "Recipes" do
4
+ let(:env) do
5
+ { "HTTP_ACCEPT" => "application/json" }
6
+ end
7
+
8
+ let(:params) do
9
+ {
10
+ name: "name",
11
+ type: 1,
12
+ }
13
+ end
14
+
15
+ describe "POST /recipes" do
16
+ context "without required param" do
17
+ before do
18
+ params.delete(:name)
19
+ end
20
+
21
+ it "returns 400" do
22
+ post "/recipes", params, env
23
+ response.status.should == 400
24
+ end
25
+ end
26
+
27
+ context "with other typed param" do
28
+ before do
29
+ params[:type] = "x"
30
+ end
31
+
32
+ it "returns 400" do
33
+ post "/recipes", params, env
34
+ response.status.should == 400
35
+ end
36
+ end
37
+
38
+ context "without non-required param" do
39
+ before do
40
+ params.delete(:type)
41
+ end
42
+
43
+ it "creates a new recipe" do
44
+ post "/recipes", params, env
45
+ response.status.should == 201
46
+ end
47
+ end
48
+
49
+ context "with valid condition", :autodoc do
50
+ it "creates a new recipe" do
51
+ post "/recipes", params, env
52
+ response.status.should == 201
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,18 @@
1
+ ENV["RAILS_ENV"] ||= "test"
2
+ require File.expand_path("../../spec/dummy/config/environment", __FILE__)
3
+ require "rspec/rails"
4
+ require "rspec/autorun"
5
+
6
+ RSpec.configure do |config|
7
+ # If you"re not using ActiveRecord, or you"d prefer not to run each of your
8
+ # examples within a transaction, remove the following line or assign false
9
+ # instead of true.
10
+ config.use_transactional_fixtures = true
11
+
12
+ # If true, the base class of anonymous controllers will be inferred
13
+ # automatically. This will be the default behavior in future versions of
14
+ # rspec-rails.
15
+ config.infer_base_class_for_anonymous_controllers = false
16
+
17
+ config.treat_symbols_as_metadata_keys_with_true_values = true
18
+ end
metadata ADDED
@@ -0,0 +1,214 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: autodoc
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Ryo Nakamura
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-06-07 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: awesome_print
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '1.3'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '1.3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rails
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: 3.2.11
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: 3.2.11
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: sqlite3
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description:
98
+ email:
99
+ - r7kamura@gmail.com
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - .gitignore
105
+ - Gemfile
106
+ - LICENSE.txt
107
+ - README.md
108
+ - Rakefile
109
+ - autodoc.gemspec
110
+ - lib/autodoc.rb
111
+ - lib/autodoc/collector.rb
112
+ - lib/autodoc/document.rb
113
+ - lib/autodoc/version.rb
114
+ - spec/dummy/Rakefile
115
+ - spec/dummy/app/assets/javascripts/application.js
116
+ - spec/dummy/app/assets/stylesheets/application.css
117
+ - spec/dummy/app/controllers/application_controller.rb
118
+ - spec/dummy/app/controllers/recipes_controller.rb
119
+ - spec/dummy/app/helpers/application_helper.rb
120
+ - spec/dummy/app/mailers/.gitkeep
121
+ - spec/dummy/app/models/.gitkeep
122
+ - spec/dummy/app/models/recipe.rb
123
+ - spec/dummy/app/views/layouts/application.html.erb
124
+ - spec/dummy/config.ru
125
+ - spec/dummy/config/application.rb
126
+ - spec/dummy/config/boot.rb
127
+ - spec/dummy/config/database.yml
128
+ - spec/dummy/config/environment.rb
129
+ - spec/dummy/config/environments/development.rb
130
+ - spec/dummy/config/environments/production.rb
131
+ - spec/dummy/config/environments/test.rb
132
+ - spec/dummy/config/initializers/backtrace_silencers.rb
133
+ - spec/dummy/config/initializers/inflections.rb
134
+ - spec/dummy/config/initializers/mime_types.rb
135
+ - spec/dummy/config/initializers/secret_token.rb
136
+ - spec/dummy/config/initializers/session_store.rb
137
+ - spec/dummy/config/initializers/wrap_parameters.rb
138
+ - spec/dummy/config/locales/en.yml
139
+ - spec/dummy/config/routes.rb
140
+ - spec/dummy/db/migrate/20130607075126_create_recipes.rb
141
+ - spec/dummy/db/schema.rb
142
+ - spec/dummy/doc/recipes.md
143
+ - spec/dummy/lib/assets/.gitkeep
144
+ - spec/dummy/log/.gitkeep
145
+ - spec/dummy/public/404.html
146
+ - spec/dummy/public/422.html
147
+ - spec/dummy/public/500.html
148
+ - spec/dummy/public/favicon.ico
149
+ - spec/dummy/script/rails
150
+ - spec/requests/recipes_spec.rb
151
+ - spec/spec_helper.rb
152
+ homepage: https://github.com/r7kamura/autodoc
153
+ licenses:
154
+ - MIT
155
+ metadata: {}
156
+ post_install_message:
157
+ rdoc_options: []
158
+ require_paths:
159
+ - lib
160
+ required_ruby_version: !ruby/object:Gem::Requirement
161
+ requirements:
162
+ - - '>='
163
+ - !ruby/object:Gem::Version
164
+ version: '0'
165
+ required_rubygems_version: !ruby/object:Gem::Requirement
166
+ requirements:
167
+ - - '>='
168
+ - !ruby/object:Gem::Version
169
+ version: '0'
170
+ requirements: []
171
+ rubyforge_project:
172
+ rubygems_version: 2.0.2
173
+ signing_key:
174
+ specification_version: 4
175
+ summary: Auto-generate API documents from your request-specs.
176
+ test_files:
177
+ - spec/dummy/Rakefile
178
+ - spec/dummy/app/assets/javascripts/application.js
179
+ - spec/dummy/app/assets/stylesheets/application.css
180
+ - spec/dummy/app/controllers/application_controller.rb
181
+ - spec/dummy/app/controllers/recipes_controller.rb
182
+ - spec/dummy/app/helpers/application_helper.rb
183
+ - spec/dummy/app/mailers/.gitkeep
184
+ - spec/dummy/app/models/.gitkeep
185
+ - spec/dummy/app/models/recipe.rb
186
+ - spec/dummy/app/views/layouts/application.html.erb
187
+ - spec/dummy/config.ru
188
+ - spec/dummy/config/application.rb
189
+ - spec/dummy/config/boot.rb
190
+ - spec/dummy/config/database.yml
191
+ - spec/dummy/config/environment.rb
192
+ - spec/dummy/config/environments/development.rb
193
+ - spec/dummy/config/environments/production.rb
194
+ - spec/dummy/config/environments/test.rb
195
+ - spec/dummy/config/initializers/backtrace_silencers.rb
196
+ - spec/dummy/config/initializers/inflections.rb
197
+ - spec/dummy/config/initializers/mime_types.rb
198
+ - spec/dummy/config/initializers/secret_token.rb
199
+ - spec/dummy/config/initializers/session_store.rb
200
+ - spec/dummy/config/initializers/wrap_parameters.rb
201
+ - spec/dummy/config/locales/en.yml
202
+ - spec/dummy/config/routes.rb
203
+ - spec/dummy/db/migrate/20130607075126_create_recipes.rb
204
+ - spec/dummy/db/schema.rb
205
+ - spec/dummy/doc/recipes.md
206
+ - spec/dummy/lib/assets/.gitkeep
207
+ - spec/dummy/log/.gitkeep
208
+ - spec/dummy/public/404.html
209
+ - spec/dummy/public/422.html
210
+ - spec/dummy/public/500.html
211
+ - spec/dummy/public/favicon.ico
212
+ - spec/dummy/script/rails
213
+ - spec/requests/recipes_spec.rb
214
+ - spec/spec_helper.rb