singer 0.1.0 → 0.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 +4 -4
- data/exe/singer +1 -7
- data/lib/singer/paths.rb +8 -0
- data/lib/singer/template.rb +36 -0
- data/lib/singer/version.rb +1 -1
- data/lib/singer.rb +7 -1
- data/templates/tdd/lib/ruby.rb +13 -0
- data/templates/tdd/test/test_ruby.rb +16 -0
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 52a8bd4bab0f3283223aa2db41a7bbffb58e84c8033f123892a5526942e35102
|
4
|
+
data.tar.gz: 0031afac6095b8c2d40b6a699f698c5c170b2a115b4aeca0c5c29149cf22498b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: db604b8c31e53948e5a367b4282173ecc098b09ab1cd6c4ff28e941bfd5598818b03551354924e65671de348e09e5bb89d7695565d38340475a49051f9db0a9f
|
7
|
+
data.tar.gz: 90505991f184b2925937143403c70b43287e6bce20088300fe79c603f52cde53d8b87645792b6c07564554c80b4f219689339ab09d96db78682dc4671f89f5c4
|
data/exe/singer
CHANGED
data/lib/singer/paths.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
|
3
|
+
module Singer
|
4
|
+
# describes one type of code that Singer can generate
|
5
|
+
class Template
|
6
|
+
def self.all
|
7
|
+
@all ||= load_all
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.load_all
|
11
|
+
Dir[File.join(Paths.templates_from_gem, '*')].to_h do |template_dir|
|
12
|
+
[File.basename(template_dir), new(template_dir)]
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
attr_reader :path, :files
|
17
|
+
|
18
|
+
def initialize(path)
|
19
|
+
@path = path
|
20
|
+
Dir.chdir(path) do # we could use only Dir[base: path], but all the code uses relative paths
|
21
|
+
entries = Dir['**/*']
|
22
|
+
@files = entries.select{ File.file?(_1) }
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def generate(output_path)
|
27
|
+
FileUtils.mkdir_p(output_path)
|
28
|
+
files.each do |file|
|
29
|
+
input_file = File.join(path, file)
|
30
|
+
output_file = File.join(output_path, file)
|
31
|
+
FileUtils.mkdir_p(File.dirname(output_file))
|
32
|
+
FileUtils.cp(input_file, output_file)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
data/lib/singer/version.rb
CHANGED
data/lib/singer.rb
CHANGED
@@ -1,6 +1,12 @@
|
|
1
1
|
require_relative 'singer/version'
|
2
|
+
require_relative 'singer/paths'
|
3
|
+
require_relative 'singer/template'
|
2
4
|
|
5
|
+
# Singer, which generates Sinatra apps etc. from templates
|
3
6
|
module Singer
|
4
7
|
class Error < StandardError; end
|
5
|
-
|
8
|
+
|
9
|
+
def self.generate
|
10
|
+
Template.all['tdd'].generate('.')
|
11
|
+
end
|
6
12
|
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'colorize'
|
2
|
+
require 'awesome_print'
|
3
|
+
|
4
|
+
class <%= Singer::CONFIGURATION.camelcase_name %>
|
5
|
+
def hello(who:)
|
6
|
+
"Hello, #{who}."
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
if File.expand_path($PROGRAM_NAME) == File.expand_path(__FILE__)
|
11
|
+
ciastka = <%= Singer::CONFIGURATION.camelcase_name %>.new
|
12
|
+
puts "Testing testing: #{ciastka.hello(who: :world).green}"
|
13
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'minitest/rg'
|
2
|
+
require 'minitest/autorun' if $PROGRAM_NAME == __FILE__
|
3
|
+
|
4
|
+
require_relative '<%= Singer::CONFIGURATION.snakecase_name %>'
|
5
|
+
|
6
|
+
class Test<%= Singer::CONFIGURATION.camelcase_name %> < Minitest::Test
|
7
|
+
# TEST_INPUT = File.read('input_mini.txt').lines(chomp: true)
|
8
|
+
|
9
|
+
def setup
|
10
|
+
@<%= Singer::CONFIGURATION.snakecase_name %> = <%= Singer::CONFIGURATION.camelcase_name %>.new
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_hello_interpolates_into_string
|
14
|
+
assert_equal 'Hello, world.', @<%= Singer::CONFIGURATION.snakecase_name %>.hello(who: :world)
|
15
|
+
end
|
16
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: singer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Emil Chludziński
|
8
8
|
bindir: exe
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-01-
|
10
|
+
date: 2025-01-19 00:00:00.000000000 Z
|
11
11
|
dependencies: []
|
12
12
|
description: |
|
13
13
|
Singer is a highly configurable templating system intended for generating Ruby boilerplate.
|
@@ -23,7 +23,11 @@ files:
|
|
23
23
|
- README.md
|
24
24
|
- exe/singer
|
25
25
|
- lib/singer.rb
|
26
|
+
- lib/singer/paths.rb
|
27
|
+
- lib/singer/template.rb
|
26
28
|
- lib/singer/version.rb
|
29
|
+
- templates/tdd/lib/ruby.rb
|
30
|
+
- templates/tdd/test/test_ruby.rb
|
27
31
|
homepage: https://gitlab.com/tanstaafl/singer/
|
28
32
|
licenses:
|
29
33
|
- MIT
|