letter_opener_web_s3 0.2.0 → 0.3.0

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
  SHA1:
3
- metadata.gz: da29ab99c2d5074b4aae47528f0945f139eb6a3e
4
- data.tar.gz: 830d53bb6d680174f115ecdb753cbd818cf3c49e
3
+ metadata.gz: c4d2ee027cb4672c22ec4bbdc1220fa574069afe
4
+ data.tar.gz: 24d66eafe77e990241f6b0f5e2fdb182d1b30e4f
5
5
  SHA512:
6
- metadata.gz: 36b3dc3272f2a2c5d771854c195e4a712df308b41006151989cf2b1bcd86fa65ebe155f9330feec82d744bd63b308231b8c50e4ff26f5d64874557669c576510
7
- data.tar.gz: 9fe31c3cb6c741e20a249f7b9407acd6dbd81054b6887dd7ee786f59b0c1a02e8b5257baf25d616e4db31990a66f15661f02b677d300741079f8c502518f5bbf
6
+ metadata.gz: 1ac29c6819882269722d6ee0b178729074ca19e0ca861876e8c7ab83983aac7e52a0beed240d6c203289dd4c23c87d6a7228a0237a73d27ecb38b50324f5cc07
7
+ data.tar.gz: f84fe23b63bae9f96e7d8705b1129cfc9a132dad92a653d9d54775a3a1beeaea96903d032a498e422588855f20919151605100ddac56d8844393574323366aa3
data/README.md CHANGED
@@ -37,10 +37,6 @@ To support application assets need configure `action_mailer.asset_host`
37
37
 
38
38
  Without configuration, gem works like `letter_opener_web` use local file storage
39
39
 
40
- ## TODO
41
-
42
- Need check letters with attachments
43
-
44
40
  ## Contributing
45
41
 
46
42
  Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/letter_opener_web_s3. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
@@ -26,7 +26,7 @@ module LetterOpenerWebS3::LetterExtension
26
26
  def attachments
27
27
  @attachments ||= LetterOpenerWebS3.bucket.objects(prefix: File.join(base_dir, 'attachments'))
28
28
  .each_with_object({}) do |file, hash|
29
- hash[File.basename(file)] = File.expand_path(file)
29
+ hash[File.basename(file.key)] = LetterOpenerWebS3.bucket.object(file.key).public_url
30
30
  end
31
31
  end
32
32
 
@@ -12,14 +12,13 @@ module LetterOpenerWebS3::MessageExtension
12
12
  def render
13
13
  if mail.attachments.any?
14
14
  attachments_dir = File.join(@location, 'attachments')
15
- # TODO: need check render with attachment
16
15
  mail.attachments.each do |attachment|
17
16
  filename = attachment.filename.gsub(/[^\w.]/, '_')
18
17
  path = File.join(attachments_dir, filename)
19
18
 
20
19
  object(path).put(body: attachment.body.raw_source, content_length: attachment.body.raw_source.size)
21
20
 
22
- @attachments << [attachment.filename, "attachments/#{URI.escape(filename)}"]
21
+ @attachments << [attachment.filename, URI.escape(object(path).public_url)]
23
22
  end
24
23
  end
25
24
 
@@ -32,6 +31,19 @@ module LetterOpenerWebS3::MessageExtension
32
31
  File.read(File.join(letter_opener_path.gsub('message.rb', ''), 'message.html.erb'))
33
32
  end
34
33
 
34
+ def body
35
+ @body ||= begin
36
+ body = (@part || @mail).decoded
37
+
38
+ mail.attachments.each do |attachment|
39
+ item = @attachments.select{|filename, _| filename == attachment.filename}.first
40
+ body.gsub!(attachment.url, item.last)
41
+ end
42
+
43
+ body
44
+ end
45
+ end
46
+
35
47
  private
36
48
 
37
49
  def object(filepath)
@@ -1,3 +1,3 @@
1
1
  module LetterOpenerWebS3
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: letter_opener_web_s3
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vital Ryabchinskiy
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-04-16 00:00:00.000000000 Z
11
+ date: 2017-04-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler