singer 2.0.0 → 2.2.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b91934a916b675cfddecdac26f48673a77e9e2f014ae94a7db7623df0adaac67
4
- data.tar.gz: f8a8384bdbba9f096d303e91fbd68a2b1063239d89e5f072d1e8e551cee1b7d2
3
+ metadata.gz: 1496a866af8bd84f5f37b7fd231ebca183cb1af9527c80fcf82d7d12e559ae60
4
+ data.tar.gz: d162ae6671bde936f13594d4a9ce989179d207f96a92eb3a24496f5db5116fe6
5
5
  SHA512:
6
- metadata.gz: 5a0d34e3e4ba0b18a55151f796f30d8b0bad715f74a084f37456a4cdebb74d8f66543db90003dc84877a19ef295f0664f1e5ba190cd137d67a670f8819802d01
7
- data.tar.gz: d9245c0f2fcbc5671a078daf5bcf71977ba2ec661c1b599e0aedaa2e679948bc4d9ebad738a6302daefe515dae253a5d8d59d6b12b0779b7796b6c9bf52b35d2
6
+ metadata.gz: 475541c7ea0a9c63f64eb9ee72c8267b0e4eb9f3aa9e240587e37010077123a8dc3e7ab2005c0bea4a7bd0849ec088879d4acb6967ebad766ab829e1b093d26c
7
+ data.tar.gz: c2cb1b56b6b65d644a844c7305ebf1fa2158d221bce249d1f9cd8970273709f0578df79c2307d89037fa45a57912ccc0a4b6341395ff6e16c651ede61823c57d
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2025 Emil Chludziński
3
+ Copyright (c) 2025-2026 Emil Chludziński
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -19,13 +19,17 @@ For `PROJECT_NAME`, using `snake_case` is best, although an attempt will be made
19
19
 
20
20
  ## Writing your own templates
21
21
 
22
- Many features of Singer will become clearer when seeing actual usage - please feel encouraged to examine the templates shipped with the gem (you can find them in `templates_from_gem` shown by the `singer --show-paths`).
22
+ Many features of Singer will become clearer when seeing actual usage - please feel encouraged to examine the templates shipped with the gem (you can find them in `templates_from_gem` shown by the `singer --list-paths`).
23
23
 
24
24
  ### Template location
25
25
 
26
- User-provided templates should be placed in the directory named `templates_from_user` in the `singer --show-paths` output.
26
+ User-provided templates should be placed in the directory named `templates_from_user` in the `singer --list-paths` output.
27
27
  Each template resides in a subdirectory - the subdirectory's name becomes the template's name, and is not included in the generated paths (Singer will only replicate the directory structure _inside_ it).
28
28
 
29
+ ### Using templates from somewhere else
30
+
31
+ You can also, instead of the name of a known template via `[TEMPLATE_NAME]`, specify the full path to your custom template with the `--template-path` option.
32
+
29
33
  ### Variables available to templates
30
34
 
31
35
  Templates written in ERB or other templating mechanisms that execute Ruby code will have access to `Singer.configuration` object and its accessors. For example, the following code in a `my_template`'s file:
data/lib/singer/paths.rb CHANGED
@@ -18,7 +18,12 @@ module Singer
18
18
  end
19
19
 
20
20
  def self.output_path(...)
21
- File.join(...).gsub(/__([[:alpha:]][[:word:]]+)__/) do |match|
21
+ substitute_variables(File.join(...))
22
+ end
23
+
24
+ # will substitute non-forbidden variables, 2 characters or more
25
+ def self.substitute_variables(path)
26
+ path.gsub(/__([[:alpha:]][[:word:]]*[[:alpha:]])__/) do |match|
22
27
  potential_config = $1.downcase
23
28
 
24
29
  if variable_name_can_be_substituted?(potential_config)
@@ -1,3 +1,3 @@
1
1
  module Singer
2
- VERSION = '2.0.0'.freeze
2
+ VERSION = '2.2.0'.freeze
3
3
  end
@@ -1,6 +1,6 @@
1
1
  require 'minitest_helper'
2
2
 
3
- class TestAutoloading < Minitest::Test
3
+ class AutoloadingTest < Minitest::Test
4
4
  def test_zeitwerk_has_one_loader
5
5
  refute_empty Zeitwerk::Registry.loaders
6
6
  assert_equal 1, Zeitwerk::Registry.loaders.size
@@ -1,7 +1,7 @@
1
1
  require 'minitest_helper'
2
2
 
3
3
  # TODO: remove
4
- class TestHello < Minitest::Test
4
+ class HelloTest < Minitest::Test
5
5
  def test_greet_with_a_param_generates_a_greeting_string
6
6
  assert_equal 'Hello, stranger.', <%= Singer.configuration.project_name_camelcase %>::Hello.greet(:stranger)
7
7
  end
@@ -1,6 +1,6 @@
1
1
  require 'minitest_helper'
2
2
 
3
- class TestServerErrorDumping < Minitest::Test
3
+ class ServerErrorDumpingTest < Minitest::Test
4
4
  def test_dump_errors_backtrace_is_filtered_against_vendor
5
5
  exc = generate_exception_with_realistic_backtrace
6
6
  assert exc.backtrace.any?{ _1.include?('/vendor/') } # now you see me
@@ -1,6 +1,6 @@
1
1
  require 'minitest_helper'
2
2
 
3
- class TestServer < Minitest::Test
3
+ class ServerTest < Minitest::Test
4
4
  include Rack::Test::Methods
5
5
 
6
6
  def app
@@ -3,7 +3,7 @@ require 'minitest/autorun' if File.expand_path($PROGRAM_NAME) == File.expand_pat
3
3
 
4
4
  require_relative '../lib/<%= Singer.configuration.project_name_snakecase %>'
5
5
 
6
- class Test<%= Singer.configuration.project_name_camelcase %> < Minitest::Test
6
+ class <%= Singer.configuration.project_name_camelcase %>Test < Minitest::Test
7
7
  # TEST_INPUT = File.read('input_mini.txt').lines(chomp: true)
8
8
 
9
9
  def setup
@@ -0,0 +1,9 @@
1
+ class <%= Singer.configuration.project_name_camelcase %>Test < Minitest::Test
2
+ def setup
3
+ @<%= Singer.configuration.project_name_snakecase %> = <%= Singer.configuration.project_name_camelcase %>.new
4
+ end
5
+
6
+ def test_something
7
+ flunk
8
+ end
9
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: singer
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Emil Chludziński
@@ -25,7 +25,8 @@ dependencies:
25
25
  version: '0'
26
26
  description: |
27
27
  Singer is a highly configurable templating system intended for generating Ruby boilerplate.
28
- It aims to make creating and extending Sinatra apps easier.
28
+ Its main aim is to make creating and extending Sinatra apps easier.
29
+ It can also be used to generate pretty much any other files from templates, with defined directory structure.
29
30
  email:
30
31
  - tanstaafl@tlen.pl
31
32
  executables:
@@ -52,17 +53,18 @@ files:
52
53
  - templates/sinatra_app/lib/__PROJECT_NAME_SNAKECASE__/hello.rb
53
54
  - templates/sinatra_app/lib/__PROJECT_NAME_SNAKECASE__/server.rb
54
55
  - templates/sinatra_app/lib/zeitwerk_setup.rb
56
+ - templates/sinatra_app/test/autoloading_test.rb
57
+ - templates/sinatra_app/test/hello_test.rb
55
58
  - templates/sinatra_app/test/minitest_helper.rb
56
- - templates/sinatra_app/test/server/test_server.rb
57
- - templates/sinatra_app/test/server/test_server_error_dumping.rb
58
- - templates/sinatra_app/test/test_autoloading.rb
59
- - templates/sinatra_app/test/test_hello.rb
59
+ - templates/sinatra_app/test/server/server_error_dumping_test.rb
60
+ - templates/sinatra_app/test/server/server_test.rb
60
61
  - templates/sinatra_app/views/index.haml
61
62
  - templates/sinatra_app/views/layout.haml
62
63
  - templates/sinatra_app/views/style.sass
63
64
  - templates/tdd/Gemfile
64
65
  - templates/tdd/lib/__PROJECT_NAME_SNAKECASE__.rb
65
- - templates/tdd/test/test___PROJECT_NAME_SNAKECASE__.rb
66
+ - templates/tdd/test/__PROJECT_NAME_SNAKECASE___test.rb
67
+ - templates/test/test/__PROJECT_NAME_SNAKECASE___test.rb
66
68
  homepage: https://gitlab.com/tanstaafl/singer/
67
69
  licenses:
68
70
  - MIT
@@ -84,7 +86,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
84
86
  - !ruby/object:Gem::Version
85
87
  version: '0'
86
88
  requirements: []
87
- rubygems_version: 3.6.7
89
+ rubygems_version: 4.0.6
88
90
  specification_version: 4
89
91
  summary: Singer generates code (such as Sinatra apps) from templates.
90
92
  test_files: []