code-ruby 1.5.2 → 1.5.4
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 +4 -4
- data/Gemfile.lock +21 -6
- data/VERSION +1 -1
- data/code-ruby.gemspec +2 -0
- data/lib/code/concerns/shared.rb +4 -0
- data/lib/code/object/base_64.rb +72 -0
- data/lib/code/object/global.rb +10 -0
- data/lib/code/object/list.rb +30 -1
- data/lib/code/object/range.rb +7 -0
- data/lib/code/object/smtp.rb +87 -0
- data/lib/code-ruby.rb +1 -0
- data/spec/code_spec.rb +4 -0
- metadata +32 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b0a4ebe8420069b359de1d7ef70a23b88b1eb586860e786a44f23f95b44b8597
|
4
|
+
data.tar.gz: 3e1730f163e40f18fb693b269600363a4ef62d3962933792f72c2c834649194f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eb6aea50d77aa1fa7fd50e214fc20e9907d00bcf46a1c1fa94698c40b50aa50697ad5bd963223dc70311f21ab7870f9ccf7b4dc37df108ecade737673538cc09
|
7
|
+
data.tar.gz: 97750b4568b82a9ca6cceecaf84ba9d9894bbd4e0bc2279e5756e47fd8f03b7bdcb42008f65bd81ef4338a8852f285fd757fa5b89cbf19b049be9d957c89832f
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
code-ruby (1.5.
|
4
|
+
code-ruby (1.5.4)
|
5
5
|
activesupport
|
6
6
|
base64
|
7
7
|
bigdecimal
|
@@ -9,7 +9,9 @@ PATH
|
|
9
9
|
dorian-arguments
|
10
10
|
json
|
11
11
|
language-ruby
|
12
|
+
mail
|
12
13
|
net-http
|
14
|
+
net-smtp
|
13
15
|
nokogiri
|
14
16
|
uri
|
15
17
|
zeitwerk
|
@@ -46,6 +48,7 @@ GEM
|
|
46
48
|
bigdecimal
|
47
49
|
rexml
|
48
50
|
csv (3.3.4)
|
51
|
+
date (3.4.1)
|
49
52
|
did-you-mean (0.1.1)
|
50
53
|
levenshtein (>= 0.2.0)
|
51
54
|
diff-lcs (1.6.2)
|
@@ -104,7 +107,12 @@ GEM
|
|
104
107
|
libv8-node (23.6.1.0-x86_64-linux)
|
105
108
|
lint_roller (1.1.0)
|
106
109
|
logger (1.7.0)
|
107
|
-
|
110
|
+
mail (2.8.1)
|
111
|
+
mini_mime (>= 0.1.1)
|
112
|
+
net-imap
|
113
|
+
net-pop
|
114
|
+
net-smtp
|
115
|
+
mini_mime (1.1.5)
|
108
116
|
mini_racer (0.18.1)
|
109
117
|
libv8-node (~> 23.6.1.0)
|
110
118
|
minitest (5.25.5)
|
@@ -112,9 +120,15 @@ GEM
|
|
112
120
|
ruby2_keywords (~> 0.0.1)
|
113
121
|
net-http (0.6.0)
|
114
122
|
uri
|
115
|
-
|
116
|
-
|
117
|
-
|
123
|
+
net-imap (0.5.8)
|
124
|
+
date
|
125
|
+
net-protocol
|
126
|
+
net-pop (0.1.2)
|
127
|
+
net-protocol
|
128
|
+
net-protocol (0.2.2)
|
129
|
+
timeout
|
130
|
+
net-smtp (0.5.1)
|
131
|
+
net-protocol
|
118
132
|
nokogiri (1.18.8-arm64-darwin)
|
119
133
|
racc (~> 1.4)
|
120
134
|
nokogiri (1.18.8-x86_64-linux-gnu)
|
@@ -222,6 +236,7 @@ GEM
|
|
222
236
|
unicode-display_width (>= 1.1.1, < 4)
|
223
237
|
thor (1.3.2)
|
224
238
|
tilt (2.6.0)
|
239
|
+
timeout (0.4.3)
|
225
240
|
tzinfo (2.0.6)
|
226
241
|
concurrent-ruby (~> 1.0)
|
227
242
|
unicode-display_width (3.1.4)
|
@@ -240,7 +255,7 @@ GEM
|
|
240
255
|
|
241
256
|
PLATFORMS
|
242
257
|
arm64-darwin-23
|
243
|
-
|
258
|
+
arm64-darwin-24
|
244
259
|
x86_64-linux
|
245
260
|
|
246
261
|
DEPENDENCIES
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.5.
|
1
|
+
1.5.4
|
data/code-ruby.gemspec
CHANGED
@@ -20,7 +20,9 @@ Gem::Specification.new do |s|
|
|
20
20
|
s.add_dependency "dorian-arguments"
|
21
21
|
s.add_dependency "json"
|
22
22
|
s.add_dependency "language-ruby"
|
23
|
+
s.add_dependency "mail"
|
23
24
|
s.add_dependency "net-http"
|
25
|
+
s.add_dependency "net-smtp"
|
24
26
|
s.add_dependency "nokogiri"
|
25
27
|
s.add_dependency "uri"
|
26
28
|
s.add_dependency "zeitwerk"
|
data/lib/code/concerns/shared.rb
CHANGED
@@ -0,0 +1,72 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Code
|
4
|
+
class Object
|
5
|
+
class Base64 < Object
|
6
|
+
def self.call(**args)
|
7
|
+
code_operator = args.fetch(:operator, nil).to_code
|
8
|
+
code_arguments = args.fetch(:arguments, []).to_code
|
9
|
+
code_value = code_arguments.code_first
|
10
|
+
|
11
|
+
case code_operator.to_s
|
12
|
+
when "encode"
|
13
|
+
sig(args) { String }
|
14
|
+
code_encode(code_value)
|
15
|
+
when "decode"
|
16
|
+
sig(args) { String }
|
17
|
+
code_decode(code_value)
|
18
|
+
when "strict_encode"
|
19
|
+
sig(args) { String }
|
20
|
+
code_strict_encode(code_value)
|
21
|
+
when "strict_decode"
|
22
|
+
sig(args) { String }
|
23
|
+
code_strict_decode(code_value)
|
24
|
+
when "urlsafe_encode"
|
25
|
+
sig(args) { String }
|
26
|
+
code_urlsafe_encode(code_value)
|
27
|
+
when "urlsafe_decode"
|
28
|
+
sig(args) { String }
|
29
|
+
code_urlsafe_decode(code_value)
|
30
|
+
else
|
31
|
+
super
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.code_encode(string)
|
36
|
+
code_string = string.to_code
|
37
|
+
|
38
|
+
String.new(::Base64.encode64(code_string.to_s))
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.code_decode(string)
|
42
|
+
code_string = string.to_code
|
43
|
+
|
44
|
+
String.new(::Base64.decode64(code_string.to_s))
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.code_strict_encode(string)
|
48
|
+
code_string = string.to_code
|
49
|
+
|
50
|
+
String.new(::Base64.strict_encode64(code_string.to_s))
|
51
|
+
end
|
52
|
+
|
53
|
+
def self.code_strict_decode(string)
|
54
|
+
code_string = string.to_code
|
55
|
+
|
56
|
+
String.new(::Base64.strict_decode64(code_string.to_s))
|
57
|
+
end
|
58
|
+
|
59
|
+
def self.code_urlsafe_encode(string)
|
60
|
+
code_string = string.to_code
|
61
|
+
|
62
|
+
String.new(::Base64.urlsafe_encode64(code_string.to_s))
|
63
|
+
end
|
64
|
+
|
65
|
+
def self.code_urlsafe_decode(string)
|
66
|
+
code_string = string.to_code
|
67
|
+
|
68
|
+
String.new(::Base64.urlsafe_decode64(code_string.to_s))
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
data/lib/code/object/global.rb
CHANGED
@@ -138,6 +138,16 @@ class Code
|
|
138
138
|
when "Http"
|
139
139
|
sig(args) { Object.repeat }
|
140
140
|
code_arguments.any? ? Http.new(*code_arguments.raw) : Class.new(Http)
|
141
|
+
when "Smtp"
|
142
|
+
sig(args) { Object.repeat }
|
143
|
+
code_arguments.any? ? Smtp.new(*code_arguments.raw) : Class.new(Smtp)
|
144
|
+
when "Base64"
|
145
|
+
sig(args) { Object.repeat }
|
146
|
+
if code_arguments.any?
|
147
|
+
Base64.new(*code_arguments.raw)
|
148
|
+
else
|
149
|
+
Class.new(Base64)
|
150
|
+
end
|
141
151
|
when "Json"
|
142
152
|
sig(args) { Object.repeat }
|
143
153
|
code_arguments.any? ? Json.new(*code_arguments.raw) : Class.new(Json)
|
data/lib/code/object/list.rb
CHANGED
@@ -30,6 +30,9 @@ class Code
|
|
30
30
|
when "<<", "append"
|
31
31
|
sig(args) { Object }
|
32
32
|
code_append(code_value)
|
33
|
+
when "-", "minus"
|
34
|
+
sig(args) { List }
|
35
|
+
code_minus(code_value)
|
33
36
|
when "any?"
|
34
37
|
sig(args) { Function.maybe }
|
35
38
|
code_any?(code_value, **globals)
|
@@ -50,7 +53,13 @@ class Code
|
|
50
53
|
code_shuffle
|
51
54
|
when "flatten"
|
52
55
|
sig(args) { Integer.maybe }
|
53
|
-
code_flatten
|
56
|
+
code_flatten(code_value)
|
57
|
+
when "pop"
|
58
|
+
sig(args) { Integer.maybe }
|
59
|
+
code_pop(code_value)
|
60
|
+
when "shift"
|
61
|
+
sig(args) { Integer.maybe }
|
62
|
+
code_shift(code_value)
|
54
63
|
when "include?"
|
55
64
|
sig(args) { Object }
|
56
65
|
code_include?(code_value)
|
@@ -142,6 +151,12 @@ class Code
|
|
142
151
|
self
|
143
152
|
end
|
144
153
|
|
154
|
+
def code_minus(other)
|
155
|
+
code_other = other.to_code
|
156
|
+
|
157
|
+
List.new(raw - code_other.raw)
|
158
|
+
end
|
159
|
+
|
145
160
|
def code_detect(argument, **globals)
|
146
161
|
code_argument = argument.to_code
|
147
162
|
|
@@ -214,6 +229,20 @@ class Code
|
|
214
229
|
)
|
215
230
|
end
|
216
231
|
|
232
|
+
def code_pop(n = nil)
|
233
|
+
code_n = n.to_code
|
234
|
+
n = code_n.raw
|
235
|
+
|
236
|
+
code_n.nothing? ? raw.pop || Nothing.new : List.new(raw.pop(n))
|
237
|
+
end
|
238
|
+
|
239
|
+
def code_shift(n = nil)
|
240
|
+
code_n = n.to_code
|
241
|
+
n = code_n.raw
|
242
|
+
|
243
|
+
code_n.nothing? ? raw.shift || Nothing.new : List.new(raw.shift(n))
|
244
|
+
end
|
245
|
+
|
217
246
|
def code_include?(other)
|
218
247
|
code_other = other.to_code
|
219
248
|
|
data/lib/code/object/range.rb
CHANGED
@@ -60,6 +60,9 @@ class Code
|
|
60
60
|
when "step"
|
61
61
|
sig(args) { Integer | Decimal }
|
62
62
|
code_step(code_value)
|
63
|
+
when "sample"
|
64
|
+
sig(args)
|
65
|
+
code_sample
|
63
66
|
when "to_list"
|
64
67
|
sig(args)
|
65
68
|
code_to_list
|
@@ -182,6 +185,10 @@ class Code
|
|
182
185
|
def code_to_list
|
183
186
|
List.new(raw.to_a)
|
184
187
|
end
|
188
|
+
|
189
|
+
def code_sample
|
190
|
+
code_to_list.code_sample
|
191
|
+
end
|
185
192
|
end
|
186
193
|
end
|
187
194
|
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Code
|
4
|
+
class Object
|
5
|
+
class Smtp < Dictionary
|
6
|
+
def call(**args)
|
7
|
+
code_operator = args.fetch(:operator, nil).to_code
|
8
|
+
code_arguments = args.fetch(:arguments, []).to_code
|
9
|
+
code_value = code_arguments.code_first
|
10
|
+
|
11
|
+
case code_operator.to_s
|
12
|
+
when "send"
|
13
|
+
sig(args) do
|
14
|
+
{
|
15
|
+
from: String.maybe,
|
16
|
+
to: String.maybe,
|
17
|
+
subject: String.maybe,
|
18
|
+
body: String.maybe,
|
19
|
+
body_text: String.maybe,
|
20
|
+
body_html: String.maybe
|
21
|
+
}
|
22
|
+
end
|
23
|
+
|
24
|
+
code_send(
|
25
|
+
from: code_value.code_get("from"),
|
26
|
+
to: code_value.code_get("to"),
|
27
|
+
subject: code_value.code_get("subject"),
|
28
|
+
body: code_value.code_get("body"),
|
29
|
+
body_text: code_value.code_get("body_text"),
|
30
|
+
body_html: code_value.code_get("body_html")
|
31
|
+
)
|
32
|
+
else
|
33
|
+
super
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def code_send(
|
38
|
+
from: nil,
|
39
|
+
to: nil,
|
40
|
+
subject: nil,
|
41
|
+
body: nil,
|
42
|
+
body_text: nil,
|
43
|
+
body_html: nil
|
44
|
+
)
|
45
|
+
code_from = from.to_code
|
46
|
+
code_to = to.to_code
|
47
|
+
code_subject = subject.to_code
|
48
|
+
code_body = body.to_code
|
49
|
+
code_body_text = body_text.to_code
|
50
|
+
code_body_html = body_html.to_code
|
51
|
+
|
52
|
+
mail = Mail.new
|
53
|
+
mail.from = code_from.to_s
|
54
|
+
mail.to = code_to.to_s
|
55
|
+
mail.subject = code_subject.to_s
|
56
|
+
|
57
|
+
text_part = Mail::Part.new
|
58
|
+
text_part.content_type = "text/plain; charset=UTF-8"
|
59
|
+
text_part.body = code_body_text.to_s.presence || code_body.to_s
|
60
|
+
|
61
|
+
html_part = Mail::Part.new
|
62
|
+
html_part.content_type = "text/html; charset=UTF-8"
|
63
|
+
html_part.body = code_body_html.to_s
|
64
|
+
|
65
|
+
mail.content_type = "multipart/alternative"
|
66
|
+
mail.add_part(text_part)
|
67
|
+
mail.add_part(html_part) if code_body_html.to_s.present?
|
68
|
+
|
69
|
+
mail.delivery_method(
|
70
|
+
:smtp,
|
71
|
+
{
|
72
|
+
address: code_get("address").to_s,
|
73
|
+
port: code_get("port").to_i,
|
74
|
+
user_name: code_get("user_name").to_s,
|
75
|
+
password: code_get("password").to_s,
|
76
|
+
authentication: code_get("authentication").to_s,
|
77
|
+
enable_starttls_auto: code_get("enable_starttls_auto").truthy?
|
78
|
+
}
|
79
|
+
)
|
80
|
+
|
81
|
+
mail.deliver!
|
82
|
+
|
83
|
+
Nothing.new
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
data/lib/code-ruby.rb
CHANGED
data/spec/code_spec.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: code-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.
|
4
|
+
version: 1.5.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dorian Marié
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-05-
|
10
|
+
date: 2025-05-22 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: activesupport
|
@@ -107,6 +107,20 @@ dependencies:
|
|
107
107
|
- - ">="
|
108
108
|
- !ruby/object:Gem::Version
|
109
109
|
version: '0'
|
110
|
+
- !ruby/object:Gem::Dependency
|
111
|
+
name: mail
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - ">="
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '0'
|
117
|
+
type: :runtime
|
118
|
+
prerelease: false
|
119
|
+
version_requirements: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - ">="
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '0'
|
110
124
|
- !ruby/object:Gem::Dependency
|
111
125
|
name: net-http
|
112
126
|
requirement: !ruby/object:Gem::Requirement
|
@@ -121,6 +135,20 @@ dependencies:
|
|
121
135
|
- - ">="
|
122
136
|
- !ruby/object:Gem::Version
|
123
137
|
version: '0'
|
138
|
+
- !ruby/object:Gem::Dependency
|
139
|
+
name: net-smtp
|
140
|
+
requirement: !ruby/object:Gem::Requirement
|
141
|
+
requirements:
|
142
|
+
- - ">="
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: '0'
|
145
|
+
type: :runtime
|
146
|
+
prerelease: false
|
147
|
+
version_requirements: !ruby/object:Gem::Requirement
|
148
|
+
requirements:
|
149
|
+
- - ">="
|
150
|
+
- !ruby/object:Gem::Version
|
151
|
+
version: '0'
|
124
152
|
- !ruby/object:Gem::Dependency
|
125
153
|
name: nokogiri
|
126
154
|
requirement: !ruby/object:Gem::Requirement
|
@@ -229,6 +257,7 @@ files:
|
|
229
257
|
- lib/code/node/unary_minus.rb
|
230
258
|
- lib/code/node/while.rb
|
231
259
|
- lib/code/object.rb
|
260
|
+
- lib/code/object/base_64.rb
|
232
261
|
- lib/code/object/boolean.rb
|
233
262
|
- lib/code/object/class.rb
|
234
263
|
- lib/code/object/code.rb
|
@@ -248,6 +277,7 @@ files:
|
|
248
277
|
- lib/code/object/nothing.rb
|
249
278
|
- lib/code/object/parameter.rb
|
250
279
|
- lib/code/object/range.rb
|
280
|
+
- lib/code/object/smtp.rb
|
251
281
|
- lib/code/object/string.rb
|
252
282
|
- lib/code/object/time.rb
|
253
283
|
- lib/code/parser.rb
|