draft_box 0.0.1 → 0.0.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: e3fefedd7a473d1101e01fc2577793271f1a31fc642e8487c3bc60816a982291
4
- data.tar.gz: 8d3d685787454a383ad1184d763fe8c0546bce85b33c4aabdbae3570e90d500c
3
+ metadata.gz: 810d24fb1ae9b877a1de545a4b91ae5a8e501f2817d823ba799afbb609b9c861
4
+ data.tar.gz: 8d347ecc7d1662422f7ea02ec74afca947a82c77738e4214ef5c124306f654d0
5
5
  SHA512:
6
- metadata.gz: 8995b11fd93e62153dde02c26d074671e9dee9c71fb9196f0ffe4c33067b3b6fa06c3e3fa8055e37a389171df83493135e1c29154452c777866314ff9673a19a
7
- data.tar.gz: f86a3b3102af31ce86e356304c9ea9428d27bd2d258712a35bf5f90c1eaf6a81be3ec9aebf924f14e7ce2b4936d5caf2e64fad0480d056cd62cf1592f966cfd2
6
+ metadata.gz: cdc8bedba1bcd7818f959db5cd49a7008fcbfc8488e9ffa1609e5a1f7bc36f4f9b4e56bf0b1531b0b3a854944b8fae90e7ecca3da26299195fb1e0c010a70657
7
+ data.tar.gz: e659f0b821bd207e1e8f11865cbef280a8fa5d6d7386bb8a5002acb641d08ea6710b122215a8922aa825905680a04a80df20985aae3270f1397edbddde8edf70
@@ -9,27 +9,14 @@ module DraftBox
9
9
  def deliver!(mail)
10
10
  validate_mail!(mail)
11
11
 
12
- # subject: mail.subject
13
- # body: mail.body.to_s
14
- # from: mail.from
15
- # to: mail.to
16
- # cc: mail.cc
17
- # bcc: mail.bcc
18
- # attachments: mail.attachments
19
-
20
- # Attachment:
21
- # filename: attachment.filename
22
- # content_type: attachment.content_type
23
- # content: attachment.body.to_s
24
-
25
12
  ActiveRecord::Base.transaction do
26
13
  email = DraftBox::Email.create!(
27
14
  subject: mail.subject,
28
15
  body: mail.parts.empty? ? mail.body.to_s : mail.parts.find { |p| p.content_type.start_with?('text/html', 'text/plain') }&.body.to_s,
29
16
  from: mail.from.first,
30
- to: mail.to,
31
- cc: mail.cc,
32
- bcc: mail.bcc
17
+ recipients: mail.to,
18
+ carbon_copies: mail.cc || [],
19
+ blind_copies: mail.bcc || []
33
20
  )
34
21
 
35
22
  mail.attachments.each do |attachment|
@@ -3,7 +3,7 @@ module DraftBox
3
3
  module_function
4
4
 
5
5
  def to_s
6
- '0.0.1'
6
+ '0.0.2'
7
7
  end
8
8
  end
9
9
  end
@@ -16,8 +16,6 @@ module Generators
16
16
  template "attachments_migration.rb", "db/migrate/#{timestamp}_create_draft_box_attachments.rb"
17
17
  end
18
18
 
19
- private
20
-
21
19
  def migration_version
22
20
  "[#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}]"
23
21
  end
@@ -30,6 +28,10 @@ module Generators
30
28
  key_string = options[:primary_key_type]
31
29
  ", id: :#{key_string}" if key_string
32
30
  end
31
+
32
+ def sqlite?
33
+ ActiveRecord::Base.configurations.configs_for(env_name: Rails.env, name: "primary").adapter_class.to_s.match?(/sqlite/i)
34
+ end
33
35
  end
34
36
  end
35
37
  end
@@ -4,9 +4,18 @@ class CreateDraftBoxEmails < ActiveRecord::Migration<%= migration_version %>
4
4
  t.string :subject
5
5
  t.text :body
6
6
  t.string :from
7
- t.string :to, array: true, default: []
8
- t.string :cc, array: true, default: []
9
- t.string :bcc, array: true, default: []
7
+ <% unless sqlite? -%>
8
+ t.string :recipients, array: true, default: []
9
+ t.string :carbon_copies, array: true, default: []
10
+ t.string :blind_copies, array: true, default: []
11
+ <% else %>
12
+ t.json :recipients, null: false, default: []
13
+ t.json :carbon_copies, null: false, default: []
14
+ t.json :blind_copies, null: false, default: []
15
+ t.check_constraint "JSON_TYPE(recipients) = 'array'", name: 'draft_box_emails_recipients_is_array'
16
+ t.check_constraint "JSON_TYPE(carbon_copies) = 'array'", name: 'draft_box_emails_carbon_copies_is_array'
17
+ t.check_constraint "JSON_TYPE(blind_copies) = 'array'", name: 'draft_box_emails_blind_copies_is_array'
18
+ <% end -%>
10
19
 
11
20
  t.timestamps
12
21
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: draft_box
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paweł Dąbrowski