endpoint_base 0.0.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/.gitignore +19 -0
- data/.rspec +2 -0
- data/.ruby-version +1 -0
- data/.travis.yml +7 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +84 -0
- data/Rakefile +1 -0
- data/endpoint_base.gemspec +29 -0
- data/lib/cross_origin.rb +49 -0
- data/lib/endpoint_base.rb +13 -0
- data/lib/integrator_utils.rb +58 -0
- data/lib/spree/testing_support/controllers.rb +20 -0
- data/spec/cross_origin_spec.rb +20 -0
- data/spec/integrator_utils_spec.rb +52 -0
- data/spec/spec_helper.rb +34 -0
- metadata +174 -0
    
        checksums.yaml
    ADDED
    
    | @@ -0,0 +1,7 @@ | |
| 1 | 
            +
            ---
         | 
| 2 | 
            +
            SHA1:
         | 
| 3 | 
            +
              metadata.gz: 534fad9f53890503329c7a8da7faa1c4ffa934a9
         | 
| 4 | 
            +
              data.tar.gz: 64588c322e901dead79193836ad83079f64cf3df
         | 
| 5 | 
            +
            SHA512:
         | 
| 6 | 
            +
              metadata.gz: 6933b9113d0214114c308b7bcc4769107b9fe44088bdd1adab65f82e7efe76719c916d733f6d4a221c0e4fd1e1391854c1c73519e1b23d1b1a55fb6977b415cd
         | 
| 7 | 
            +
              data.tar.gz: 33a94a1b4c1cdaed3369b1e39fe4190e0dfa700ac5fc1f979dc91de441832351483d9d63f4af69d21ebb0b69705bd961215885cde9752b2ed9c77086e6e601dc
         | 
    
        data/.gitignore
    ADDED
    
    
    
        data/.rspec
    ADDED
    
    
    
        data/.ruby-version
    ADDED
    
    | @@ -0,0 +1 @@ | |
| 1 | 
            +
            2.0.0
         | 
    
        data/.travis.yml
    ADDED
    
    
    
        data/Gemfile
    ADDED
    
    
    
        data/LICENSE.txt
    ADDED
    
    | @@ -0,0 +1,22 @@ | |
| 1 | 
            +
            Copyright (c) 2013 Andrew Hooker
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            MIT License
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            Permission is hereby granted, free of charge, to any person obtaining
         | 
| 6 | 
            +
            a copy of this software and associated documentation files (the
         | 
| 7 | 
            +
            "Software"), to deal in the Software without restriction, including
         | 
| 8 | 
            +
            without limitation the rights to use, copy, modify, merge, publish,
         | 
| 9 | 
            +
            distribute, sublicense, and/or sell copies of the Software, and to
         | 
| 10 | 
            +
            permit persons to whom the Software is furnished to do so, subject to
         | 
| 11 | 
            +
            the following conditions:
         | 
| 12 | 
            +
             | 
| 13 | 
            +
            The above copyright notice and this permission notice shall be
         | 
| 14 | 
            +
            included in all copies or substantial portions of the Software.
         | 
| 15 | 
            +
             | 
| 16 | 
            +
            THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
         | 
| 17 | 
            +
            EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
         | 
| 18 | 
            +
            MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
         | 
| 19 | 
            +
            NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
         | 
| 20 | 
            +
            LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
         | 
| 21 | 
            +
            OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
         | 
| 22 | 
            +
            WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
         | 
    
        data/README.md
    ADDED
    
    | @@ -0,0 +1,84 @@ | |
| 1 | 
            +
            # EndpointBase
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            TODO: Write a gem description
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            ## Installation
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            Add this line to your application's Gemfile:
         | 
| 8 | 
            +
             | 
| 9 | 
            +
                gem 'endpoint_base'
         | 
| 10 | 
            +
             | 
| 11 | 
            +
            And then execute:
         | 
| 12 | 
            +
             | 
| 13 | 
            +
                $ bundle
         | 
| 14 | 
            +
             | 
| 15 | 
            +
            Or install it yourself as:
         | 
| 16 | 
            +
             | 
| 17 | 
            +
                $ gem install endpoint_base
         | 
| 18 | 
            +
             | 
| 19 | 
            +
            ## Usage
         | 
| 20 | 
            +
             | 
| 21 | 
            +
            ```ruby
         | 
| 22 | 
            +
            require 'endpoint_base'
         | 
| 23 | 
            +
             | 
| 24 | 
            +
            class SampleEndpoint < EndpointBase
         | 
| 25 | 
            +
             | 
| 26 | 
            +
              post '/sample' do
         | 
| 27 | 
            +
                result = { 'message_id'    => @message[:message_id],
         | 
| 28 | 
            +
                           'notifications' => [ { 'level'       => 'info',
         | 
| 29 | 
            +
                                                  'subject'     => 'New sample',
         | 
| 30 | 
            +
                                                  'description' => '...' } ] }
         | 
| 31 | 
            +
                process_result 200, result
         | 
| 32 | 
            +
              end
         | 
| 33 | 
            +
            end
         | 
| 34 | 
            +
             | 
| 35 | 
            +
            ```
         | 
| 36 | 
            +
             | 
| 37 | 
            +
            ## Testing
         | 
| 38 | 
            +
             | 
| 39 | 
            +
            EndpointBase provides a `Controllers` testing support.
         | 
| 40 | 
            +
             | 
| 41 | 
            +
            ```ruby
         | 
| 42 | 
            +
            # ...
         | 
| 43 | 
            +
            require 'spree/testing_support/controllers'
         | 
| 44 | 
            +
             | 
| 45 | 
            +
            # ...
         | 
| 46 | 
            +
             | 
| 47 | 
            +
            RSpec.configure do |config|
         | 
| 48 | 
            +
              config.include Rack::Test::Methods
         | 
| 49 | 
            +
              config.include Spree::TestingSupport::Controllers
         | 
| 50 | 
            +
            end
         | 
| 51 | 
            +
            ```
         | 
| 52 | 
            +
             | 
| 53 | 
            +
            Which enables you to use `json_response` and `auth` in your Endpoint tests. It also sets `ENV['ENDPOINT_KEY'] ||= '123'`.
         | 
| 54 | 
            +
             | 
| 55 | 
            +
            ```ruby
         | 
| 56 | 
            +
            require 'spec_helper'
         | 
| 57 | 
            +
             | 
| 58 | 
            +
            describe SampleEndpoint do
         | 
| 59 | 
            +
              let(:request) { { message: 'sample:new',
         | 
| 60 | 
            +
                                message_id: '1234567',
         | 
| 61 | 
            +
                                payload: { parameters: [] } } }
         | 
| 62 | 
            +
             | 
| 63 | 
            +
              describe '/sample' do
         | 
| 64 | 
            +
                it 'notifies a new sample' do
         | 
| 65 | 
            +
                  post '/sample', request.to_json, auth
         | 
| 66 | 
            +
             | 
| 67 | 
            +
                  expect(last_response).to be_ok
         | 
| 68 | 
            +
             | 
| 69 | 
            +
                  expect(json_response['notifications']).to have(1).item
         | 
| 70 | 
            +
                  expect(json_response['notifications'].first).to eq ({ 'level'       => 'info',
         | 
| 71 | 
            +
                                                                        'subject'     => 'New Sample',
         | 
| 72 | 
            +
                                                                        'description' => '...' })
         | 
| 73 | 
            +
                end
         | 
| 74 | 
            +
              end
         | 
| 75 | 
            +
            end
         | 
| 76 | 
            +
            ```
         | 
| 77 | 
            +
             | 
| 78 | 
            +
            ## Contributing
         | 
| 79 | 
            +
             | 
| 80 | 
            +
            1. Fork it
         | 
| 81 | 
            +
            2. Create your feature branch (`git checkout -b my-new-feature`)
         | 
| 82 | 
            +
            3. Commit your changes (`git commit -am 'Add some feature'`)
         | 
| 83 | 
            +
            4. Push to the branch (`git push origin my-new-feature`)
         | 
| 84 | 
            +
            5. Create new Pull Request
         | 
    
        data/Rakefile
    ADDED
    
    | @@ -0,0 +1 @@ | |
| 1 | 
            +
            require "bundler/gem_tasks"
         | 
| @@ -0,0 +1,29 @@ | |
| 1 | 
            +
            # -*- encoding: utf-8 -*-
         | 
| 2 | 
            +
            lib = File.expand_path('../lib', __FILE__)
         | 
| 3 | 
            +
            $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            Gem::Specification.new do |gem|
         | 
| 6 | 
            +
              gem.name          = "endpoint_base"
         | 
| 7 | 
            +
              gem.version       = '0.0.1'
         | 
| 8 | 
            +
              gem.authors       = ["Andrew Hooker"]
         | 
| 9 | 
            +
              gem.email         = ["andrew@spreecommerce.com"]
         | 
| 10 | 
            +
              gem.description   = %q{Shared functionality for spree professional endpoints}
         | 
| 11 | 
            +
              gem.summary       = %q{Spree Endpoints}
         | 
| 12 | 
            +
              gem.homepage      = "http://www.spreecommerce.com"
         | 
| 13 | 
            +
             | 
| 14 | 
            +
              gem.files         = `git ls-files`.split($/)
         | 
| 15 | 
            +
              gem.executables   = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
         | 
| 16 | 
            +
              gem.test_files    = gem.files.grep(%r{^(test|spec|features)/})
         | 
| 17 | 
            +
              gem.require_paths = ["lib"]
         | 
| 18 | 
            +
             | 
| 19 | 
            +
              gem.add_dependency 'sinatra', '1.4.3'
         | 
| 20 | 
            +
              gem.add_dependency 'sinatra-contrib'
         | 
| 21 | 
            +
              gem.add_dependency 'json'
         | 
| 22 | 
            +
              gem.add_dependency 'activesupport'
         | 
| 23 | 
            +
             | 
| 24 | 
            +
              gem.add_development_dependency 'rake'
         | 
| 25 | 
            +
              gem.add_development_dependency 'rspec'
         | 
| 26 | 
            +
              gem.add_development_dependency 'rack-test'
         | 
| 27 | 
            +
              gem.add_development_dependency 'vcr'
         | 
| 28 | 
            +
            end
         | 
| 29 | 
            +
             | 
    
        data/lib/cross_origin.rb
    ADDED
    
    | @@ -0,0 +1,49 @@ | |
| 1 | 
            +
            require 'sinatra/base'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            module Sinatra
         | 
| 4 | 
            +
              module CrossOrigin
         | 
| 5 | 
            +
                module Helpers
         | 
| 6 | 
            +
             | 
| 7 | 
            +
                  # Apply cross origin headers either
         | 
| 8 | 
            +
                  # from global config or custom config passed
         | 
| 9 | 
            +
                  # as a hash
         | 
| 10 | 
            +
                  def cross_origin(hash=nil)
         | 
| 11 | 
            +
                    return unless request.env['HTTP_ORIGIN']
         | 
| 12 | 
            +
                    settings.set hash if hash
         | 
| 13 | 
            +
             | 
| 14 | 
            +
                    origin = settings.allow_origin == :any ? request.env['HTTP_ORIGIN'] : settings.allow_origin
         | 
| 15 | 
            +
                    methods = settings.allow_methods.map{ |m| m.to_s.upcase! }.join(', ')
         | 
| 16 | 
            +
             | 
| 17 | 
            +
                    headers_list = {
         | 
| 18 | 
            +
                      'Access-Control-Allow-Origin' => origin,
         | 
| 19 | 
            +
                      'Access-Control-Allow-Methods' => methods,
         | 
| 20 | 
            +
                      'Access-Control-Allow-Headers' => settings.allow_headers.map(&:to_s).join(', '),
         | 
| 21 | 
            +
                      'Access-Control-Allow-Credentials' => settings.allow_credentials.to_s,
         | 
| 22 | 
            +
                      'Access-Control-Max-Age' => settings.max_age.to_s
         | 
| 23 | 
            +
                    }
         | 
| 24 | 
            +
             | 
| 25 | 
            +
                    headers headers_list
         | 
| 26 | 
            +
                  end
         | 
| 27 | 
            +
                end
         | 
| 28 | 
            +
             | 
| 29 | 
            +
                def self.registered(app)
         | 
| 30 | 
            +
             | 
| 31 | 
            +
                  app.helpers CrossOrigin::Helpers
         | 
| 32 | 
            +
             | 
| 33 | 
            +
                  app.set :cross_origin, false
         | 
| 34 | 
            +
                  app.set :allow_origin, :any
         | 
| 35 | 
            +
                  app.set :allow_methods, [:post, :get, :options]
         | 
| 36 | 
            +
                  app.set :allow_credentials, true
         | 
| 37 | 
            +
                  app.set :allow_headers, ["*", "Content-Type", "Accept", "AUTHORIZATION", "Cache-Control"]
         | 
| 38 | 
            +
                  app.set :max_age, 1728000
         | 
| 39 | 
            +
             | 
| 40 | 
            +
                  app.before do
         | 
| 41 | 
            +
                    cross_origin if settings.cross_origin
         | 
| 42 | 
            +
                  end
         | 
| 43 | 
            +
             | 
| 44 | 
            +
                end
         | 
| 45 | 
            +
              end
         | 
| 46 | 
            +
             | 
| 47 | 
            +
              register CrossOrigin
         | 
| 48 | 
            +
             | 
| 49 | 
            +
            end
         | 
| @@ -0,0 +1,58 @@ | |
| 1 | 
            +
            require 'sinatra/base'
         | 
| 2 | 
            +
            require 'sinatra/json'
         | 
| 3 | 
            +
            require 'json'
         | 
| 4 | 
            +
            require 'active_support/core_ext/hash'
         | 
| 5 | 
            +
            require 'multi_json'
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            module Sinatra
         | 
| 8 | 
            +
              module IntegratorUtils
         | 
| 9 | 
            +
             | 
| 10 | 
            +
                module Helpers
         | 
| 11 | 
            +
                  def config(message)
         | 
| 12 | 
            +
                    conf = message[:payload]['parameters'] || []
         | 
| 13 | 
            +
             | 
| 14 | 
            +
                    conf.inject(HashWithIndifferentAccess.new) do |result, param|
         | 
| 15 | 
            +
                      result[param[:name]] = param[:value]
         | 
| 16 | 
            +
                      result
         | 
| 17 | 
            +
                    end
         | 
| 18 | 
            +
                  end
         | 
| 19 | 
            +
             | 
| 20 | 
            +
                  def process_result(code, response)
         | 
| 21 | 
            +
                    status code
         | 
| 22 | 
            +
                    json response
         | 
| 23 | 
            +
                  end
         | 
| 24 | 
            +
                end
         | 
| 25 | 
            +
             | 
| 26 | 
            +
                def self.registered(app)
         | 
| 27 | 
            +
             | 
| 28 | 
            +
                  app.helpers Sinatra::JSON
         | 
| 29 | 
            +
                  app.helpers IntegratorUtils::Helpers
         | 
| 30 | 
            +
             | 
| 31 | 
            +
                  app.set :public_folder, './public'
         | 
| 32 | 
            +
             | 
| 33 | 
            +
                  app.before do
         | 
| 34 | 
            +
                    if request.get? && request.path_info == '/'
         | 
| 35 | 
            +
                      redirect '/endpoint.json'
         | 
| 36 | 
            +
                    else
         | 
| 37 | 
            +
                      halt 401 if request.env["HTTP_X_AUGURY_TOKEN"] != ENV['ENDPOINT_KEY']
         | 
| 38 | 
            +
                    end
         | 
| 39 | 
            +
             | 
| 40 | 
            +
                    if request.post?
         | 
| 41 | 
            +
                      begin
         | 
| 42 | 
            +
                        @message = ::JSON.parse(request.body.read).with_indifferent_access
         | 
| 43 | 
            +
                        @config = config(@message)
         | 
| 44 | 
            +
                      rescue Exception => e
         | 
| 45 | 
            +
                        halt 406
         | 
| 46 | 
            +
                      end
         | 
| 47 | 
            +
                    end
         | 
| 48 | 
            +
                  end
         | 
| 49 | 
            +
             | 
| 50 | 
            +
                  app.get '/auth' do
         | 
| 51 | 
            +
                    status 200
         | 
| 52 | 
            +
                  end
         | 
| 53 | 
            +
                end
         | 
| 54 | 
            +
             | 
| 55 | 
            +
              end
         | 
| 56 | 
            +
             | 
| 57 | 
            +
              register IntegratorUtils
         | 
| 58 | 
            +
            end
         | 
| @@ -0,0 +1,20 @@ | |
| 1 | 
            +
            module Spree
         | 
| 2 | 
            +
              module TestingSupport
         | 
| 3 | 
            +
                module Controllers
         | 
| 4 | 
            +
                  ENV['ENDPOINT_KEY'] ||= '123'
         | 
| 5 | 
            +
             | 
| 6 | 
            +
                  def auth
         | 
| 7 | 
            +
                    { 'HTTP_X_AUGURY_TOKEN' => ENV['ENDPOINT_KEY'], 'CONTENT_TYPE' => 'application/json' }
         | 
| 8 | 
            +
                  end
         | 
| 9 | 
            +
             | 
| 10 | 
            +
                  def json_response
         | 
| 11 | 
            +
                    @json_response ||= JSON.parse(last_response.body)
         | 
| 12 | 
            +
                  end
         | 
| 13 | 
            +
             | 
| 14 | 
            +
                  def app
         | 
| 15 | 
            +
                    described_class
         | 
| 16 | 
            +
                  end
         | 
| 17 | 
            +
                end
         | 
| 18 | 
            +
              end
         | 
| 19 | 
            +
            end
         | 
| 20 | 
            +
             | 
| @@ -0,0 +1,20 @@ | |
| 1 | 
            +
            require 'spec_helper'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            module Sinatra
         | 
| 4 | 
            +
              describe CrossOrigin do
         | 
| 5 | 
            +
                let(:payload) { {:payload => {} }.to_json }
         | 
| 6 | 
            +
                let(:headers) { {'HTTP_X_AUGURY_TOKEN' => 'x123', "CONTENT_TYPE" => "application/json", 'HTTP_ORIGIN' => 'http://spreecommerce.com'} }
         | 
| 7 | 
            +
             | 
| 8 | 
            +
                it "should include CORS headers when ORIGIN is specified" do
         | 
| 9 | 
            +
                  post '/', payload, headers
         | 
| 10 | 
            +
                  last_response.headers['Access-Control-Allow-Origin'].should == 'http://spreecommerce.com'
         | 
| 11 | 
            +
                end
         | 
| 12 | 
            +
             | 
| 13 | 
            +
                it "should not include CORS headers when ORIGIN is not specified" do
         | 
| 14 | 
            +
                  headers.delete('HTTP_ORIGIN')
         | 
| 15 | 
            +
                  post '/', payload, headers
         | 
| 16 | 
            +
                  last_response.headers['Access-Control-Allow-Origin'].should be_nil
         | 
| 17 | 
            +
                end
         | 
| 18 | 
            +
             | 
| 19 | 
            +
              end
         | 
| 20 | 
            +
            end
         | 
| @@ -0,0 +1,52 @@ | |
| 1 | 
            +
            require 'spec_helper'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            module Sinatra
         | 
| 4 | 
            +
              describe IntegratorUtils do
         | 
| 5 | 
            +
                let(:payload) { {:payload => {} }.to_json }
         | 
| 6 | 
            +
                let(:headers) { {'HTTP_X_AUGURY_TOKEN' => 'x123', "CONTENT_TYPE" => "application/json"} }
         | 
| 7 | 
            +
             | 
| 8 | 
            +
                it "should reject request without auth" do
         | 
| 9 | 
            +
                  post '/', payload
         | 
| 10 | 
            +
                  last_response.status.should == 401
         | 
| 11 | 
            +
                end
         | 
| 12 | 
            +
             | 
| 13 | 
            +
                it "should accept POST with auth" do
         | 
| 14 | 
            +
                  post '/', payload, headers
         | 
| 15 | 
            +
                  last_response.status.should == 200
         | 
| 16 | 
            +
                end
         | 
| 17 | 
            +
             | 
| 18 | 
            +
                it "should redirect to endpoint.json for GET on root url" do
         | 
| 19 | 
            +
                  get '/', nil, {}
         | 
| 20 | 
            +
                  last_response.status.should == 302
         | 
| 21 | 
            +
                  last_response.location.should == 'http://example.org/endpoint.json'
         | 
| 22 | 
            +
                end
         | 
| 23 | 
            +
             | 
| 24 | 
            +
                it 'returns a 200 for /auth check' do
         | 
| 25 | 
            +
                  get '/auth', {}, headers
         | 
| 26 | 
            +
                  last_response.status.should == 200
         | 
| 27 | 
            +
                end
         | 
| 28 | 
            +
             | 
| 29 | 
            +
                it "should parse valid json from body" do
         | 
| 30 | 
            +
                  post '/', {payload: {}, test: [{"west" => 1}, {"south" => false}]}.to_json, headers
         | 
| 31 | 
            +
                  msg = ::JSON.parse(last_response.body)
         | 
| 32 | 
            +
                  msg['test'].size.should == 2
         | 
| 33 | 
            +
                  msg['test'].first['west'].should == 1
         | 
| 34 | 
            +
                  msg['test'].last[:south].should be_false
         | 
| 35 | 
            +
                end
         | 
| 36 | 
            +
             | 
| 37 | 
            +
                it "should return 406 if body is not valid json" do
         | 
| 38 | 
            +
                  post '/', 'notjson', headers
         | 
| 39 | 
            +
                  last_response.status.should == 406
         | 
| 40 | 
            +
                end
         | 
| 41 | 
            +
             | 
| 42 | 
            +
                it "should find parameters" do
         | 
| 43 | 
            +
                  body = { 'payload' => { 'parameters' => [{'name' => 'x', 'value' => 1}, {'name' => '2', 'value' => 3}] } }.to_json
         | 
| 44 | 
            +
                  post '/config', body, headers
         | 
| 45 | 
            +
             | 
| 46 | 
            +
                  response = ::JSON.parse(last_response.body)
         | 
| 47 | 
            +
                  response['x'].should == 1
         | 
| 48 | 
            +
                  response['2'].should == 3
         | 
| 49 | 
            +
                end
         | 
| 50 | 
            +
             | 
| 51 | 
            +
              end
         | 
| 52 | 
            +
            end
         | 
    
        data/spec/spec_helper.rb
    ADDED
    
    | @@ -0,0 +1,34 @@ | |
| 1 | 
            +
            require 'rubygems'
         | 
| 2 | 
            +
            require 'bundler'
         | 
| 3 | 
            +
            require 'vcr'
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            Bundler.require(:default, :test)
         | 
| 6 | 
            +
            require 'rack/test'
         | 
| 7 | 
            +
             | 
| 8 | 
            +
            require File.join(File.dirname(__FILE__), '..', 'lib', 'endpoint_base.rb')
         | 
| 9 | 
            +
            Dir["./spec/support/**/*.rb"].each {|f| require f}
         | 
| 10 | 
            +
             | 
| 11 | 
            +
            Sinatra::Base.environment = 'test'
         | 
| 12 | 
            +
             | 
| 13 | 
            +
            def app
         | 
| 14 | 
            +
              TestEndpoint
         | 
| 15 | 
            +
            end
         | 
| 16 | 
            +
             | 
| 17 | 
            +
            RSpec.configure do |config|
         | 
| 18 | 
            +
              config.include Rack::Test::Methods
         | 
| 19 | 
            +
            end
         | 
| 20 | 
            +
             | 
| 21 | 
            +
            ENV['ENDPOINT_KEY'] = 'x123'
         | 
| 22 | 
            +
             | 
| 23 | 
            +
            class TestEndpoint < EndpointBase
         | 
| 24 | 
            +
             | 
| 25 | 
            +
              set :logging, true
         | 
| 26 | 
            +
             | 
| 27 | 
            +
              post '/' do
         | 
| 28 | 
            +
                process_result(200, @message)
         | 
| 29 | 
            +
              end
         | 
| 30 | 
            +
             | 
| 31 | 
            +
              post '/config' do
         | 
| 32 | 
            +
                process_result(200, config(@message))
         | 
| 33 | 
            +
              end
         | 
| 34 | 
            +
            end
         | 
    
        metadata
    ADDED
    
    | @@ -0,0 +1,174 @@ | |
| 1 | 
            +
            --- !ruby/object:Gem::Specification
         | 
| 2 | 
            +
            name: endpoint_base
         | 
| 3 | 
            +
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            +
              version: 0.0.1
         | 
| 5 | 
            +
            platform: ruby
         | 
| 6 | 
            +
            authors:
         | 
| 7 | 
            +
            - Andrew Hooker
         | 
| 8 | 
            +
            autorequire: 
         | 
| 9 | 
            +
            bindir: bin
         | 
| 10 | 
            +
            cert_chain: []
         | 
| 11 | 
            +
            date: 2013-11-27 00:00:00.000000000 Z
         | 
| 12 | 
            +
            dependencies:
         | 
| 13 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 14 | 
            +
              name: sinatra
         | 
| 15 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 16 | 
            +
                requirements:
         | 
| 17 | 
            +
                - - '='
         | 
| 18 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 19 | 
            +
                    version: 1.4.3
         | 
| 20 | 
            +
              type: :runtime
         | 
| 21 | 
            +
              prerelease: false
         | 
| 22 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 23 | 
            +
                requirements:
         | 
| 24 | 
            +
                - - '='
         | 
| 25 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 26 | 
            +
                    version: 1.4.3
         | 
| 27 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 28 | 
            +
              name: sinatra-contrib
         | 
| 29 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 30 | 
            +
                requirements:
         | 
| 31 | 
            +
                - - '>='
         | 
| 32 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 33 | 
            +
                    version: '0'
         | 
| 34 | 
            +
              type: :runtime
         | 
| 35 | 
            +
              prerelease: false
         | 
| 36 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 37 | 
            +
                requirements:
         | 
| 38 | 
            +
                - - '>='
         | 
| 39 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 40 | 
            +
                    version: '0'
         | 
| 41 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 42 | 
            +
              name: json
         | 
| 43 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 44 | 
            +
                requirements:
         | 
| 45 | 
            +
                - - '>='
         | 
| 46 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 47 | 
            +
                    version: '0'
         | 
| 48 | 
            +
              type: :runtime
         | 
| 49 | 
            +
              prerelease: false
         | 
| 50 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 51 | 
            +
                requirements:
         | 
| 52 | 
            +
                - - '>='
         | 
| 53 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 54 | 
            +
                    version: '0'
         | 
| 55 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 56 | 
            +
              name: activesupport
         | 
| 57 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 58 | 
            +
                requirements:
         | 
| 59 | 
            +
                - - '>='
         | 
| 60 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 61 | 
            +
                    version: '0'
         | 
| 62 | 
            +
              type: :runtime
         | 
| 63 | 
            +
              prerelease: false
         | 
| 64 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 65 | 
            +
                requirements:
         | 
| 66 | 
            +
                - - '>='
         | 
| 67 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 68 | 
            +
                    version: '0'
         | 
| 69 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 70 | 
            +
              name: rake
         | 
| 71 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 72 | 
            +
                requirements:
         | 
| 73 | 
            +
                - - '>='
         | 
| 74 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 75 | 
            +
                    version: '0'
         | 
| 76 | 
            +
              type: :development
         | 
| 77 | 
            +
              prerelease: false
         | 
| 78 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 79 | 
            +
                requirements:
         | 
| 80 | 
            +
                - - '>='
         | 
| 81 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 82 | 
            +
                    version: '0'
         | 
| 83 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 84 | 
            +
              name: rspec
         | 
| 85 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 86 | 
            +
                requirements:
         | 
| 87 | 
            +
                - - '>='
         | 
| 88 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 89 | 
            +
                    version: '0'
         | 
| 90 | 
            +
              type: :development
         | 
| 91 | 
            +
              prerelease: false
         | 
| 92 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 93 | 
            +
                requirements:
         | 
| 94 | 
            +
                - - '>='
         | 
| 95 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 96 | 
            +
                    version: '0'
         | 
| 97 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 98 | 
            +
              name: rack-test
         | 
| 99 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 100 | 
            +
                requirements:
         | 
| 101 | 
            +
                - - '>='
         | 
| 102 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 103 | 
            +
                    version: '0'
         | 
| 104 | 
            +
              type: :development
         | 
| 105 | 
            +
              prerelease: false
         | 
| 106 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 107 | 
            +
                requirements:
         | 
| 108 | 
            +
                - - '>='
         | 
| 109 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 110 | 
            +
                    version: '0'
         | 
| 111 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 112 | 
            +
              name: vcr
         | 
| 113 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 114 | 
            +
                requirements:
         | 
| 115 | 
            +
                - - '>='
         | 
| 116 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 117 | 
            +
                    version: '0'
         | 
| 118 | 
            +
              type: :development
         | 
| 119 | 
            +
              prerelease: false
         | 
| 120 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 121 | 
            +
                requirements:
         | 
| 122 | 
            +
                - - '>='
         | 
| 123 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 124 | 
            +
                    version: '0'
         | 
| 125 | 
            +
            description: Shared functionality for spree professional endpoints
         | 
| 126 | 
            +
            email:
         | 
| 127 | 
            +
            - andrew@spreecommerce.com
         | 
| 128 | 
            +
            executables: []
         | 
| 129 | 
            +
            extensions: []
         | 
| 130 | 
            +
            extra_rdoc_files: []
         | 
| 131 | 
            +
            files:
         | 
| 132 | 
            +
            - .gitignore
         | 
| 133 | 
            +
            - .rspec
         | 
| 134 | 
            +
            - .ruby-version
         | 
| 135 | 
            +
            - .travis.yml
         | 
| 136 | 
            +
            - Gemfile
         | 
| 137 | 
            +
            - LICENSE.txt
         | 
| 138 | 
            +
            - README.md
         | 
| 139 | 
            +
            - Rakefile
         | 
| 140 | 
            +
            - endpoint_base.gemspec
         | 
| 141 | 
            +
            - lib/cross_origin.rb
         | 
| 142 | 
            +
            - lib/endpoint_base.rb
         | 
| 143 | 
            +
            - lib/integrator_utils.rb
         | 
| 144 | 
            +
            - lib/spree/testing_support/controllers.rb
         | 
| 145 | 
            +
            - spec/cross_origin_spec.rb
         | 
| 146 | 
            +
            - spec/integrator_utils_spec.rb
         | 
| 147 | 
            +
            - spec/spec_helper.rb
         | 
| 148 | 
            +
            homepage: http://www.spreecommerce.com
         | 
| 149 | 
            +
            licenses: []
         | 
| 150 | 
            +
            metadata: {}
         | 
| 151 | 
            +
            post_install_message: 
         | 
| 152 | 
            +
            rdoc_options: []
         | 
| 153 | 
            +
            require_paths:
         | 
| 154 | 
            +
            - lib
         | 
| 155 | 
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         | 
| 156 | 
            +
              requirements:
         | 
| 157 | 
            +
              - - '>='
         | 
| 158 | 
            +
                - !ruby/object:Gem::Version
         | 
| 159 | 
            +
                  version: '0'
         | 
| 160 | 
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 161 | 
            +
              requirements:
         | 
| 162 | 
            +
              - - '>='
         | 
| 163 | 
            +
                - !ruby/object:Gem::Version
         | 
| 164 | 
            +
                  version: '0'
         | 
| 165 | 
            +
            requirements: []
         | 
| 166 | 
            +
            rubyforge_project: 
         | 
| 167 | 
            +
            rubygems_version: 2.0.14
         | 
| 168 | 
            +
            signing_key: 
         | 
| 169 | 
            +
            specification_version: 4
         | 
| 170 | 
            +
            summary: Spree Endpoints
         | 
| 171 | 
            +
            test_files:
         | 
| 172 | 
            +
            - spec/cross_origin_spec.rb
         | 
| 173 | 
            +
            - spec/integrator_utils_spec.rb
         | 
| 174 | 
            +
            - spec/spec_helper.rb
         |