Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
rackr (0.0.68)
rackr (0.0.69)
erubi (~> 1.12)
oj (~> 3.15)
rack (>= 2.0, < 4.0)
Expand Down
2 changes: 1 addition & 1 deletion examples/playground/app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def call(_req)
end

App =
Rackr.new(config).call do
Rackr.new(config).app do
get do |req|
req.session['visitas'] ||= 0

Expand Down
2 changes: 1 addition & 1 deletion examples/playground/config.ru
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ puts "\n"
#require_relative '../lib/rackr'
#require 'rackr'

#run (Rackr.new.call do
#run (Rackr.new.app do
#get do |req|
#[200, {'content-type' => 'text/html'}, ["<h1>Hello!</h1>"]]
#end
Expand Down
2 changes: 1 addition & 1 deletion examples/realworld-api/app/app.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
App =
Rackr.new(Config.get).call do
Rackr.new(Config.get).app do
error do |req, e|
p "Rollbar.error(#{e})"

Expand Down
4 changes: 2 additions & 2 deletions lib/rackr.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

# Rackr is a simple router for Rack.
class Rackr
VERSION = '0.0.68'
VERSION = '0.0.69'

class NotFound < StandardError; end

Expand All @@ -31,7 +31,7 @@ def initialize(config = {}, before: [], after: [])
@router = Router.new(config, before: before, after: after)
end

def call(&)
def app(&)
instance_eval(&)

@router
Expand Down
2 changes: 1 addition & 1 deletion lib/spec/rackr/callback_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class SomeClass3
context 'not returning valid rack request' do
it do
app = Rack::Builder.new do
run(Rackr.new(before: proc { 123 }).call do
run(Rackr.new(before: proc { 123 }).app do
get { render text: 'hello' }

error do |_req, e|
Expand Down
30 changes: 15 additions & 15 deletions lib/spec/rackr_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class Index; def self.call; end; end
end

it 'should generate resources routes' do
app = Rackr.new.call do
app = Rackr.new.app do
resources :foods
end

Expand All @@ -90,7 +90,7 @@ class Index; def self.call; end; end
end

it 'should generate resources routes with custom id' do
app = Rackr.new.call do
app = Rackr.new.app do
resources :foods, id: :food_id
end

Expand All @@ -100,7 +100,7 @@ class Index; def self.call; end; end
end

it 'should generate resources routes with a block' do
app = Rackr.new.call do
app = Rackr.new.app do
resources :foods do
get 'test', -> { 'test' }
end
Expand All @@ -111,7 +111,7 @@ class Index; def self.call; end; end

context 'when nesting resources' do
it 'should nest resources routes with a block' do
app = Rackr.new.call do
app = Rackr.new.app do
resources :foods do
resources :nesteds do
resources :foos
Expand All @@ -124,7 +124,7 @@ class Index; def self.call; end; end
end

it 'should nest deeper resources routes with a block' do
app = Rackr.new.call do
app = Rackr.new.app do
resources :foods, id: :food_id do
resources :nesteds, id: :nested_id do
resources :foos
Expand All @@ -138,7 +138,7 @@ class Index; def self.call; end; end

context 'with new params' do
it 'should generate resources routes with custom path' do
app = Rackr.new.call do
app = Rackr.new.app do
resources :foods, path: 'comidas'
end

Expand All @@ -149,7 +149,7 @@ class Index; def self.call; end; end
end

it 'should generate resources routes with custom paths for actions' do
app = Rackr.new.call do
app = Rackr.new.app do
resources :foods, paths: {
index: 'todos',
new: 'novo',
Expand Down Expand Up @@ -179,7 +179,7 @@ class Cb3; def self.call; end; end
end

it 'should add before and after callbacks to specified actions' do
app = Rackr.new.call do
app = Rackr.new.app do
resources :foods, callbacks: [
{ actions: :index, before: Callbacks::Foods::Cb1 },
{ actions: %i[show edit], after: [Callbacks::Foods::Cb2, Callbacks::Foods::Cb3] }
Expand Down Expand Up @@ -220,7 +220,7 @@ def self.call; end
end

it 'should infer const name from scope hierarchy' do
app = Rackr.new.call do
app = Rackr.new.app do
scope 'api' do
scope 'users' do
resources :name
Expand Down Expand Up @@ -264,7 +264,7 @@ class Assign; def self.call; end; end
end

it 'should infer assign callback ignoring the scope' do
app = Rackr.new.call do
app = Rackr.new.app do
scope 'api' do
resources :articles, id: :slug
end
Expand All @@ -278,7 +278,7 @@ class Assign; def self.call; end; end
end

it 'should infer nested assign callbacks ignoring the scope' do
app = Rackr.new.call do
app = Rackr.new.app do
scope 'api' do
resources :articles do
scope 'another' do
Expand Down Expand Up @@ -313,7 +313,7 @@ def self.call(_env, _exception)
end

it 'should route to a specific action for a given error class' do
app = Rackr.new.call do
app = Rackr.new.app do
get 'raise_custom_error' do
raise CustomError
end
Expand All @@ -330,7 +330,7 @@ def self.call(_env, _exception)
end

it 'should handle specific errors' do
app = Rackr.new.call do
app = Rackr.new.app do
get 'raise_a' do
raise CustomErrorA
end
Expand All @@ -349,7 +349,7 @@ def self.call(_env, _exception)
end

it 'should fallback to general error if no specific handler' do
app = Rackr.new.call do
app = Rackr.new.app do
get 'raise_b' do
raise CustomErrorB
end
Expand All @@ -368,7 +368,7 @@ def self.call(_env, _exception)
end

it 'should handle specific errors within scopes' do
app = Rackr.new.call do
app = Rackr.new.app do
error do |_, e|
[500, {}, ["General Error: #{e.class}"]]
end
Expand Down
2 changes: 1 addition & 1 deletion perf_tests/r10k/builders/rackr.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
File.open("#{File.dirname(__FILE__)}/../apps/rackr_#{LEVELS}_#{ROUTES_PER_LEVEL}.rb", 'wb') do |f|
f.puts "# frozen-string-literal: true"
f.puts "require_relative '../../../lib/rackr'"
f.puts "App = Rackr.new.call do"
f.puts "App = Rackr.new.app do"
rackr_routes.call(f, LEVELS, '/', "/", ['a'])
f.puts "end"
end
Binary file added rackr-0.0.69.gem
Binary file not shown.
19 changes: 10 additions & 9 deletions rackr.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,24 @@ require_relative 'lib/rackr'
Gem::Specification.new do |s|
s.name = 'rackr'
s.version = Rackr::VERSION
s.summary = 'A friendly web micro-framework.'
s.description = 'A friendly web micro-framework.'
s.summary = 'Rack first web framework.'
s.description = 'Rack first web framework.'
s.authors = ['Henrique F. Teixeira']
s.email = 'hriqueft@gmail.com'
s.files =
['lib/rackr.rb',
'lib/rackr/utils.rb',
'lib/rackr/action.rb',
'lib/rackr/callback.rb',
'lib/rackr/router.rb',
'lib/rackr/router/dev_html/errors.rb',
'lib/rackr/router/dev_html/dump.rb',
'lib/rackr/router/endpoint.rb',
'lib/rackr/router/dev_html/errors.rb',
'lib/rackr/router/build_request.rb',
'lib/rackr/router/endpoint.rb',
'lib/rackr/router/errors.rb',
'lib/rackr/router/path_route.rb',
'lib/rackr/router/route.rb']
'lib/rackr/router/route.rb',
'lib/rackr/action/callbacks.rb',
'lib/rackr/action.rb',
'lib/rackr/callback.rb',
'lib/rackr/router.rb',
'lib/rackr/utils.rb']
s.homepage =
'https://github.com/henrique-ft/rackr'
s.license = 'MIT'
Expand Down
2 changes: 1 addition & 1 deletion templates/fullstack/app/app.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
App =
Rackr.new(Config.get).call do
Rackr.new(Config.get).app do
get { render text: 'hello world' }

# Beta
Expand Down
1 change: 0 additions & 1 deletion templates/inertia/.gitignore

This file was deleted.

16 changes: 0 additions & 16 deletions templates/inertia/Gemfile

This file was deleted.

68 changes: 0 additions & 68 deletions templates/inertia/Gemfile.lock

This file was deleted.

26 changes: 0 additions & 26 deletions templates/inertia/README.md

This file was deleted.

33 changes: 0 additions & 33 deletions templates/inertia/app/actions/base.rb

This file was deleted.

Loading