freya 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c5b4b5265e572d4f48040c32f4574b5154e9d3f3
4
- data.tar.gz: dc6c7ceb059acf6b63c841f9ed45b4ebc5ec888f
3
+ metadata.gz: c20cb87d4dc89671f64c5d80b08cf92cc777c8d7
4
+ data.tar.gz: 2506895aa7760277dcb486689d611f327f02dba9
5
5
  SHA512:
6
- metadata.gz: 6a1f1ace562115e7be0029a2dd69f2848771c40fb9a60c97d5fcbf17b80192fa2a40843a246680a34c0f0a8099a78832091c9f2ef2d8a801da128078f762be86
7
- data.tar.gz: 4bd964421cbb38696390c3b37f7e019279cb6d2744ea020e70434251f53597e70c6b051afbf0b20008dbed373ecbd6fca21481ee0fb35fdd9f9829a6bc231e58
6
+ metadata.gz: 4264622b00d019bbac7e21e3d13d57dee027d5013313f90a4402d18ade324853ca0858ee9e3961f101f0cb030cac7bdd88cf9d6bd46fb2d0123f5542abce7b15
7
+ data.tar.gz: 8409d899a05477de3e8381b94e05c3d92d8c3c986539f35ee229555a3e1d38df851eeb48538d799d418ee8066acbb32fcde2e25cc7408554adc42383aebdd723
data/lib/freya.rb CHANGED
@@ -1,8 +1,7 @@
1
1
  require 'freya/version'
2
- require 'active_support/core_ext/hash'
2
+ require 'active_support/core_ext'
3
3
  require 'yaml'
4
4
  require 'rails'
5
- require 'uri/mailto'
6
5
 
7
6
  module Freya
8
7
  class Template
@@ -26,9 +25,18 @@ module Freya
26
25
 
27
26
  class Email < OpenStruct
28
27
  def link
29
- URI::MailTo.build({ to: to, headers: [
30
- ['subject', URI.escape(subject)], ['body', URI.escape(body)], *cc.map { |email| ['cc', email] }
31
- ] }).opaque
28
+ extras = %w{ cc bcc body subject }.select { |extra| send(extra).present? }.map { |extra| [extra, send(extra)] }.map { |extra|
29
+ name = extra[0]
30
+ value = extra[1]
31
+
32
+ [value].flatten.map do |component|
33
+ "#{name}=#{Rack::Utils.escape_path(component)}"
34
+ end
35
+ }.compact
36
+
37
+ extras = extras.empty? ? '' : '?' + extras.join('&')
38
+
39
+ "#{to}#{extras}"
32
40
  end
33
41
 
34
42
  def body
data/lib/freya/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Freya
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
data/spec/freya_spec.rb CHANGED
@@ -21,7 +21,7 @@ describe Freya::Email do
21
21
  describe '#link' do
22
22
  it 'builds a mail link with options like to, cc and the email body' do
23
23
  Freya::Email.new(name: 'test_email', subject: 'subject', to: 'test@test.com', cc: ['test1@test.com', 'test2@test.com']).link.should eq(
24
- 'test@test.com?subject=subject&body=This%20is%20the%20test%20email&cc=test1@test.com&cc=test2@test.com'
24
+ 'test@test.com?cc=test1%40test.com&cc=test2%40test.com&body=This%20is%20the%20test%20email&subject=subject'
25
25
  )
26
26
  end
27
27
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: freya
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matteo Depalo