template-ruby 0.6.3 → 0.6.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fd86e9a8f7b032f9cba8130850b0e1318837ae12b409bf05e0d3084f7b87a1f8
4
- data.tar.gz: 4ffad807a8904a9914f48b69c0e63de4d9e2e829f67ed7209b25cc79688744e5
3
+ metadata.gz: ba26171068662fbb7a3629a5db8c34b934d4c5795fa9dec16e3fa6e122affb9a
4
+ data.tar.gz: 601ac55cf6eee07171ad01f7dae7766abfb09780eadc6119e74112b8deccfa26
5
5
  SHA512:
6
- metadata.gz: c73de839e8882af7e41610a9875b6e7bec6773a0f7980fe2df469f25fcf4edf9d628730f531c051fb958d36d93b276b20b5823302cddd555890434e67a02020e
7
- data.tar.gz: 6b37fe976195028ed03eff1f371a18253a25f599161382d66607f402614643845cdb76363d54ed2f93b3746f2576e83d00a125ee42df762ee6323a6e97ac9538
6
+ metadata.gz: afcc3236a4a9768a7562096cd7744ba62c52a5218b651e5be952fe208e18877955351324366507ce1c584c02b2991e10b415354ca8b5f0a1d45f00c08dce4a77
7
+ data.tar.gz: 3fc0935474b9a0076e02b2a6c2973313c6be88d3b2f5c59e0fa08de324f7fb1303d9d0620dff923d6a717c2824dca4ea94ce4cc30c8e1029c0d52540bf27064d
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 3.3.0
data/.tool-versions ADDED
@@ -0,0 +1 @@
1
+ ruby 3.3.0
data/Gemfile CHANGED
@@ -1,6 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source "https://rubygems.org"
2
4
 
3
5
  gemspec
4
6
 
7
+ ruby "3.3.0"
8
+
5
9
  gem "rspec"
6
10
  gem "ruby-prof"
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- template-ruby (0.6.1)
4
+ template-ruby (0.6.5)
5
5
  code-ruby (~> 0)
6
6
  language-ruby (~> 0)
7
7
  zeitwerk (~> 2)
@@ -9,7 +9,9 @@ PATH
9
9
  GEM
10
10
  remote: https://rubygems.org/
11
11
  specs:
12
- code-ruby (0.6.0)
12
+ bigdecimal (3.1.6)
13
+ code-ruby (0.6.2)
14
+ bigdecimal (~> 3)
13
15
  language-ruby (~> 0)
14
16
  zeitwerk (~> 2)
15
17
  diff-lcs (1.5.0)
@@ -28,16 +30,20 @@ GEM
28
30
  diff-lcs (>= 1.2.0, < 2.0)
29
31
  rspec-support (~> 3.12.0)
30
32
  rspec-support (3.12.1)
31
- ruby-prof (1.6.3)
33
+ ruby-prof (1.7.0)
32
34
  zeitwerk (2.6.12)
33
35
 
34
36
  PLATFORMS
35
37
  arm64-darwin-22
38
+ arm64-darwin-23
36
39
 
37
40
  DEPENDENCIES
38
41
  rspec
39
42
  ruby-prof
40
43
  template-ruby!
41
44
 
45
+ RUBY VERSION
46
+ ruby 3.3.0p0
47
+
42
48
  BUNDLED WITH
43
- 2.4.22
49
+ 2.5.6
data/bin/template CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  require "optparse"
4
5
  require_relative "../lib/template-ruby"
@@ -9,11 +10,7 @@ OptionParser
9
10
  .new do |opts|
10
11
  opts.banner = "Usage: template [options]"
11
12
 
12
- opts.on(
13
- "-v",
14
- "--version",
15
- "Version of template"
16
- ) do |input|
13
+ opts.on("-v", "--version", "Version of template") do |_input|
17
14
  puts Template::Version
18
15
  exit
19
16
  end
@@ -48,10 +45,7 @@ OptionParser
48
45
  "Set timeout in seconds"
49
46
  ) { |timeout| options[:timeout] = timeout.to_f }
50
47
 
51
- opts.on(
52
- "--profile",
53
- "Profile Ruby code"
54
- ) do |timeout|
48
+ opts.on("--profile", "Profile Ruby code") do |_timeout|
55
49
  require "ruby-prof"
56
50
  options[:profile] = true
57
51
  end
@@ -70,9 +64,7 @@ OptionParser
70
64
  input = options.fetch(:input, "")
71
65
  context = options.fetch(:context, "")
72
66
 
73
- if options[:profile]
74
- RubyProf.start
75
- end
67
+ RubyProf.start if options[:profile]
76
68
 
77
69
  if options[:parse]
78
70
  pp ::Template::Parser.parse(input).to_raw
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Template
2
4
  class Node
3
5
  class CodePart < Node
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Template
2
4
  class Node
3
5
  class Part < Node
@@ -7,7 +9,7 @@ class Template
7
9
  elsif part.key?(:code)
8
10
  @part = ::Template::Node::CodePart.new(part[:code])
9
11
  else
10
- raise NotImplementedError.new(part.inspect)
12
+ raise NotImplementedError, part.inspect
11
13
  end
12
14
  end
13
15
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Template
2
4
  class Node
3
5
  class Template < Node
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Template
2
4
  class Node
3
5
  class TextPart < Node
@@ -5,7 +7,7 @@ class Template
5
7
  @text = text
6
8
  end
7
9
 
8
- def evaluate(**args)
10
+ def evaluate(**_args)
9
11
  ::Code::Object::String.new(@text.to_s)
10
12
  end
11
13
  end
data/lib/template/node.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Template
2
4
  class Node < ::Code::Node
3
5
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Template
2
4
  class Parser
3
5
  class Template < Language
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Template
2
4
  class Parser
3
5
  def initialize(input)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative "../template"
2
4
 
3
- Template::Version = Gem::Version.new("0.6.3")
5
+ Template::Version = Gem::Version.new("0.6.5")
data/lib/template-ruby.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "stringio"
2
4
  require "timeout"
3
5
  require "zeitwerk"
data/lib/template.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Template
2
4
  EMPTY_STRING = ""
3
5
  GLOBALS = %i[io context object].freeze
@@ -5,10 +7,14 @@ class Template
5
7
 
6
8
  def initialize(input, io: ::StringIO.new, timeout: DEFAULT_TIMEOUT, ruby: {})
7
9
  @input = input
8
- @parsed = Timeout.timeout(timeout) { ::Template::Parser.parse(@input).to_raw }
10
+ @parsed =
11
+ Timeout.timeout(timeout) { ::Template::Parser.parse(@input).to_raw }
9
12
  @io = io
10
13
  @timeout = timeout || DEFAULT_TIMEOUT
11
- @ruby = Timeout.timeout(timeout) { ::Code::Ruby.to_code(ruby || {}).code_to_context }
14
+ @ruby =
15
+ Timeout.timeout(timeout) do
16
+ ::Code::Ruby.to_code(ruby || {}).code_to_context
17
+ end
12
18
  end
13
19
 
14
20
  def self.evaluate(
@@ -30,7 +36,9 @@ class Template
30
36
  ::Code.evaluate(context, timeout:, io:, ruby:).code_to_context
31
37
  end
32
38
 
33
- raise(Error::IncompatibleContext) unless context.is_a?(::Code::Object::Context)
39
+ unless context.is_a?(::Code::Object::Context)
40
+ raise(Error::IncompatibleContext)
41
+ end
34
42
 
35
43
  context = context.merge(ruby)
36
44
 
data/spec/spec_helper.rb CHANGED
@@ -1 +1,3 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative "../lib/template-ruby"
@@ -4,7 +4,7 @@ require "spec_helper"
4
4
 
5
5
  RSpec.describe Code do
6
6
  [
7
- ["Hello {name}", "{name: :Dorian}", "Hello Dorian"],
7
+ ["Hello {name}", "{name: :Dorian}", "Hello Dorian"]
8
8
  ].each do |input, context, expected|
9
9
  it "#{input} (#{context}) == #{expected}" do
10
10
  expect(Template.evaluate(input, context)).to eq(expected)
@@ -1,3 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "English"
1
4
  require_relative "lib/template/version"
2
5
 
3
6
  Gem::Specification.new do |s|
@@ -8,14 +11,13 @@ Gem::Specification.new do |s|
8
11
  'A templating programming language, like "Hello {name}" with {name: "Dorian"} gives "Hello Dorian"'
9
12
  s.authors = ["Dorian Marié"]
10
13
  s.email = "dorian@dorianmarie.fr"
11
- s.files = `git ls-files`.split($/)
12
- s.test_files = s.files.grep(%r{^(test|spec|features)/})
14
+ s.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
13
15
  s.require_paths = ["lib"]
14
- s.homepage = "https://github.com/dorianmariefr/template-ruby"
16
+ s.homepage = "https://github.com/dorianmariecom/template-ruby"
15
17
  s.license = "MIT"
16
18
  s.executables = "template"
17
19
 
18
- s.add_dependency "zeitwerk", "~> 2"
19
20
  s.add_dependency "code-ruby", "~> 0"
20
21
  s.add_dependency "language-ruby", "~> 0"
22
+ s.add_dependency "zeitwerk", "~> 2"
21
23
  end
metadata CHANGED
@@ -1,31 +1,31 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: template-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.3
4
+ version: 0.6.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dorian Marié
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-11-24 00:00:00.000000000 Z
11
+ date: 2024-02-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: zeitwerk
14
+ name: code-ruby
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '2'
19
+ version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '2'
26
+ version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: code-ruby
28
+ name: language-ruby
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
@@ -39,19 +39,19 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: language-ruby
42
+ name: zeitwerk
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: '2'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '0'
54
+ version: '2'
55
55
  description: 'A templating programming language, like "Hello {name}" with {name: "Dorian"}
56
56
  gives "Hello Dorian"'
57
57
  email: dorian@dorianmarie.fr
@@ -61,6 +61,8 @@ extensions: []
61
61
  extra_rdoc_files: []
62
62
  files:
63
63
  - ".rspec"
64
+ - ".ruby-version"
65
+ - ".tool-versions"
64
66
  - Gemfile
65
67
  - Gemfile.lock
66
68
  - README.md
@@ -78,7 +80,7 @@ files:
78
80
  - spec/spec_helper.rb
79
81
  - spec/template_spec.rb
80
82
  - template-ruby.gemspec
81
- homepage: https://github.com/dorianmariefr/template-ruby
83
+ homepage: https://github.com/dorianmariecom/template-ruby
82
84
  licenses:
83
85
  - MIT
84
86
  metadata: {}
@@ -97,10 +99,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
97
99
  - !ruby/object:Gem::Version
98
100
  version: '0'
99
101
  requirements: []
100
- rubygems_version: 3.4.22
102
+ rubygems_version: 3.5.3
101
103
  signing_key:
102
104
  specification_version: 4
103
105
  summary: A templating programming language
104
- test_files:
105
- - spec/spec_helper.rb
106
- - spec/template_spec.rb
106
+ test_files: []