pad 0.1 → 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: 058b01c4386ace1f7d6a9b898fa6da23f9b0518b
4
- data.tar.gz: ea3349c1c52820c85d39b1974e7eb890e8e30b9b
3
+ metadata.gz: be8e3f8388ad03d852a1356a6b5c99aee54c907d
4
+ data.tar.gz: dba6b05edc6d58a47dd7364af92f0a1b194dcdfc
5
5
  SHA512:
6
- metadata.gz: c33ce3a17e5f3cb20f78f5c6a0720f5ffc43d4707b749ea2537ace2490db1fa3bf55c3637d435527d5babb55bae664ddd88b3d714e921d6d763c79bbc1bb9467
7
- data.tar.gz: fce9ff83eab32c09ad397270670789627b83cde079387007c83d54b936db64b464f1b9e2e7aed0db8bf258b69141b8de18bbc10206cec0ee1d564582fa092207
6
+ metadata.gz: fe6c5734a0dd29eb4ea1e96328287bbfc4926fd40fa7fdc938130841569e0148a160d8d66294701a1d9126048cc3a62e08dc3c1bfb966e247554c9e3ed57992c
7
+ data.tar.gz: db95c2aceda6d694940664824e6f4b29b384f28d07b609c9a0253147d0334dcb4370a6655a9f0f1f8c2fb8ecdf56e8b3431000a2b9f487605ad843b93833e202
data/.gitignore CHANGED
@@ -1,3 +1,4 @@
1
1
  /.idea/
2
2
  /coverage/
3
- /pkg/
3
+ /pkg/
4
+ /Gemfile.lock/
@@ -0,0 +1 @@
1
+ -global
data/Gemfile CHANGED
@@ -1,4 +1,3 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- # Specify your gem's dependencies in pad.gemspec
4
3
  gemspec
data/README.md CHANGED
@@ -25,8 +25,48 @@ Or install it yourself as:
25
25
 
26
26
  ## Usage
27
27
 
28
+ ### Models
29
+ You can create your own models and use Pad attributes by including ```Pad.model``` in your classes.
30
+ This will add an ```attribute``` method you can use to add attributes to your class.
31
+
32
+ ```ruby
33
+ require 'pad'
34
+
35
+ class Vehicle
36
+ include Pad.model
37
+
38
+ attribute :year
39
+ attribute :manufacturer
40
+ attribute :make
41
+ end
42
+ ```
43
+
44
+ Attribute values can be passed into the constructor as a hash using a key of the attribute name.
45
+ ```ruby
46
+ sienna = Vehicle.new year: 2006, manufacturer: 'Toyota', make: 'Sienna' # => #<Vehicle:0x007fcdacd2ff38 @year=2006, @manufacturer="Toyota", @make="Sienna">
47
+ ```
48
+
49
+ And readers and writers are available for each attribute:
50
+ ```ruby
51
+ sienna.year # => 2006
52
+ sienna.year = 2007
53
+ sienna # => #<Vehicle:0x007fcdacd2ff38 @year=2007, @manufacturer="Toyota", @make="Sienna">
54
+ ```
55
+
56
+ You can set the type of an attribute
57
+ ```ruby
58
+ attribute :name, String
59
+ ```
60
+
61
+ You can set the visibility of attributes:
62
+
63
+ ```ruby
64
+ attribute :private, String, reader: :private, writer: :private
65
+ attribute :protected, String, reader: :protected, writer: :protected
66
+ attribute :public, String, reader: :public, writer: :public
67
+ ```
28
68
  ### Entities
29
- You can create entities which have a built-in 'id' attribute which uniquely identifies the entity.
69
+ You can create entities which extend models with a built-in 'id' attribute which uniquely identifies the entity.
30
70
 
31
71
  ```ruby
32
72
  require 'pad'
@@ -47,24 +87,31 @@ another_dave = Person.new id: 21
47
87
  dave == another_dave # => true
48
88
  ```
49
89
 
50
- ### Custom Classes
51
- You can create your own classes and use Pad attributes.
90
+ ### Value Objects
91
+ You can create value objects which have use read-only attribute values to denote equality.
92
+ Attribute values are passed into the constructor as a hash. Attributes to be considered
93
+ when checking equality are surrounded by a ```values``` block.
52
94
 
53
95
  ```ruby
54
96
  require 'pad'
55
97
 
56
- class Vehicle
57
- include Pad.model
98
+ class Price
99
+ include Pad.value_object
58
100
 
59
- attribute :year
60
- attribute :manufacturer
61
- attribute :make
101
+ values do
102
+ attribute :cost
103
+ attribute :currency
104
+ end
105
+
106
+ attribute :id
62
107
  end
63
108
 
64
- sienna = Vehicle.new year: 2006, manufacturer: 'Toyota', make: 'Sienna' # => #<Vehicle:0x007fcdacd2ff38 @year=2006, @manufacturer="Toyota", @make="Sienna">
65
- sienna.year # => 2006
66
- sienna.year = 2007
67
- sienna # => #<Vehicle:0x007fcdacd2ff38 @year=2007, @manufacturer="Toyota", @make="Sienna">
109
+ pen1 = Price.new id: 1, cost: 100, currency: 'CAD' # => ##<Price cost=100 currency="CAD">
110
+ pen2 = Price.new id: 2, cost: 100, currency: 'CAD' # => ##<Price cost=100 currency="CAD">
111
+ pen3 = Price.new id: 3, cost: 999, currency: 'CAD' # => ##<Price cost=100 currency="CAD">
112
+
113
+ pen1 == pen2 # => true
114
+ pen1 == pen3 # => false
68
115
  ```
69
116
 
70
117
  ## Contributing
data/Rakefile CHANGED
@@ -3,6 +3,7 @@ require 'rspec/core/rake_task'
3
3
  require 'rubocop/rake_task'
4
4
 
5
5
  RSpec::Core::RakeTask.new(:spec)
6
- RuboCop::RakeTask.new
7
-
6
+ RuboCop::RakeTask.new do |task|
7
+ task.options << '--display-cop-names'
8
+ end
8
9
  task default: [:spec, :rubocop, :build]
data/lib/pad.rb CHANGED
@@ -1,9 +1,13 @@
1
1
  require 'pad/virtus'
2
2
 
3
+ # TODO: Move to separate gem
4
+ require 'pad/delegate_via'
5
+
3
6
  require 'pad/configuration'
4
7
  require 'pad/version'
5
8
  require 'pad/entity'
6
- require 'pad/repository/memory'
9
+
10
+ require 'pad/services/logger'
7
11
 
8
12
  module Pad
9
13
  class << self
@@ -5,8 +5,7 @@ module Pad
5
5
 
6
6
  # @api private
7
7
  def initialize(options = {})
8
- self.builder = options.fetch(:builder, Pad::Virtus)
9
- self.repository = options.fetch(:repository, Pad::Repository::Memory)
8
+ self.builder = options.fetch(:builder, Pad::Virtus)
10
9
 
11
10
  yield self if block_given?
12
11
  end
@@ -0,0 +1,38 @@
1
+
2
+ module DelegateVia
3
+ class << self
4
+ def included(base)
5
+ base.extend ClassMethods
6
+ end
7
+ end
8
+
9
+ module ClassMethods
10
+ # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
11
+ def delegate_via(accessor_name, *method_names, &return_block)
12
+ options = method_names.last.is_a?(Hash) ? method_names.pop : {}
13
+ via_method = options.fetch(:via, :map)
14
+
15
+ mod = if const_defined?(:DelegateVia, false)
16
+ const_get(:DelegateVia)
17
+ else
18
+ new_mod = Module.new do
19
+ def self.to_s
20
+ "DelegateVia(#{instance_methods(false).join(', ')})"
21
+ end
22
+ end
23
+ const_set(:DelegateVia, new_mod)
24
+ end
25
+
26
+ mod.module_eval do
27
+ method_names.each do |method_name|
28
+ define_method method_name do |*args, &block|
29
+ accessor = __send__(accessor_name)
30
+ result = accessor.__send__(via_method) { |service| service.__send__(method_name, *args, &block) }
31
+ return_block ? instance_exec(result, &return_block) : result
32
+ end
33
+ end
34
+ end
35
+ include mod
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,23 @@
1
+ require 'logger'
2
+
3
+ module Pad
4
+ module Services
5
+ class Logger
6
+ include DelegateVia
7
+
8
+ def register(*loggers)
9
+ self.loggers.concat(loggers)
10
+ end
11
+
12
+ def loggers
13
+ @loggers ||= []
14
+ end
15
+
16
+ delegate_via :loggers, :debug, :info, :warn, :error, :fatal, :unknown, &:any?
17
+ delegate_via :loggers, :debug?, :info?, :warn?, :error?, :fatal?, &:any?
18
+
19
+ delegate_via :loggers, :add, :log, &:any?
20
+ delegate_via :loggers, :<<, &:first
21
+ end
22
+ end
23
+ end
@@ -1,3 +1,3 @@
1
1
  module Pad
2
- VERSION ||= '0.1'
2
+ VERSION ||= '0.1.1'
3
3
  end
@@ -21,12 +21,19 @@ Gem::Specification.new do |gem|
21
21
 
22
22
  gem.add_dependency 'virtus', '~> 1.0'
23
23
 
24
- gem.add_development_dependency 'attribute_matcher', '~> 0.1'
24
+ gem.add_development_dependency 'attribute_matcher', '~> 0.3'
25
25
  gem.add_development_dependency 'bundler', '~> 1.7'
26
26
  gem.add_development_dependency 'coveralls', '~> 0.7'
27
- gem.add_development_dependency 'delegate_matcher', '~> 0.0'
27
+ gem.add_development_dependency 'delegate_matcher', '~> 0.1'
28
28
  gem.add_development_dependency 'guard', '~> 2.13'
29
29
  gem.add_development_dependency 'guard-rspec', '~> 4.6'
30
+
31
+ if RUBY_VERSION =~ /2/
32
+ gem.add_development_dependency 'pry-byebug', '~> 3.3'
33
+ else
34
+ gem.add_development_dependency 'pry-debugger', '~> 0.2'
35
+ end
36
+
30
37
  gem.add_development_dependency 'rake', '~> 10.0'
31
38
  gem.add_development_dependency 'rspec', '~> 3.0'
32
39
  gem.add_development_dependency 'rspec-its', '~> 1.1'
@@ -35,23 +35,5 @@ module Pad
35
35
  expect(configuration.builder).to be builder
36
36
  end
37
37
  end
38
-
39
- describe 'repository' do
40
- let(:repository) { double 'repository' }
41
-
42
- it 'should default to Pad::Repository::Memory' do
43
- expect(subject.repository).to be Pad::Repository::Memory
44
- end
45
-
46
- it 'should be settable' do
47
- subject.repository = repository
48
- expect(subject.repository).to be repository
49
- end
50
-
51
- it 'should be settable via initialization' do
52
- configuration = Configuration.new(repository: repository)
53
- expect(configuration.repository).to be repository
54
- end
55
- end
56
38
  end
57
39
  end
@@ -0,0 +1,76 @@
1
+ require 'spec_helper'
2
+
3
+ describe DelegateVia do
4
+ let(:klass) { Struct.new(:delegates) { include DelegateVia } }
5
+ let(:delegates) { [double('delegate1').as_null_object, double('delegate2').as_null_object] }
6
+
7
+ subject { klass.new }
8
+
9
+ before { subject.delegates = delegates }
10
+ before { klass.class_eval { delegate_via :delegates, :call } }
11
+
12
+ describe 'with arguments' do
13
+ it { should delegate(:call).with.to(*delegates) }
14
+ it { should delegate(:call).with('arg').to(*delegates) }
15
+ it { should delegate(:call).with('arg', 'arg2').to(*delegates) }
16
+ end
17
+
18
+ describe 'with multiple methods' do
19
+ before { klass.class_eval { delegate_via :delegates, :call2, :call3 } }
20
+ it { should delegate(:call2).to(*delegates) }
21
+ it { should delegate(:call3).to(*delegates) }
22
+ end
23
+
24
+ describe 'blocks' do
25
+ it { should delegate(:call).to(*delegates).with_block }
26
+ end
27
+
28
+ describe 'via method' do
29
+ it 'should default to "map"' do
30
+ should delegate(:call).to(:delegates).as(:map)
31
+ end
32
+
33
+ it 'should allow accessor method to be provided' do
34
+ klass.class_eval { delegate_via :delegates, :call, via: :each }
35
+ should delegate(:call).to(:delegates).as(:each)
36
+ end
37
+ end
38
+
39
+ describe 'return value' do
40
+ it 'with no result block should return array of result values from delegates' do
41
+ expect(subject.call).to eq delegates
42
+ end
43
+
44
+ it 'should should set self to the delegator in the result block' do
45
+ block_self = nil
46
+ klass.class_eval { delegate_via(:delegates, :call) { block_self = self } }
47
+
48
+ subject.call
49
+ expect(block_self).to be subject
50
+ end
51
+
52
+ it 'should should pass delegate results to the result block' do
53
+ block_result = nil
54
+ klass.class_eval { delegate_via(:delegates, :call) { |result| block_result = result } }
55
+
56
+ subject.call
57
+ expect(block_result).to eq delegates
58
+ end
59
+
60
+ it 'should return value from the result block' do
61
+ klass.class_eval { delegate_via(:delegates, :call) { :return_value } }
62
+ expect(subject.call).to eq :return_value
63
+ end
64
+ end
65
+
66
+ describe 'to_s' do
67
+ it 'with a single delegation' do
68
+ expect(klass.ancestors[1].to_s).to eq 'DelegateVia(call)'
69
+ end
70
+
71
+ it 'with multiple delegations' do
72
+ klass.class_eval { delegate_via :delegates, :call2, :call3 }
73
+ expect(klass.ancestors[1].to_s).to eq 'DelegateVia(call, call2, call3)'
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,12 @@
1
+ require 'spec_helper'
2
+
3
+ module Pad
4
+ module Services
5
+ describe Logger do
6
+ specify 'should log to console' do
7
+ subject.register ::Logger.new(STDOUT)
8
+ expect { subject.info 'test' }.to output(/^I.*INFO.*test$/).to_stdout_from_any_process
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,77 @@
1
+ require 'spec_helper'
2
+
3
+ module Pad
4
+ module Services
5
+ describe Logger do
6
+ let(:logger1) { double('logger1') }
7
+ let(:logger2) { double('logger2') }
8
+ let(:loggers) { [logger1, logger2] }
9
+
10
+ before { subject.register logger1, logger2 }
11
+
12
+ [:debug, :info, :warn, :error, :fatal, :unknown].each do |method|
13
+ before do
14
+ allow(logger1).to receive(method) { true }
15
+ allow(logger2).to receive(method) { true }
16
+ end
17
+
18
+ it "#{method} should be delegated with a message" do
19
+ expect(subject).to delegate(method).to(*loggers).with('message').and_return true
20
+ end
21
+
22
+ it "#{method} should be delegated without a message" do
23
+ expect(subject).to delegate(method).to(*loggers).and_return true
24
+ end
25
+
26
+ it "#{method} should be delegated with a block" do
27
+ expect(subject).to delegate(method).to(*loggers).with_block.and_return true
28
+ end
29
+
30
+ it "#{method} should return true if any logger returns true" do
31
+ allow(logger1).to receive(method) { true }
32
+ allow(logger2).to receive(method) { false }
33
+ expect(subject.send(method, 'message')).to be true
34
+ end
35
+
36
+ it "#{method} should return false if all loggers return false" do
37
+ allow(logger1).to receive(method) { false }
38
+ allow(logger2).to receive(method) { false }
39
+ expect(subject.send(method, 'message')).to be false
40
+ end
41
+
42
+ next if method == :unknown
43
+
44
+ it "#{method}? should return true if any logger return true" do
45
+ allow(logger1).to receive("#{method}?") { true }
46
+ allow(logger2).to receive("#{method}?") { false }
47
+ expect(subject).to delegate("#{method}?").to(*loggers).and_return true
48
+ end
49
+
50
+ it "#{method}? should return false if all loggers return false" do
51
+ allow(logger1).to receive("#{method}?") { false }
52
+ allow(logger2).to receive("#{method}?") { false }
53
+ expect(subject).to delegate("#{method}?").to(*loggers).and_return false
54
+ end
55
+ end
56
+
57
+ it '<< should be delegated' do
58
+ allow(logger1).to receive(:<<) { 7 }
59
+ allow(logger2).to receive(:<<) { 35 }
60
+ expect(subject).to delegate(:<<).with('message').to(*loggers).and_return 7
61
+ end
62
+
63
+ [:add, :log].each do |method|
64
+ describe "#{method}" do
65
+ before do
66
+ allow(logger1).to receive(method) { false }
67
+ allow(logger2).to receive(method) { false }
68
+ end
69
+
70
+ it { should delegate(method).with(::Logger::INFO).to(*loggers).with_block.and_return false }
71
+ it { should delegate(method).with(::Logger::INFO, 'message').to(*loggers).and_return false }
72
+ it { should delegate(method).with(::Logger::INFO, 'message', 'progname').to(*loggers).and_return false }
73
+ end
74
+ end
75
+ end
76
+ end
77
+ end
@@ -3,8 +3,8 @@ require 'spec_helper'
3
3
  describe Pad do
4
4
  subject { Pad }
5
5
 
6
- let(:options) { { some: :option } }
7
- let(:builder) { double 'builder' }
6
+ let(:options) { { some: :option } }
7
+ let(:builder) { double('builder').as_null_object }
8
8
  let(:default_builder) { Pad.config.builder }
9
9
 
10
10
  [:model, :entity, :value_object].each do |method|
@@ -17,25 +17,33 @@ module Pad
17
17
  describe 'type' do
18
18
  before do
19
19
  klass.class_eval do
20
- attribute :name, String, default: ''
20
+ attribute :name, String
21
21
  end
22
22
  end
23
23
 
24
24
  it { is_expected.to have_attribute(:name).of_type(String) }
25
25
  end
26
26
 
27
- describe 'visibility' do
27
+ describe 'options' do
28
28
  before do
29
29
  klass.class_eval do
30
30
  attribute :private, String, reader: :private, writer: :private
31
31
  attribute :protected, String, reader: :protected, writer: :protected
32
32
  attribute :public, String, reader: :public, writer: :public
33
+
34
+ attribute :name, String, default: 'Joe'
33
35
  end
34
36
  end
35
37
 
36
- it { is_expected.to have_attribute(:private). with_reader(:private). with_writer(:private) }
37
- it { is_expected.to have_attribute(:protected).with_reader(:protected).with_writer(:protected) }
38
- it { is_expected.to have_attribute(:public). with_reader(:public). with_writer(:public) }
38
+ describe 'visibility' do
39
+ it { is_expected.to have_attribute(:private). with_reader(:private). with_writer(:private) }
40
+ it { is_expected.to have_attribute(:protected).with_reader(:protected).with_writer(:protected) }
41
+ it { is_expected.to have_attribute(:public). with_reader(:public). with_writer(:public) }
42
+ end
43
+
44
+ describe 'default' do
45
+ it { is_expected.to have_attribute(:name).with_value('Joe') }
46
+ end
39
47
  end
40
48
 
41
49
  # TODO: add checks for mass assignment, constructor
@@ -6,19 +6,48 @@ module Pad
6
6
  shared_examples 'a value object module' do |mod|
7
7
  include_examples 'attribute examples', mod
8
8
 
9
- let(:klass) { Class.new { include mod } }
10
- subject { klass.new }
9
+ subject { klass.new }
11
10
 
12
- describe 'default visibility' do
13
- subject { klass.new }
11
+ let(:klass) do
12
+ Class.new do
13
+ include mod
14
14
 
15
- before do
16
- klass.class_eval do
17
- attribute :default
15
+ values do
16
+ attribute :name
18
17
  end
18
+
19
+ attribute :age
19
20
  end
21
+ end
20
22
 
21
- it { is_expected.to have_attribute(:default).with_reader(:public).with_writer(:private) }
23
+ describe 'default visibility' do
24
+ it { is_expected.to have_attribute(:name).with_reader(:public).with_writer(:private) }
25
+ end
26
+
27
+ describe 'equality' do
28
+ specify 'with value attributes all nil' do
29
+ joe1 = klass.new
30
+ joe2 = klass.new
31
+ expect(joe1).to eq joe2
32
+ end
33
+
34
+ specify 'with value attributes having same values' do
35
+ joe1 = klass.new name: 'Joe'
36
+ joe2 = klass.new name: 'Joe'
37
+ expect(joe1).to eq joe2
38
+ end
39
+
40
+ specify 'with non-value attributes having different values' do
41
+ joe1 = klass.new age: 22
42
+ joe2 = klass.new age: 99
43
+ expect(joe1).to eq joe2
44
+ end
45
+
46
+ specify 'with value attributes having different values' do
47
+ joe = klass.new name: 'Joe'
48
+ jane = klass.new name: 'Jane'
49
+ expect(jane).to_not eq joe
50
+ end
22
51
  end
23
52
  end
24
53
  end
@@ -3,6 +3,8 @@ require 'coveralls'
3
3
  require 'simplecov'
4
4
  require 'rspec/its'
5
5
 
6
+ require RUBY_VERSION =~ /2/ ? 'pry-byebug' : 'pry-debugger'
7
+
6
8
  SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
7
9
  SimpleCov::Formatter::HTMLFormatter,
8
10
  Coveralls::SimpleCov::Formatter
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pad
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.1'
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Declan Whelan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-07 00:00:00.000000000 Z
11
+ date: 2016-08-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: virtus
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0.1'
33
+ version: '0.3'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0.1'
40
+ version: '0.3'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -72,14 +72,14 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '0.0'
75
+ version: '0.1'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '0.0'
82
+ version: '0.1'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: guard
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -108,6 +108,20 @@ dependencies:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
110
  version: '4.6'
111
+ - !ruby/object:Gem::Dependency
112
+ name: pry-byebug
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '3.3'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '3.3'
111
125
  - !ruby/object:Gem::Dependency
112
126
  name: rake
113
127
  requirement: !ruby/object:Gem::Requirement
@@ -173,23 +187,26 @@ extensions: []
173
187
  extra_rdoc_files: []
174
188
  files:
175
189
  - ".gitignore"
190
+ - ".rbenv-gemsets"
176
191
  - ".rubocop.yml"
177
192
  - ".travis.yml"
178
193
  - Gemfile
179
- - Gemfile.lock
180
194
  - Guardfile
181
195
  - LICENSE.txt
182
196
  - README.md
183
197
  - Rakefile
184
198
  - lib/pad.rb
185
199
  - lib/pad/configuration.rb
200
+ - lib/pad/delegate_via.rb
186
201
  - lib/pad/entity.rb
187
- - lib/pad/repository/memory.rb
202
+ - lib/pad/services/logger.rb
188
203
  - lib/pad/version.rb
189
204
  - lib/pad/virtus.rb
190
205
  - pad.gemspec
191
206
  - spec/lib/pad/configuration_spec.rb
192
- - spec/lib/pad/repository/memory_spec.rb
207
+ - spec/lib/pad/delegate_via_spec.rb
208
+ - spec/lib/pad/services/logger_acceptance_spec.rb
209
+ - spec/lib/pad/services/logger_spec.rb
193
210
  - spec/lib/pad/version_spec.rb
194
211
  - spec/lib/pad/virtus_spec.rb
195
212
  - spec/lib/pad_spec.rb
@@ -218,14 +235,16 @@ required_rubygems_version: !ruby/object:Gem::Requirement
218
235
  version: '0'
219
236
  requirements: []
220
237
  rubyforge_project:
221
- rubygems_version: 2.4.5
238
+ rubygems_version: 2.5.1
222
239
  signing_key:
223
240
  specification_version: 4
224
241
  summary: A light weight framework for supporting Ports & Adapters designs with Domain
225
242
  Driven Design
226
243
  test_files:
227
244
  - spec/lib/pad/configuration_spec.rb
228
- - spec/lib/pad/repository/memory_spec.rb
245
+ - spec/lib/pad/delegate_via_spec.rb
246
+ - spec/lib/pad/services/logger_acceptance_spec.rb
247
+ - spec/lib/pad/services/logger_spec.rb
229
248
  - spec/lib/pad/version_spec.rb
230
249
  - spec/lib/pad/virtus_spec.rb
231
250
  - spec/lib/pad_spec.rb
@@ -1,133 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- pad (0.1)
5
- virtus (~> 1.0)
6
-
7
- GEM
8
- remote: https://rubygems.org/
9
- specs:
10
- ast (2.1.0)
11
- astrolabe (1.3.1)
12
- parser (~> 2.2)
13
- attribute_matcher (0.1)
14
- axiom-types (0.1.1)
15
- descendants_tracker (~> 0.0.4)
16
- ice_nine (~> 0.11.0)
17
- thread_safe (~> 0.3, >= 0.3.1)
18
- coderay (1.1.0)
19
- coercible (1.0.0)
20
- descendants_tracker (~> 0.0.1)
21
- coveralls (0.7.2)
22
- multi_json (~> 1.3)
23
- rest-client (= 1.6.7)
24
- simplecov (>= 0.7)
25
- term-ansicolor (= 1.2.2)
26
- thor (= 0.18.1)
27
- delegate_matcher (0.0.1)
28
- descendants_tracker (0.0.4)
29
- thread_safe (~> 0.3, >= 0.3.1)
30
- diff-lcs (1.2.5)
31
- docile (1.1.5)
32
- equalizer (0.0.11)
33
- ffi (1.9.10)
34
- formatador (0.2.5)
35
- guard (2.13.0)
36
- formatador (>= 0.2.4)
37
- listen (>= 2.7, <= 4.0)
38
- lumberjack (~> 1.0)
39
- nenv (~> 0.1)
40
- notiffany (~> 0.0)
41
- pry (>= 0.9.12)
42
- shellany (~> 0.0)
43
- thor (>= 0.18.1)
44
- guard-compat (1.2.1)
45
- guard-rspec (4.6.4)
46
- guard (~> 2.1)
47
- guard-compat (~> 1.1)
48
- rspec (>= 2.99.0, < 4.0)
49
- ice_nine (0.11.1)
50
- listen (3.0.3)
51
- rb-fsevent (>= 0.9.3)
52
- rb-inotify (>= 0.9)
53
- lumberjack (1.0.9)
54
- method_source (0.8.2)
55
- mime-types (2.4.3)
56
- multi_json (1.10.1)
57
- nenv (0.2.0)
58
- notiffany (0.0.8)
59
- nenv (~> 0.1)
60
- shellany (~> 0.0)
61
- parser (2.2.2.6)
62
- ast (>= 1.1, < 3.0)
63
- powerpack (0.1.1)
64
- pry (0.10.2)
65
- coderay (~> 1.1.0)
66
- method_source (~> 0.8.1)
67
- slop (~> 3.4)
68
- rainbow (2.0.0)
69
- rake (10.4.2)
70
- rb-fsevent (0.9.6)
71
- rb-inotify (0.9.5)
72
- ffi (>= 0.5.0)
73
- rest-client (1.6.7)
74
- mime-types (>= 1.16)
75
- rspec (3.3.0)
76
- rspec-core (~> 3.3.0)
77
- rspec-expectations (~> 3.3.0)
78
- rspec-mocks (~> 3.3.0)
79
- rspec-core (3.3.2)
80
- rspec-support (~> 3.3.0)
81
- rspec-expectations (3.3.1)
82
- diff-lcs (>= 1.2.0, < 2.0)
83
- rspec-support (~> 3.3.0)
84
- rspec-its (1.1.0)
85
- rspec-core (>= 3.0.0)
86
- rspec-expectations (>= 3.0.0)
87
- rspec-mocks (3.3.2)
88
- diff-lcs (>= 1.2.0, < 2.0)
89
- rspec-support (~> 3.3.0)
90
- rspec-support (3.3.0)
91
- rubocop (0.33.0)
92
- astrolabe (~> 1.3)
93
- parser (>= 2.2.2.5, < 3.0)
94
- powerpack (~> 0.1)
95
- rainbow (>= 1.99.1, < 3.0)
96
- ruby-progressbar (~> 1.4)
97
- ruby-progressbar (1.7.5)
98
- shellany (0.0.1)
99
- simplecov (0.9.1)
100
- docile (~> 1.1.0)
101
- multi_json (~> 1.0)
102
- simplecov-html (~> 0.8.0)
103
- simplecov-html (0.8.0)
104
- slop (3.6.0)
105
- term-ansicolor (1.2.2)
106
- tins (~> 0.8)
107
- thor (0.18.1)
108
- thread_safe (0.3.5)
109
- tins (0.13.2)
110
- virtus (1.0.5)
111
- axiom-types (~> 0.1)
112
- coercible (~> 1.0)
113
- descendants_tracker (~> 0.0, >= 0.0.3)
114
- equalizer (~> 0.0, >= 0.0.9)
115
-
116
- PLATFORMS
117
- ruby
118
-
119
- DEPENDENCIES
120
- attribute_matcher (~> 0.1)
121
- bundler (~> 1.7)
122
- coveralls (~> 0.7)
123
- delegate_matcher (~> 0.0)
124
- guard (~> 2.13)
125
- guard-rspec (~> 4.6)
126
- pad!
127
- rake (~> 10.0)
128
- rspec (~> 3.0)
129
- rspec-its (~> 1.1)
130
- rubocop (~> 0.30)
131
-
132
- BUNDLED WITH
133
- 1.10.6
@@ -1,25 +0,0 @@
1
- module Pad
2
- module Repository
3
- class Memory
4
- def initialize
5
- self.repository = {}
6
- end
7
-
8
- def save(entity)
9
- repository[entity.id] = entity
10
- end
11
-
12
- def find(id)
13
- repository[id]
14
- end
15
-
16
- def delete(entity)
17
- repository[entity.id] = nil
18
- end
19
-
20
- private
21
-
22
- attr_accessor :repository
23
- end
24
- end
25
- end
@@ -1,28 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module Pad
4
- module Repository
5
- describe Memory do
6
- let(:entity) { OpenStruct.new id: 42 }
7
-
8
- describe 'find' do
9
- it { should respond_to :find }
10
- end
11
-
12
- describe 'save' do
13
- it 'should save' do
14
- subject.save entity
15
- expect(subject.find 42).to be entity
16
- end
17
- end
18
-
19
- describe 'delete' do
20
- it 'should delete' do
21
- subject.save entity
22
- subject.delete entity
23
- expect(subject.find 42).to be_nil
24
- end
25
- end
26
- end
27
- end
28
- end