1
0
Fork 0
mirror of https://github.com/sinatra/sinatra synced 2023-03-27 23:18:01 -04:00

Rename Sinatra::Params to Sinatra::RequiredParams

/cc #131
This commit is contained in:
Zachary Scott 2016-05-04 17:19:29 +09:00
parent 63c07585d0
commit bd4fd3f66e
5 changed files with 13 additions and 13 deletions

View file

@ -49,7 +49,7 @@ Currently included:
logger instance using +logger+ setting. That logger then will logger instance using +logger+ setting. That logger then will
be available as #logger helper method in your routes and views. be available as #logger helper method in your routes and views.
* `sinatra/params`: Ensure if required query parameters exist * `sinatra/required_params`: Ensure if required query parameters exist
## Custom Extensions ## Custom Extensions

View file

@ -19,7 +19,7 @@ module Sinatra
helpers :JSON helpers :JSON
helpers :LinkHeader helpers :LinkHeader
helpers :Streaming helpers :Streaming
helpers :Params helpers :RequiredParams
end end
## ##

View file

@ -1,7 +1,7 @@
require 'sinatra/base' require 'sinatra/base'
module Sinatra module Sinatra
# = Sinatra::Params # = Sinatra::RequiredParams
# #
# Ensure required query parameters # Ensure required query parameters
# #
@ -25,7 +25,7 @@ module Sinatra
# In a classic application simply require the helpers, and start using them: # In a classic application simply require the helpers, and start using them:
# #
# require "sinatra" # require "sinatra"
# require "sinatra/params" # require "sinatra/required_params"
# #
# # The rest of your classic application code goes here... # # The rest of your classic application code goes here...
# #
@ -35,15 +35,15 @@ module Sinatra
# the application to use them: # the application to use them:
# #
# require "sinatra/base" # require "sinatra/base"
# require "sinatra/params" # require "sinatra/required_params"
# #
# class MyApp < Sinatra::Base # class MyApp < Sinatra::Base
# helpers Sinatra::Params # helpers Sinatra::RequiredParams
# #
# # The rest of your modular application code goes here... # # The rest of your modular application code goes here...
# end # end
# #
module Params module RequiredParams
def required_params(*keys) def required_params(*keys)
_required_params(params, *keys) _required_params(params, *keys)
end end
@ -67,5 +67,5 @@ module Sinatra
end end
end end
helpers Params helpers RequiredParams
end end

View file

@ -147,7 +147,7 @@ Gem::Specification.new do |s|
"lib/sinatra/reloader.rb", "lib/sinatra/reloader.rb",
"lib/sinatra/respond_with.rb", "lib/sinatra/respond_with.rb",
"lib/sinatra/streaming.rb", "lib/sinatra/streaming.rb",
"lib/sinatra/params.rb", "lib/sinatra/required_params.rb",
"lib/sinatra/test_helpers.rb", "lib/sinatra/test_helpers.rb",
"sinatra-contrib.gemspec", "sinatra-contrib.gemspec",
"spec/capture_spec.rb", "spec/capture_spec.rb",

View file

@ -1,11 +1,11 @@
require_relative 'spec_helper' require_relative 'spec_helper'
describe Sinatra::Params do describe Sinatra::RequiredParams do
context "#required_params" do context "#required_params" do
context "simple keys" do context "simple keys" do
before do before do
mock_app do mock_app do
helpers Sinatra::Params helpers Sinatra::RequiredParams
get('/') { required_params(:p1, :p2) } get('/') { required_params(:p1, :p2) }
end end
end end
@ -29,7 +29,7 @@ describe Sinatra::Params do
context "hash keys" do context "hash keys" do
before do before do
mock_app do mock_app do
helpers Sinatra::Params helpers Sinatra::RequiredParams
get('/') { required_params(:p1, :p2 => :p21) } get('/') { required_params(:p1, :p2 => :p21) }
end end
end end
@ -45,7 +45,7 @@ describe Sinatra::Params do
context "complex keys" do context "complex keys" do
before do before do
mock_app do mock_app do
helpers Sinatra::Params helpers Sinatra::RequiredParams
get('/') { required_params(:p1 => [:p11, {:p12 => :p121, :p122 => [:p123, {:p124 => :p1241}]}]) } get('/') { required_params(:p1 => [:p11, {:p12 => :p121, :p122 => [:p123, {:p124 => :p1241}]}]) }
end end
end end