pizza_delivery 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c78cc1cc2f52299a6e110e1de919c1de0cce1fd4
4
+ data.tar.gz: 633d3e9229b36c7d2ae15adc11dc4fd0fb0be8eb
5
+ SHA512:
6
+ metadata.gz: 0041cae3d7bec9cdc84f30816ae69f261b6dd74afde058d64e2168080187bbc474823b54d89036a67a1ba04667924eb8ac586bf25cc9bcb19d86b918bbdf2425
7
+ data.tar.gz: 9e6d886e9365ed63d31128b7086ca5ef3ecaf8b8831d88ab0b46a32a39b382da9e6266554179ef760ec6f066d6edad8237e27c0e34b48b73f7bfb7af6ebcbc5e
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ .DS_Store
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Steven Weiss
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,31 @@
1
+ # Pizza Delivery
2
+
3
+ Pizza Delivery is a tiny library for implementing a service layer abstraction.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'pizza_delivery'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install pizza_delivery
20
+
21
+
22
+ For RubyMotion, use the [Pizza Delivery Motion](https://github.com/sirscriptalot/pizza_delivery_motion) gem.
23
+
24
+ ## Usage
25
+
26
+ TODO
27
+
28
+ ## License
29
+
30
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
31
+
data/Rakefile ADDED
@@ -0,0 +1,5 @@
1
+ task :spec do
2
+ Dir.glob('./spec/**/*_spec.rb').each { |file| require file }
3
+ end
4
+
5
+ task :default => :spec
@@ -0,0 +1,3 @@
1
+ module PizzaDelivery
2
+ VERSION = '0.1.0'.freeze
3
+ end
@@ -0,0 +1,27 @@
1
+ require_relative './pizza_delivery/version'
2
+
3
+ module PizzaDelivery
4
+ module Caller
5
+ def call(service_class, callback, *args)
6
+ service_class.new(self, callback, *args).call
7
+ end
8
+ end
9
+
10
+ class Service
11
+ attr_reader :caller_instance, :callback
12
+
13
+ def initialize(caller_instance, callback, *args)
14
+ @caller_instance = caller_instance
15
+ @callback = callback
16
+ @args = args
17
+ end
18
+
19
+ def call
20
+ raise NotImplementedError, 'abstract'
21
+ end
22
+
23
+ def deliver(status, payload)
24
+ caller_instance.send(callback, status, payload)
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,12 @@
1
+ require_relative './lib/pizza_delivery/version'
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = 'pizza_delivery'
5
+ s.summary = 'Pizza Delivery'
6
+ s.version = PizzaDelivery::VERSION
7
+ s.authors = ['Steve Weiss']
8
+ s.email = ['weissst@mail.gvsu.edu']
9
+ s.homepage = 'https://github.com/sirscriptalot/pizza_delivery'
10
+ s.license = 'MIT'
11
+ s.files = `git ls-files`.split("\n")
12
+ end
@@ -0,0 +1,74 @@
1
+ require_relative './spec_helper'
2
+
3
+ class Caller
4
+ include PizzaDelivery::Caller
5
+
6
+ attr_reader :status, :payload
7
+
8
+ def initialize
9
+ @status, @payload = nil, nil
10
+ end
11
+
12
+ def receive(status, payload)
13
+ @status, @payload = status, payload
14
+ end
15
+ end
16
+
17
+ class Service < PizzaDelivery::Service
18
+ def call
19
+ deliver :status, {}
20
+ end
21
+ end
22
+
23
+ describe PizzaDelivery::Caller do
24
+ describe '#call' do
25
+ before do
26
+ @caller_instance = Caller.new
27
+ end
28
+
29
+ context 'callback is a symbol' do
30
+ it 'responds to service with callback' do
31
+ @caller_instance.status.must_be_nil
32
+ @caller_instance.payload.must_be_nil
33
+
34
+ @caller_instance.call Service, :receive
35
+
36
+ @caller_instance.status.wont_be_nil
37
+ @caller_instance.payload.wont_be_nil
38
+ end
39
+ end
40
+
41
+ context 'callback is a string' do
42
+ it 'responds to service with callback' do
43
+ @caller_instance.status.must_be_nil
44
+ @caller_instance.payload.must_be_nil
45
+
46
+ @caller_instance.call Service, "receive"
47
+
48
+ @caller_instance.status.wont_be_nil
49
+ @caller_instance.payload.wont_be_nil
50
+ end
51
+ end
52
+ end
53
+ end
54
+
55
+ describe PizzaDelivery::Service do
56
+ describe '#call' do
57
+ it 'must be implemented by subclass' do
58
+ lambda { PizzaDelivery::Service.new(nil, nil).call }.must_raise NotImplementedError
59
+ end
60
+ end
61
+
62
+ describe '#deliver' do
63
+ it 'calls caller_instance callback with status, payload' do
64
+ caller_instance = Caller.new
65
+ service = Service.new(caller_instance, :receive)
66
+ status = :status
67
+ payload = { foo: :bar }
68
+ service.deliver status, payload
69
+
70
+ caller_instance.status.must_equal status
71
+ caller_instance.payload.must_equal payload
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,6 @@
1
+ require 'minitest/autorun'
2
+ require_relative '../lib/pizza_delivery'
3
+
4
+ def context(*args, &block)
5
+ describe(*args, &block)
6
+ end
metadata ADDED
@@ -0,0 +1,54 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pizza_delivery
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Steve Weiss
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-10-14 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description:
14
+ email:
15
+ - weissst@mail.gvsu.edu
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - ".gitignore"
21
+ - Gemfile
22
+ - LICENSE.txt
23
+ - README.md
24
+ - Rakefile
25
+ - lib/pizza_delivery.rb
26
+ - lib/pizza_delivery/version.rb
27
+ - pizza_delivery.gemspec
28
+ - spec/pizza_delivery_spec.rb
29
+ - spec/spec_helper.rb
30
+ homepage: https://github.com/sirscriptalot/pizza_delivery
31
+ licenses:
32
+ - MIT
33
+ metadata: {}
34
+ post_install_message:
35
+ rdoc_options: []
36
+ require_paths:
37
+ - lib
38
+ required_ruby_version: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: '0'
43
+ required_rubygems_version: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ requirements: []
49
+ rubyforge_project:
50
+ rubygems_version: 2.5.1
51
+ signing_key:
52
+ specification_version: 4
53
+ summary: Pizza Delivery
54
+ test_files: []