lvr 0.0.0 → 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGES.md +2 -0
- data/README.md +5 -5
- data/VERSION +1 -1
- data/lib/lvr/refine/core.rb +29 -0
- data/lib/lvr/refine.rb +6 -0
- data/lib/lvr/template/filters.rb +24 -0
- data/lib/lvr/template/tags.rb +26 -0
- data/lib/lvr/template.rb +61 -0
- data/lib/lvr.rb +18 -0
- metadata +21 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8de888bfc04fe70f2af261015f3033724cbcd11da0b432a4883414afc8357793
|
|
4
|
+
data.tar.gz: 8cca6ee12d6d57cf7aa179d46d9e2954089a706448fcaf4cebe6b83186869f86
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a44fd9275fad94aefe5552e51af3c710cc4a209d021a8b26a8248d53066ada34e12069503146e3129925580fd646bae11b84981a21b0cd376afdab11ec15edc6
|
|
7
|
+
data.tar.gz: b535fdc7414b3f4efc16d0f41110b7678e3df35b94b433e743a9b7e456d3c309ab15f4095b7840340a5f1fdd55ad83baea87518e59b4dd8aec1a3b3ee7826429
|
data/CHANGES.md
CHANGED
|
@@ -5,4 +5,6 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## 0.0.1 - 2026-06-25
|
|
9
|
+
|
|
8
10
|
## 0.0.0 - 2026-06-24
|
data/README.md
CHANGED
|
@@ -60,11 +60,11 @@ git clone https://github.com/artob/lvr.git
|
|
|
60
60
|
|
|
61
61
|
---
|
|
62
62
|
|
|
63
|
-
[](https://x.com/intent/post?url=https
|
|
64
|
-
[](https://reddit.com/submit?url=https
|
|
65
|
-
[](https://news.ycombinator.com/submitlink?u=https
|
|
66
|
-
[](https://www.facebook.com/sharer/sharer.php?u=https
|
|
67
|
-
[](https://www.linkedin.com/sharing/share-offsite/?url=https
|
|
63
|
+
[](https://x.com/intent/post?url=https%3A%2F%2Fgithub.com%2Fartob%2Flvr&text=Lvr)
|
|
64
|
+
[](https://reddit.com/submit?url=https%3A%2F%2Fgithub.com%2Fartob%2Flvr&title=Lvr)
|
|
65
|
+
[](https://news.ycombinator.com/submitlink?u=https%3A%2F%2Fgithub.com%2Fartob%2Flvr&t=Lvr)
|
|
66
|
+
[](https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fgithub.com%2Fartob%2Flvr)
|
|
67
|
+
[](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fgithub.com%2Fartob%2Flvr)
|
|
68
68
|
|
|
69
69
|
[Lvr]: https://lvr.dev
|
|
70
70
|
[Ruby]: https://ruby-lang.org
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.0.
|
|
1
|
+
0.0.1
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# This is free and unencumbered software released into the public domain.
|
|
2
|
+
|
|
3
|
+
module Lvr; end
|
|
4
|
+
module Lvr::Refine; end
|
|
5
|
+
|
|
6
|
+
##
|
|
7
|
+
# Refinements for core Ruby types.
|
|
8
|
+
#
|
|
9
|
+
# @example
|
|
10
|
+
# using Lvr::Refine::Core
|
|
11
|
+
#
|
|
12
|
+
module Lvr::Refine::Core
|
|
13
|
+
refine ::Object do
|
|
14
|
+
def deep_stringify_keys = self.dup
|
|
15
|
+
def deep_stringify_keys! = self
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
refine ::Array do
|
|
19
|
+
def deep_stringify_keys = self.map(&:deep_stringify_keys)
|
|
20
|
+
def deep_stringify_keys! = self.map!(&:deep_stringify_keys!)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
refine ::Hash do
|
|
24
|
+
def deep_stringify_keys = self.transform_keys(&:to_s)
|
|
25
|
+
.transform_values(&:deep_stringify_keys)
|
|
26
|
+
def deep_stringify_keys! = self.transform_keys!(&:to_s)
|
|
27
|
+
.transform_values!(&:deep_stringify_keys!)
|
|
28
|
+
end
|
|
29
|
+
end # Lvr::Refine::Core
|
data/lib/lvr/refine.rb
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# This is free and unencumbered software released into the public domain.
|
|
2
|
+
|
|
3
|
+
module Lvr; end
|
|
4
|
+
class Lvr::Template; end
|
|
5
|
+
|
|
6
|
+
module Lvr::Template::Filters
|
|
7
|
+
##
|
|
8
|
+
# @param [String, #to_s] input
|
|
9
|
+
# @return [String]
|
|
10
|
+
def camelcase(input)
|
|
11
|
+
output = pascalcase(input)
|
|
12
|
+
output[0].downcase + output[1..]
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
##
|
|
16
|
+
# @param [String, #to_s] input
|
|
17
|
+
# @return [String]
|
|
18
|
+
def constcase(input) = input.to_s.split(' ').map(&:upcase).join('_')
|
|
19
|
+
|
|
20
|
+
##
|
|
21
|
+
# @param [String, #to_s] input
|
|
22
|
+
# @return [String]
|
|
23
|
+
def pascalcase(input) = input.to_s.split(' ').map(&:capitalize).join('')
|
|
24
|
+
end # Lvr::Template::Filters
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# This is free and unencumbered software released into the public domain.
|
|
2
|
+
|
|
3
|
+
require 'cgi'
|
|
4
|
+
|
|
5
|
+
module Lvr; end
|
|
6
|
+
class Lvr::Template; end
|
|
7
|
+
|
|
8
|
+
module Lvr::Template::Tags
|
|
9
|
+
##
|
|
10
|
+
# A tag that renders the footer badges.
|
|
11
|
+
class Footer < Liquid::Tag
|
|
12
|
+
def initialize(tag_name, text, tokens) = super
|
|
13
|
+
|
|
14
|
+
def render(context)
|
|
15
|
+
project_title = CGI.escape(context['project']['title'])
|
|
16
|
+
github_repository_link = CGI.escape(context['github']['repository']['link'])
|
|
17
|
+
<<~EOF.chomp
|
|
18
|
+
[](https://x.com/intent/post?url=#{github_repository_link}&text=#{project_title})
|
|
19
|
+
[](https://reddit.com/submit?url=#{github_repository_link}&title=#{project_title})
|
|
20
|
+
[](https://news.ycombinator.com/submitlink?u=#{github_repository_link}&t=#{project_title})
|
|
21
|
+
[](https://www.facebook.com/sharer/sharer.php?u=#{github_repository_link})
|
|
22
|
+
[](https://www.linkedin.com/sharing/share-offsite/?url=#{github_repository_link})
|
|
23
|
+
EOF
|
|
24
|
+
end
|
|
25
|
+
end # Footer
|
|
26
|
+
end # Lvr::Template::Tags
|
data/lib/lvr/template.rb
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# This is free and unencumbered software released into the public domain.
|
|
2
|
+
|
|
3
|
+
require 'liquid'
|
|
4
|
+
require_relative 'refine/core'
|
|
5
|
+
|
|
6
|
+
module Lvr; end
|
|
7
|
+
|
|
8
|
+
class Lvr::Template
|
|
9
|
+
using Lvr::Refine::Core
|
|
10
|
+
|
|
11
|
+
##
|
|
12
|
+
# @param [Pathname, #to_s] input_path
|
|
13
|
+
# @return [Template]
|
|
14
|
+
def self.load(input_path) = self.new.load(input_path)
|
|
15
|
+
|
|
16
|
+
##
|
|
17
|
+
# @param [String, #to_s] input
|
|
18
|
+
# @return [Template]
|
|
19
|
+
def self.parse(input) = self.new.parse(input)
|
|
20
|
+
|
|
21
|
+
##
|
|
22
|
+
# @param [String, #to_s] input
|
|
23
|
+
# @return [void]
|
|
24
|
+
def initialize(**options)
|
|
25
|
+
@env = Liquid::Environment.new
|
|
26
|
+
@env.register_filter(Lvr::Template::Filters)
|
|
27
|
+
@env.register_tag('footer', Lvr::Template::Tags::Footer)
|
|
28
|
+
@template = Liquid::Template.new(environment: @env)
|
|
29
|
+
@options = options
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
##
|
|
33
|
+
# @param [Pathname, #to_s] input_path
|
|
34
|
+
# @return [Template] `self`
|
|
35
|
+
def load(input_path)
|
|
36
|
+
@template.parse(File.read(input_path.to_s))
|
|
37
|
+
self
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
##
|
|
41
|
+
# @param [String, #to_s] input
|
|
42
|
+
# @return [Template] `self`
|
|
43
|
+
def parse(input)
|
|
44
|
+
@template.parse(input.to_s)
|
|
45
|
+
self
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
##
|
|
49
|
+
# @param [Hash, #to_h] context
|
|
50
|
+
# @return [Object]
|
|
51
|
+
def render(**context)
|
|
52
|
+
@template.render!(context.deep_stringify_keys!, {
|
|
53
|
+
error_mode: :strict,
|
|
54
|
+
strict_filters: true,
|
|
55
|
+
strict_variables: true,
|
|
56
|
+
}.merge(@options))
|
|
57
|
+
end
|
|
58
|
+
end # Lvr::Template
|
|
59
|
+
|
|
60
|
+
require_relative 'template/filters'
|
|
61
|
+
require_relative 'template/tags'
|
data/lib/lvr.rb
CHANGED
|
@@ -1,3 +1,21 @@
|
|
|
1
1
|
# This is free and unencumbered software released into the public domain.
|
|
2
2
|
|
|
3
|
+
module Lvr
|
|
4
|
+
##
|
|
5
|
+
# Codegen an output file from a given template and context.
|
|
6
|
+
#
|
|
7
|
+
# @param [Pathname, #to_s] output_path The path to write the rendered template to
|
|
8
|
+
# @param [Pathname, #to_s] template_path The template to render
|
|
9
|
+
# @param [Hash] context The context to render the template with
|
|
10
|
+
def self.codegen(output_path, template_path, **context)
|
|
11
|
+
File.open(output_path.to_s, 'w') do |output_file|
|
|
12
|
+
template = Template.load(template_path.to_s)
|
|
13
|
+
output = template.render(**context)
|
|
14
|
+
output_file.write(output)
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end # Lvr
|
|
18
|
+
|
|
19
|
+
require_relative 'lvr/refine'
|
|
20
|
+
require_relative 'lvr/template'
|
|
3
21
|
require_relative 'lvr/version'
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: lvr
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Arto Bendiken
|
|
8
8
|
bindir: bin
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date: 2026-06-
|
|
10
|
+
date: 2026-06-25 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: rspec
|
|
@@ -37,6 +37,20 @@ dependencies:
|
|
|
37
37
|
- - "~>"
|
|
38
38
|
- !ruby/object:Gem::Version
|
|
39
39
|
version: '0.9'
|
|
40
|
+
- !ruby/object:Gem::Dependency
|
|
41
|
+
name: liquid
|
|
42
|
+
requirement: !ruby/object:Gem::Requirement
|
|
43
|
+
requirements:
|
|
44
|
+
- - "~>"
|
|
45
|
+
- !ruby/object:Gem::Version
|
|
46
|
+
version: '5.12'
|
|
47
|
+
type: :runtime
|
|
48
|
+
prerelease: false
|
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
50
|
+
requirements:
|
|
51
|
+
- - "~>"
|
|
52
|
+
- !ruby/object:Gem::Version
|
|
53
|
+
version: '5.12'
|
|
40
54
|
description: Lvr for Ruby
|
|
41
55
|
email: arto@bendiken.net
|
|
42
56
|
executables: []
|
|
@@ -49,6 +63,11 @@ files:
|
|
|
49
63
|
- UNLICENSE
|
|
50
64
|
- VERSION
|
|
51
65
|
- lib/lvr.rb
|
|
66
|
+
- lib/lvr/refine.rb
|
|
67
|
+
- lib/lvr/refine/core.rb
|
|
68
|
+
- lib/lvr/template.rb
|
|
69
|
+
- lib/lvr/template/filters.rb
|
|
70
|
+
- lib/lvr/template/tags.rb
|
|
52
71
|
- lib/lvr/version.rb
|
|
53
72
|
homepage: https://github.com/artob/lvr
|
|
54
73
|
licenses:
|