code-ruby 0.15.5 → 0.15.7

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: 6a3d6be7b141289c2a4f0dd2541783cf9703735108ca1558ec830d2ef870dd55
4
- data.tar.gz: ce27ea1527b9a282f62a56b3460cf1ecaf6a3100a36b1aebfbdbddce11e30d48
3
+ metadata.gz: 9d6911c3f589574fc7de30da9671e3d104c22a291d258c2e3413466d91c1fa25
4
+ data.tar.gz: c48d44f2d4b40b532970946cdf8268680271f828645daec849e616b1700e29fa
5
5
  SHA512:
6
- metadata.gz: 0bdcdd5e603046f0fee34a8f22e195388f3422907d54224a9041fd37617ec075f3aea348b54ce00f579d144977b38a34d47aa29dc7b4644a4eac8aa20f74183e
7
- data.tar.gz: bd7a1a18eafce4ce000e0f92bf27222d48085790c8e83e4c648d632e26b7465c60c7759f372d53dce349025b745e9e455472b89300649cddc24da146d3e1307f
6
+ metadata.gz: ea68423505a7a3ceede3745f24ad2df6f696bfd54158f99f0b86f520ed6a85694620b3333711a4431fba8e54f1210221b890c701e6728bdd87f0bbe348cfc75a
7
+ data.tar.gz: cbb894ccba3bc62b55e2949f9dcc889eb6dbc8e8cf209439937d5b297bcb3b88bbe68614a9e1bcbeeea5bebb32cca6ae3f6e3d34c58a8d9c5081e6edc7600e94
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- code-ruby (0.15.5)
4
+ code-ruby (0.15.7)
5
5
  activesupport
6
6
  bigdecimal
7
7
  did-you-mean
@@ -87,6 +87,13 @@ class Code
87
87
  else
88
88
  Class.new(IdentifierList)
89
89
  end
90
+ when "Html"
91
+ sig(args) { Object.repeat }
92
+ if arguments.any?
93
+ Html.new(*arguments.raw)
94
+ else
95
+ Class.new(Html)
96
+ end
90
97
  when "evaluate"
91
98
  sig(args) { Object }
92
99
  Code.evaluate(value.to_s)
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Code
4
+ class Object
5
+ class Html < Object
6
+ def initialize(*args, **_kargs, &_block)
7
+ @raw = nil
8
+ end
9
+
10
+ def self.call(**args)
11
+ operator = args.fetch(:operator, nil)
12
+ arguments = args.fetch(:arguments, List.new)
13
+
14
+ case operator.to_s
15
+ when "link_to"
16
+ sig(args) { [String.maybe, String.maybe] }
17
+ code_link_to(*arguments.raw)
18
+ when "escape"
19
+ sig(args) { String.maybe }
20
+ code_escape(*arguments.raw)
21
+ else
22
+ super
23
+ end
24
+ end
25
+
26
+ def self.code_link_to(text = nil, href = nil)
27
+ text ||= Nothing.new
28
+ href ||= Nothing.new
29
+
30
+ String.new(<<~LINK.strip)
31
+ <a href="#{CGI.escape(href.raw.to_s)}">#{CGI.escape(text.raw.to_s)}</a>
32
+ LINK
33
+ end
34
+
35
+ def self.code_escape(string = nil)
36
+ string ||= Nothing.new
37
+
38
+ String.new(CGI.escape(string.raw.to_s))
39
+ end
40
+ end
41
+ end
42
+ end
data/lib/code/version.rb CHANGED
@@ -2,4 +2,4 @@
2
2
 
3
3
  require_relative "../code"
4
4
 
5
- Code::Version = Gem::Version.new("0.15.5")
5
+ Code::Version = Gem::Version.new("0.15.7")
data/spec/code_spec.rb CHANGED
@@ -70,6 +70,9 @@ RSpec.describe Code do
70
70
  IdentifierList.new
71
71
  IdentifierList.new([])
72
72
  Time.new(nothing).before?
73
+ Html.link_to
74
+ Html.link_to('/')
75
+ Html.link_to('Home','/')
73
76
  ].each { |input| it(input) { Code.evaluate(input) } }
74
77
 
75
78
  [
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: code-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.15.5
4
+ version: 0.15.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dorian Marié
@@ -164,6 +164,7 @@ files:
164
164
  - lib/code/object/duration.rb
165
165
  - lib/code/object/function.rb
166
166
  - lib/code/object/global.rb
167
+ - lib/code/object/html.rb
167
168
  - lib/code/object/identifier_list.rb
168
169
  - lib/code/object/integer.rb
169
170
  - lib/code/object/json.rb