template-ruby 0.7.2 → 1.0.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: 1fd82e44d1e415aa4708f5753a6e0fa406e215829b6941fcc9c21a8be47320e7
4
- data.tar.gz: 8e9fb00f26e997eeb65c825b755c98b622b2b4e08b642893bc1284700aea6814
3
+ metadata.gz: db311323ca45e9d60dcaaed36860dd5279d1d058a0335d237360218bf2bbd11e
4
+ data.tar.gz: 79f2b4493839c39eb10796d440275aebf59ad96f78317e640019bf04ebfb200a
5
5
  SHA512:
6
- metadata.gz: ecbc7d50c0279ddaf4bb5a1c3af02a73966390a0189a1fd875c8894fa7191e4a6f27033c234a744e20af71e20800e666320c14056c6aaa2a2f6e6168ecb6bba5
7
- data.tar.gz: 63c70c8b11129002a29c91948d3da27d70888c4e67053b433f5e535b4a3c4c7d0931f38c7e47ff16e73a93931d293818dad92049974070d620d8aa2566656b73
6
+ metadata.gz: ccdd1827656e53089211967d9db8cea06cab30b7606d4cbb50052353071af3bdfbd6e9a568a7b55d16160407f549cfad05fb219c3c5a6945e173b03eb38fe23d
7
+ data.tar.gz: 19982e2ebfb0d70d0125484bcc7f3532e35099dfaffee0a12c2a3d643ec58b9ab7e53a3fb848d6f7cca43150554339b99e0a0479ddeebe68ab411ea5ec5885ef
data/Gemfile.lock CHANGED
@@ -1,15 +1,16 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- template-ruby (0.7.2)
4
+ template-ruby (1.0.0)
5
5
  code-ruby
6
+ dorian-arguments
6
7
  language-ruby
7
8
  zeitwerk
8
9
 
9
10
  GEM
10
11
  remote: https://rubygems.org/
11
12
  specs:
12
- activesupport (7.2.0)
13
+ activesupport (7.2.1)
13
14
  base64
14
15
  bigdecimal
15
16
  concurrent-ruby (~> 1.0, >= 1.3.1)
@@ -23,10 +24,11 @@ GEM
23
24
  ast (2.4.2)
24
25
  base64 (0.2.0)
25
26
  bigdecimal (3.1.8)
26
- code-ruby (0.15.14)
27
+ code-ruby (0.15.16)
27
28
  activesupport
28
29
  bigdecimal
29
30
  did-you-mean
31
+ dorian-arguments
30
32
  json
31
33
  language-ruby
32
34
  zeitwerk
@@ -35,11 +37,17 @@ GEM
35
37
  did-you-mean (0.1.1)
36
38
  levenshtein (>= 0.2.0)
37
39
  diff-lcs (1.5.1)
40
+ dorian-arguments (0.4.1)
41
+ activesupport
42
+ bigdecimal
43
+ dorian-to_struct
44
+ dorian-to_struct (0.6.0)
38
45
  drb (2.2.1)
39
46
  i18n (1.14.5)
40
47
  concurrent-ruby (~> 1.0)
41
48
  json (2.7.2)
42
- language-ruby (0.9.0)
49
+ language-ruby (0.9.3)
50
+ dorian-arguments
43
51
  zeitwerk
44
52
  language_server-protocol (3.17.0.3)
45
53
  levenshtein (0.2.2)
@@ -53,7 +61,7 @@ GEM
53
61
  rack (3.1.7)
54
62
  rainbow (3.1.1)
55
63
  regexp_parser (2.9.2)
56
- rexml (3.3.5)
64
+ rexml (3.3.6)
57
65
  strscan
58
66
  rspec (3.13.0)
59
67
  rspec-core (~> 3.13.0)
@@ -61,7 +69,7 @@ GEM
61
69
  rspec-mocks (~> 3.13.0)
62
70
  rspec-core (3.13.0)
63
71
  rspec-support (~> 3.13.0)
64
- rspec-expectations (3.13.1)
72
+ rspec-expectations (3.13.2)
65
73
  diff-lcs (>= 1.2.0, < 2.0)
66
74
  rspec-support (~> 3.13.0)
67
75
  rspec-mocks (3.13.1)
@@ -87,10 +95,10 @@ GEM
87
95
  rubocop-performance (1.21.1)
88
96
  rubocop (>= 1.48.1, < 2.0)
89
97
  rubocop-ast (>= 1.31.1, < 2.0)
90
- rubocop-rails (2.25.1)
98
+ rubocop-rails (2.26.0)
91
99
  activesupport (>= 4.2.0)
92
100
  rack (>= 1.1)
93
- rubocop (>= 1.33.0, < 2.0)
101
+ rubocop (>= 1.52.0, < 2.0)
94
102
  rubocop-ast (>= 1.31.1, < 2.0)
95
103
  rubocop-rails-omakase (1.0.0)
96
104
  rubocop
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 1.0.0
data/bin/template CHANGED
@@ -1,105 +1,71 @@
1
1
  #!/usr/bin/env ruby
2
2
  # frozen_string_literal: true
3
3
 
4
- require "optparse"
5
4
  require_relative "../lib/template-ruby"
6
-
7
- options = {
8
- timeout: 0,
9
- profile: false,
10
- profiler: "text",
11
- input: "",
12
- parse: false
13
- }
14
-
15
- argv =
16
- OptionParser
17
- .new do |opts|
18
- opts.banner = "Usage: template INPUT\n\n"
19
-
20
- opts.on("-v", "--version", "Version of Template") do |_input|
21
- puts Code::Version
22
- exit
23
- end
24
-
25
- opts.on(
26
- "-i INPUT",
27
- "--input INPUT",
28
- "Input in the Template language (String or File)"
29
- ) do |input|
30
- input = File.read(input) if File.exist?(input)
31
-
32
- options[:input] = input
33
- end
34
-
35
- opts.on("-p", "--parse", "Parser tree for input") do |parse|
36
- options[:parse] = parse
37
- end
38
-
39
- opts.on(
40
- "-t TIMEOUT",
41
- "--timeout TIMEOUT",
42
- "Set timeout in seconds"
43
- ) { |timeout| options[:timeout] = timeout.to_f }
44
-
45
- opts.on(
46
- "-z TIME_ZONE",
47
- "--time-zone TIME_ZONE",
48
- "Set time zone"
49
- ) { |time_zone| Time.zone = time_zone }
50
-
51
- opts.on("--profile", "Profile Ruby code") do |_timeout|
52
- require "ruby-prof"
53
- options[:profile] = true
54
- end
55
-
56
- opts.on(
57
- "--profiler TYPE",
58
- "Profiler output type (text (default) or html)"
59
- ) do |profiler|
60
- require "ruby-prof"
61
- options[:profile] = true
62
- options[:profiler] = profiler
63
- end
64
- end
65
- .parse!
66
-
67
- options[:input] = argv.join(" ") if options[:input].empty?
68
-
69
- abort <<~HELP if options[:input].empty?
70
- Usage: template INPUT
71
-
72
- -v, --version Version of Template
73
- -i, --input INPUT Input in the Template language (String or File)
74
- -p, --parse Parser tree for input
75
- -t, --timeout TIMEOUT Set timeout in seconds
76
- --profile Profile Ruby code
77
- --profiler TYPE Profiler output type (text (default) or html)
78
- HELP
79
-
80
- RubyProf.start if options[:profile]
81
-
82
- if options[:parse]
83
- pp Template::Parser.parse(options[:input]).to_raw
5
+ require "dorian/arguments"
6
+
7
+ parsed =
8
+ Dorian::Arguments.parse(
9
+ input: {
10
+ type: :string,
11
+ alias: :i
12
+ },
13
+ parse: {
14
+ type: :boolean,
15
+ alias: :p
16
+ },
17
+ profile: :boolean,
18
+ profiler: :string,
19
+ timeout: {
20
+ type: :integer,
21
+ alias: :t
22
+ },
23
+ version: {
24
+ type: :boolean,
25
+ alias: :v
26
+ },
27
+ help: {
28
+ type: :boolean,
29
+ alias: :h
30
+ }
31
+ )
32
+
33
+ abort Template::Version.to_s if parsed.options.version
34
+ abort parsed.help if parsed.options.help
35
+
36
+ input = parsed.options.input.to_s
37
+ input = File.read(input) if File.exist?(input)
38
+ input += parsed.arguments.join(" ")
39
+ input += parsed.files.map { |file| File.read(file) }.join
40
+
41
+ abort parsed.help if input.empty?
42
+
43
+ profile = parsed.options.profile || !parsed.options.profiler.empty?
44
+ require "ruby-prof" if profile
45
+
46
+ RubyProf.start if profile
47
+
48
+ if parsed.options.parse
49
+ pp Template::Parser.parse(input).to_raw
84
50
  else
85
- print Template.evaluate(
86
- options[:input],
87
- output: $stdout,
88
- error: $stderr,
89
- timeout: options[:timeout]
90
- )
51
+ print(
52
+ Template.evaluate(
53
+ input,
54
+ output: $stdout,
55
+ error: $stderr,
56
+ timeout: parsed.options.timeout
57
+ )
58
+ )
91
59
  end
92
60
 
93
- if options[:profile]
61
+ if profile
94
62
  result = RubyProf.stop
95
63
 
96
- if options[:profiler] == "text"
97
- printer = RubyProf::FlatPrinter.new(result)
98
- printer.print($stdout)
99
- elsif options[:profiler] == "html"
64
+ if parsed.options.profiler == "html"
100
65
  printer = RubyProf::GraphHtmlPrinter.new(result)
101
66
  printer.print($stdout)
102
67
  else
103
- abort "#{options[:profiler]} not recognized"
68
+ printer = RubyProf::FlatPrinter.new(result)
69
+ printer.print($stdout)
104
70
  end
105
71
  end
@@ -2,4 +2,5 @@
2
2
 
3
3
  require_relative "../template"
4
4
 
5
- Template::Version = Gem::Version.new("0.7.2")
5
+ Template::Version =
6
+ Gem::Version.new(File.read(File.expand_path("../../../VERSION", __FILE__)))
@@ -1,11 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "English"
4
- require_relative "lib/template/version"
5
-
6
3
  Gem::Specification.new do |s|
7
4
  s.name = "template-ruby"
8
- s.version = ::Template::Version
5
+ s.version = File.read("VERSION").strip
9
6
  s.summary = "templating language"
10
7
  s.description = s.summary
11
8
  s.authors = ["Dorian Marié"]
@@ -18,4 +15,5 @@ Gem::Specification.new do |s|
18
15
  s.add_dependency "code-ruby"
19
16
  s.add_dependency "language-ruby"
20
17
  s.add_dependency "zeitwerk"
18
+ s.add_dependency "dorian-arguments"
21
19
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: template-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.2
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dorian Marié
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-08-18 00:00:00.000000000 Z
11
+ date: 2024-08-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: code-ruby
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: dorian-arguments
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
55
69
  description: templating language
56
70
  email: dorian@dorianmarie.fr
57
71
  executables:
@@ -71,6 +85,7 @@ files:
71
85
  - Gemfile.lock
72
86
  - LICENSE
73
87
  - README.md
88
+ - VERSION
74
89
  - bin/rspec
75
90
  - bin/template
76
91
  - bin/test