template-ruby 0.6.0 → 0.6.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -0
- data/Gemfile.lock +4 -3
- data/README.md +3 -0
- data/bin/template +94 -0
- data/lib/template/version.rb +1 -1
- data/lib/template-ruby.rb +1 -1
- data/template-ruby.gemspec +2 -1
- metadata +7 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 563310c18f63131c45c4e8fb05a002765c9fe67b5d118d0bbd1683d9ba52fe8c
|
4
|
+
data.tar.gz: 5d135daf4766e24fbff6ac875050432510f5408e1e105d7834985ff540e0e0f7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b28803d77e9e60bb4f38377c8f81755f23e3d89bbb9cf35bf779337a3ecf86854db6acfa2f018fd126cbf234b8307640aa1d0567b4747c7df432d4a6aa157a30
|
7
|
+
data.tar.gz: 48c9939a07e16a0f400970554938296f5e6faa7114226e641814f4442ebc0bd0ee898e0a00a7c5ff5c624495d871806771c1cbf6316b8c517bc0eedc175abfd8
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
template-ruby (0.6.
|
4
|
+
template-ruby (0.6.1)
|
5
5
|
code-ruby (~> 0)
|
6
|
-
language (~> 0)
|
6
|
+
language-ruby (~> 0)
|
7
7
|
zeitwerk (~> 2)
|
8
8
|
|
9
9
|
GEM
|
@@ -13,7 +13,6 @@ GEM
|
|
13
13
|
language-ruby (~> 0)
|
14
14
|
zeitwerk (~> 2)
|
15
15
|
diff-lcs (1.5.0)
|
16
|
-
language (0.6.0)
|
17
16
|
language-ruby (0.6.0)
|
18
17
|
zeitwerk (~> 2)
|
19
18
|
rspec (3.12.0)
|
@@ -29,6 +28,7 @@ GEM
|
|
29
28
|
diff-lcs (>= 1.2.0, < 2.0)
|
30
29
|
rspec-support (~> 3.12.0)
|
31
30
|
rspec-support (3.12.1)
|
31
|
+
ruby-prof (1.6.3)
|
32
32
|
zeitwerk (2.6.12)
|
33
33
|
|
34
34
|
PLATFORMS
|
@@ -36,6 +36,7 @@ PLATFORMS
|
|
36
36
|
|
37
37
|
DEPENDENCIES
|
38
38
|
rspec
|
39
|
+
ruby-prof
|
39
40
|
template-ruby!
|
40
41
|
|
41
42
|
BUNDLED WITH
|
data/README.md
ADDED
data/bin/template
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "optparse"
|
4
|
+
require_relative "../lib/template-ruby"
|
5
|
+
|
6
|
+
options = { timeout: 0, profile: false, profiler: "text" }
|
7
|
+
|
8
|
+
OptionParser
|
9
|
+
.new do |opts|
|
10
|
+
opts.banner = "Usage: template [options]"
|
11
|
+
|
12
|
+
opts.on(
|
13
|
+
"-v",
|
14
|
+
"--version",
|
15
|
+
"Version of template"
|
16
|
+
) do |input|
|
17
|
+
puts Template::Version
|
18
|
+
exit
|
19
|
+
end
|
20
|
+
|
21
|
+
opts.on(
|
22
|
+
"-i INPUT",
|
23
|
+
"--input=INPUT",
|
24
|
+
"Input in the template language (String or File)"
|
25
|
+
) do |input|
|
26
|
+
input = File.read(input) if File.exist?(input)
|
27
|
+
|
28
|
+
options[:input] = input
|
29
|
+
end
|
30
|
+
|
31
|
+
opts.on(
|
32
|
+
"-c CONTEXT",
|
33
|
+
"--context=CONTEXT",
|
34
|
+
"Context in the code language (String or File)"
|
35
|
+
) do |context|
|
36
|
+
context = File.read(context) if File.exist?(context)
|
37
|
+
|
38
|
+
options[:context] = context
|
39
|
+
end
|
40
|
+
|
41
|
+
opts.on("-p", "--parse", "Get parser results for input") do |parse|
|
42
|
+
options[:parse] = parse
|
43
|
+
end
|
44
|
+
|
45
|
+
opts.on(
|
46
|
+
"-t TIMEOUT",
|
47
|
+
"--timeout=TIMEOUT",
|
48
|
+
"Set timeout in seconds"
|
49
|
+
) { |timeout| options[:timeout] = timeout.to_f }
|
50
|
+
|
51
|
+
opts.on(
|
52
|
+
"--profile",
|
53
|
+
"Profile Ruby code"
|
54
|
+
) do |timeout|
|
55
|
+
require "ruby-prof"
|
56
|
+
options[:profile] = true
|
57
|
+
end
|
58
|
+
|
59
|
+
opts.on(
|
60
|
+
"--profiler TYPE",
|
61
|
+
"Profiler output type (text (default) or html)"
|
62
|
+
) do |profiler|
|
63
|
+
require "ruby-prof"
|
64
|
+
options[:profile] = true
|
65
|
+
options[:profiler] = profiler
|
66
|
+
end
|
67
|
+
end
|
68
|
+
.parse!
|
69
|
+
|
70
|
+
input = options.fetch(:input, "")
|
71
|
+
context = options.fetch(:context, "")
|
72
|
+
|
73
|
+
if options[:profile]
|
74
|
+
RubyProf.start
|
75
|
+
end
|
76
|
+
|
77
|
+
if options[:parse]
|
78
|
+
pp ::Template::Parser.parse(input).to_raw
|
79
|
+
else
|
80
|
+
Template.evaluate(input, context, io: $stdout, timeout: options[:timeout])
|
81
|
+
end
|
82
|
+
|
83
|
+
if options[:profile]
|
84
|
+
result = RubyProf.stop
|
85
|
+
if options[:profiler] == "text"
|
86
|
+
printer = RubyProf::FlatPrinter.new(result)
|
87
|
+
printer.print($stdout)
|
88
|
+
elsif options[:profiler] == "html"
|
89
|
+
printer = RubyProf::GraphHtmlPrinter.new(result)
|
90
|
+
printer.print($stdout)
|
91
|
+
else
|
92
|
+
abort "#{options[:profiler]} not recognized"
|
93
|
+
end
|
94
|
+
end
|
data/lib/template/version.rb
CHANGED
data/lib/template-ruby.rb
CHANGED
data/template-ruby.gemspec
CHANGED
@@ -13,8 +13,9 @@ Gem::Specification.new do |s|
|
|
13
13
|
s.require_paths = ["lib"]
|
14
14
|
s.homepage = "https://github.com/dorianmariefr/template-ruby"
|
15
15
|
s.license = "MIT"
|
16
|
+
s.executables = "template"
|
16
17
|
|
17
18
|
s.add_dependency "zeitwerk", "~> 2"
|
18
|
-
s.add_dependency "code-ruby", "~> 0
|
19
|
+
s.add_dependency "code-ruby", "~> 0"
|
19
20
|
s.add_dependency "language-ruby", "~> 0"
|
20
21
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: template-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dorian Marié
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '0
|
33
|
+
version: '0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '0
|
40
|
+
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: language-ruby
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -55,13 +55,16 @@ dependencies:
|
|
55
55
|
description: 'A templating programming language, like "Hello {name}" with {name: "Dorian"}
|
56
56
|
gives "Hello Dorian"'
|
57
57
|
email: dorian@dorianmarie.fr
|
58
|
-
executables:
|
58
|
+
executables:
|
59
|
+
- template
|
59
60
|
extensions: []
|
60
61
|
extra_rdoc_files: []
|
61
62
|
files:
|
62
63
|
- ".rspec"
|
63
64
|
- Gemfile
|
64
65
|
- Gemfile.lock
|
66
|
+
- README.md
|
67
|
+
- bin/template
|
65
68
|
- lib/template-ruby.rb
|
66
69
|
- lib/template.rb
|
67
70
|
- lib/template/node.rb
|