Skip to content

Commit

Permalink
Merge pull request #211 from pakyow/routing-refactor
Browse files Browse the repository at this point in the history
Core routing refactor
  • Loading branch information
bryanp committed Mar 29, 2017
2 parents 835a063 + e526bd6 commit 62d94df
Show file tree
Hide file tree
Showing 130 changed files with 5,884 additions and 5,079 deletions.
21 changes: 21 additions & 0 deletions .rubocop.yml
@@ -1,7 +1,19 @@
inherit_from: .rubocop_todo.yml

AllCops:
TargetRubyVersion: 2.4

Exclude:
- 'bin/**/*'
- 'vendor/**/*'
- '**/spec/**/*'
- 'pakyow-mailer/**/*'
- 'pakyow-presenter/**/*'
- 'pakyow-rake/**/*'
- 'pakyow-realtime/**/*'
- 'pakyow-support/**/*'
- 'pakyow-test/**/*'
- 'pakyow-ui/**/*'
DisplayCopNames: true

BlockDelimiters:
Expand Down Expand Up @@ -33,3 +45,12 @@ Style/FormatString:

Style/RegexpLiteral:
Enabled: false

Style/MethodName:
Enabled: false

Style/ParallelAssignment:
Enabled: false

Style/Semicolon:
Enabled: false
148 changes: 148 additions & 0 deletions .rubocop_todo.yml
@@ -0,0 +1,148 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2017-03-22 17:29:38 -0700 using RuboCop version 0.47.1.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

# Offense count: 3
# Cop supports --auto-correct.
# Configuration parameters: Include.
# Include: **/Gemfile, **/gems.rb
Bundler/OrderedGems:
Exclude:
- 'Gemfile'

# Offense count: 1
# Cop supports --auto-correct.
Lint/DeprecatedClassMethods:
Exclude:
- 'lib/generators/pakyow/app/app_generator.rb'

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: IgnoreEmptyBlocks, AllowUnusedKeywordArguments.
Lint/UnusedBlockArgument:
Exclude:
- 'lib/generators/pakyow/app/app_generator.rb'

# Offense count: 1
# Cop supports --auto-correct.
Performance/RegexpMatch:
Exclude:
- 'lib/pakyow/logger/formatters/logfmt.rb'

# Offense count: 2
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: nested, compact
Style/ClassAndModuleChildren:
Exclude:
- 'example/app/lib/helpers.rb'
- 'lib/generators/pakyow/app/templates/app/lib/helpers.rb'

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, SingleLineConditionsOnly, IncludeTernaryExpressions.
# SupportedStyles: assign_to_condition, assign_inside_condition
Style/ConditionalAssignment:
Exclude:
- 'lib/pakyow/request.rb'

# Offense count: 3
Style/Documentation:
Exclude:
- 'spec/**/*'
- 'test/**/*'
- 'example/app/lib/helpers.rb'
- 'lib/generators/pakyow/app/app_generator.rb'
- 'lib/generators/pakyow/app/templates/app/lib/helpers.rb'

# Offense count: 3
# Configuration parameters: MinBodyLength.
Style/GuardClause:
Exclude:
- 'pakyow-core/lib/pakyow/core/router.rb'
- 'pakyow-core/lib/pakyow/core/routing/extension.rb'

# Offense count: 3
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols.
# SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys
Style/HashSyntax:
Exclude:
- 'Rakefile'

# Offense count: 2
# Cop supports --auto-correct.
Style/MutableConstant:
Exclude:
- 'lib/generators/pakyow/app/app_generator.rb'
- 'pakyow-core/lib/pakyow/core/app.rb'

# Offense count: 1
# Cop supports --auto-correct.
Style/RedundantSelf:
Exclude:
- 'lib/generators/pakyow/app/app_generator.rb'

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: only_raise, only_fail, semantic
Style/SignalException:
Exclude:
- 'Rakefile'

# Offense count: 1
# Cop supports --auto-correct.
Style/SpaceAfterComma:
Exclude:
- 'lib/generators/pakyow/app/app_generator.rb'

# Offense count: 3
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: space, no_space
Style/SpaceBeforeBlockBraces:
Exclude:
- 'lib/generators/pakyow/app/app_generator.rb'

# Offense count: 3
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, EnforcedStyleForEmptyBraces, SupportedStylesForEmptyBraces, SpaceBeforeBlockParameters.
# SupportedStyles: space, no_space
# SupportedStylesForEmptyBraces: space, no_space
Style/SpaceInsideBlockBraces:
Exclude:
- 'Rakefile'
- 'lib/generators/pakyow/app/app_generator.rb'

# Offense count: 37
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, ConsistentQuotesInMultiline.
# SupportedStyles: single_quotes, double_quotes
Style/StringLiterals:
Exclude:
- 'Rakefile'
- 'example/Gemfile'
- 'example/Rakefile'
- 'example/app/lib/routes.rb'
- 'lib/generators/pakyow/app/app_generator.rb'
- 'lib/generators/pakyow/app/templates/Rakefile'
- 'lib/generators/pakyow/app/templates/app/define.rb'
- 'lib/generators/pakyow/app/templates/app/lib/routes.rb'

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: IgnoredMethods.
# IgnoredMethods: respond_to, define_method
Style/SymbolProc:
Exclude:
- 'lib/generators/pakyow/app/app_generator.rb'

# Offense count: 11
# Cop supports --auto-correct.
Style/TrailingWhitespace:
Exclude:
- 'lib/pakyow/environment.rb'
8 changes: 1 addition & 7 deletions Gemfile
@@ -1,6 +1,7 @@
source "https://rubygems.org"

gemspec
gemspec path: "pakyow-core"

gem "rake", "~> 11.1"
gem "rack", "~> 2.0"
Expand All @@ -18,8 +19,6 @@ gem "redis", "~> 3.2"

group :test do
gem "minitest", "~> 5.6"
gem "rspec", "~> 3.2"
gem "pry", "~> 0.10"

gem "simplecov", "~> 0.10", require: false, group: :test
gem "simplecov-console", "~> 0.2"
Expand All @@ -32,8 +31,3 @@ group :test do
gem "httparty", "~> 0.14"
gem "puma", "~> 3.6"
end

group :development do
gem "guard-rspec", "~> 4.6", require: false
gem "rubocop", "~> 0.34"
end
2 changes: 1 addition & 1 deletion example/app/lib/routes.rb
@@ -1,4 +1,4 @@
Pakyow::App.routes do
Pakyow::App.router do
default do
logger.info 'hello ' + Time.now.to_s
end
Expand Down
14 changes: 7 additions & 7 deletions lib/pakyow/all.rb
@@ -1,10 +1,10 @@
%w(
pakyow-support
pakyow-core
pakyow-presenter
pakyow-mailer
pakyow-realtime
pakyow-ui
support
core
presenter
mailer
realtime
ui
).each do |lib|
require lib
require "pakyow/#{lib}"
end
3 changes: 2 additions & 1 deletion lib/pakyow/environment.rb
Expand Up @@ -154,7 +154,7 @@ module Pakyow
# Loads the default middleware stack.
#
before :setup do
use Rack::ContentType, "text/html;charset=utf-8"
use Rack::ContentType, "text/html"
use Rack::ContentLength
use Rack::Head
use Rack::MethodOverride
Expand Down Expand Up @@ -287,6 +287,7 @@ def forked
call_hooks :after, :fork
end

# TODO: this is only ever used by tests and should be removed
# @api private
def call(env)
builder.call(env)
Expand Down
19 changes: 6 additions & 13 deletions lib/pakyow/request.rb
Expand Up @@ -14,11 +14,6 @@ class Request < Rack::Request
# @api public
attr_accessor :error

def initialize(*)
super
@env["CONTENT_TYPE"] = "text/html"
end

# Returns the request method (e.g. `:get`).
#
# @api public
Expand All @@ -34,15 +29,13 @@ def method
#
# @api public
def format
type = Rack::Mime::MIME_TYPES.select { |_key, value|
value == @env["CONTENT_TYPE"]
}
return @format if defined?(@format)

return if type.empty?
extension = type.keys.first
# works around a dumb thing in Rack::Mime
return :html if extension == ".htm"
extension[1..-1].to_sym
if path.include?(".")
@format = path.split(".").last.to_sym
else
@format = :html
end
end

# Returns an indifferentized params hash.
Expand Down
1 change: 0 additions & 1 deletion pakyow-core/lib/pakyow-core.rb

This file was deleted.

28 changes: 8 additions & 20 deletions pakyow-core/lib/pakyow/core.rb
@@ -1,25 +1,13 @@
require "find"
require "rack"
require "rack/file"
require "cgi"

require "pakyow"
require "pakyow/support"

require "pakyow/core/helpers"
require "pakyow/core/app_context"
require "pakyow/core/loader"
require "pakyow/core/router"
require "pakyow/core/route_merger"
require "pakyow/core/route_module"
require "pakyow/core/route_set"
require "pakyow/core/route_eval"
require "pakyow/core/route_expansion_eval"
require "pakyow/core/route_template_eval"
require "pakyow/core/route_template_defaults"
require "pakyow/core/route_lookup"
require "pakyow/core/app"
require "pakyow/core/errors"

require "pakyow/core/hooks"
require "pakyow/core/controller"
require "pakyow/core/helpers"

require "pakyow/core/router"
require "pakyow/core/routing/route"
require "pakyow/core/routing/extension"
require "pakyow/core/routing/route"
require "pakyow/core/routing/expansion"
require "pakyow/core/routing/extensions/resource"

0 comments on commit 62d94df

Please sign in to comment.