Skip to content

Commit

Permalink
use mruby master
Browse files Browse the repository at this point in the history
  • Loading branch information
pyama86 committed Sep 25, 2023
1 parent 2de908b commit 863a063
Show file tree
Hide file tree
Showing 202 changed files with 6,421 additions and 4,467 deletions.
50 changes: 24 additions & 26 deletions mrbgems/ngx_mruby_mrblib/mrblib/mrb_nginx.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class Nginx
class Request
def scheme
self.var.scheme
var.scheme
end

def document_root
Expand All @@ -14,32 +14,33 @@ def read_body
end

def body
self.get_body
get_body
end

def uri_args
args_to_hash(self.args)
args_to_hash(args)
end

def uri_args=(params)
raise ArgumentError unless params.is_a?(Hash)
self.args = params.map{|k,v| "#{k}=#{v}"}.join("&")

self.args = params.map { |k, v| "#{k}=#{v}" }.join('&')
end

def post_args
args_to_hash(self.body)
args_to_hash(body)
end

private

def args_to_hash(args)
Hash[*args.split("&").map{|arg| arg.split("=", 2)}.flatten]
Hash[*args.split('&').map { |arg| arg.split('=', 2) }.flatten]
end
end

class Headers_in
def user_agent
self["User-Agent"]
self['User-Agent']
end
end

Expand All @@ -50,32 +51,32 @@ def self.var
class Utils
class << self
def encode_parameters(params, delimiter = '&', quote = nil)
if params.is_a?(Hash)
params = params.map do |key, value|
sprintf("%s=%s%s%s", escape(key), quote, escape(value), quote)
end
else
params = params.map { |value| escape(value) }
end
params = if params.is_a?(Hash)
params.map do |key, value|
format('%s=%s%s%s', escape(key), quote, escape(value), quote)
end
else
params.map { |value| escape(value) }
end
delimiter ? params.join(delimiter) : params
end

def escape(str)
reserved_str = [
"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "n", "m", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z",
"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z",
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
"-", ".", "_", "~"
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'n', 'm', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
'-', '.', '_', '~'
]
tmp = ''
str = str.to_s
str.size.times do |idx|
chr = str[idx]
if reserved_str.include?(chr)
tmp += chr
else
tmp += "%" + chr.unpack("H*").first.upcase
end
tmp += if reserved_str.include?(chr)
chr
else
'%' + chr.unpack1('H*').upcase
end
end
tmp
end
Expand Down Expand Up @@ -122,7 +123,6 @@ class Response
end
end


module Kernel
def get_server_class
Nginx
Expand All @@ -132,10 +132,8 @@ def _ngx_mrb_prepare_fiber(nginx_handler)
fiber_handler = Fiber.new { nginx_handler.call }

lambda do
GC.disable
# BUG?: return nginx_handler directly from fiber, not proc in any case.
result = fiber_handler.resume
GC.enable
[fiber_handler.alive?, result]
end
end
Expand Down
14 changes: 14 additions & 0 deletions mruby/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.DS_Store
.idea
.vscode
*.bak
*.iml
*.ipr
*.swp
*.tmp

/.yardoc
/bin
/build
/doc/api
/doc/capi
26 changes: 8 additions & 18 deletions mruby/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -8,37 +8,27 @@ root = true
[*]
charset = utf-8
end_of_line = lf
indent_size = 8
indent_style = tab
indent_size = 2
indent_style = space
insert_final_newline = true
tab_width = 8
trim_trailing_whitespace = true

[{Makefile,Makefile.*,makefile,*.mk}]
trim_trailing_whitespace = true
indent_style = tab
#max_line_length = 80

[*.{c,cc,C,cxx,cpp,h,hh,H,hxx,hpp,inc,y}]
indent_size = 2
indent_style = space
trim_trailing_whitespace = true
#[*.{c,cc,C,cxx,cpp,h,hh,H,hxx,hpp,inc,y}]
#max_line_length = 120

[{*.rb,Rakefile,rakefile,*.rake,*.gemspec,*.gembox}]
indent_size = 2
indent_style = space
trim_trailing_whitespace = true
#[{*.rb,Rakefile,rakefile,*.rake,*.gemspec,*.gembox}]
#max_line_length = 120

# limitation to US-ASCII
[*.bat]
end_of_line = crlf
indent_style = space
#max_line_length = 80

[*.{yaml,yml}]
indent_size = 2
indent_style = space
#[*.{yaml,yml}]

[*.md]
indent_size = 2
indent_style = space
#[*.md]
4 changes: 4 additions & 0 deletions mruby/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
* text=auto eol=lf
*.bat text eol=crlf
*.cmd text eol=crlf
*.png binary
7 changes: 5 additions & 2 deletions mruby/.github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# Basic set up

version: 2
updates:

# Maintain dependencies for Ruby
- package-ecosystem: "bundler"
directory: "/"
schedule:
interval: "daily"
# Maintain dependencies for GitHub Actions
- package-ecosystem: "github-actions"
directory: "/"
Expand Down
29 changes: 29 additions & 0 deletions mruby/.github/labeler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
benchmark:
- benchmark/**/*
build:
- Makefile
- Rakefile
- build_config/**/*
- lib/**/*
- tasks/**/*
core:
- include/**/*
- mrblib/**/*
- src/**/*
- test/**/*
doc:
- CONTRIBUTING.md
- LEGAL
- LICENSE
- NEWS
- README.md
- SECURITY.md
- TODO.md
- doc/**/*
- examples/**/*
github:
- .github/**/*
mrbgems:
- mrbgems/**/*
oss-fuzz:
- oss-fuzz/**/*
6 changes: 6 additions & 0 deletions mruby/.github/linters/.markdown-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,11 @@ MD025: false
# MD026 no-trailing-punctuation - Trailing punctuation in heading
MD026: false

# MD033/no-inline-html - Inline HTML
MD033: false

# MD040 fenced-code-language - Fenced code blocks should have a language specified
MD040: false

# MD041 first-line-heading/first-line-h1 - First line in a file should be a top-level heading
MD041: false
6 changes: 4 additions & 2 deletions mruby/.github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ jobs:
CXX: ${{ matrix.cxx }}
LD: ${{ matrix.cc }}
steps:
- uses: actions/checkout@v3
- name: "Checkout ${{ github.ref }} ( ${{ github.sha }} )"
uses: actions/checkout@v4
- name: Ruby version
run: ruby -v
- name: Compiler version
Expand All @@ -41,7 +42,8 @@ jobs:
env:
MRUBY_CONFIG: ci/msvc
steps:
- uses: actions/checkout@v3
- name: "Checkout ${{ github.ref }} ( ${{ github.sha }} )"
uses: actions/checkout@v4
- name: Ruby version
run: ruby -v
- name: Build and test
Expand Down
53 changes: 0 additions & 53 deletions mruby/.github/workflows/codeql-analysis.yml

This file was deleted.

15 changes: 15 additions & 0 deletions mruby/.github/workflows/labeler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# https://github.com/actions/labeler
name: Pull Request Labeler
on:
- pull_request_target
jobs:
triage:
permissions:
contents: read
pull-requests: write
runs-on: ubuntu-latest
steps:
- uses: actions/labeler@v4
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
sync-labels: true
15 changes: 3 additions & 12 deletions mruby/.github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# https://pre-commit.com/
name: Lint

on: [pull_request]
Expand All @@ -6,22 +7,12 @@ permissions:
contents: read

jobs:
misspell:
name: Check spelling with misspell
runs-on: ubuntu-latest
steps:
- name: Check Out
uses: actions/checkout@v3
- name: Install
run: wget -O - -q https://git.io/misspell | sh -s -- -b .
- name: Run misspell
run: git ls-files --empty-directory | xargs ./misspell -error
pre-commit:
name: Run pre-commit
runs-on: ubuntu-latest
steps:
- name: Check Out
uses: actions/checkout@v3
- name: "Checkout ${{ github.ref }} ( ${{ github.sha }} )"
uses: actions/checkout@v4
- name: Install
run: |
python -m pip install --upgrade pip
Expand Down
1 change: 1 addition & 0 deletions mruby/.github/workflows/oss-fuzz.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# https://github.com/google/oss-fuzz
name: CIFuzz
on: [pull_request]
permissions:
Expand Down
7 changes: 4 additions & 3 deletions mruby/.github/workflows/super-linter.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# https://github.com/super-linter/super-linter
name: Super-Linter

on: [pull_request]
Expand All @@ -13,13 +14,13 @@ jobs:
name: Lint Code Base
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3
- name: "Checkout ${{ github.ref }} ( ${{ github.sha }} )"
uses: actions/checkout@v4
with:
# Full git history is needed to get a proper list of changed files within `super-linter`
fetch-depth: 0
- name: Lint Code Base
uses: github/super-linter/slim@v4.10.1
uses: super-linter/super-linter/slim@v5.3.1
env:
ERROR_ON_MISSING_EXEC_BIT: true
VALIDATE_BASH: true
Expand Down
Loading

0 comments on commit 863a063

Please sign in to comment.