├── .ruby-version ├── .dockerignore ├── compose.yml ├── heroku.yml ├── .hadolint.yaml ├── config.ru ├── .github ├── dependabot.yml ├── workflows │ ├── build.yml │ ├── test.yml │ ├── lint.yml │ └── codeql-analysis.yml └── SECURITY.md ├── .gitignore ├── .rubocop.yml ├── .editorconfig ├── app.yaml ├── app.json ├── .vscode ├── settings.json ├── extensions.json ├── tasks.json └── launch.json ├── Gemfile ├── Dockerfile ├── LICENSE ├── README.md ├── spec └── fluentular_spec.rb ├── Gemfile.lock └── app.rb /.ruby-version: -------------------------------------------------------------------------------- 1 | 3.2.1 2 | -------------------------------------------------------------------------------- /.dockerignore: -------------------------------------------------------------------------------- 1 | * 2 | !Gemfile 3 | !Gemfile.lock 4 | !app.rb 5 | !config.ru 6 | -------------------------------------------------------------------------------- /compose.yml: -------------------------------------------------------------------------------- 1 | services: 2 | app: 3 | build: . 4 | ports: 5 | - 8080:8080 6 | -------------------------------------------------------------------------------- /heroku.yml: -------------------------------------------------------------------------------- 1 | build: 2 | languages: 3 | - ruby 4 | 5 | run: 6 | web: bundle exec rackup config.ru -p ${PORT} 7 | -------------------------------------------------------------------------------- /.hadolint.yaml: -------------------------------------------------------------------------------- 1 | # Hadolint configuration 2 | # https://github.com/hadolint/hadolint#configure 3 | 4 | ignored: 5 | - DL3018 6 | -------------------------------------------------------------------------------- /config.ru: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | $LOAD_PATH.unshift(__dir__) 4 | 5 | require 'app' 6 | run Sinatra::Application 7 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: bundler 4 | directory: / 5 | schedule: 6 | interval: daily 7 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Bundler 2 | /bin 3 | /.bundle 4 | /.config 5 | /vendor 6 | 7 | # Others 8 | /coverage 9 | /tmp 10 | 11 | # Elastic Beanstalk Files 12 | .elasticbeanstalk/* 13 | !.elasticbeanstalk/*.cfg.yml 14 | !.elasticbeanstalk/*.global.yml 15 | -------------------------------------------------------------------------------- /.rubocop.yml: -------------------------------------------------------------------------------- 1 | # Add `rubocop-rspec` as optional plugin 2 | require: 3 | - rubocop-performance 4 | - rubocop-rspec 5 | 6 | AllCops: 7 | NewCops: enable 8 | TargetRubyVersion: 3.2 9 | 10 | Metrics/BlockLength: 11 | Exclude: 12 | - 'spec/**/*' 13 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig is awesome: https://EditorConfig.org 2 | 3 | # top-most EditorConfig file 4 | root = true 5 | 6 | [*] 7 | charset = utf-8 8 | indent_style = space 9 | indent_size = 2 10 | trim_trailing_whitespace = true 11 | end_of_line = lf 12 | insert_final_newline = true 13 | -------------------------------------------------------------------------------- /app.yaml: -------------------------------------------------------------------------------- 1 | # Google App Engine Configuration 2 | # https://cloud.google.com/appengine/docs/flexible/custom-runtimes/configuring-your-app-with-app-yaml 3 | 4 | # General settings 5 | runtime: custom 6 | vm: true 7 | api_version: 1 8 | 9 | # Scaling settings 10 | manual_scaling: 11 | instances: 1 12 | -------------------------------------------------------------------------------- /app.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Fluentular", 3 | "description": "Fluentular is a Fluentd regular expression editor", 4 | "repository": "https://github.com/tomohiro/fluentular", 5 | "keywords": ["ruby", "sinatra", "fluentd"], 6 | "website": "https://fluentular.herokuapp.com", 7 | "stack": "container" 8 | } 9 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "ruby": { 3 | "useBundler": false, 4 | "useLanguageServer": true, 5 | "lint": { 6 | "rubocop": { 7 | "useBundler": true 8 | }, 9 | "reek": { 10 | "useBundler": true 11 | } 12 | }, 13 | "format": "rubocop" 14 | }, 15 | "solargraph.useBundler": false, 16 | } 17 | -------------------------------------------------------------------------------- /.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": [ 3 | "editorconfig.editorconfig", 4 | // Please install following gems to use Ruby extensions. 5 | // gem install solargraph 6 | // gem install debase 7 | // gem install ruby-debug-ide 8 | "rebornix.ruby", 9 | "castwide.solargraph", 10 | "ms-azuretools.vscode-docker" 11 | ] 12 | } 13 | -------------------------------------------------------------------------------- /.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0.0", 3 | "tasks": [ 4 | { 5 | "label": "rubocop", 6 | "command": "${workspaceRoot}/bin/rubocop", 7 | "args": [ 8 | "--parallel" 9 | ], 10 | "problemMatcher": [] 11 | }, 12 | { 13 | "label": "rspec", 14 | "command": "${workspaceRoot}/bin/rspec", 15 | "problemMatcher": [] 16 | } 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2.0", 3 | "configurations": [ 4 | { 5 | "name": "Debug server", 6 | "type": "Ruby", 7 | "request": "launch", 8 | "program": "${workspaceRoot}/bin/rackup", 9 | "args": [ 10 | "--server", 11 | "puma", 12 | "--host", 13 | "0.0.0.0", 14 | "--port", 15 | "8080" 16 | ], 17 | "useBundler": true 18 | } 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | source 'https://rubygems.org' 4 | ruby '3.2.1' 5 | 6 | gem 'fluentd' 7 | gem 'haml' 8 | gem 'puma' 9 | gem 'sinatra' 10 | gem 'sinatra-contrib' 11 | 12 | group :development, :test do 13 | # Testing tools 14 | gem 'rack-test' 15 | gem 'rspec' 16 | gem 'simplecov', require: false 17 | gem 'simplecov-lcov', require: false 18 | 19 | # Lint/Analyse/Detect tools 20 | gem 'reek' 21 | gem 'rubocop' 22 | gem 'rubocop-performance' 23 | gem 'rubocop-rspec' 24 | end 25 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: Build 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | pull_request: 8 | branches: 9 | - main 10 | 11 | jobs: 12 | docker: 13 | runs-on: ubuntu-20.04 14 | steps: 15 | - uses: actions/checkout@v2 16 | - name: Setup Docker Buildx 17 | uses: docker/setup-buildx-action@v1 18 | - name: Build a Docker image 19 | uses: docker/build-push-action@v2 20 | with: 21 | push: false 22 | cache-from: type=registry,ref=tomohiro/fluentular:latest 23 | -------------------------------------------------------------------------------- /.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | name: Test 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | pull_request: 8 | branches: 9 | - main 10 | 11 | jobs: 12 | rspec: 13 | runs-on: ubuntu-20.04 14 | env: 15 | TZ: Asia/Tokyo 16 | BUNDLE_WITHOUT: development 17 | steps: 18 | - uses: actions/checkout@v2 19 | - name: Setup Ruby 20 | uses: ruby/setup-ruby@v1 21 | with: 22 | bundler-cache: true 23 | - name: Run RSpec 24 | run: bundle exec rspec 25 | - name: Send coverage report to Coveralls 26 | uses: coverallsapp/github-action@master 27 | with: 28 | github-token: ${{ secrets.GITHUB_TOKEN }} 29 | -------------------------------------------------------------------------------- /.github/SECURITY.md: -------------------------------------------------------------------------------- 1 | Security Policy 2 | ================================================================================ 3 | 4 | 5 | Supported Versions 6 | -------------------------------------------------------------------------------- 7 | 8 | Version | Supported 9 | --------- | -------------------------------------------------------------------- 10 | v1.12.x | Maintenance 11 | v1.11.x | Maintenance 12 | < v1.10.1 | EOL 13 | 14 | 15 | Reporting a Vulnerability 16 | -------------------------------------------------------------------------------- 17 | 18 | Please report to tomohiro@hey.com 19 | 20 | 21 | Known Issues 22 | -------------------------------------------------------------------------------- 23 | 24 | Nothing. 25 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | # Build for install dependency RubyGems 2 | FROM ruby:3.2.1-alpine3.17 AS bundle 3 | 4 | WORKDIR /tmp 5 | COPY Gemfile . 6 | COPY Gemfile.lock . 7 | 8 | RUN set -ex \ 9 | && apk add --update --no-cache curl build-base \ 10 | && bundle config set frozen true \ 11 | && bundle config set without 'test:development' \ 12 | && bundle install --jobs=4 \ 13 | && rm -rf "${GEM_HOME}/cache/*" 14 | 15 | # Build for Sinatra app 16 | FROM ruby:3.2.1-alpine3.17 17 | COPY --from=bundle ${GEM_HOME} ${GEM_HOME} 18 | 19 | ENV RACK_ENV=deployment 20 | ENV RUBYOPT=--yjit 21 | 22 | WORKDIR /usr/src/app 23 | COPY . . 24 | 25 | EXPOSE 8080 26 | ENTRYPOINT ["bundle"] 27 | CMD ["exec", "rackup", "--host", "0.0.0.0", "-p", "8080"] 28 | 29 | HEALTHCHECK CMD wget -q -O /dev/null http://0:8080 || exit 1 30 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012 - 2023 Tomohiro Taira 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /.github/workflows/lint.yml: -------------------------------------------------------------------------------- 1 | name: Lint 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | pull_request: 8 | branches: 9 | - main 10 | 11 | jobs: 12 | rubocop: 13 | runs-on: ubuntu-20.04 14 | steps: 15 | - uses: actions/checkout@v2 16 | with: 17 | ref: ${{ github.event.pull_request.head.sha }} 18 | - name: Setup Ruby 19 | uses: ruby/setup-ruby@v1 20 | with: 21 | bundler-cache: true 22 | - uses: r7kamura/rubocop-problem-matchers-action@v1 23 | - name: Run RuboCop 24 | run: bundle exec rubocop --parallel 25 | reek: 26 | runs-on: ubuntu-20.04 27 | steps: 28 | - uses: actions/checkout@v2 29 | with: 30 | ref: ${{ github.event.pull_request.head.sha }} 31 | - name: Setup Ruby 32 | uses: ruby/setup-ruby@v1 33 | with: 34 | bundler-cache: true 35 | - name: Run Reek 36 | run: bundle exec reek $(git ls-files '*.rb') 37 | docker: 38 | runs-on: ubuntu-20.04 39 | steps: 40 | - uses: actions/checkout@v2 41 | with: 42 | ref: ${{ github.event.pull_request.head.sha }} 43 | - name: Check Docker Compose configuration 44 | run: docker compose convert 45 | -------------------------------------------------------------------------------- /.github/workflows/codeql-analysis.yml: -------------------------------------------------------------------------------- 1 | # For most projects, this workflow file will not need changing; you simply need 2 | # to commit it to your repository. 3 | # 4 | # You may wish to alter this file to override the set of languages analyzed, 5 | # or to provide custom queries or build logic. 6 | # 7 | # ******** NOTE ******** 8 | # We have attempted to detect the languages in your repository. Please check 9 | # the `language` matrix defined below to confirm you have the correct set of 10 | # supported CodeQL languages. 11 | # 12 | name: "CodeQL" 13 | 14 | on: 15 | push: 16 | branches: [ main ] 17 | pull_request: 18 | # The branches below must be a subset of the branches above 19 | branches: [ main ] 20 | schedule: 21 | - cron: '31 17 * * 3' 22 | 23 | jobs: 24 | analyze: 25 | name: Analyze 26 | runs-on: ubuntu-latest 27 | permissions: 28 | actions: read 29 | contents: read 30 | security-events: write 31 | 32 | strategy: 33 | fail-fast: false 34 | matrix: 35 | language: [ 'ruby' ] 36 | # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] 37 | # Learn more about CodeQL language support at https://git.io/codeql-language-support 38 | 39 | steps: 40 | - name: Checkout repository 41 | uses: actions/checkout@v2 42 | 43 | # Initializes the CodeQL tools for scanning. 44 | - name: Initialize CodeQL 45 | uses: github/codeql-action/init@v1 46 | with: 47 | languages: ${{ matrix.language }} 48 | # If you wish to specify custom queries, you can do so here or in a config file. 49 | # By default, queries listed here will override any specified in a config file. 50 | # Prefix the list here with "+" to use these queries and those in the config file. 51 | # queries: ./path/to/local/query, your-org/your-repo/queries@main 52 | 53 | # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). 54 | # If this step fails, then you should remove it and run the build manually (see below) 55 | - name: Autobuild 56 | uses: github/codeql-action/autobuild@v1 57 | 58 | # ℹ️ Command-line programs to run using the OS shell. 59 | # 📚 https://git.io/JvXDl 60 | 61 | # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines 62 | # and modify them (or add more) to build your code if your project 63 | # uses a compiled language 64 | 65 | #- run: | 66 | # make bootstrap 67 | # make release 68 | 69 | - name: Perform CodeQL Analysis 70 | uses: github/codeql-action/analyze@v1 71 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Fluentular [![Heroku App](https://img.shields.io/badge/heroku-ready-430098.svg?style=flat-square&logo=heroku&logoColor=white)](https://fluentular.herokuapp.com) [![LICENSE](https://img.shields.io/github/license/tomohiro/fluentular.svg?style=flat-square)](LICENSE) 2 | 3 | a Fluentd regular expression editor 4 | 5 | [![Docker Pulls](https://img.shields.io/docker/pulls/tomohiro/fluentular.svg?style=flat-square&logo=docker)](https://hub.docker.com/r/tomohiro/fluentular/) 6 | [![Build Status](https://img.shields.io/github/actions/workflow/status/tomohiro/fluentular/.github/workflows/test.yml?branch=main&logo=github&style=flat-square)](https://github.com/tomohiro/fluentular/actions) 7 | [![Coverage Status](https://img.shields.io/coveralls/tomohiro/fluentular.svg?style=flat-square&logo=coveralls)](https://coveralls.io/github/tomohiro/fluentular) 8 | [![Code Climate](https://img.shields.io/codeclimate/maintainability-percentage/tomohiro/fluentular.svg?style=flat-square&logo=code-climate)](https://codeclimate.com/github/tomohiro/fluentular) 9 | [![Dependabot](https://img.shields.io/badge/dependabot-enabled-success?style=flat-square&logo=dependabot)](https://github.com/tomohiro/fluentular/network/dependencies) 10 | 11 | 12 | ![Fluentular Screenshot](https://user-images.githubusercontent.com/54254/100218981-c85b8280-2f58-11eb-8cab-856c1e09c48e.png) 13 | 14 | 15 | Platforms 16 | -------------------------------------------------------------------------------- 17 | 18 | - [Heroku](#heroku) 19 | - [Docker](#docker) 20 | 21 | 22 | ### Heroku 23 | 24 | [![Deploy](https://www.herokucdn.com/deploy/button.png)](https://heroku.com/deploy) 25 | 26 | 27 | ### Docker 28 | 29 | You can download and run Fluentular container from [DockerHub](https://hub.docker.com/r/tomohiro/fluentular/): 30 | 31 | ``` 32 | $ docker pull tomohiro/fluentular:latest 33 | $ docker run -d -p 8080:8080 tomohiro/fluentular:latest 34 | ``` 35 | 36 | #### Own build 37 | 38 | Also you can build the app when after clone this repository: 39 | 40 | ``` 41 | $ cd fluentular 42 | $ docker compose up -d 43 | $ docker compose ps 44 | NAME COMMAND SERVICE STATUS PORTS 45 | fluentular-app-1 "bundle exec rackup …" app running (healthy) 0.0.0.0:8080->8080/tcp 46 | ``` 47 | 48 | 49 | Acknowledgment 50 | ------------------------------------------------------------------------------- 51 | 52 | - [fluentdのformat(正規表現)の作り方について試行錯誤中 #fluentd - Glide Note - グライドノート](http://blog.glidenote.com/blog/2012/07/15/fluentd-regex-debug/) 53 | - [Fluentdでparser用の正規表現を書く・試す - tagomorisのメモ置き場](http://d.hatena.ne.jp/tagomoris/20120715/1342368392) 54 | - [Scriptular](http://scriptular.com/) 55 | - [Rubular: a Ruby regular expression editor and tester](http://rubular.com/) 56 | 57 | 58 | LICENSE 59 | -------------------------------------------------------------------------------- 60 | 61 | © 2012 - 2023 Tomohiro Taira. 62 | 63 | This project licensed under the MIT license. See [LICENSE](LICENSE) for details. 64 | -------------------------------------------------------------------------------- /spec/fluentular_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'simplecov' 4 | require 'simplecov-lcov' 5 | SimpleCov::Formatter::LcovFormatter.config do |c| 6 | c.report_with_single_file = true 7 | c.single_report_path = 'coverage/lcov.info' 8 | end 9 | SimpleCov.formatter = SimpleCov::Formatter::LcovFormatter 10 | SimpleCov.start 11 | 12 | Warning[:deprecated] = true 13 | ENV['RACK_ENV'] = 'test' 14 | $LOAD_PATH.unshift(File.expand_path('../', File.dirname(__FILE__))) 15 | 16 | require 'app' 17 | require 'rspec' 18 | require 'rack/test' 19 | 20 | describe Fluentular do 21 | include Rack::Test::Methods 22 | 23 | subject { last_response } 24 | 25 | let(:app) do 26 | Sinatra::Application 27 | end 28 | 29 | describe 'GET /' do 30 | before { get '/' } 31 | 32 | it { is_expected.to be_ok } 33 | it { is_expected.to match 'Fluentular' } 34 | end 35 | 36 | describe 'GET /parse' do 37 | before { get '/parse', request_params } 38 | 39 | context 'with valid regular expression' do 40 | let(:request_params) do 41 | { 42 | input: 'example.com', 43 | regexp: '(?[^ ]*)', 44 | time_format: '' 45 | } 46 | end 47 | 48 | it { is_expected.to be_ok } 49 | it { is_expected.to match 'host\nexample.com' } 50 | end 51 | 52 | context 'with parsing valid time format' do 53 | let(:request_params) do 54 | { 55 | input: '25/Nov/2013:18:09:45 +0900 example.com', 56 | regexp: '(?