api_doc_viewer 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 92cf06b3e60ca449c24dff0eb65978182e03dfe2
4
- data.tar.gz: 428396d3e4fadff6d768ed9ff7c594dfc9304df9
3
+ metadata.gz: 25c2ca3661218734a8b9cbf73ea26f37439670eb
4
+ data.tar.gz: c74bb775676baaa917b630144748afd5bd971bc6
5
5
  SHA512:
6
- metadata.gz: 7f731f25047fc71c2fafbea12d403aecfc374034fdb7fc4b206a240c88639f0a89916daa1005cf58ce21d1f90c1d64712b33c6183c08169f084eab16170abf55
7
- data.tar.gz: 72e568abd9b99eda06daff3e5e4c96e7201ed3388deb42f134d36382df72b1f096836067ee5465fdb1b33e6c2b18c09a4bca129ddfbd9b81376b9a4a624f490f
6
+ metadata.gz: 0b4521dc23aa928c4dc37f2c3a33f5b1c7783484203fa309cd960ae8ceb91de17dee528f07403b21260f7f2d84aaf4db9e8e6d05032ee44491e3cb33f9f209ea
7
+ data.tar.gz: 3b6888920a487570fee74909ec648360f8633996723a906e91d5ada8fca31c78ad1e2acf90b1edd97b0b350ea834302863f57d7141680e86ddd46093d58daeb1
data/Rakefile CHANGED
@@ -14,11 +14,9 @@ RDoc::Task.new(:rdoc) do |rdoc|
14
14
  rdoc.rdoc_files.include('lib/**/*.rb')
15
15
  end
16
16
 
17
- APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
17
+ APP_RAKEFILE = File.expand_path('../test/dummy/Rakefile', __FILE__)
18
18
  load 'rails/tasks/engine.rake'
19
19
 
20
-
21
-
22
20
  Bundler::GemHelper.install_tasks
23
21
 
24
22
  require 'rake/testtask'
@@ -30,5 +28,4 @@ Rake::TestTask.new(:test) do |t|
30
28
  t.verbose = false
31
29
  end
32
30
 
33
-
34
31
  task default: :test
@@ -22,7 +22,7 @@ angular.module('controllers').controller 'mainController', ['$scope', 'mainServi
22
22
  ]
23
23
 
24
24
  formatJSONWithSpaces = (data) ->
25
- if data && data.trim().match(/^\{.*\}$/)
25
+ if data && data.trim().match(/^[\[\{].*[\}\]]$/)
26
26
  JSON.stringify(JSON.parse(data), undefined, 2);
27
27
 
28
28
  filterHeaders = (headers) ->
@@ -1,18 +1,15 @@
1
- require_dependency "api_doc_viewer/application_controller"
1
+ require_dependency 'api_doc_viewer/application_controller'
2
2
 
3
3
  module ApiDocViewer
4
4
  class MainController < ApplicationController
5
-
6
5
  def index
7
6
  end
8
7
 
9
8
  def documentation
10
- file = File.join(Rails.root, 'doc', 'api', params[:link] || 'index.json')
11
- if File.exists?(file)
12
- render json: File.read(file)
13
- else
14
- head :not_found
15
- end
9
+ path = File.join(Rails.root, 'doc', 'api', params[:link] || 'index.json')
10
+ return head :unauthorized if path.include?('..') || !path.ends_with?('.json')
11
+ return head :not_found unless File.exist?(path)
12
+ render json: File.read(path)
16
13
  end
17
14
  end
18
15
  end
data/config/routes.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  ApiDocViewer::Engine.routes.draw do
2
-
2
+
3
3
  root to: 'main#index', via: :get
4
4
  get 'documentation', to: 'main#documentation'
5
5
  end
@@ -1,3 +1,3 @@
1
1
  module ApiDocViewer
2
- VERSION = "0.1.0"
2
+ VERSION = '0.2.0'
3
3
  end
@@ -1,4 +1,4 @@
1
- require "api_doc_viewer/engine"
1
+ require 'api_doc_viewer/engine'
2
2
 
3
3
  module ApiDocViewer
4
4
  end
@@ -1,7 +1,7 @@
1
1
  require 'test_helper'
2
2
 
3
3
  class ApiDocViewerTest < ActiveSupport::TestCase
4
- test "truth" do
4
+ test 'truth' do
5
5
  assert_kind_of Module, ApiDocViewer
6
6
  end
7
7
  end
@@ -3,7 +3,7 @@ require File.expand_path('../boot', __FILE__)
3
3
  require 'rails/all'
4
4
 
5
5
  Bundler.require(*Rails.groups)
6
- require "api_doc_viewer"
6
+ require 'api_doc_viewer'
7
7
 
8
8
  module Dummy
9
9
  class Application < Rails::Application
@@ -20,4 +20,3 @@ module Dummy
20
20
  # config.i18n.default_locale = :de
21
21
  end
22
22
  end
23
-
@@ -14,7 +14,7 @@ Dummy::Application.configure do
14
14
 
15
15
  # Configure static asset server for tests with Cache-Control for performance.
16
16
  config.serve_static_assets = true
17
- config.static_cache_control = "public, max-age=3600"
17
+ config.static_cache_control = 'public, max-age=3600'
18
18
 
19
19
  # Show full error reports and disable caching.
20
20
  config.consider_all_requests_local = true
@@ -1,4 +1,4 @@
1
1
  Rails.application.routes.draw do
2
2
 
3
- mount ApiDocViewer::Engine => "/api_doc_viewer"
3
+ mount ApiDocViewer::Engine => '/api_doc_viewer'
4
4
  end
@@ -11,5 +11,10 @@ ApiDocViewerTest: test_truth
11
11
   (0.3ms) begin transaction
12
12
  ----------------------------
13
13
  ApiDocViewerTest: test_truth
14
+ ----------------------------
15
+  (0.1ms) rollback transaction
16
+  (0.1ms) begin transaction
17
+ ----------------------------
18
+ ApiDocViewerTest: test_truth
14
19
  ----------------------------
15
20
   (0.1ms) rollback transaction
@@ -7,4 +7,3 @@ class NavigationTest < ActionDispatch::IntegrationTest
7
7
  # assert true
8
8
  # end
9
9
  end
10
-
data/test/test_helper.rb CHANGED
@@ -1,8 +1,8 @@
1
1
  # Configure Rails Environment
2
- ENV["RAILS_ENV"] = "test"
2
+ ENV['RAILS_ENV'] = 'test'
3
3
 
4
- require File.expand_path("../dummy/config/environment.rb", __FILE__)
5
- require "rails/test_help"
4
+ require File.expand_path('../dummy/config/environment.rb', __FILE__)
5
+ require 'rails/test_help'
6
6
 
7
7
  Rails.backtrace_cleaner.remove_silencers!
8
8
 
@@ -11,5 +11,5 @@ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
11
11
 
12
12
  # Load fixtures from the engine
13
13
  if ActiveSupport::TestCase.method_defined?(:fixture_path=)
14
- ActiveSupport::TestCase.fixture_path = File.expand_path("../fixtures", __FILE__)
14
+ ActiveSupport::TestCase.fixture_path = File.expand_path('../fixtures', __FILE__)
15
15
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: api_doc_viewer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Endri Gjiri
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-04 00:00:00.000000000 Z
11
+ date: 2014-09-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails