From c3ee730d0f5943f3a7f747f5022ef08d216e0233 Mon Sep 17 00:00:00 2001 From: Timur Vafin Date: Mon, 8 Jul 2013 20:54:17 +0400 Subject: [PATCH] Introduce ApiTaster.route_path configuration option --- lib/api_taster.rb | 3 +++ lib/api_taster/route.rb | 2 +- spec/dummy/{app => lib}/api_tasters/global_params/test.rb | 0 spec/dummy/{app => lib}/api_tasters/mapper/test1.rb | 0 .../dummy/{app => lib}/api_tasters/route_collector/test1.rb | 0 .../dummy/{app => lib}/api_tasters/route_collector/test2.rb | 0 spec/mapper_spec.rb | 6 +++--- spec/route_collector_spec.rb | 2 +- 8 files changed, 8 insertions(+), 5 deletions(-) rename spec/dummy/{app => lib}/api_tasters/global_params/test.rb (100%) rename spec/dummy/{app => lib}/api_tasters/mapper/test1.rb (100%) rename spec/dummy/{app => lib}/api_tasters/route_collector/test1.rb (100%) rename spec/dummy/{app => lib}/api_tasters/route_collector/test2.rb (100%) diff --git a/lib/api_taster.rb b/lib/api_taster.rb index 2132588..81d1168 100644 --- a/lib/api_taster.rb +++ b/lib/api_taster.rb @@ -12,6 +12,9 @@ module ApiTaster mattr_accessor :global_params self.global_params = {} + mattr_accessor :route_path + self.route_path = "#{Rails.root}/lib/api_tasters" + def self.routes(&block) ApiTaster::RouteCollector.routes << block end diff --git a/lib/api_taster/route.rb b/lib/api_taster/route.rb index 6dde219..521e6fb 100644 --- a/lib/api_taster/route.rb +++ b/lib/api_taster/route.rb @@ -9,7 +9,7 @@ class Route cattr_accessor :metadata class << self - def map_routes(path = "#{Rails.root}/app/api_tasters") + def map_routes(path = ApiTaster.route_path) self.route_set = Rails.application.routes self.supplied_params = {} self.obsolete_definitions = [] diff --git a/spec/dummy/app/api_tasters/global_params/test.rb b/spec/dummy/lib/api_tasters/global_params/test.rb similarity index 100% rename from spec/dummy/app/api_tasters/global_params/test.rb rename to spec/dummy/lib/api_tasters/global_params/test.rb diff --git a/spec/dummy/app/api_tasters/mapper/test1.rb b/spec/dummy/lib/api_tasters/mapper/test1.rb similarity index 100% rename from spec/dummy/app/api_tasters/mapper/test1.rb rename to spec/dummy/lib/api_tasters/mapper/test1.rb diff --git a/spec/dummy/app/api_tasters/route_collector/test1.rb b/spec/dummy/lib/api_tasters/route_collector/test1.rb similarity index 100% rename from spec/dummy/app/api_tasters/route_collector/test1.rb rename to spec/dummy/lib/api_tasters/route_collector/test1.rb diff --git a/spec/dummy/app/api_tasters/route_collector/test2.rb b/spec/dummy/lib/api_tasters/route_collector/test2.rb similarity index 100% rename from spec/dummy/app/api_tasters/route_collector/test2.rb rename to spec/dummy/lib/api_tasters/route_collector/test2.rb diff --git a/spec/mapper_spec.rb b/spec/mapper_spec.rb index b028a3c..1127ef4 100644 --- a/spec/mapper_spec.rb +++ b/spec/mapper_spec.rb @@ -6,7 +6,7 @@ module ApiTaster before(:all) do ApiTaster.global_params = { :foo => 'bar' } - Route.map_routes "#{Rails.root}/app/api_tasters/global_params" + Route.map_routes "#{Rails.root}/lib/api_tasters/global_params" end it "merges params" do @@ -25,7 +25,7 @@ module ApiTaster end Route.route_set = routes - Route.map_routes "#{Rails.root}/app/api_tasters/mapper" + Route.map_routes "#{Rails.root}/lib/api_tasters/mapper" end it "records obsolete definitions" do @@ -40,7 +40,7 @@ module ApiTaster end end - Route.map_routes "#{Rails.root}/app/api_tasters/mapper" + Route.map_routes "#{Rails.root}/lib/api_tasters/mapper" end it "gets users" do diff --git a/spec/route_collector_spec.rb b/spec/route_collector_spec.rb index 7302bbc..5cde5a6 100644 --- a/spec/route_collector_spec.rb +++ b/spec/route_collector_spec.rb @@ -6,7 +6,7 @@ module ApiTaster Rails.application.routes.draw do resources :dummy_users end - Route.map_routes "#{Rails.root}/app/api_tasters/route_collector" + Route.map_routes "#{Rails.root}/lib/api_tasters/route_collector" end it "gets users" do