diff --git a/Appraisals b/Appraisals index d57ae2d..98ff3ca 100644 --- a/Appraisals +++ b/Appraisals @@ -14,3 +14,9 @@ appraise "rails-5.0.0" do gem "rails", "5.0.0" gem 'rails-controller-testing' end + +appraise "rails-api-4.2.7" do + gem 'rails', '4.2.7.1' + gem 'rails-api', '0.4.0' + gem 'actionpack' , '4.2.7.1' +end diff --git a/Gemfile b/Gemfile index 73ceb37..7445b1d 100644 --- a/Gemfile +++ b/Gemfile @@ -4,8 +4,6 @@ gemspec gem 'wash_out', github: 'inossidabile/wash_out' -if RUBY_VERSION >= "2.2.0" - gem 'activesupport', '>= 4.0', '>= 4.0' -else +if RUBY_VERSION < "2.2.0" gem 'activesupport', '>= 4.0', '< 5.0' end diff --git a/app/controllers/washout_builder/washout_builder_controller.rb b/app/controllers/washout_builder/washout_builder_controller.rb index 3156464..1b2f6f4 100644 --- a/app/controllers/washout_builder/washout_builder_controller.rb +++ b/app/controllers/washout_builder/washout_builder_controller.rb @@ -22,19 +22,33 @@ def all route_details = params[:name].present? ? controller_is_a_service?(params[:name]) : nil if route_details.present? && defined?(controller_class(params[:name])) @document = WashoutBuilder::Document::Generator.new(route_details, controller_class(params[:name]).controller_path) - render template: 'wash_with_html/doc', layout: false, - content_type: 'text/html' + render_html('wash_with_html/doc') elsif @services = all_services - render template: 'wash_with_html/all_services', layout: false, - content_type: 'text/html' + render_html('wash_with_html/all_services') end end private def env_controller_path - request.env['washout_builder.controller_path'] + request.env['washout_builder.controller_path'] + end + + + def render_html(path, options= { layout: false, content_type: 'text/html' }) + options = options.merge(template: path) + respond_to do |format| + format.json { render options } + render_html_format_all(format, options) + end + end + + def render_html_format_all(format, options) + format.all do + response.content_type = 'text/html; charset=utf-8' + render options.merge(formats: [:html]) + end end # tries to find all services by searching through the rails controller diff --git a/gemfiles/rails_4.0.0.gemfile b/gemfiles/rails_4.0.0.gemfile index 7a53f7b..c42e2a3 100644 --- a/gemfiles/rails_4.0.0.gemfile +++ b/gemfiles/rails_4.0.0.gemfile @@ -3,7 +3,6 @@ source "http://rubygems.org" gem "wash_out", :github => "inossidabile/wash_out" -gem "activesupport", ">= 4.0", ">= 4.0" gem "rails", "4.0.0" gemspec :path => "../" diff --git a/gemfiles/rails_4.1.1.gemfile b/gemfiles/rails_4.1.1.gemfile index 269486a..b482c77 100644 --- a/gemfiles/rails_4.1.1.gemfile +++ b/gemfiles/rails_4.1.1.gemfile @@ -3,7 +3,6 @@ source "http://rubygems.org" gem "wash_out", :github => "inossidabile/wash_out" -gem "activesupport", ">= 4.0", ">= 4.0" gem "rails", "4.1.1" gemspec :path => "../" diff --git a/gemfiles/rails_4.2.0.gemfile b/gemfiles/rails_4.2.0.gemfile index 11a50cd..5f49524 100644 --- a/gemfiles/rails_4.2.0.gemfile +++ b/gemfiles/rails_4.2.0.gemfile @@ -3,7 +3,6 @@ source "http://rubygems.org" gem "wash_out", :github => "inossidabile/wash_out" -gem "activesupport", ">= 4.0", ">= 4.0" gem "rails", "4.2.0" gemspec :path => "../" diff --git a/gemfiles/rails_5.0.0.gemfile b/gemfiles/rails_5.0.0.gemfile index dd6ea02..bc89f84 100644 --- a/gemfiles/rails_5.0.0.gemfile +++ b/gemfiles/rails_5.0.0.gemfile @@ -3,7 +3,6 @@ source "http://rubygems.org" gem "wash_out", :github => "inossidabile/wash_out" -gem "activesupport", ">= 4.0", ">= 4.0" gem "rails", "5.0.0" gem "rails-controller-testing" diff --git a/gemfiles/rails_api_4.2.7.gemfile b/gemfiles/rails_api_4.2.7.gemfile new file mode 100644 index 0000000..bf72dab --- /dev/null +++ b/gemfiles/rails_api_4.2.7.gemfile @@ -0,0 +1,10 @@ +# This file was generated by Appraisal + +source "http://rubygems.org" + +gem "wash_out", :github => "inossidabile/wash_out" +gem "rails", "4.2.7.1" +gem "rails-api", "0.4.0" +gem "actionpack", "4.2.7.1" + +gemspec :path => "../" diff --git a/lib/washout_builder.rb b/lib/washout_builder.rb index 3a910bf..ad670fd 100644 --- a/lib/washout_builder.rb +++ b/lib/washout_builder.rb @@ -25,7 +25,6 @@ def wash_out(controller_name, options={}) controller_class_name = controller_name.to_s.underscore end match "#{controller_name}/soap_doc" => WashoutBuilder::Router.new(controller_class_name), via: :get, - format: false, as: "#{controller_class_name}_soap_doc" end original_wash_out(controller_name, options) diff --git a/lib/washout_builder/router.rb b/lib/washout_builder/router.rb index b19b8b9..40697e4 100644 --- a/lib/washout_builder/router.rb +++ b/lib/washout_builder/router.rb @@ -9,6 +9,7 @@ def initialize(controller_path) def call(env) env['washout_builder.controller_path'] = @controller_path + env["action_dispatch.request.content_type"] = Mime[:html] ::WashoutBuilder::WashoutBuilderController.action(:all).call(env) end diff --git a/lib/washout_builder/version.rb b/lib/washout_builder/version.rb index 1733a44..7e9e5bc 100644 --- a/lib/washout_builder/version.rb +++ b/lib/washout_builder/version.rb @@ -12,7 +12,7 @@ module VERSION # the minor version of the gem MINOR = 6 # the tiny version of the gem - TINY = 2 + TINY = 3 # if the version should be a prerelease PRE = nil