Simple authorization library and role managment for Ruby.
Ruby >= 2.2.2
| defmodule Slug1 do | |
| def slugify(input), do: map_slug(input, %{pattern: ~r/\s+/}) | |
| def slugify2(input), do: map_slug(input, %{pattern: " "}) | |
| defp map_slug(input, %{pattern: pattern}) do | |
| input | |
| |> to_string() | |
| |> String.trim() | |
| |> String.downcase() |
| raise 'Wrong Ruby version!' unless RUBY_VERSION >= '2.6.0' | |
| module Strings | |
| Trim = -> str { String(str).strip } | |
| Replace = -> (sub, new_sub, str) { String(str).gsub(sub, new_sub) } | |
| LowerCase = -> str { String(str).downcase } | |
| end | |
| # -- Alternative syntax -- | |
| Slugify = # Slugify = |
| class TaskArgumentsCalculator | |
| def initialize(operator) | |
| @operator = operator | |
| end | |
| def call(_task, args) | |
| puts map_numbers(args).reduce(&@operator) | |
| end |
| ArgAsNumber = -> (args) do | |
| -> key { args[key].to_f } | |
| end | |
| CalculateTaskArgumentsWith = -> (operator) do | |
| -> (task, args) do | |
| arg_as_number = ArgAsNumber.(args) | |
| puts [:a, :b].map(&arg_as_number).reduce(&operator) |
| # Runtime dependency: | |
| # gem install bundler --no-ri --no-rdoc | |
| # How to run: | |
| # ruby example_1.rb | |
| require "bundler/inline" | |
| gemfile do | |
| source "https://rubygems.org" |
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <title>jQuery.behavior</title> | |
| <meta charset="utf-8"> | |
| <meta name="viewport" content="width=device-width"> | |
| </head> | |
| <body> | |
| <a href="01.html">01</a> | <a href="02.html">02</a> | <a href="03.html">03</a> | <a href="04.html">04</a> | <a href="05.html">05</a> |
Development dependencies:
Features:
| module Foo | |
| A = 1 | |
| B = 2 | |
| def a1 | |
| A | |
| end | |
| def b1 | |
| B |