refactor: use __dir__ in File.expand_path
__dir__ is nice, and available.
This commit is contained in:
parent
5459750259
commit
1559a20b06
|
@ -404,7 +404,7 @@ end
|
|||
|
||||
|
||||
```ruby
|
||||
set :public_folder, File.dirname(__FILE__) + '/static'
|
||||
set :public_folder, __dir__ + '/static'
|
||||
```
|
||||
|
||||
URL ഇളിൽ ഡയറക്ടറി പാത ഉണ്ടാകില്ല . A file
|
||||
|
|
2
Rakefile
2
Rakefile
|
@ -9,7 +9,7 @@ task :spec => :test
|
|||
CLEAN.include "**/*.rbc"
|
||||
|
||||
def source_version
|
||||
@source_version ||= File.read(File.expand_path("../VERSION", __FILE__)).strip
|
||||
@source_version ||= File.read(File.expand_path("VERSION", __dir__)).strip
|
||||
end
|
||||
|
||||
def prev_feature
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# encoding: utf-8
|
||||
$LOAD_PATH.unshift File.expand_path('../lib', __FILE__)
|
||||
$LOAD_PATH.unshift File.expand_path('lib', __dir__)
|
||||
|
||||
begin
|
||||
require 'bundler'
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
version = File.read(File.expand_path("../../VERSION", __FILE__)).strip
|
||||
version = File.read(File.expand_path("../VERSION", __dir__)).strip
|
||||
|
||||
Gem::Specification.new do |s|
|
||||
# general infos
|
||||
|
|
|
@ -2,7 +2,7 @@ require 'rack/protection'
|
|||
require 'rack/test'
|
||||
require 'rack'
|
||||
|
||||
Dir[File.expand_path('../support/**/*.rb', __FILE__)].each { |f| require f }
|
||||
Dir[File.expand_path('support/**/*.rb', __dir__)].each { |f| require f }
|
||||
|
||||
# This file was generated by the `rspec --init` command. Conventionally, all
|
||||
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
$LOAD_PATH.unshift File.expand_path('../lib', __FILE__)
|
||||
$LOAD_PATH.unshift File.expand_path('lib', __dir__)
|
||||
require 'open-uri'
|
||||
require 'yaml'
|
||||
require 'sinatra/contrib/version'
|
||||
|
|
|
@ -28,7 +28,7 @@ module Sinatra
|
|||
#
|
||||
# class Runner < Sinatra::Runner
|
||||
# def app_file
|
||||
# File.expand_path("../server.rb", __FILE__)
|
||||
# File.expand_path("server.rb", __dir__)
|
||||
# end
|
||||
# end
|
||||
#
|
||||
|
@ -49,7 +49,7 @@ module Sinatra
|
|||
# For an example, check https://github.com/apotonick/roar/blob/master/test/integration/runner.rb
|
||||
class Runner
|
||||
def app_file
|
||||
File.expand_path("../server.rb", __FILE__)
|
||||
File.expand_path("server.rb", __dir__)
|
||||
end
|
||||
|
||||
def run
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# -*- encoding: utf-8 -*-
|
||||
|
||||
version = File.read(File.expand_path("../../VERSION", __FILE__)).strip
|
||||
version = File.read(File.expand_path("../VERSION", __dir__)).strip
|
||||
|
||||
Gem::Specification.new do |s|
|
||||
s.name = "sinatra-contrib"
|
||||
|
|
|
@ -4,7 +4,7 @@ describe Sinatra::ConfigFile do
|
|||
def config_file(*args, &block)
|
||||
mock_app do
|
||||
register Sinatra::ConfigFile
|
||||
set :root, File.expand_path('../config_file', __FILE__)
|
||||
set :root, File.expand_path('config_file', __dir__)
|
||||
instance_eval(&block) if block
|
||||
config_file(*args)
|
||||
end
|
||||
|
|
|
@ -4,7 +4,7 @@ describe Sinatra::ContentFor do
|
|||
subject do
|
||||
Sinatra.new do
|
||||
helpers Sinatra::ContentFor
|
||||
set :views, File.expand_path("../content_for", __FILE__)
|
||||
set :views, File.expand_path("content_for", __dir__)
|
||||
end.new!
|
||||
end
|
||||
|
||||
|
@ -215,7 +215,7 @@ describe Sinatra::ContentFor do
|
|||
mock_app do
|
||||
helpers Sinatra::ContentFor
|
||||
set inner, :layout_engine => outer
|
||||
set :views, File.expand_path("../content_for", __FILE__)
|
||||
set :views, File.expand_path("content_for", __dir__)
|
||||
get('/:view') { render(inner, params[:view].to_sym) }
|
||||
get('/:layout/:view') do
|
||||
render inner, params[:view].to_sym, :layout => params[:layout].to_sym
|
||||
|
|
|
@ -661,10 +661,10 @@ describe Sinatra::Namespace do
|
|||
|
||||
specify 'can use a custom views directory' do
|
||||
mock_app do
|
||||
set :views, File.expand_path('../namespace', __FILE__)
|
||||
set :views, File.expand_path('namespace', __dir__)
|
||||
send(verb, '/') { erb :foo }
|
||||
namespace('/foo') do
|
||||
set :views, File.expand_path('../namespace/nested', __FILE__)
|
||||
set :views, File.expand_path('namespace/nested', __dir__)
|
||||
send(verb) { erb :foo }
|
||||
end
|
||||
end
|
||||
|
|
|
@ -4,7 +4,7 @@ require 'fileutils'
|
|||
describe Sinatra::Reloader do
|
||||
# Returns the temporary directory.
|
||||
def tmp_dir
|
||||
File.expand_path('../../tmp', __FILE__)
|
||||
File.expand_path('../tmp', __dir__)
|
||||
end
|
||||
|
||||
# Returns the path of the Sinatra application file created by
|
||||
|
@ -48,7 +48,7 @@ describe Sinatra::Reloader do
|
|||
options[:parent] ||= 'Sinatra::Base'
|
||||
|
||||
update_file(app_file_path) do |f|
|
||||
template_path = File.expand_path('../reloader/app.rb.erb', __FILE__)
|
||||
template_path = File.expand_path('reloader/app.rb.erb', __dir__)
|
||||
template = Tilt.new(template_path, nil, :trim => '<>')
|
||||
f.write template.render(Object.new, options)
|
||||
end
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
version = File.read(File.expand_path("../VERSION", __FILE__)).strip
|
||||
version = File.read(File.expand_path("VERSION", __dir__)).strip
|
||||
|
||||
Gem::Specification.new 'sinatra', version do |s|
|
||||
s.description = "Sinatra is a DSL for quickly creating web applications in Ruby with minimal effort."
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
require File.expand_path('../helper', __FILE__)
|
||||
require File.expand_path('helper', __dir__)
|
||||
|
||||
begin
|
||||
require 'asciidoctor'
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
require File.expand_path('../helper', __FILE__)
|
||||
require File.expand_path('helper', __dir__)
|
||||
|
||||
class BaseTest < Minitest::Test
|
||||
describe 'Sinatra::Base subclasses' do
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
require File.expand_path('../helper', __FILE__)
|
||||
require File.expand_path('helper', __dir__)
|
||||
|
||||
begin
|
||||
require 'builder'
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
require File.expand_path('../helper', __FILE__)
|
||||
require File.expand_path('helper', __dir__)
|
||||
|
||||
begin
|
||||
require 'coffee-script'
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# I like coding: UTF-8
|
||||
require File.expand_path('../helper', __FILE__)
|
||||
require File.expand_path('helper', __dir__)
|
||||
|
||||
class CompileTest < Minitest::Test
|
||||
def self.parses pattern, example, expected_params, mtype = :sinatra, mopts = {}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
require File.expand_path('../helper', __FILE__)
|
||||
require File.expand_path('helper', __dir__)
|
||||
|
||||
begin
|
||||
require 'creole'
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
require File.expand_path('../helper', __FILE__)
|
||||
require File.expand_path('helper', __dir__)
|
||||
|
||||
class DelegatorTest < Minitest::Test
|
||||
class Mirror
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# encoding: UTF-8
|
||||
require File.expand_path('../helper', __FILE__)
|
||||
require File.expand_path('helper', __dir__)
|
||||
require 'erb'
|
||||
|
||||
class BaseTest < Minitest::Test
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
require File.expand_path('../helper', __FILE__)
|
||||
require File.expand_path('helper', __dir__)
|
||||
|
||||
class ERBTest < Minitest::Test
|
||||
def engine
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
require File.expand_path('../helper', __FILE__)
|
||||
require File.expand_path('helper', __dir__)
|
||||
|
||||
class ExtensionsTest < Minitest::Test
|
||||
module FooExtensions
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
require File.expand_path('../helper', __FILE__)
|
||||
require File.expand_path('helper', __dir__)
|
||||
|
||||
class BeforeFilterTest < Minitest::Test
|
||||
it "executes filters in the order defined" do
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
require File.expand_path('../helper', __FILE__)
|
||||
require File.expand_path('helper', __dir__)
|
||||
|
||||
begin
|
||||
require 'haml'
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
require File.expand_path('../helper', __FILE__)
|
||||
require File.expand_path('helper', __dir__)
|
||||
require 'date'
|
||||
require 'json'
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ get '/send' do
|
|||
end
|
||||
|
||||
get '/send_file' do
|
||||
file = File.expand_path '../../views/a/in_a.str', __FILE__
|
||||
file = File.expand_path '../views/a/in_a.str', __dir__
|
||||
send_file file
|
||||
end
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
require File.expand_path('../integration_helper', __FILE__)
|
||||
require File.expand_path('integration_helper', __dir__)
|
||||
|
||||
module IntegrationAsyncHelper
|
||||
def it(message, &block)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
require File.expand_path('../helper', __FILE__)
|
||||
require File.expand_path('../integration_async_helper', __FILE__)
|
||||
require File.expand_path('helper', __dir__)
|
||||
require File.expand_path('integration_async_helper', __dir__)
|
||||
|
||||
# These tests are like integration_test, but they test asynchronous streaming.
|
||||
class IntegrationAsyncTest < Minitest::Test
|
||||
|
|
|
@ -22,7 +22,7 @@ module IntegrationHelper
|
|||
end
|
||||
|
||||
def app_file
|
||||
File.expand_path('../integration/app.rb', __FILE__)
|
||||
File.expand_path('integration/app.rb', __dir__)
|
||||
end
|
||||
|
||||
def environment
|
||||
|
@ -62,7 +62,7 @@ module IntegrationHelper
|
|||
cmd << File.expand_path(file, dir).inspect
|
||||
end
|
||||
cmd << "-w" unless net_http_server?
|
||||
cmd << "-I" << File.expand_path('../../lib', __FILE__).inspect
|
||||
cmd << "-I" << File.expand_path('../lib', __dir__).inspect
|
||||
cmd << app_file.inspect << '-s' << server << '-o' << '127.0.0.1' << '-p' << port
|
||||
cmd << "-e" << environment.to_s << '2>&1'
|
||||
cmd.join " "
|
||||
|
@ -112,7 +112,7 @@ module IntegrationHelper
|
|||
# Create a new container, set load paths and env
|
||||
# SINGLETHREAD means create a new runtime
|
||||
vm = org.jruby.embed.ScriptingContainer.new(org.jruby.embed.LocalContextScope::SINGLETHREAD)
|
||||
vm.load_paths = [File.expand_path('../../lib', __FILE__)]
|
||||
vm.load_paths = [File.expand_path('../lib', __dir__)]
|
||||
vm.environment = ENV.merge('APP_ENV' => environment.to_s)
|
||||
|
||||
# This ensures processing of RUBYOPT which activates Bundler
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
require File.expand_path('../helper', __FILE__)
|
||||
require File.expand_path('../integration_helper', __FILE__)
|
||||
require File.expand_path('helper', __dir__)
|
||||
require File.expand_path('integration_helper', __dir__)
|
||||
|
||||
# These tests start a real server and talk to it over TCP.
|
||||
# Every test runs with every detected server.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
require File.expand_path('../helper', __FILE__)
|
||||
require File.expand_path('helper', __dir__)
|
||||
|
||||
begin
|
||||
require 'liquid'
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
require File.expand_path('../helper', __FILE__)
|
||||
require File.expand_path('helper', __dir__)
|
||||
|
||||
class FooError < RuntimeError
|
||||
end
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
require File.expand_path('../helper', __FILE__)
|
||||
require File.expand_path('helper', __dir__)
|
||||
|
||||
begin
|
||||
require 'markaby'
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
require File.expand_path('../helper', __FILE__)
|
||||
require File.expand_path('helper', __dir__)
|
||||
|
||||
MarkdownTest = proc do
|
||||
def markdown_app(&block)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
require File.expand_path('../helper', __FILE__)
|
||||
require File.expand_path('helper', __dir__)
|
||||
|
||||
begin
|
||||
require 'wikicloth'
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
require File.expand_path('../helper', __FILE__)
|
||||
require File.expand_path('helper', __dir__)
|
||||
|
||||
class MiddlewareTest < Minitest::Test
|
||||
setup do
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
require File.expand_path('../helper', __FILE__)
|
||||
require File.expand_path('helper', __dir__)
|
||||
|
||||
begin
|
||||
require 'nokogiri'
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
require File.expand_path('../helper', __FILE__)
|
||||
require File.expand_path('helper', __dir__)
|
||||
|
||||
begin
|
||||
require 'rabl'
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
require File.expand_path('../helper', __FILE__)
|
||||
require File.expand_path('helper', __dir__)
|
||||
require 'rack'
|
||||
|
||||
class RackTest < Minitest::Test
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
require File.expand_path('../helper', __FILE__)
|
||||
require File.expand_path('helper', __dir__)
|
||||
|
||||
begin
|
||||
require 'radius'
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
require File.expand_path('../helper', __FILE__)
|
||||
require File.expand_path('helper', __dir__)
|
||||
|
||||
begin
|
||||
require 'rdoc'
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# Tests to check if all the README examples work.
|
||||
require File.expand_path('../helper', __FILE__)
|
||||
require File.expand_path('helper', __dir__)
|
||||
|
||||
class ReadmeTest < Minitest::Test
|
||||
example do
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
require File.expand_path('../helper', __FILE__)
|
||||
require File.expand_path('helper', __dir__)
|
||||
require 'stringio'
|
||||
|
||||
class RequestTest < Minitest::Test
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# encoding: utf-8
|
||||
|
||||
require File.expand_path('../helper', __FILE__)
|
||||
require File.expand_path('helper', __dir__)
|
||||
|
||||
class ResponseTest < Minitest::Test
|
||||
setup { @response = Sinatra::Response.new([], 200, { 'Content-Type' => 'text/html' }) }
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
require File.expand_path('../helper', __FILE__)
|
||||
require File.expand_path('helper', __dir__)
|
||||
|
||||
class ThirdPartyError < RuntimeError
|
||||
def http_status; 400 end
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
require File.expand_path('../helper', __FILE__)
|
||||
require File.expand_path('helper', __dir__)
|
||||
|
||||
module RouteAddedTest
|
||||
@routes, @procs = [], []
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# I like coding: UTF-8
|
||||
require File.expand_path('../helper', __FILE__)
|
||||
require File.expand_path('helper', __dir__)
|
||||
|
||||
# Helper method for easy route pattern matching testing
|
||||
def route_def(pattern)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
require File.expand_path('../helper', __FILE__)
|
||||
require File.expand_path('helper', __dir__)
|
||||
|
||||
begin
|
||||
require 'sass'
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
require File.expand_path('../helper', __FILE__)
|
||||
require File.expand_path('helper', __dir__)
|
||||
|
||||
begin
|
||||
require 'sass'
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
require File.expand_path('../helper', __FILE__)
|
||||
require File.expand_path('helper', __dir__)
|
||||
require 'stringio'
|
||||
|
||||
module Rack::Handler
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
require File.expand_path('../helper', __FILE__)
|
||||
require File.expand_path('helper', __dir__)
|
||||
|
||||
class SettingsTest < Minitest::Test
|
||||
setup do
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
require File.expand_path('../helper', __FILE__)
|
||||
require File.expand_path('helper', __dir__)
|
||||
|
||||
class SinatraTest < Minitest::Test
|
||||
it 'creates a new Sinatra::Base subclass on new' do
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
require File.expand_path('../helper', __FILE__)
|
||||
require File.expand_path('helper', __dir__)
|
||||
|
||||
begin
|
||||
require 'slim'
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
require File.expand_path('../helper', __FILE__)
|
||||
require File.expand_path('helper', __dir__)
|
||||
|
||||
class StaticTest < Minitest::Test
|
||||
setup do
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
require File.expand_path('../helper', __FILE__)
|
||||
require File.expand_path('helper', __dir__)
|
||||
|
||||
class StreamingTest < Minitest::Test
|
||||
Stream = Sinatra::Helpers::Stream
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# encoding: UTF-8
|
||||
require File.expand_path('../helper', __FILE__)
|
||||
require File.expand_path('helper', __dir__)
|
||||
File.delete(__dir__ + '/views/layout.test') rescue nil
|
||||
|
||||
class TestTemplate < Tilt::Template
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
require File.expand_path('../helper', __FILE__)
|
||||
require File.expand_path('helper', __dir__)
|
||||
|
||||
begin
|
||||
require 'redcloth'
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
require File.expand_path('../helper', __FILE__)
|
||||
require File.expand_path('helper', __dir__)
|
||||
|
||||
begin
|
||||
require 'wlang'
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
require File.expand_path('../helper', __FILE__)
|
||||
require File.expand_path('helper', __dir__)
|
||||
|
||||
begin
|
||||
require 'yajl'
|
||||
|
|
Loading…
Reference in New Issue