template-ruby 0.5.6 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (184) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -4
  3. data/Gemfile.lock +15 -22
  4. data/lib/template/version.rb +1 -1
  5. data/lib/template-ruby.rb +2 -3
  6. data/lib/template.rb +18 -22
  7. data/spec/spec_helper.rb +0 -5
  8. data/spec/template_spec.rb +13 -0
  9. data/template-ruby.gemspec +2 -1
  10. metadata +34 -222
  11. data/.cherry.js +0 -21
  12. data/.editorconfig +0 -9
  13. data/.github/workflows/rspec.yml +0 -14
  14. data/.gitignore +0 -2
  15. data/.prettierrc +0 -3
  16. data/.tool-versions +0 -1
  17. data/CHANGELOG.md +0 -55
  18. data/LICENSE +0 -7
  19. data/README.md +0 -103
  20. data/TODO +0 -17
  21. data/bin/code +0 -76
  22. data/bin/format +0 -3
  23. data/bin/publish +0 -19
  24. data/bin/template +0 -85
  25. data/bin/test +0 -17
  26. data/code-ruby.gemspec +0 -17
  27. data/docs/class.code +0 -9
  28. data/docs/euler/1.template +0 -10
  29. data/docs/euler/2.template +0 -16
  30. data/docs/euler/3.template +0 -16
  31. data/docs/euler/4.template +0 -10
  32. data/docs/euler/5.template +0 -13
  33. data/docs/fibonnaci.template +0 -14
  34. data/docs/meetup.code +0 -12
  35. data/docs/precedence.template +0 -36
  36. data/docs/rain.code +0 -22
  37. data/docs/slack.code +0 -17
  38. data/docs/stripe.code +0 -7
  39. data/docs/twitter.code +0 -9
  40. data/language-ruby.gemspec +0 -17
  41. data/lib/code/error.rb +0 -18
  42. data/lib/code/node/base_10.rb +0 -29
  43. data/lib/code/node/base_16.rb +0 -13
  44. data/lib/code/node/base_2.rb +0 -13
  45. data/lib/code/node/base_8.rb +0 -13
  46. data/lib/code/node/boolean.rb +0 -22
  47. data/lib/code/node/call.rb +0 -47
  48. data/lib/code/node/call_argument.rb +0 -21
  49. data/lib/code/node/chained_call.rb +0 -23
  50. data/lib/code/node/code.rb +0 -20
  51. data/lib/code/node/decimal.rb +0 -26
  52. data/lib/code/node/dictionnary.rb +0 -33
  53. data/lib/code/node/equal.rb +0 -34
  54. data/lib/code/node/function.rb +0 -20
  55. data/lib/code/node/function_parameter.rb +0 -31
  56. data/lib/code/node/if.rb +0 -59
  57. data/lib/code/node/if_modifier.rb +0 -47
  58. data/lib/code/node/list.rb +0 -16
  59. data/lib/code/node/negation.rb +0 -15
  60. data/lib/code/node/not.rb +0 -15
  61. data/lib/code/node/nothing.rb +0 -12
  62. data/lib/code/node/number.rb +0 -25
  63. data/lib/code/node/operation.rb +0 -38
  64. data/lib/code/node/power.rb +0 -20
  65. data/lib/code/node/rescue.rb +0 -17
  66. data/lib/code/node/splat.rb +0 -15
  67. data/lib/code/node/statement.rb +0 -59
  68. data/lib/code/node/string.rb +0 -53
  69. data/lib/code/node/ternary.rb +0 -24
  70. data/lib/code/node/unary_minus.rb +0 -15
  71. data/lib/code/node/while.rb +0 -35
  72. data/lib/code/node.rb +0 -13
  73. data/lib/code/object/argument.rb +0 -32
  74. data/lib/code/object/boolean.rb +0 -27
  75. data/lib/code/object/decimal.rb +0 -162
  76. data/lib/code/object/dictionnary.rb +0 -96
  77. data/lib/code/object/function.rb +0 -64
  78. data/lib/code/object/global.rb +0 -42
  79. data/lib/code/object/integer.rb +0 -221
  80. data/lib/code/object/list.rb +0 -207
  81. data/lib/code/object/nothing.rb +0 -23
  82. data/lib/code/object/number.rb +0 -6
  83. data/lib/code/object/range.rb +0 -146
  84. data/lib/code/object/ruby_function.rb +0 -31
  85. data/lib/code/object/string.rb +0 -102
  86. data/lib/code/object.rb +0 -197
  87. data/lib/code/parser/addition.rb +0 -21
  88. data/lib/code/parser/and_operator.rb +0 -17
  89. data/lib/code/parser/bitwise_and.rb +0 -17
  90. data/lib/code/parser/bitwise_or.rb +0 -21
  91. data/lib/code/parser/boolean.rb +0 -17
  92. data/lib/code/parser/call.rb +0 -122
  93. data/lib/code/parser/chained_call.rb +0 -47
  94. data/lib/code/parser/class.rb +0 -45
  95. data/lib/code/parser/code.rb +0 -25
  96. data/lib/code/parser/dictionnary.rb +0 -67
  97. data/lib/code/parser/equal.rb +0 -94
  98. data/lib/code/parser/equality.rb +0 -35
  99. data/lib/code/parser/equality_lower.rb +0 -9
  100. data/lib/code/parser/function.rb +0 -85
  101. data/lib/code/parser/greater.rb +0 -25
  102. data/lib/code/parser/group.rb +0 -22
  103. data/lib/code/parser/if.rb +0 -63
  104. data/lib/code/parser/if_modifier.rb +0 -55
  105. data/lib/code/parser/list.rb +0 -42
  106. data/lib/code/parser/multiplication.rb +0 -25
  107. data/lib/code/parser/name.rb +0 -107
  108. data/lib/code/parser/negation.rb +0 -30
  109. data/lib/code/parser/not_keyword.rb +0 -23
  110. data/lib/code/parser/nothing.rb +0 -22
  111. data/lib/code/parser/number.rb +0 -154
  112. data/lib/code/parser/operation.rb +0 -35
  113. data/lib/code/parser/or_keyword.rb +0 -21
  114. data/lib/code/parser/or_operator.rb +0 -17
  115. data/lib/code/parser/power.rb +0 -43
  116. data/lib/code/parser/range.rb +0 -17
  117. data/lib/code/parser/rescue.rb +0 -39
  118. data/lib/code/parser/shift.rb +0 -21
  119. data/lib/code/parser/splat.rb +0 -31
  120. data/lib/code/parser/statement.rb +0 -9
  121. data/lib/code/parser/string.rb +0 -78
  122. data/lib/code/parser/ternary.rb +0 -46
  123. data/lib/code/parser/unary_minus.rb +0 -31
  124. data/lib/code/parser/while.rb +0 -36
  125. data/lib/code/parser/whitespace.rb +0 -49
  126. data/lib/code/parser.rb +0 -19
  127. data/lib/code/ruby.rb +0 -174
  128. data/lib/code-ruby.rb +0 -10
  129. data/lib/code.rb +0 -47
  130. data/lib/language/atom.rb +0 -342
  131. data/lib/language/output.rb +0 -130
  132. data/lib/language/parser/absent/present.rb +0 -8
  133. data/lib/language/parser/absent.rb +0 -6
  134. data/lib/language/parser/end_of_input.rb +0 -6
  135. data/lib/language/parser/interuption.rb +0 -38
  136. data/lib/language/parser/not_end_of_input.rb +0 -6
  137. data/lib/language/parser/str/not_found.rb +0 -16
  138. data/lib/language/parser/str.rb +0 -6
  139. data/lib/language/parser.rb +0 -53
  140. data/lib/language-ruby.rb +0 -10
  141. data/lib/language.rb +0 -80
  142. data/spec/code/addition_spec.rb +0 -13
  143. data/spec/code/and_operator_spec.rb +0 -13
  144. data/spec/code/bitwise_and_spec.rb +0 -13
  145. data/spec/code/bitwise_or_spec.rb +0 -13
  146. data/spec/code/boolean_spec.rb +0 -13
  147. data/spec/code/call_spec.rb +0 -21
  148. data/spec/code/chained_call_spec.rb +0 -16
  149. data/spec/code/code_spec.rb +0 -29
  150. data/spec/code/dictionnary_spec.rb +0 -17
  151. data/spec/code/equal_spec.rb +0 -26
  152. data/spec/code/equality_spec.rb +0 -13
  153. data/spec/code/function_spec.rb +0 -18
  154. data/spec/code/greater_spec.rb +0 -18
  155. data/spec/code/group_spec.rb +0 -12
  156. data/spec/code/if_modifier_spec.rb +0 -20
  157. data/spec/code/if_spec.rb +0 -25
  158. data/spec/code/list_spec.rb +0 -19
  159. data/spec/code/multiplication_spec.rb +0 -18
  160. data/spec/code/negation_spec.rb +0 -20
  161. data/spec/code/not_keyword_spec.rb +0 -13
  162. data/spec/code/nothing_spec.rb +0 -17
  163. data/spec/code/number_spec.rb +0 -22
  164. data/spec/code/or_keyword_spec.rb +0 -17
  165. data/spec/code/or_operator_spec.rb +0 -16
  166. data/spec/code/parser/boolean_spec.rb +0 -16
  167. data/spec/code/parser/call_spec.rb +0 -26
  168. data/spec/code/parser/chained_call.rb +0 -17
  169. data/spec/code/parser/dictionnary_spec.rb +0 -18
  170. data/spec/code/parser/function_spec.rb +0 -16
  171. data/spec/code/parser/group_spec.rb +0 -18
  172. data/spec/code/parser/list_spec.rb +0 -18
  173. data/spec/code/parser/number_spec.rb +0 -12
  174. data/spec/code/parser/string_spec.rb +0 -21
  175. data/spec/code/parser_spec.rb +0 -23
  176. data/spec/code/power_spec.rb +0 -13
  177. data/spec/code/range_spec.rb +0 -16
  178. data/spec/code/rescue_spec.rb +0 -13
  179. data/spec/code/shift_spec.rb +0 -13
  180. data/spec/code/splat_spec.rb +0 -13
  181. data/spec/code/string_spec.rb +0 -27
  182. data/spec/code/ternary_spec.rb +0 -18
  183. data/spec/code/unary_minus_spec.rb +0 -13
  184. data/spec/code/while_spec.rb +0 -18
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 85a62b57a542b3efd227470d49473db796da2b091f9c827a637d1b877196dfc0
4
- data.tar.gz: 3bebdecdd1017fb28756407d7c759739a92c7367d2da1c0184b2c992412b065f
3
+ metadata.gz: e9a4bbcdb1f2f2854cd079871ae335cd91b4104d5aef15824e7b14995677d108
4
+ data.tar.gz: ae2ff0751a8bb499a930f60981c9d1cc06d6199eb30a934b7a6f5ae806692db1
5
5
  SHA512:
6
- metadata.gz: a6accd36def6ee891d77c5bc70e61aba6d945250fe26ecd004992a9eb9d8ddcb5eade880417436e8d088203366aa92757d1a2f6d76cffa6f39c9b906ac6da276
7
- data.tar.gz: 28ed842cf8c9cbfbe624b2f4bfadaa256cbf3472210949d023a7e915a73e1ace1447d67d1c117ef403b94f5c0d76b24569105dc27753ac4777c79ed40d7a863a
6
+ metadata.gz: 8c1e8db664717fbed97f2af4ba995c4c04ae5b130f6f6e1c8046f76cbfafb34992f12adb1148644e9af240454614abbba87c9ada10502ad987fd9166026387e7
7
+ data.tar.gz: 9631aaeb911bdce1bdb054979325f6482b408c0f50c3c45fd74002d98782ed1dfe06b70ebd7859b66e3460790d934204e116385734c8741efaebdfa3a8ae02ec
data/Gemfile CHANGED
@@ -1,8 +1,5 @@
1
1
  source "https://rubygems.org"
2
2
 
3
- gemspec name: "template-ruby"
4
- gemspec name: "code-ruby"
3
+ gemspec
5
4
 
6
5
  gem "rspec"
7
- gem "syntax_tree", github: "dorianmariefr/syntax_tree"
8
- gem "ruby-prof"
data/Gemfile.lock CHANGED
@@ -1,49 +1,42 @@
1
- GIT
2
- remote: https://github.com/dorianmariefr/syntax_tree.git
3
- revision: f7c9dc36a3d60c90a8d2411f123913b37319dc11
4
- specs:
5
- syntax_tree (5.0.1)
6
- prettier_print (>= 1.1.0)
7
-
8
1
  PATH
9
2
  remote: .
10
3
  specs:
11
- code-ruby (0.5.6)
12
- zeitwerk (~> 2)
13
- template-ruby (0.5.6)
4
+ template-ruby (0.6.0)
5
+ code-ruby (~> 0)
6
+ language (~> 0)
14
7
  zeitwerk (~> 2)
15
8
 
16
9
  GEM
17
10
  remote: https://rubygems.org/
18
11
  specs:
12
+ code-ruby (0.6.0)
13
+ language-ruby (~> 0)
14
+ zeitwerk (~> 2)
19
15
  diff-lcs (1.5.0)
20
- prettier_print (1.1.0)
16
+ language (0.6.0)
17
+ language-ruby (0.6.0)
18
+ zeitwerk (~> 2)
21
19
  rspec (3.12.0)
22
20
  rspec-core (~> 3.12.0)
23
21
  rspec-expectations (~> 3.12.0)
24
22
  rspec-mocks (~> 3.12.0)
25
- rspec-core (3.12.0)
23
+ rspec-core (3.12.2)
26
24
  rspec-support (~> 3.12.0)
27
- rspec-expectations (3.12.0)
25
+ rspec-expectations (3.12.3)
28
26
  diff-lcs (>= 1.2.0, < 2.0)
29
27
  rspec-support (~> 3.12.0)
30
- rspec-mocks (3.12.0)
28
+ rspec-mocks (3.12.6)
31
29
  diff-lcs (>= 1.2.0, < 2.0)
32
30
  rspec-support (~> 3.12.0)
33
- rspec-support (3.12.0)
34
- ruby-prof (1.4.3)
35
- zeitwerk (2.6.6)
31
+ rspec-support (3.12.1)
32
+ zeitwerk (2.6.12)
36
33
 
37
34
  PLATFORMS
38
- arm64-darwin-21
39
35
  arm64-darwin-22
40
36
 
41
37
  DEPENDENCIES
42
- code-ruby!
43
38
  rspec
44
- ruby-prof
45
- syntax_tree!
46
39
  template-ruby!
47
40
 
48
41
  BUNDLED WITH
49
- 2.3.18
42
+ 2.4.22
@@ -1,3 +1,3 @@
1
1
  require_relative "../template"
2
2
 
3
- Template::Version = Gem::Version.new("0.5.6")
3
+ Template::Version = Gem::Version.new("0.6.0")
data/lib/template-ruby.rb CHANGED
@@ -1,10 +1,9 @@
1
- require "bigdecimal"
2
1
  require "stringio"
3
2
  require "timeout"
4
3
  require "zeitwerk"
4
+ require "code-ruby"
5
+ require "template-ruby"
5
6
 
6
7
  loader = Zeitwerk::Loader.for_gem(warn_on_extra_files: false)
7
8
  loader.ignore("#{__dir__}/template-ruby.rb")
8
- loader.ignore("#{__dir__}/code-ruby.rb")
9
- loader.ignore("#{__dir__}/language-ruby.rb")
10
9
  loader.setup
data/lib/template.rb CHANGED
@@ -1,42 +1,40 @@
1
1
  class Template
2
- DEFAULT_TIMEOUT = 10
2
+ EMPTY_STRING = ""
3
+ GLOBALS = %i[io context object].freeze
4
+ DEFAULT_TIMEOUT = 0
3
5
 
4
6
  def initialize(input, io: StringIO.new, timeout: DEFAULT_TIMEOUT, ruby: {})
5
7
  @input = input
6
- @parsed =
7
- Timeout.timeout(timeout) { ::Template::Parser.parse(@input).to_raw }
8
+ @parsed = Timeout.timeout(timeout) { ::Template::Parser.parse(@input).to_raw }
8
9
  @io = io
9
10
  @timeout = timeout || DEFAULT_TIMEOUT
10
- @ruby = ::Code::Ruby.to_code(ruby || {})
11
+ @ruby = Timeout.timeout(timeout) { ::Code::Ruby.to_code(ruby || {}).code_to_context }
11
12
  end
12
13
 
13
- def self.render(
14
+ def self.evaluate(
14
15
  input,
15
16
  context = "",
16
17
  io: StringIO.new,
17
18
  timeout: DEFAULT_TIMEOUT,
18
19
  ruby: {}
19
20
  )
20
- new(input, io: io, timeout: timeout, ruby: ruby).render(context)
21
+ new(input, io:, timeout:, ruby:).evaluate(context)
21
22
  end
22
23
 
23
- def render(context = "")
24
+ def evaluate(context = "")
24
25
  Timeout.timeout(timeout) do
25
- if context != ""
26
- context = ::Code.evaluate(context, timeout: timeout, io: io, ruby: ruby)
27
- else
28
- context = ::Code::Object::Dictionnary.new
29
- end
30
-
31
- if !context.is_a?(::Code::Object::Dictionnary)
32
- raise ::Code::Template::IncompatibleContext.new(
33
- "context must be a dictionnary"
34
- )
35
- end
26
+ context =
27
+ if context == EMPTY_STRING
28
+ Object::Context.new
29
+ else
30
+ Code.evaluate(context, timeout:, io:, ruby:).code_to_context
31
+ end
32
+
33
+ raise(Error::IncompatibleContext) unless context.is_a?(::Code::Object::Context)
36
34
 
37
35
  context = context.merge(ruby)
38
36
 
39
- ::Template::Node::Template.new(parsed).evaluate(context: context, io: io)
37
+ ::Template::Node::Template.new(parsed).evaluate(context:, io:)
40
38
 
41
39
  io.is_a?(StringIO) ? io.string : nil
42
40
  end
@@ -44,7 +42,5 @@ class Template
44
42
 
45
43
  private
46
44
 
47
- attr_reader :parsed, :io, :timeout, :ruby
45
+ attr_reader :input, :parsed, :timeout, :io, :ruby
48
46
  end
49
-
50
- require_relative "template/version"
data/spec/spec_helper.rb CHANGED
@@ -1,6 +1 @@
1
1
  require_relative "../lib/template-ruby"
2
- require "json"
3
-
4
- RSpec.configure do |c|
5
- c.example_status_persistence_file_path = "tmp/examples.txt"
6
- end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "spec_helper"
4
+
5
+ RSpec.describe Code do
6
+ [
7
+ ["Hello {name}", "{name: :Dorian}", "Hello Dorian"],
8
+ ].each do |input, context, expected|
9
+ it "#{input} (#{context}) == #{expected}" do
10
+ expect(Template.evaluate(input, context)).to eq(expected)
11
+ end
12
+ end
13
+ end
@@ -13,7 +13,8 @@ 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"
17
16
 
18
17
  s.add_dependency "zeitwerk", "~> 2"
18
+ s.add_dependency "code-ruby", "~> 0.6"
19
+ s.add_dependency "language-ruby", "~> 0"
19
20
  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.5.6
4
+ version: 0.6.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: 2023-01-18 00:00:00.000000000 Z
11
+ date: 2023-11-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: zeitwerk
@@ -24,148 +24,44 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '2'
27
+ - !ruby/object:Gem::Dependency
28
+ name: code-ruby
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.6'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.6'
41
+ - !ruby/object:Gem::Dependency
42
+ name: language-ruby
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
27
55
  description: 'A templating programming language, like "Hello {name}" with {name: "Dorian"}
28
56
  gives "Hello Dorian"'
29
57
  email: dorian@dorianmarie.fr
30
- executables:
31
- - template
58
+ executables: []
32
59
  extensions: []
33
60
  extra_rdoc_files: []
34
61
  files:
35
- - ".cherry.js"
36
- - ".editorconfig"
37
- - ".github/workflows/rspec.yml"
38
- - ".gitignore"
39
- - ".prettierrc"
40
62
  - ".rspec"
41
- - ".tool-versions"
42
- - CHANGELOG.md
43
63
  - Gemfile
44
64
  - Gemfile.lock
45
- - LICENSE
46
- - README.md
47
- - TODO
48
- - bin/code
49
- - bin/format
50
- - bin/publish
51
- - bin/template
52
- - bin/test
53
- - code-ruby.gemspec
54
- - docs/class.code
55
- - docs/euler/1.template
56
- - docs/euler/2.template
57
- - docs/euler/3.template
58
- - docs/euler/4.template
59
- - docs/euler/5.template
60
- - docs/fibonnaci.template
61
- - docs/meetup.code
62
- - docs/precedence.template
63
- - docs/rain.code
64
- - docs/slack.code
65
- - docs/stripe.code
66
- - docs/twitter.code
67
- - language-ruby.gemspec
68
- - lib/code-ruby.rb
69
- - lib/code.rb
70
- - lib/code/error.rb
71
- - lib/code/node.rb
72
- - lib/code/node/base_10.rb
73
- - lib/code/node/base_16.rb
74
- - lib/code/node/base_2.rb
75
- - lib/code/node/base_8.rb
76
- - lib/code/node/boolean.rb
77
- - lib/code/node/call.rb
78
- - lib/code/node/call_argument.rb
79
- - lib/code/node/chained_call.rb
80
- - lib/code/node/code.rb
81
- - lib/code/node/decimal.rb
82
- - lib/code/node/dictionnary.rb
83
- - lib/code/node/equal.rb
84
- - lib/code/node/function.rb
85
- - lib/code/node/function_parameter.rb
86
- - lib/code/node/if.rb
87
- - lib/code/node/if_modifier.rb
88
- - lib/code/node/list.rb
89
- - lib/code/node/negation.rb
90
- - lib/code/node/not.rb
91
- - lib/code/node/nothing.rb
92
- - lib/code/node/number.rb
93
- - lib/code/node/operation.rb
94
- - lib/code/node/power.rb
95
- - lib/code/node/rescue.rb
96
- - lib/code/node/splat.rb
97
- - lib/code/node/statement.rb
98
- - lib/code/node/string.rb
99
- - lib/code/node/ternary.rb
100
- - lib/code/node/unary_minus.rb
101
- - lib/code/node/while.rb
102
- - lib/code/object.rb
103
- - lib/code/object/argument.rb
104
- - lib/code/object/boolean.rb
105
- - lib/code/object/decimal.rb
106
- - lib/code/object/dictionnary.rb
107
- - lib/code/object/function.rb
108
- - lib/code/object/global.rb
109
- - lib/code/object/integer.rb
110
- - lib/code/object/list.rb
111
- - lib/code/object/nothing.rb
112
- - lib/code/object/number.rb
113
- - lib/code/object/range.rb
114
- - lib/code/object/ruby_function.rb
115
- - lib/code/object/string.rb
116
- - lib/code/parser.rb
117
- - lib/code/parser/addition.rb
118
- - lib/code/parser/and_operator.rb
119
- - lib/code/parser/bitwise_and.rb
120
- - lib/code/parser/bitwise_or.rb
121
- - lib/code/parser/boolean.rb
122
- - lib/code/parser/call.rb
123
- - lib/code/parser/chained_call.rb
124
- - lib/code/parser/class.rb
125
- - lib/code/parser/code.rb
126
- - lib/code/parser/dictionnary.rb
127
- - lib/code/parser/equal.rb
128
- - lib/code/parser/equality.rb
129
- - lib/code/parser/equality_lower.rb
130
- - lib/code/parser/function.rb
131
- - lib/code/parser/greater.rb
132
- - lib/code/parser/group.rb
133
- - lib/code/parser/if.rb
134
- - lib/code/parser/if_modifier.rb
135
- - lib/code/parser/list.rb
136
- - lib/code/parser/multiplication.rb
137
- - lib/code/parser/name.rb
138
- - lib/code/parser/negation.rb
139
- - lib/code/parser/not_keyword.rb
140
- - lib/code/parser/nothing.rb
141
- - lib/code/parser/number.rb
142
- - lib/code/parser/operation.rb
143
- - lib/code/parser/or_keyword.rb
144
- - lib/code/parser/or_operator.rb
145
- - lib/code/parser/power.rb
146
- - lib/code/parser/range.rb
147
- - lib/code/parser/rescue.rb
148
- - lib/code/parser/shift.rb
149
- - lib/code/parser/splat.rb
150
- - lib/code/parser/statement.rb
151
- - lib/code/parser/string.rb
152
- - lib/code/parser/ternary.rb
153
- - lib/code/parser/unary_minus.rb
154
- - lib/code/parser/while.rb
155
- - lib/code/parser/whitespace.rb
156
- - lib/code/ruby.rb
157
- - lib/language-ruby.rb
158
- - lib/language.rb
159
- - lib/language/atom.rb
160
- - lib/language/output.rb
161
- - lib/language/parser.rb
162
- - lib/language/parser/absent.rb
163
- - lib/language/parser/absent/present.rb
164
- - lib/language/parser/end_of_input.rb
165
- - lib/language/parser/interuption.rb
166
- - lib/language/parser/not_end_of_input.rb
167
- - lib/language/parser/str.rb
168
- - lib/language/parser/str/not_found.rb
169
65
  - lib/template-ruby.rb
170
66
  - lib/template.rb
171
67
  - lib/template/node.rb
@@ -176,50 +72,8 @@ files:
176
72
  - lib/template/parser.rb
177
73
  - lib/template/parser/template.rb
178
74
  - lib/template/version.rb
179
- - spec/code/addition_spec.rb
180
- - spec/code/and_operator_spec.rb
181
- - spec/code/bitwise_and_spec.rb
182
- - spec/code/bitwise_or_spec.rb
183
- - spec/code/boolean_spec.rb
184
- - spec/code/call_spec.rb
185
- - spec/code/chained_call_spec.rb
186
- - spec/code/code_spec.rb
187
- - spec/code/dictionnary_spec.rb
188
- - spec/code/equal_spec.rb
189
- - spec/code/equality_spec.rb
190
- - spec/code/function_spec.rb
191
- - spec/code/greater_spec.rb
192
- - spec/code/group_spec.rb
193
- - spec/code/if_modifier_spec.rb
194
- - spec/code/if_spec.rb
195
- - spec/code/list_spec.rb
196
- - spec/code/multiplication_spec.rb
197
- - spec/code/negation_spec.rb
198
- - spec/code/not_keyword_spec.rb
199
- - spec/code/nothing_spec.rb
200
- - spec/code/number_spec.rb
201
- - spec/code/or_keyword_spec.rb
202
- - spec/code/or_operator_spec.rb
203
- - spec/code/parser/boolean_spec.rb
204
- - spec/code/parser/call_spec.rb
205
- - spec/code/parser/chained_call.rb
206
- - spec/code/parser/dictionnary_spec.rb
207
- - spec/code/parser/function_spec.rb
208
- - spec/code/parser/group_spec.rb
209
- - spec/code/parser/list_spec.rb
210
- - spec/code/parser/number_spec.rb
211
- - spec/code/parser/string_spec.rb
212
- - spec/code/parser_spec.rb
213
- - spec/code/power_spec.rb
214
- - spec/code/range_spec.rb
215
- - spec/code/rescue_spec.rb
216
- - spec/code/shift_spec.rb
217
- - spec/code/splat_spec.rb
218
- - spec/code/string_spec.rb
219
- - spec/code/ternary_spec.rb
220
- - spec/code/unary_minus_spec.rb
221
- - spec/code/while_spec.rb
222
75
  - spec/spec_helper.rb
76
+ - spec/template_spec.rb
223
77
  - template-ruby.gemspec
224
78
  homepage: https://github.com/dorianmariefr/template-ruby
225
79
  licenses:
@@ -240,52 +94,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
240
94
  - !ruby/object:Gem::Version
241
95
  version: '0'
242
96
  requirements: []
243
- rubygems_version: 3.3.26
97
+ rubygems_version: 3.4.22
244
98
  signing_key:
245
99
  specification_version: 4
246
100
  summary: A templating programming language
247
101
  test_files:
248
- - spec/code/addition_spec.rb
249
- - spec/code/and_operator_spec.rb
250
- - spec/code/bitwise_and_spec.rb
251
- - spec/code/bitwise_or_spec.rb
252
- - spec/code/boolean_spec.rb
253
- - spec/code/call_spec.rb
254
- - spec/code/chained_call_spec.rb
255
- - spec/code/code_spec.rb
256
- - spec/code/dictionnary_spec.rb
257
- - spec/code/equal_spec.rb
258
- - spec/code/equality_spec.rb
259
- - spec/code/function_spec.rb
260
- - spec/code/greater_spec.rb
261
- - spec/code/group_spec.rb
262
- - spec/code/if_modifier_spec.rb
263
- - spec/code/if_spec.rb
264
- - spec/code/list_spec.rb
265
- - spec/code/multiplication_spec.rb
266
- - spec/code/negation_spec.rb
267
- - spec/code/not_keyword_spec.rb
268
- - spec/code/nothing_spec.rb
269
- - spec/code/number_spec.rb
270
- - spec/code/or_keyword_spec.rb
271
- - spec/code/or_operator_spec.rb
272
- - spec/code/parser/boolean_spec.rb
273
- - spec/code/parser/call_spec.rb
274
- - spec/code/parser/chained_call.rb
275
- - spec/code/parser/dictionnary_spec.rb
276
- - spec/code/parser/function_spec.rb
277
- - spec/code/parser/group_spec.rb
278
- - spec/code/parser/list_spec.rb
279
- - spec/code/parser/number_spec.rb
280
- - spec/code/parser/string_spec.rb
281
- - spec/code/parser_spec.rb
282
- - spec/code/power_spec.rb
283
- - spec/code/range_spec.rb
284
- - spec/code/rescue_spec.rb
285
- - spec/code/shift_spec.rb
286
- - spec/code/splat_spec.rb
287
- - spec/code/string_spec.rb
288
- - spec/code/ternary_spec.rb
289
- - spec/code/unary_minus_spec.rb
290
- - spec/code/while_spec.rb
291
102
  - spec/spec_helper.rb
103
+ - spec/template_spec.rb
data/.cherry.js DELETED
@@ -1,21 +0,0 @@
1
- module.exports = {
2
- project_name: 'dorianmariefr/template-ruby',
3
- metrics: [
4
- {
5
- name: 'todo',
6
- pattern: /TODO:/i,
7
- },
8
- {
9
- name: 'fixme',
10
- pattern: /FIXME:/i,
11
- },
12
- {
13
- name: 'rubocop',
14
- pattern: /rubocop:disable/,
15
- },
16
- {
17
- name: 'eslint',
18
- pattern: /eslint-disable/,
19
- },
20
- ],
21
- }
data/.editorconfig DELETED
@@ -1,9 +0,0 @@
1
- root = true
2
-
3
- [*]
4
- charset = utf-8
5
- end_of_line = lf
6
- insert_final_newline = true
7
- indent_style = space
8
- indent_size = 2
9
- trim_trailing_whitespace = true
@@ -1,14 +0,0 @@
1
- name: RSpec
2
-
3
- on: [push, pull_request]
4
-
5
- jobs:
6
- build:
7
- name: RSpec
8
- runs-on: ubuntu-latest
9
-
10
- steps:
11
- - uses: actions/checkout@v1
12
- - uses: actions/setup-ruby@v1
13
- - run: bundle install
14
- - run: bundle exec rspec
data/.gitignore DELETED
@@ -1,2 +0,0 @@
1
- *.gem
2
- tmp/
data/.prettierrc DELETED
@@ -1,3 +0,0 @@
1
- {
2
- "rubyPlugins": "plugin/trailing_comma"
3
- }
data/.tool-versions DELETED
@@ -1 +0,0 @@
1
- ruby 3.1.3
data/CHANGELOG.md DELETED
@@ -1,55 +0,0 @@
1
- # Changelog
2
-
3
- All notable changes to this project will be documented in this file.
4
-
5
- The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
- and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
-
8
- ## 0.4.0 / 2022-10-21
9
-
10
- - Rewrite of how functions are called internally (no more `public_send`)
11
- - Call ruby functions from template/code
12
-
13
- ## 0.3.1 / 2022-10-13
14
-
15
- - Fix Zeitwerk auto-loading issue
16
-
17
- ## 0.3.0 / 2022-10-10
18
-
19
- - `bin/template` accepts `--timeout` (or `-t`) parameter
20
- - Adds `bin/code` with same options as `bin/template`
21
- - Prevent loose syntax like `{ a: }`, `[1,,,]` and `()`
22
- - Change precedence of defined? (to allow `defined?(name) ? name : nothing`)
23
- - Updates parsers to allow `while false end == nothing`
24
- - String interpolations like `"1 + 1 = {1 + 1}"`
25
- - `context(:name)` to get a function without calling it for instance
26
- - `.to_string` on all objects
27
- - `1 + "a"` and `"a" + 1.0` for instance now convert to strings
28
- - `Dictionnary#each` e.g. `{ a: 1 }.each { |k, v| print(k) }`
29
- - Fix context duplication issue that was preventing implementation of recursive
30
- functions like Fibonacci
31
-
32
- ## 0.2.4 / 2022-08-02
33
-
34
- - Add method `String#*`, e.g. `{"Dorian " \* 2}" -> "Dorian Dorian "
35
- - Add executable to gem, e.g. `template --help`
36
-
37
- ## 0.2.3 / 2022-08-31
38
-
39
- - Add default timeout for code and template parsing and evaluation
40
-
41
- ## 0.2.2 / 2022-08-31
42
-
43
- - Fix parsing error when the template is empty, e.g. ""
44
-
45
- ## 0.2.1 / 2022-08-31
46
-
47
- - Fix parsing error on empty code like `Hello {`
48
-
49
- ## 0.2.0 / 2022-08-30
50
-
51
- - Programming language capable of solving the first 5 Project Euler problems
52
-
53
- ## 0.1.0 / 2022-07-28
54
-
55
- - Initial version with interpolation
data/LICENSE DELETED
@@ -1,7 +0,0 @@
1
- Copyright 2022 Dorian Marié <dorian@dorianmarie.fr>
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
-
5
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
-
7
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.