initial commit

This commit is contained in:
Aleks Rūtiņš 2024-09-08 20:57:06 -04:00
commit 5779c37f5b
19 changed files with 421 additions and 0 deletions

27
.github/workflows/main.yml vendored Normal file
View file

@ -0,0 +1,27 @@
name: Ruby
on:
push:
branches:
- main
pull_request:
jobs:
build:
runs-on: ubuntu-latest
name: Ruby ${{ matrix.ruby }}
strategy:
matrix:
ruby:
- '3.3.5'
steps:
- uses: actions/checkout@v4
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
- name: Run the default task
run: bundle exec rake

8
.gitignore vendored Normal file
View file

@ -0,0 +1,8 @@
/.bundle/
/.yardoc
/_yardoc/
/coverage/
/doc/
/pkg/
/spec/reports/
/tmp/

3
.standard.yml Normal file
View file

@ -0,0 +1,3 @@
# For available configuration options, see:
# https://github.com/standardrb/standard
ruby_version: 3.0

16
Gemfile Normal file
View file

@ -0,0 +1,16 @@
# frozen_string_literal: true
source "https://rubygems.org"
# Specify your gem's dependencies in phlexite.gemspec
gemspec
gem "rake", "~> 13.0"
gem "minitest", "~> 5.16"
gem "standard", "~> 1.3"
gem "phlex", "~> 1.11"
gem "steep", "~> 1.7", :group => :development

120
Gemfile.lock Normal file
View file

@ -0,0 +1,120 @@
PATH
remote: .
specs:
phlexite (0.1.0)
GEM
remote: https://rubygems.org/
specs:
activesupport (7.2.1)
base64
bigdecimal
concurrent-ruby (~> 1.0, >= 1.3.1)
connection_pool (>= 2.2.5)
drb
i18n (>= 1.6, < 2)
logger (>= 1.4.2)
minitest (>= 5.1)
securerandom (>= 0.3)
tzinfo (~> 2.0, >= 2.0.5)
ast (2.4.2)
base64 (0.2.0)
bigdecimal (3.1.8)
concurrent-ruby (1.3.4)
connection_pool (2.4.1)
csv (3.3.0)
drb (2.2.1)
ffi (1.17.0)
ffi (1.17.0-arm64-darwin)
fileutils (1.7.2)
i18n (1.14.5)
concurrent-ruby (~> 1.0)
json (2.7.2)
language_server-protocol (3.17.0.3)
lint_roller (1.1.0)
listen (3.9.0)
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
logger (1.6.1)
minitest (5.25.1)
parallel (1.26.3)
parser (3.3.5.0)
ast (~> 2.4.1)
racc
phlex (1.11.0)
racc (1.8.1)
rainbow (3.1.1)
rake (13.2.1)
rb-fsevent (0.11.2)
rb-inotify (0.11.1)
ffi (~> 1.0)
rbs (3.5.3)
logger
regexp_parser (2.9.2)
rexml (3.3.7)
rubocop (1.65.1)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
parser (>= 3.3.0.2)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 2.4, < 3.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.31.1, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.32.3)
parser (>= 3.3.1.0)
rubocop-performance (1.21.1)
rubocop (>= 1.48.1, < 2.0)
rubocop-ast (>= 1.31.1, < 2.0)
ruby-progressbar (1.13.0)
securerandom (0.3.1)
standard (1.40.0)
language_server-protocol (~> 3.17.0.2)
lint_roller (~> 1.0)
rubocop (~> 1.65.0)
standard-custom (~> 1.0.0)
standard-performance (~> 1.4)
standard-custom (1.0.2)
lint_roller (~> 1.0)
rubocop (~> 1.50)
standard-performance (1.4.0)
lint_roller (~> 1.1)
rubocop-performance (~> 1.21.0)
steep (1.7.1)
activesupport (>= 5.1)
concurrent-ruby (>= 1.1.10)
csv (>= 3.0.9)
fileutils (>= 1.1.0)
json (>= 2.1.0)
language_server-protocol (>= 3.15, < 4.0)
listen (~> 3.0)
logger (>= 1.3.0)
parser (>= 3.1)
rainbow (>= 2.2.2, < 4.0)
rbs (>= 3.5.0.pre)
securerandom (>= 0.1)
strscan (>= 1.0.0)
terminal-table (>= 2, < 4)
strscan (3.1.0)
terminal-table (3.0.2)
unicode-display_width (>= 1.1.1, < 3)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
unicode-display_width (2.5.0)
PLATFORMS
arm64-darwin-23
ruby
DEPENDENCIES
minitest (~> 5.16)
phlex (~> 1.11)
phlexite!
rake (~> 13.0)
standard (~> 1.3)
steep (~> 1.7)
BUNDLED WITH
2.5.18

21
LICENSE.txt Normal file
View file

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2024 Aleks Rūtiņš
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

39
README.md Normal file
View file

@ -0,0 +1,39 @@
# Phlexite
TODO: Delete this and the text below, and describe your gem
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/phlexite`. To experiment with that code, run `bin/console` for an interactive prompt.
## Installation
TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
Install the gem and add to the application's Gemfile by executing:
```bash
bundle add UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
```
If bundler is not being used to manage dependencies, install the gem by executing:
```bash
gem install UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
```
## Usage
TODO: Write usage instructions here
## Development
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
## Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/phlexite.
## License
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).

10
Rakefile Normal file
View file

@ -0,0 +1,10 @@
# frozen_string_literal: true
require "bundler/gem_tasks"
require "minitest/test_task"
Minitest::TestTask.create
require "standard/rake"
task default: %i[test standard]

28
Steepfile Normal file
View file

@ -0,0 +1,28 @@
D = Steep::Diagnostic
target :lib do
signature "sig"
check "lib" # Directory name
# ignore "lib/templates/*.rb"
# library "pathname" # Standard libraries
# library "strong_json" # Gems
# library "phlex"
# configure_code_diagnostics(D::Ruby.default) # `default` diagnostics setting (applies by default)
# configure_code_diagnostics(D::Ruby.strict) # `strict` diagnostics setting
# configure_code_diagnostics(D::Ruby.lenient) # `lenient` diagnostics setting
# configure_code_diagnostics(D::Ruby.silent) # `silent` diagnostics setting
# configure_code_diagnostics do |hash| # You can setup everything yourself
# hash[D::Ruby::NoMethod] = :information
# end
end
# target :test do
# signature "sig", "sig-private"
#
# check "test"
#
# # library "pathname" # Standard libraries
# end

11
bin/console Executable file
View file

@ -0,0 +1,11 @@
#!/usr/bin/env ruby
# frozen_string_literal: true
require "bundler/setup"
require "phlexite"
# You can add fixtures and/or initialization code here to make experimenting
# with your gem easier. You can also use a different console, if you like.
require "irb"
IRB.start(__FILE__)

8
bin/setup Executable file
View file

@ -0,0 +1,8 @@
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
set -vx
bundle install
# Do any other automated setup that you need to do here

7
lib/phlexite.rb Normal file
View file

@ -0,0 +1,7 @@
# frozen_string_literal: true
require_relative "phlexite/version"
module Phlexite
class Error < StandardError; end
end

20
lib/phlexite/router.rb Normal file
View file

@ -0,0 +1,20 @@
class Phlexite::Router
def initialize(base, site)
@base = base
@site = site
end
def group(new_base)
router = Phlexite::Router.new(File::join(@base, new_base), @site)
yield router
end
def page(out_path, component)
File::write(full_out_path(out_path), component.call)
end
private
def full_out_path(out_path)
File::join(@site.build_dir, @site.base_url, @base, out_path)
end
end

13
lib/phlexite/site.rb Normal file
View file

@ -0,0 +1,13 @@
# frozen_string_literal: true
require_relative 'router.rb'
class Phlexite::Site < Phlexite::Router
attr_accessor :build_dir, :base_url
def initialize
super("/", self)
base_url = "/"
yield self
end
end

5
lib/phlexite/version.rb Normal file
View file

@ -0,0 +1,5 @@
# frozen_string_literal: true
module Phlexite
VERSION = "0.1.0"
end

41
phlexite.gemspec Normal file
View file

@ -0,0 +1,41 @@
# frozen_string_literal: true
require_relative "lib/phlexite/version"
Gem::Specification.new do |spec|
spec.name = "phlexite"
spec.version = Phlexite::VERSION
spec.authors = ["Aleks Rūtiņš"]
spec.email = ["aleks@rutins.com"]
spec.summary = "TODO: Write a short summary, because RubyGems requires one."
spec.description = "TODO: Write a longer description or delete this line."
spec.homepage = "TODO: Put your gem's website or public repo URL here."
spec.license = "MIT"
spec.required_ruby_version = ">= 3.0.0"
spec.metadata["allowed_push_host"] = "TODO: Set to your gem server 'https://example.com'"
spec.metadata["homepage_uri"] = spec.homepage
spec.metadata["source_code_uri"] = "TODO: Put your gem's public repo URL here."
spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
# Specify which files should be added to the gem when it is released.
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
gemspec = File.basename(__FILE__)
spec.files = IO.popen(%w[git ls-files -z], chdir: __dir__, err: IO::NULL) do |ls|
ls.readlines("\x0", chomp: true).reject do |f|
(f == gemspec) ||
f.start_with?(*%w[bin/ test/ spec/ features/ .git .github appveyor Gemfile])
end
end
spec.bindir = "exe"
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
spec.require_paths = ["lib"]
# Uncomment to register a new dependency of your gem
# spec.add_dependency "example-gem", "~> 1.0"
# For more information and examples about making a new gem, check out our
# guide at: https://bundler.io/guides/creating_gem.html
end

25
sig/phlexite.rbs Normal file
View file

@ -0,0 +1,25 @@
module Phlexite
VERSION: String
# See the writing guide of rbs: https://github.com/ruby/rbs#guides
class Error < StandardError
end
class Router
def initialize: (String, Site) -> void
def page: (String, untyped) -> void
def group: (String) { (Router) -> void } -> void
private
def full_out_path: (String) -> String
end
class Site < Router
def initialize: () { (Site) -> void } -> void
def build_dir: () -> String
def build_dir=: (String) -> void
def base_url: () -> String
def base_url=: (String) -> void
end
end

6
test/test_helper.rb Normal file
View file

@ -0,0 +1,6 @@
# frozen_string_literal: true
$LOAD_PATH.unshift File.expand_path("../lib", __dir__)
require "phlexite"
require "minitest/autorun"

13
test/test_phlexite.rb Normal file
View file

@ -0,0 +1,13 @@
# frozen_string_literal: true
require "test_helper"
class TestPhlexite < Minitest::Test
def test_that_it_has_a_version_number
refute_nil ::Phlexite::VERSION
end
def test_it_does_something_useful
assert true
end
end