sunabamail 0.1.0 → 0.1.2

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: 856ebc548796776b7b192691b54668c2e81c9c2cfceb62b2057ab9358071270c
4
- data.tar.gz: fa2b1dcb6033d4f6ad9a2af74937d07c03b2b8bdbfb2e91d2a9b11c9dd012d2e
3
+ metadata.gz: 6c4339fd772c1bead6c12dbb69aa44c4271c1080a6bc15b8f0d6939609e052b2
4
+ data.tar.gz: 66ff4d243f7c392a25b8c11803d4133ef1ab2eaf2b3658df9165e5589a7c2790
5
5
  SHA512:
6
- metadata.gz: fa0b4dc118595c7eb59f2d368c719925ba0e90cdb4bc6b661d9d46083306fcb706c1e8396dbabc9cd4fa22507e12cd7fab8df76eff91bd9ba829b0f1610c37dd
7
- data.tar.gz: ec79d435cba4ddfaf3bc7dae08b8abc5a2bf8ed2655172242fe7406f495baf387f1bd5cb35ac786b49bc4a2ed6f0ac1fc9be6459bbbe69391aa9a4ed398c05fe
6
+ metadata.gz: 87f258c54ba3f6a7ca957b52abc8ba088454365518d8120858e373247787617c2900f387254377f829e4aad7e8622e087b39f12f04244d11b87ad873c73b3b45
7
+ data.tar.gz: f2cb19518101926daca43e79493dd0b560b98eddb40d7e8577ce4b8237d2ae5817975969bc4e30515466f9463d94f4454bc108b5fe506b90e33485718fc293db
@@ -15,7 +15,6 @@ jobs:
15
15
  matrix:
16
16
  ruby: ['3.1', '3.2', '3.3', '3.4', '4.0']
17
17
  rails:
18
- - '~> 7.0.0'
19
18
  - '~> 7.1.0'
20
19
  - '~> 7.2.0'
21
20
  - '~> 8.0.0'
data/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.1.2] - 2026-05-08
4
+
5
+ - fix mailer view
6
+
7
+ ## [0.1.1] - 2026-05-07
8
+
9
+ - fix Rails 7.x does't work.
10
+ - Changed the lower version to 7.1 due to several issues, including differences in the DB schema.
11
+
3
12
  ## [0.1.0] - 2026-05-06
4
13
 
5
14
  - Initial release
@@ -1,4 +1,2 @@
1
1
  class Sunabamail::ApplicationController < ActionController::Base
2
- # Only allow modern browsers supporting webp images, web push, badges, import maps, CSS nesting, and CSS :has.
3
- allow_browser versions: :modern
4
2
  end
@@ -4,6 +4,6 @@ class Sunabamail::Messages::ApplicationController < Sunabamail::ApplicationContr
4
4
  private
5
5
 
6
6
  def set_message
7
- @message = Sunabamail::Message.find(params.expect(:message_id))
7
+ @message = Sunabamail::Message.find(params[:message_id])
8
8
  end
9
9
  end
@@ -8,6 +8,6 @@ class Sunabamail::Messages::AttachmentsController < Sunabamail::Messages::Applic
8
8
  private
9
9
 
10
10
  def set_attachment
11
- @attachment = @message.mail.attachments[params.expect(:id).to_i]
11
+ @attachment = @message.mail.attachments[params[:id].to_i]
12
12
  end
13
13
  end
@@ -1,6 +1,6 @@
1
1
  class Sunabamail::Messages::HtmlsController < Sunabamail::Messages::ApplicationController
2
2
  def show
3
- html = @message.mail.html_part.body.to_s.force_encoding(@message.mail.charset)
3
+ html = @message.mail.html_body
4
4
  doc = Nokogiri::HTML.fragment(html)
5
5
  doc.css("a").each do |a|
6
6
  a["target"] = "_blank"
@@ -1,7 +1,7 @@
1
1
  class Sunabamail::Messages::SourcesController < Sunabamail::Messages::ApplicationController
2
2
  def show
3
- send_data @message.mail.html_part.body.to_s.force_encoding(@message.mail.charset),
4
- type: "text/plain",
5
- disposition: "inline"
3
+ html = @message.mail.html_body
4
+
5
+ send_data html, type: "text/plain", disposition: "inline"
6
6
  end
7
7
  end
@@ -1,7 +1,7 @@
1
1
  class Sunabamail::Messages::TextsController < Sunabamail::Messages::ApplicationController
2
2
  def show
3
- send_data @message.mail.text_part.body.to_s.force_encoding(@message.mail.charset),
4
- type: "text/plain",
5
- disposition: "inline"
3
+ text = @message.mail.text_body
4
+
5
+ send_data text, type: "text/plain", disposition: "inline"
6
6
  end
7
7
  end
@@ -17,6 +17,6 @@ class Sunabamail::MessagesController < Sunabamail::ApplicationController
17
17
  private
18
18
 
19
19
  def set_message
20
- @message = Sunabamail::Message.find(params.expect(:id))
20
+ @message = Sunabamail::Message.find(params[:id])
21
21
  end
22
22
  end
@@ -0,0 +1,48 @@
1
+ class Sunabamail::Mail
2
+ def initialize(raw)
3
+ @mail_message = Mail::Message.new(raw.encoded)
4
+ end
5
+
6
+ def has_text?
7
+ return true if text_part.present?
8
+
9
+ "text/plain" == mime_type
10
+ end
11
+
12
+ def has_html?
13
+ return true if html_part.present?
14
+
15
+ "text/html" == mime_type
16
+ end
17
+
18
+ def text_body
19
+ if multipart?
20
+ decoded_body(text_part)
21
+ elsif "text/plain" == mime_type
22
+ decoded_body(mail_message)
23
+ end
24
+ end
25
+
26
+ def html_body
27
+ if multipart?
28
+ decoded_body(html_part)
29
+ elsif "text/html" == mime_type
30
+ decoded_body(mail_message)
31
+ end
32
+ end
33
+
34
+ def attachments = mail_message.attachments
35
+
36
+ private
37
+
38
+ attr_reader :mail_message
39
+
40
+ delegate :mime_type, :multipart?, :html_part, :text_part, to: :mail_message, private: true
41
+
42
+ def decoded_body(part)
43
+ return nil unless part
44
+
45
+ body = part.body.to_s.dup
46
+ part.charset ? body.force_encoding(part.charset) : body
47
+ end
48
+ end
@@ -7,6 +7,6 @@ class Sunabamail::Message < Sunabamail::Record
7
7
  autosave: true
8
8
 
9
9
  def mail
10
- Mail::Message.new(raw.encoded)
10
+ Sunabamail::Mail.new(raw)
11
11
  end
12
12
  end
@@ -48,23 +48,20 @@
48
48
  </div>
49
49
  <% end %>
50
50
 
51
- <% has_html = mail.html_part.present? %>
52
- <% has_text = mail.text_part.present? %>
53
-
54
51
  <div class="message-views-tabs-container">
55
52
  <div class="message-views-tabs">
56
- <% if has_html %>
53
+ <% if mail.has_html? %>
57
54
  <button class="message-view-tab" data-mail-view-handle data-mail-view-target="html">Html</button>
58
55
  <button class="message-view-tab" data-mail-view-handle data-mail-view-target="source">Html Source</button>
59
56
  <% end %>
60
- <% if has_text %>
57
+ <% if mail.has_text? %>
61
58
  <button class="message-view-tab" data-mail-view-handle data-mail-view-target="text">Text</button>
62
59
  <% end %>
63
60
  <button class="message-view-tab" data-mail-view-handle data-mail-view-target="raw">Raw</button>
64
61
  </div>
65
62
  </div>
66
63
 
67
- <% if has_html %>
64
+ <% if mail.has_html? %>
68
65
  <div class="message-view-item" data-mail-view="html">
69
66
  <%= tag.iframe sealmess: "sealmess", data: { src: message_html_path(object) } %>
70
67
  </div>
@@ -72,7 +69,7 @@
72
69
  <%= tag.iframe sealmess: "sealmess", data: { src: message_source_path(object) } %>
73
70
  </div>
74
71
  <% end %>
75
- <% if has_text %>
72
+ <% if mail.has_text? %>
76
73
  <div class="message-view-item" data-mail-view="text">
77
74
  <%= tag.iframe sealmess: "sealmess", data: { src: message_text_path(object) } %>
78
75
  </div>
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Sunabamail
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.2"
5
5
  end
metadata CHANGED
@@ -1,11 +1,11 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sunabamail
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - hamajyotan
8
- bindir: exe
8
+ bindir: bin
9
9
  cert_chain: []
10
10
  date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies:
@@ -15,42 +15,42 @@ dependencies:
15
15
  requirements:
16
16
  - - ">="
17
17
  - !ruby/object:Gem::Version
18
- version: '7.0'
18
+ version: '7.1'
19
19
  type: :runtime
20
20
  prerelease: false
21
21
  version_requirements: !ruby/object:Gem::Requirement
22
22
  requirements:
23
23
  - - ">="
24
24
  - !ruby/object:Gem::Version
25
- version: '7.0'
25
+ version: '7.1'
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: activerecord
28
28
  requirement: !ruby/object:Gem::Requirement
29
29
  requirements:
30
30
  - - ">="
31
31
  - !ruby/object:Gem::Version
32
- version: '7.0'
32
+ version: '7.1'
33
33
  type: :runtime
34
34
  prerelease: false
35
35
  version_requirements: !ruby/object:Gem::Requirement
36
36
  requirements:
37
37
  - - ">="
38
38
  - !ruby/object:Gem::Version
39
- version: '7.0'
39
+ version: '7.1'
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: railties
42
42
  requirement: !ruby/object:Gem::Requirement
43
43
  requirements:
44
44
  - - ">="
45
45
  - !ruby/object:Gem::Version
46
- version: '7.0'
46
+ version: '7.1'
47
47
  type: :runtime
48
48
  prerelease: false
49
49
  version_requirements: !ruby/object:Gem::Requirement
50
50
  requirements:
51
51
  - - ">="
52
52
  - !ruby/object:Gem::Version
53
- version: '7.0'
53
+ version: '7.1'
54
54
  description: Provides a custom Action Mailer delivery method that stores outgoing
55
55
  emails in the database instead of sending them. Stored emails can be viewed through
56
56
  a dedicated interface, making it useful for development and staging environments.
@@ -75,6 +75,7 @@ files:
75
75
  - app/controllers/sunabamail/messages/sources_controller.rb
76
76
  - app/controllers/sunabamail/messages/texts_controller.rb
77
77
  - app/controllers/sunabamail/messages_controller.rb
78
+ - app/models/sunabamail/mail.rb
78
79
  - app/models/sunabamail/message.rb
79
80
  - app/models/sunabamail/message_raw.rb
80
81
  - app/models/sunabamail/record.rb
@@ -100,6 +101,8 @@ licenses:
100
101
  metadata:
101
102
  homepage_uri: https://github.com/hamajyotan/sunabamail
102
103
  source_code_uri: https://github.com/hamajyotan/sunabamail
104
+ changelog_uri: https://github.com/hamajyotan/sunabamail/blob/main/CHANGELOG.md
105
+ rubygems_mfa_required: 'true'
103
106
  rdoc_options: []
104
107
  require_paths:
105
108
  - lib
@@ -114,7 +117,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
114
117
  - !ruby/object:Gem::Version
115
118
  version: '0'
116
119
  requirements: []
117
- rubygems_version: 4.0.3
120
+ rubygems_version: 3.6.7
118
121
  specification_version: 4
119
122
  summary: A drop-in Action Mailer delivery method that stores emails in the database
120
123
  instead of sending them.