Skip to content

Commit

Permalink
Improves code consistency.
Browse files Browse the repository at this point in the history
  • Loading branch information
jejacks0n committed Apr 14, 2019
1 parent b701658 commit cf53a41
Show file tree
Hide file tree
Showing 10 changed files with 15 additions and 69 deletions.
4 changes: 2 additions & 2 deletions app/controllers/apitome/docs_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
class Apitome::DocsController < Object.const_get(Apitome.configuration.parent_controller)
layout Apitome.configuration.layout

helper_method *[
helper_method(*[
:resources,
:example,
:formatted_body,
Expand All @@ -13,7 +13,7 @@ class Apitome::DocsController < Object.const_get(Apitome.configuration.parent_co
:set_example,
:id_for,
:rendered_markdown
]
])

def index
end
Expand Down
2 changes: 1 addition & 1 deletion app/views/apitome/docs/_route.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<section class="route">
<h4><%= t(:route, scope: :apitome) %></h4>
<pre><%= "#{request['request_method']} #{request['request_path']}" %></pre>
<pre><%= "#{request["request_method"]} #{request["request_path"]}" %></pre>
</section>
2 changes: 1 addition & 1 deletion app/views/apitome/docs/_status.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<section class="status">
<h4><%= t(:status, scope: :apitome) %></h4>
<pre><code class="http"><%= request['response_status'] %></code></pre>
<pre><code class="http"><%= request["response_status"] %></code></pre>
</section>
4 changes: 2 additions & 2 deletions app/views/apitome/docs/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
</section>
<% end %>
<% if Apitome.configuration.single_page %>
<a href="#top" id="scroll-to-top" class="hidden btn btn-primary">Back to Top</a>
<a href="#top" id="scroll-to-top" class="hidden btn btn-primary">Back to Top</a>
<% end %>
<%= render 'all_examples' if Apitome.configuration.single_page %>
<%= render "all_examples" if Apitome.configuration.single_page %>
6 changes: 3 additions & 3 deletions app/views/apitome/docs/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<h1 class="resource-name"><%= example['resource'] %></h1>
<%= render partial: 'resource_explanation', locals: { explanation: example['resource_explanation'] } if example['resource_explanation'] %>
<%= render partial: 'example', locals: { example: example.merge!(link: params[:path]) } %>
<h1 class="resource-name"><%= example["resource"] %></h1>
<%= render partial: "resource_explanation", locals: { explanation: example["resource_explanation"] } if example["resource_explanation"] %>
<%= render partial: "example", locals: { example: example.merge!(link: params[:path]) } %>
4 changes: 2 additions & 2 deletions app/views/layouts/apitome/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
<body class="<%= Apitome.configuration.single_page ? "single-page" : "" %>">

<div class="container">
<%= render 'header' %>
<%= render "header" %>
<div class="container docs-container">
<div class="row">
<div class="col-md-4">
<div id="sidebar" class="sidebar hidden-print" role="complementary">
<%= render 'navigation' %>
<%= render "navigation" %>
</div>
</div>
<div class="col-md-8" role="main">
Expand Down
5 changes: 3 additions & 2 deletions lib/apitome/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module Apitome
class Configuration
include Singleton

cattr_accessor *[
cattr_accessor(*[
:mount_at,
:root,
:doc_path,
Expand All @@ -21,7 +21,7 @@ class Configuration
:http_basic_authentication,
:precompile_assets,
:simulated_response,
]
])

@@mount_at = "/api/docs"
@@root = nil # will default to Rails.root if left unset
Expand Down Expand Up @@ -51,5 +51,6 @@ def self.root=(path)
def self.configure
yield @@configuration
end

singleton_class.send(:alias_method, :setup, :configure)
end
1 change: 1 addition & 0 deletions spec/apitome/configuration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
expect(subject.readme).to eq("../api.md")
expect(subject.single_page).to be_truthy
expect(subject.remote_url).to be_nil
expect(subject.http_basic_authentication).to be_nil
# expect(subject.url_formatter).to be_truthy
expect(subject.precompile_assets).to be_truthy
expect(subject.simulated_response).to be_truthy
Expand Down
2 changes: 0 additions & 2 deletions spec/dummy/config.ru
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

# This file is used by Rack-based servers to start the application.

require_relative "config/environment"
Expand Down
54 changes: 0 additions & 54 deletions spec/dummy/config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,60 +12,6 @@

module Dummy
class Application < Rails::Application
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.

# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
# config.time_zone = 'Central Time (US & Canada)'

# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
# config.i18n.default_locale = :de

# Change our relative root url to show that if relative paths are setup properly, teaspoon will
# continue to work and load the proper urls.
config.relative_url_root = "/relative"
config.assets.prefix = "/relative/assets" # this must be set for any asset paths to be correct!

# The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that
# your test database is "scratch space" for the test suite and is wiped
# and recreated between test runs. Don't rely on the data there!
config.cache_classes = true

# Do not eager load code on boot. This avoids loading your whole application
# just for the purpose of running a single test. If you are using a tool that
# preloads Rails for running tests, you may have to set it to true.
config.eager_load = false

# Configure static file server for tests with Cache-Control for performance.
config.serve_static_files = true
config.static_cache_control = "public, max-age=3600"

# Show full error reports and disable caching.
config.consider_all_requests_local = true
config.action_controller.perform_caching = false

# Raise exceptions instead of rendering exception templates.
config.action_dispatch.show_exceptions = false

# Disable request forgery protection in test environment.
config.action_controller.allow_forgery_protection = false

# Tell Action Mailer not to deliver emails to the real world.
# The :test delivery method accumulates sent emails in the
# ActionMailer::Base.deliveries array.
# config.action_mailer.delivery_method = :test

# Randomize the order test cases are executed.
config.active_support.test_order = :random

# Print deprecation notices to the stderr.
config.active_support.deprecation = :stderr

# Raises error for missing translations
# config.action_view.raise_on_missing_translations = true
end
end

0 comments on commit cf53a41

Please sign in to comment.