mailpy 0.1.1
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 +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +28 -0
- data/Rakefile +27 -0
- data/lib/mailpy/mailer_api.rb +34 -0
- data/lib/mailpy/railtie.rb +7 -0
- data/lib/mailpy/version.rb +3 -0
- data/lib/mailpy.rb +29 -0
- metadata +98 -0
    
        checksums.yaml
    ADDED
    
    | @@ -0,0 +1,7 @@ | |
| 1 | 
            +
            ---
         | 
| 2 | 
            +
            SHA256:
         | 
| 3 | 
            +
              metadata.gz: 58a48da6593ec2adf58f9c3335cedd934b4cc5c29d7ac772a3b703ad90e1cc41
         | 
| 4 | 
            +
              data.tar.gz: 0cf2685a82429c4bfacb3e2c7ca15930399355fa2521e95b69531cdff760bc3b
         | 
| 5 | 
            +
            SHA512:
         | 
| 6 | 
            +
              metadata.gz: e15a5543a6b95836cede1de85f362cf661eaa894dc357c911f1bff0bf98132d7788a222ba14beb185aa63f347ca76ca66179c5ad05967ad10ac369b9c75d3504
         | 
| 7 | 
            +
              data.tar.gz: e5a2bba2f2bd43353b93b2602085b20dfbf7b2975b49866c5fe3845bb371652c66552e9e0d9a47e8fc0f0c61a9f7ce079682f8745efb9bf3efa952fe0168b227
         | 
    
        data/MIT-LICENSE
    ADDED
    
    | @@ -0,0 +1,20 @@ | |
| 1 | 
            +
            Copyright 2020 Nasrul Gunawan
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            Permission is hereby granted, free of charge, to any person obtaining
         | 
| 4 | 
            +
            a copy of this software and associated documentation files (the
         | 
| 5 | 
            +
            "Software"), to deal in the Software without restriction, including
         | 
| 6 | 
            +
            without limitation the rights to use, copy, modify, merge, publish,
         | 
| 7 | 
            +
            distribute, sublicense, and/or sell copies of the Software, and to
         | 
| 8 | 
            +
            permit persons to whom the Software is furnished to do so, subject to
         | 
| 9 | 
            +
            the following conditions:
         | 
| 10 | 
            +
             | 
| 11 | 
            +
            The above copyright notice and this permission notice shall be
         | 
| 12 | 
            +
            included in all copies or substantial portions of the Software.
         | 
| 13 | 
            +
             | 
| 14 | 
            +
            THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
         | 
| 15 | 
            +
            EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
         | 
| 16 | 
            +
            MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
         | 
| 17 | 
            +
            NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
         | 
| 18 | 
            +
            LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
         | 
| 19 | 
            +
            OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
         | 
| 20 | 
            +
            WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
         | 
    
        data/README.md
    ADDED
    
    | @@ -0,0 +1,28 @@ | |
| 1 | 
            +
            # Mailpy
         | 
| 2 | 
            +
            Short description and motivation.
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            ## Usage
         | 
| 5 | 
            +
            How to use my plugin.
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            ## Installation
         | 
| 8 | 
            +
            Add this line to your application's Gemfile:
         | 
| 9 | 
            +
             | 
| 10 | 
            +
            ```ruby
         | 
| 11 | 
            +
            gem 'mailpy'
         | 
| 12 | 
            +
            ```
         | 
| 13 | 
            +
             | 
| 14 | 
            +
            And then execute:
         | 
| 15 | 
            +
            ```bash
         | 
| 16 | 
            +
            $ bundle
         | 
| 17 | 
            +
            ```
         | 
| 18 | 
            +
             | 
| 19 | 
            +
            Or install it yourself as:
         | 
| 20 | 
            +
            ```bash
         | 
| 21 | 
            +
            $ gem install mailpy
         | 
| 22 | 
            +
            ```
         | 
| 23 | 
            +
             | 
| 24 | 
            +
            ## Contributing
         | 
| 25 | 
            +
            Contribution directions go here.
         | 
| 26 | 
            +
             | 
| 27 | 
            +
            ## License
         | 
| 28 | 
            +
            The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
         | 
    
        data/Rakefile
    ADDED
    
    | @@ -0,0 +1,27 @@ | |
| 1 | 
            +
            begin
         | 
| 2 | 
            +
              require 'bundler/setup'
         | 
| 3 | 
            +
            rescue LoadError
         | 
| 4 | 
            +
              puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
         | 
| 5 | 
            +
            end
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            require 'rdoc/task'
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            RDoc::Task.new(:rdoc) do |rdoc|
         | 
| 10 | 
            +
              rdoc.rdoc_dir = 'rdoc'
         | 
| 11 | 
            +
              rdoc.title    = 'Mailpy'
         | 
| 12 | 
            +
              rdoc.options << '--line-numbers'
         | 
| 13 | 
            +
              rdoc.rdoc_files.include('README.md')
         | 
| 14 | 
            +
              rdoc.rdoc_files.include('lib/**/*.rb')
         | 
| 15 | 
            +
            end
         | 
| 16 | 
            +
             | 
| 17 | 
            +
            require 'bundler/gem_tasks'
         | 
| 18 | 
            +
             | 
| 19 | 
            +
            require 'rake/testtask'
         | 
| 20 | 
            +
             | 
| 21 | 
            +
            Rake::TestTask.new(:test) do |t|
         | 
| 22 | 
            +
              t.libs << 'test'
         | 
| 23 | 
            +
              t.pattern = 'test/**/*_test.rb'
         | 
| 24 | 
            +
              t.verbose = false
         | 
| 25 | 
            +
            end
         | 
| 26 | 
            +
             | 
| 27 | 
            +
            task default: :test
         | 
| @@ -0,0 +1,34 @@ | |
| 1 | 
            +
            require 'httparty'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            class MailerApi
         | 
| 4 | 
            +
              attr_reader :options, :message
         | 
| 5 | 
            +
             | 
| 6 | 
            +
              def initialize(options, message)
         | 
| 7 | 
            +
                @options = options
         | 
| 8 | 
            +
                @message = message
         | 
| 9 | 
            +
              end
         | 
| 10 | 
            +
             | 
| 11 | 
            +
              def send
         | 
| 12 | 
            +
                send_email
         | 
| 13 | 
            +
              end
         | 
| 14 | 
            +
             | 
| 15 | 
            +
              private
         | 
| 16 | 
            +
              def send_email
         | 
| 17 | 
            +
                result = HTTParty.post(
         | 
| 18 | 
            +
                  options[:endpoint],
         | 
| 19 | 
            +
                  body: {
         | 
| 20 | 
            +
                    sender_email: options[:sender], 
         | 
| 21 | 
            +
                    recipient_email: options[:to], 
         | 
| 22 | 
            +
                    cc_email: options[:cc],
         | 
| 23 | 
            +
            		    bcc_email: options[:bcc], 
         | 
| 24 | 
            +
                    subject_email: options[:subject], 
         | 
| 25 | 
            +
                    message_email: message
         | 
| 26 | 
            +
                  }.to_json,
         | 
| 27 | 
            +
                  
         | 
| 28 | 
            +
                  headers: {
         | 
| 29 | 
            +
                    'Content-Type': 'application/json',
         | 
| 30 | 
            +
                    'Authorization': options[:token].to_s
         | 
| 31 | 
            +
                  }
         | 
| 32 | 
            +
                )    
         | 
| 33 | 
            +
              end
         | 
| 34 | 
            +
            end
         | 
    
        data/lib/mailpy.rb
    ADDED
    
    | @@ -0,0 +1,29 @@ | |
| 1 | 
            +
            require "mailpy/railtie"
         | 
| 2 | 
            +
            require "mailpy/mailer_api"
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            module Mailpy
         | 
| 5 | 
            +
              class DeliveryMethod
         | 
| 6 | 
            +
                attr_accessor :settings
         | 
| 7 | 
            +
             | 
| 8 | 
            +
                def initialize(params)
         | 
| 9 | 
            +
                  self.settings = params
         | 
| 10 | 
            +
                end
         | 
| 11 | 
            +
             | 
| 12 | 
            +
                def deliver!(mail)
         | 
| 13 | 
            +
                  MailerApi.new(mail_options(mail), mail.body.to_s).send
         | 
| 14 | 
            +
                end
         | 
| 15 | 
            +
             | 
| 16 | 
            +
                private
         | 
| 17 | 
            +
                  def mail_options(mail)
         | 
| 18 | 
            +
                    {
         | 
| 19 | 
            +
                      to: mail.to.try(:join, ', '),
         | 
| 20 | 
            +
                      cc: mail.cc.try(:join, ', '),
         | 
| 21 | 
            +
                      bcc: mail.bcc.try(:join, ', '),
         | 
| 22 | 
            +
                      sender: mail.from.try(:join, ', '),
         | 
| 23 | 
            +
                      subject: mail.subject,
         | 
| 24 | 
            +
                      endpoint: settings[:endpoint],
         | 
| 25 | 
            +
                      token: settings[:token]
         | 
| 26 | 
            +
                    }
         | 
| 27 | 
            +
                  end
         | 
| 28 | 
            +
              end
         | 
| 29 | 
            +
            end
         | 
    
        metadata
    ADDED
    
    | @@ -0,0 +1,98 @@ | |
| 1 | 
            +
            --- !ruby/object:Gem::Specification
         | 
| 2 | 
            +
            name: mailpy
         | 
| 3 | 
            +
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            +
              version: 0.1.1
         | 
| 5 | 
            +
            platform: ruby
         | 
| 6 | 
            +
            authors:
         | 
| 7 | 
            +
            - Nasrul Gunawan
         | 
| 8 | 
            +
            autorequire: 
         | 
| 9 | 
            +
            bindir: bin
         | 
| 10 | 
            +
            cert_chain: []
         | 
| 11 | 
            +
            date: 2020-11-25 00:00:00.000000000 Z
         | 
| 12 | 
            +
            dependencies:
         | 
| 13 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 14 | 
            +
              name: rails
         | 
| 15 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 16 | 
            +
                requirements:
         | 
| 17 | 
            +
                - - "~>"
         | 
| 18 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 19 | 
            +
                    version: 5.2.4
         | 
| 20 | 
            +
                - - ">="
         | 
| 21 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 22 | 
            +
                    version: 5.2.4.4
         | 
| 23 | 
            +
              type: :runtime
         | 
| 24 | 
            +
              prerelease: false
         | 
| 25 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 26 | 
            +
                requirements:
         | 
| 27 | 
            +
                - - "~>"
         | 
| 28 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 29 | 
            +
                    version: 5.2.4
         | 
| 30 | 
            +
                - - ">="
         | 
| 31 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 32 | 
            +
                    version: 5.2.4.4
         | 
| 33 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 34 | 
            +
              name: httparty
         | 
| 35 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 36 | 
            +
                requirements:
         | 
| 37 | 
            +
                - - ">="
         | 
| 38 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 39 | 
            +
                    version: '0'
         | 
| 40 | 
            +
              type: :runtime
         | 
| 41 | 
            +
              prerelease: false
         | 
| 42 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 43 | 
            +
                requirements:
         | 
| 44 | 
            +
                - - ">="
         | 
| 45 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 46 | 
            +
                    version: '0'
         | 
| 47 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 48 | 
            +
              name: sqlite3
         | 
| 49 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 50 | 
            +
                requirements:
         | 
| 51 | 
            +
                - - ">="
         | 
| 52 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 53 | 
            +
                    version: '0'
         | 
| 54 | 
            +
              type: :development
         | 
| 55 | 
            +
              prerelease: false
         | 
| 56 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 57 | 
            +
                requirements:
         | 
| 58 | 
            +
                - - ">="
         | 
| 59 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 60 | 
            +
                    version: '0'
         | 
| 61 | 
            +
            description: Description of Mailpy.
         | 
| 62 | 
            +
            email:
         | 
| 63 | 
            +
            - nasrul.remaza@gmail.com
         | 
| 64 | 
            +
            executables: []
         | 
| 65 | 
            +
            extensions: []
         | 
| 66 | 
            +
            extra_rdoc_files: []
         | 
| 67 | 
            +
            files:
         | 
| 68 | 
            +
            - MIT-LICENSE
         | 
| 69 | 
            +
            - README.md
         | 
| 70 | 
            +
            - Rakefile
         | 
| 71 | 
            +
            - lib/mailpy.rb
         | 
| 72 | 
            +
            - lib/mailpy/mailer_api.rb
         | 
| 73 | 
            +
            - lib/mailpy/railtie.rb
         | 
| 74 | 
            +
            - lib/mailpy/version.rb
         | 
| 75 | 
            +
            homepage: https://github.com/nasrulgunawan/mailpy
         | 
| 76 | 
            +
            licenses:
         | 
| 77 | 
            +
            - MIT
         | 
| 78 | 
            +
            metadata: {}
         | 
| 79 | 
            +
            post_install_message: 
         | 
| 80 | 
            +
            rdoc_options: []
         | 
| 81 | 
            +
            require_paths:
         | 
| 82 | 
            +
            - lib
         | 
| 83 | 
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         | 
| 84 | 
            +
              requirements:
         | 
| 85 | 
            +
              - - ">="
         | 
| 86 | 
            +
                - !ruby/object:Gem::Version
         | 
| 87 | 
            +
                  version: '0'
         | 
| 88 | 
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 89 | 
            +
              requirements:
         | 
| 90 | 
            +
              - - ">="
         | 
| 91 | 
            +
                - !ruby/object:Gem::Version
         | 
| 92 | 
            +
                  version: '0'
         | 
| 93 | 
            +
            requirements: []
         | 
| 94 | 
            +
            rubygems_version: 3.0.8
         | 
| 95 | 
            +
            signing_key: 
         | 
| 96 | 
            +
            specification_version: 4
         | 
| 97 | 
            +
            summary: Summary of Mailpy.
         | 
| 98 | 
            +
            test_files: []
         |