sendhub 0.1.16 → 0.1.17
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.
- data/lib/sendhub/client.rb +10 -9
- data/lib/sendhub/http.rb +7 -6
- data/lib/sendhub/plugins/rails2.rb +3 -2
- data/lib/sendhub/plugins/rails3.rb +6 -5
- metadata +32 -36
    
        data/lib/sendhub/client.rb
    CHANGED
    
    | @@ -1,29 +1,30 @@ | |
| 1 1 | 
             
            module Sendhub
         | 
| 2 2 | 
             
              class Client
         | 
| 3 | 
            -
             | 
| 4 | 
            -
                VERSION = '0.1. | 
| 5 | 
            -
             | 
| 3 | 
            +
             | 
| 4 | 
            +
                VERSION = '0.1.17'
         | 
| 5 | 
            +
             | 
| 6 6 | 
             
                def initialize(config=nil)
         | 
| 7 7 | 
             
                  config[:host] ||= 'api.sendhub.net'
         | 
| 8 8 | 
             
                  config[:protocol] ||= 'https'
         | 
| 9 9 | 
             
                  @uri = URI.parse(config[:protocol]+'://'+config[:host]+'/')
         | 
| 10 | 
            -
             | 
| 10 | 
            +
             | 
| 11 11 | 
             
                  @api_key = config[:api_key]
         | 
| 12 12 | 
             
                  @secret_key = config[:secret_key]
         | 
| 13 | 
            -
                  
         | 
| 14 | 
            -
             | 
| 13 | 
            +
                  @notification_url = config[:notification_url]
         | 
| 14 | 
            +
             | 
| 15 | 
            +
                  puts "SendhubRubyClient (v#{VERSION}): #{@uri}, #{@api_key}, #{@notification_url}"
         | 
| 15 16 | 
             
                end
         | 
| 16 | 
            -
             | 
| 17 | 
            +
             | 
| 17 18 | 
             
                def send_email(options={})
         | 
| 18 19 | 
             
                  res = _post '/emails', nil, options
         | 
| 19 20 | 
             
                  Sendhub::Response.new(res)
         | 
| 20 21 | 
             
                end
         | 
| 21 | 
            -
             | 
| 22 | 
            +
             | 
| 22 23 | 
             
                def get_email(options={})
         | 
| 23 24 | 
             
                  email_id = options.delete(:id)
         | 
| 24 25 | 
             
                  res = _get('/emails/' + email_id, options)
         | 
| 25 26 | 
             
                  Sendhub::Response.new(res)
         | 
| 26 27 | 
             
                end
         | 
| 27 | 
            -
             | 
| 28 | 
            +
             | 
| 28 29 | 
             
              end
         | 
| 29 30 | 
             
            end
         | 
    
        data/lib/sendhub/http.rb
    CHANGED
    
    | @@ -8,18 +8,19 @@ module Sendhub | |
| 8 8 | 
             
                  def _post(path, body = nil, options={})
         | 
| 9 9 | 
             
                    http(Net::HTTP::Post, path, body, options)
         | 
| 10 10 | 
             
                  end
         | 
| 11 | 
            -
             | 
| 11 | 
            +
             | 
| 12 12 | 
             
                  def securely_hash_data(data)
         | 
| 13 13 | 
             
                    Digest::SHA1.hexdigest("--#{@api_key}-#{@secret_key}-#{data}--")
         | 
| 14 14 | 
             
                  end
         | 
| 15 | 
            -
             | 
| 15 | 
            +
             | 
| 16 16 | 
             
                  def http(http_method, path, body = nil, options={})
         | 
| 17 17 | 
             
                    connection = Net::HTTP.new(@uri.host, @uri.port)
         | 
| 18 | 
            -
             | 
| 18 | 
            +
             | 
| 19 19 | 
             
                    options.merge!(:api_key => @api_key)
         | 
| 20 20 | 
             
                    options.merge!(:unique => Time.now.utc.to_i)
         | 
| 21 21 | 
             
                    options.merge!(:secret => securely_hash_data(options[:unique]))
         | 
| 22 | 
            -
                    
         | 
| 22 | 
            +
                    options.merge!(:notification_url => @notification_url) if @notification_url
         | 
| 23 | 
            +
             | 
| 23 24 | 
             
                    if @uri.scheme == 'https'
         | 
| 24 25 | 
             
                      connection.use_ssl = true
         | 
| 25 26 | 
             
                      connection.verify_mode = OpenSSL::SSL::VERIFY_PEER
         | 
| @@ -49,9 +50,9 @@ module Sendhub | |
| 49 50 | 
             
                      puts response.body
         | 
| 50 51 | 
             
                      return JSON.parse(response.body)
         | 
| 51 52 | 
             
                    end
         | 
| 52 | 
            -
             | 
| 53 | 
            +
             | 
| 53 54 | 
             
                  end
         | 
| 54 | 
            -
             | 
| 55 | 
            +
             | 
| 55 56 | 
             
                  def verify_ssl_certificate(preverify_ok, ssl_context)
         | 
| 56 57 | 
             
                   if preverify_ok != true || ssl_context.error != 0
         | 
| 57 58 | 
             
                     err_msg = "SSL Verification failed -- Preverify: #{preverify_ok}, Error: #{ssl_context.error_string} (#{ssl_context.error})"
         | 
| @@ -1,5 +1,5 @@ | |
| 1 1 | 
             
            module SendhubMethods
         | 
| 2 | 
            -
             | 
| 2 | 
            +
             | 
| 3 3 | 
             
              def self.included(base)
         | 
| 4 4 | 
             
                base.extend(ClassMethods)
         | 
| 5 5 | 
             
              end
         | 
| @@ -12,7 +12,8 @@ module SendhubMethods | |
| 12 12 | 
             
              def perform_delivery_sendhub(message)
         | 
| 13 13 | 
             
                client = Sendhub::Client.new(
         | 
| 14 14 | 
             
                  :api_key => ActionMailer::Base.sendhub_settings[:api_key],
         | 
| 15 | 
            -
                  :secret_key => ActionMailer::Base.sendhub_settings[:secret_key]
         | 
| 15 | 
            +
                  :secret_key => ActionMailer::Base.sendhub_settings[:secret_key],
         | 
| 16 | 
            +
                  :notification_url => ActionMailer::Base.sendhub_settings[:notification_url],
         | 
| 16 17 | 
             
                )
         | 
| 17 18 | 
             
                res = client.send_email(
         | 
| 18 19 | 
             
                  :from => message.from,
         | 
| @@ -3,15 +3,16 @@ module Sendhub | |
| 3 3 | 
             
                def initialize(options)
         | 
| 4 4 | 
             
                  @client = Sendhub::Client.new(
         | 
| 5 5 | 
             
                    :api_key => options[:api_key],
         | 
| 6 | 
            -
                    :secret_key => options[:secret_key]
         | 
| 6 | 
            +
                    :secret_key => options[:secret_key],
         | 
| 7 | 
            +
                    :notification_url => options[:notification_url]
         | 
| 7 8 | 
             
                  )
         | 
| 8 9 | 
             
                end
         | 
| 9 10 |  | 
| 10 11 | 
             
                def deliver!(message)
         | 
| 11 | 
            -
             | 
| 12 | 
            +
             | 
| 12 13 | 
             
                  body = message.body
         | 
| 13 14 | 
             
                  body = collect_parts(message) if message.multipart?
         | 
| 14 | 
            -
             | 
| 15 | 
            +
             | 
| 15 16 | 
             
                  res = @client.send_email(
         | 
| 16 17 | 
             
                    :from => message.from,
         | 
| 17 18 | 
             
                    :to => message.to,
         | 
| @@ -21,10 +22,10 @@ module Sendhub | |
| 21 22 | 
             
                    :content_type => message.content_type,
         | 
| 22 23 | 
             
                    :content_transfer_encoding => message.content_transfer_encoding
         | 
| 23 24 | 
             
                  )
         | 
| 24 | 
            -
             | 
| 25 | 
            +
             | 
| 25 26 | 
             
                  puts res.inspect
         | 
| 26 27 | 
             
                end
         | 
| 27 | 
            -
             | 
| 28 | 
            +
             | 
| 28 29 | 
             
                def collect_parts(message)
         | 
| 29 30 | 
             
                  message.parts.inject("\n\n\n") {|x, part| x << "--#{message.boundary}\n"; x << "#{part.to_s}\n\n"}
         | 
| 30 31 | 
             
                end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,38 +1,38 @@ | |
| 1 | 
            -
            --- !ruby/object:Gem::Specification | 
| 1 | 
            +
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: sendhub
         | 
| 3 | 
            -
            version: !ruby/object:Gem::Version | 
| 3 | 
            +
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            +
              version: 0.1.17
         | 
| 4 5 | 
             
              prerelease: 
         | 
| 5 | 
            -
              version: 0.1.16
         | 
| 6 6 | 
             
            platform: ruby
         | 
| 7 | 
            -
            authors: | 
| 7 | 
            +
            authors:
         | 
| 8 8 | 
             
            - Richard Taylor
         | 
| 9 9 | 
             
            autorequire: 
         | 
| 10 10 | 
             
            bindir: bin
         | 
| 11 11 | 
             
            cert_chain: []
         | 
| 12 | 
            -
             | 
| 13 | 
            -
             | 
| 14 | 
            -
             | 
| 15 | 
            -
            dependencies: 
         | 
| 16 | 
            -
            - !ruby/object:Gem::Dependency 
         | 
| 12 | 
            +
            date: 2012-07-11 00:00:00.000000000 Z
         | 
| 13 | 
            +
            dependencies:
         | 
| 14 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 17 15 | 
             
              name: json
         | 
| 18 | 
            -
               | 
| 19 | 
            -
              requirement: &id001 !ruby/object:Gem::Requirement 
         | 
| 16 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 20 17 | 
             
                none: false
         | 
| 21 | 
            -
                requirements: | 
| 22 | 
            -
                - -  | 
| 23 | 
            -
                  - !ruby/object:Gem::Version | 
| 18 | 
            +
                requirements:
         | 
| 19 | 
            +
                - - ! '>='
         | 
| 20 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 24 21 | 
             
                    version: 1.1.9
         | 
| 25 22 | 
             
              type: :runtime
         | 
| 26 | 
            -
               | 
| 23 | 
            +
              prerelease: false
         | 
| 24 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 25 | 
            +
                none: false
         | 
| 26 | 
            +
                requirements:
         | 
| 27 | 
            +
                - - ! '>='
         | 
| 28 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 29 | 
            +
                    version: 1.1.9
         | 
| 27 30 | 
             
            description: sendhub is a Ruby client library for SendHub.net.
         | 
| 28 31 | 
             
            email: moomerman@gmail.com
         | 
| 29 32 | 
             
            executables: []
         | 
| 30 | 
            -
             | 
| 31 33 | 
             
            extensions: []
         | 
| 32 | 
            -
             | 
| 33 34 | 
             
            extra_rdoc_files: []
         | 
| 34 | 
            -
             | 
| 35 | 
            -
            files: 
         | 
| 35 | 
            +
            files:
         | 
| 36 36 | 
             
            - LICENSE
         | 
| 37 37 | 
             
            - README.textile
         | 
| 38 38 | 
             
            - lib/sendhub.rb
         | 
| @@ -43,34 +43,30 @@ files: | |
| 43 43 | 
             
            - lib/sendhub/plugins/god.rb
         | 
| 44 44 | 
             
            - lib/sendhub/plugins/rails2.rb
         | 
| 45 45 | 
             
            - lib/sendhub/plugins/rails3.rb
         | 
| 46 | 
            -
            has_rdoc: true
         | 
| 47 46 | 
             
            homepage: http://sendhub.net/
         | 
| 48 47 | 
             
            licenses: []
         | 
| 49 | 
            -
             | 
| 50 48 | 
             
            post_install_message: 
         | 
| 51 | 
            -
            rdoc_options: | 
| 49 | 
            +
            rdoc_options:
         | 
| 52 50 | 
             
            - --inline-source
         | 
| 53 51 | 
             
            - --charset=UTF-8
         | 
| 54 | 
            -
            require_paths: | 
| 52 | 
            +
            require_paths:
         | 
| 55 53 | 
             
            - lib
         | 
| 56 | 
            -
            required_ruby_version: !ruby/object:Gem::Requirement | 
| 54 | 
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         | 
| 57 55 | 
             
              none: false
         | 
| 58 | 
            -
              requirements: | 
| 59 | 
            -
              - -  | 
| 60 | 
            -
                - !ruby/object:Gem::Version | 
| 61 | 
            -
                  version:  | 
| 62 | 
            -
            required_rubygems_version: !ruby/object:Gem::Requirement | 
| 56 | 
            +
              requirements:
         | 
| 57 | 
            +
              - - ! '>='
         | 
| 58 | 
            +
                - !ruby/object:Gem::Version
         | 
| 59 | 
            +
                  version: '0'
         | 
| 60 | 
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 63 61 | 
             
              none: false
         | 
| 64 | 
            -
              requirements: | 
| 65 | 
            -
              - -  | 
| 66 | 
            -
                - !ruby/object:Gem::Version | 
| 67 | 
            -
                  version:  | 
| 62 | 
            +
              requirements:
         | 
| 63 | 
            +
              - - ! '>='
         | 
| 64 | 
            +
                - !ruby/object:Gem::Version
         | 
| 65 | 
            +
                  version: '0'
         | 
| 68 66 | 
             
            requirements: []
         | 
| 69 | 
            -
             | 
| 70 67 | 
             
            rubyforge_project: sendhub
         | 
| 71 | 
            -
            rubygems_version: 1. | 
| 68 | 
            +
            rubygems_version: 1.8.21
         | 
| 72 69 | 
             
            signing_key: 
         | 
| 73 70 | 
             
            specification_version: 2
         | 
| 74 71 | 
             
            summary: sendhub is a Ruby client library for SendHub.net.
         | 
| 75 72 | 
             
            test_files: []
         | 
| 76 | 
            -
             |