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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/code/object/global.rb +7 -0
- data/lib/code/object/html.rb +42 -0
- data/lib/code/version.rb +1 -1
- data/spec/code_spec.rb +3 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9d6911c3f589574fc7de30da9671e3d104c22a291d258c2e3413466d91c1fa25
|
4
|
+
data.tar.gz: c48d44f2d4b40b532970946cdf8268680271f828645daec849e616b1700e29fa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ea68423505a7a3ceede3745f24ad2df6f696bfd54158f99f0b86f520ed6a85694620b3333711a4431fba8e54f1210221b890c701e6728bdd87f0bbe348cfc75a
|
7
|
+
data.tar.gz: cbb894ccba3bc62b55e2949f9dcc889eb6dbc8e8cf209439937d5b297bcb3b88bbe68614a9e1bcbeeea5bebb32cca6ae3f6e3d34c58a8d9c5081e6edc7600e94
|
data/Gemfile.lock
CHANGED
data/lib/code/object/global.rb
CHANGED
@@ -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
data/spec/code_spec.rb
CHANGED
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.
|
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
|