code-ruby 1.5.3 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 58d866d9e727af5cd21ef84470e4c1d1ca184c50404487dbf9b0dd723285df75
4
- data.tar.gz: ed804eeaabb172c04f01d37b30279ab108824aeeda15d844f45d9efdd53dbde2
3
+ metadata.gz: b0a4ebe8420069b359de1d7ef70a23b88b1eb586860e786a44f23f95b44b8597
4
+ data.tar.gz: 3e1730f163e40f18fb693b269600363a4ef62d3962933792f72c2c834649194f
5
5
  SHA512:
6
- metadata.gz: 22ff4dfc9525012aad11aafb6aa26489ce4ffec24c9d28b9dd1a0d0009766874b54345ddd4b5aa554fc67db095dbf090920d87926837877bb1df912a049499ea
7
- data.tar.gz: d0c237a243258c2c9ea6fac040d7515aba786e73752754d6abba32f62658647623620008b250a943c144b38b79c6310cc6b94d15fe2aaf4f2fee4806d4d71da4
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.3)
4
+ code-ruby (1.5.4)
5
5
  activesupport
6
6
  base64
7
7
  bigdecimal
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.5.3
1
+ 1.5.4
@@ -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
@@ -141,6 +141,13 @@ class Code
141
141
  when "Smtp"
142
142
  sig(args) { Object.repeat }
143
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
144
151
  when "Json"
145
152
  sig(args) { Object.repeat }
146
153
  code_arguments.any? ? Json.new(*code_arguments.raw) : Class.new(Json)
@@ -233,22 +233,14 @@ class Code
233
233
  code_n = n.to_code
234
234
  n = code_n.raw
235
235
 
236
- if code_n.nothing?
237
- raw.pop || Nothing.new
238
- else
239
- List.new(raw.pop(n))
240
- end
236
+ code_n.nothing? ? raw.pop || Nothing.new : List.new(raw.pop(n))
241
237
  end
242
238
 
243
239
  def code_shift(n = nil)
244
240
  code_n = n.to_code
245
241
  n = code_n.raw
246
242
 
247
- if code_n.nothing?
248
- raw.shift || Nothing.new
249
- else
250
- List.new(raw.shift(n))
251
- end
243
+ code_n.nothing? ? raw.shift || Nothing.new : List.new(raw.shift(n))
252
244
  end
253
245
 
254
246
  def code_include?(other)
@@ -27,7 +27,7 @@ class Code
27
27
  subject: code_value.code_get("subject"),
28
28
  body: code_value.code_get("body"),
29
29
  body_text: code_value.code_get("body_text"),
30
- body_html: code_value.code_get("body_html"),
30
+ body_html: code_value.code_get("body_html")
31
31
  )
32
32
  else
33
33
  super
@@ -55,14 +55,14 @@ class Code
55
55
  mail.subject = code_subject.to_s
56
56
 
57
57
  text_part = Mail::Part.new
58
- text_part.content_type = 'text/plain; charset=UTF-8'
58
+ text_part.content_type = "text/plain; charset=UTF-8"
59
59
  text_part.body = code_body_text.to_s.presence || code_body.to_s
60
60
 
61
61
  html_part = Mail::Part.new
62
- html_part.content_type = 'text/html; charset=UTF-8'
62
+ html_part.content_type = "text/html; charset=UTF-8"
63
63
  html_part.body = code_body_html.to_s
64
64
 
65
- mail.content_type = 'multipart/alternative'
65
+ mail.content_type = "multipart/alternative"
66
66
  mail.add_part(text_part)
67
67
  mail.add_part(html_part) if code_body_html.to_s.present?
68
68
 
@@ -74,8 +74,8 @@ class Code
74
74
  user_name: code_get("user_name").to_s,
75
75
  password: code_get("password").to_s,
76
76
  authentication: code_get("authentication").to_s,
77
- enable_starttls_auto: code_get("enable_starttls_auto").truthy?,
78
- },
77
+ enable_starttls_auto: code_get("enable_starttls_auto").truthy?
78
+ }
79
79
  )
80
80
 
81
81
  mail.deliver!
data/spec/code_spec.rb CHANGED
@@ -5,6 +5,8 @@ require "spec_helper"
5
5
  RSpec.describe Code do
6
6
  (
7
7
  %w[
8
+ Base64
9
+ Base64.new
8
10
  Smtp
9
11
  Smtp.new
10
12
  Time.monday?
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: 1.5.3
4
+ version: 1.5.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dorian Marié
@@ -257,6 +257,7 @@ files:
257
257
  - lib/code/node/unary_minus.rb
258
258
  - lib/code/node/while.rb
259
259
  - lib/code/object.rb
260
+ - lib/code/object/base_64.rb
260
261
  - lib/code/object/boolean.rb
261
262
  - lib/code/object/class.rb
262
263
  - lib/code/object/code.rb