dry-behaviour 0.6.0 → 0.7.0
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 +4 -4
 - data/.travis.yml +3 -2
 - data/lib/dry/behaviour/black_tie.rb +14 -7
 - data/lib/dry/behaviour/version.rb +1 -1
 - data/lib/dry/errors/not_implemented.rb +33 -9
 - metadata +2 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 68e9909166c5283d9505f7be6f541334aea5d161
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 2319fcbbb2da7b56aff3825e44788d44da99a688
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: cd3f037341b4f6f2e28d9e4478d763fc6bd554d09e5be20be2ac08c2fad405be3a2ce8e45a273cdd0c6bbbf26efd8ee0abaf4edb6d48e4760c933ebaf54d1397
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: cea7c3a4b77dbc7cc4215e38b853c92d96670fe8677c771a2d1914b6e60293d163fc00d9bd3a60b97966849e5a7f025cb3b39c0b30afb933c62e25dfdafb4497
         
     | 
    
        data/.travis.yml
    CHANGED
    
    
| 
         @@ -24,7 +24,9 @@ module Dry 
     | 
|
| 
       24 
24 
     | 
    
         
             
                  (instance_methods(false) - ims).each { |m| class_eval { module_function m } }
         
     | 
| 
       25 
25 
     | 
    
         | 
| 
       26 
26 
     | 
    
         
             
                  singleton_class.send :define_method, :method_missing do |method, *_args|
         
     | 
| 
       27 
     | 
    
         
            -
                    raise Dry::Protocol::NotImplemented.new( 
     | 
| 
      
 27 
     | 
    
         
            +
                    raise Dry::Protocol::NotImplemented.new(
         
     | 
| 
      
 28 
     | 
    
         
            +
                      :method, inspect, method: method, self: self
         
     | 
| 
      
 29 
     | 
    
         
            +
                    )
         
     | 
| 
       28 
30 
     | 
    
         
             
                  end
         
     | 
| 
       29 
31 
     | 
    
         | 
| 
       30 
32 
     | 
    
         
             
                  singleton_class.send :define_method, :implementation_for do |receiver|
         
     | 
| 
         @@ -33,16 +35,21 @@ module Dry 
     | 
|
| 
       33 
35 
     | 
    
         
             
                    end.reject(&:nil?).first
         
     | 
| 
       34 
36 
     | 
    
         
             
                  end
         
     | 
| 
       35 
37 
     | 
    
         | 
| 
       36 
     | 
    
         
            -
                  BlackTie.protocols[self].each do |method, *_| # FIXME: CHECK  
     | 
| 
      
 38 
     | 
    
         
            +
                  BlackTie.protocols[self].each do |method, *_| # FIXME: CHECK ARITY HERE
         
     | 
| 
       37 
39 
     | 
    
         
             
                    singleton_class.send :define_method, method do |receiver = nil, *args|
         
     | 
| 
       38 
40 
     | 
    
         
             
                      impl = implementation_for(receiver)
         
     | 
| 
       39 
     | 
    
         
            -
                      raise Dry::Protocol::NotImplemented.new( 
     | 
| 
      
 41 
     | 
    
         
            +
                      raise Dry::Protocol::NotImplemented.new(
         
     | 
| 
      
 42 
     | 
    
         
            +
                        :protocol, inspect,
         
     | 
| 
      
 43 
     | 
    
         
            +
                        method: method, receiver: receiver, args: args, self: self
         
     | 
| 
      
 44 
     | 
    
         
            +
                      ) unless impl
         
     | 
| 
       40 
45 
     | 
    
         
             
                      begin
         
     | 
| 
       41 
46 
     | 
    
         
             
                        impl[method].(*args.unshift(receiver))
         
     | 
| 
       42 
     | 
    
         
            -
                      rescue  
     | 
| 
       43 
     | 
    
         
            -
                        raise Dry::Protocol::NotImplemented.new( 
     | 
| 
       44 
     | 
    
         
            -
             
     | 
| 
       45 
     | 
    
         
            -
             
     | 
| 
      
 47 
     | 
    
         
            +
                      rescue => e
         
     | 
| 
      
 48 
     | 
    
         
            +
                        raise Dry::Protocol::NotImplemented.new(
         
     | 
| 
      
 49 
     | 
    
         
            +
                            :nested, inspect,
         
     | 
| 
      
 50 
     | 
    
         
            +
                            cause: e,
         
     | 
| 
      
 51 
     | 
    
         
            +
                            method: method, receiver: receiver, args: args, impl: impl, self: self
         
     | 
| 
      
 52 
     | 
    
         
            +
                          )
         
     | 
| 
       46 
53 
     | 
    
         
             
                      end
         
     | 
| 
       47 
54 
     | 
    
         
             
                    end
         
     | 
| 
       48 
55 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -1,15 +1,39 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            module Dry
         
     | 
| 
       2 
2 
     | 
    
         
             
              module Protocol
         
     | 
| 
       3 
3 
     | 
    
         
             
                class NotImplemented < StandardError
         
     | 
| 
       4 
     | 
    
         
            -
                   
     | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
       6 
     | 
    
         
            -
             
     | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
       8 
     | 
    
         
            -
             
     | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
      
 4 
     | 
    
         
            +
                  attr_reader :proto, :details
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
                  def initialize(type, proto, **details)
         
     | 
| 
      
 7 
     | 
    
         
            +
                    @proto, @details = proto, details
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
                    @details[:message] =
         
     | 
| 
      
 10 
     | 
    
         
            +
                      case type
         
     | 
| 
      
 11 
     | 
    
         
            +
                      when :protocol
         
     | 
| 
      
 12 
     | 
    
         
            +
                        "Protocol “#{@proto}” is not implemented for “#{@details[:receiver].class}”."
         
     | 
| 
      
 13 
     | 
    
         
            +
                      when :method
         
     | 
| 
      
 14 
     | 
    
         
            +
                        "Protocol “#{@proto}” does not declare method “#{@details[:method]}”."
         
     | 
| 
      
 15 
     | 
    
         
            +
                      when :nested
         
     | 
| 
      
 16 
     | 
    
         
            +
                        "Protocol “#{@proto}” failed to invoke the implementation.\n" \
         
     | 
| 
      
 17 
     | 
    
         
            +
                        " ⮩  caused by “#{cause.class}” with a message\n" \
         
     | 
| 
      
 18 
     | 
    
         
            +
                        " ⮩    “#{cause.message}”\n" \
         
     | 
| 
      
 19 
     | 
    
         
            +
                        " ⮩  rescue this exception and inspect `NotImplemented#cause' for details."
         
     | 
| 
      
 20 
     | 
    
         
            +
                      else
         
     | 
| 
      
 21 
     | 
    
         
            +
                        "Protocol “#{proto}” is invalid."
         
     | 
| 
      
 22 
     | 
    
         
            +
                      end
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
                    super(@details[:message])
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
                    if @details[:cause]
         
     | 
| 
      
 27 
     | 
    
         
            +
                      set_backtrace(
         
     | 
| 
      
 28 
     | 
    
         
            +
                        @details[:cause].backtrace.reject do |line| # FIXME drop_while ??
         
     | 
| 
      
 29 
     | 
    
         
            +
                          line =~ %r[dry-behaviour/lib/dry/behaviour]
         
     | 
| 
      
 30 
     | 
    
         
            +
                        end
         
     | 
| 
      
 31 
     | 
    
         
            +
                      )
         
     | 
| 
      
 32 
     | 
    
         
            +
                    end
         
     | 
| 
      
 33 
     | 
    
         
            +
                  end
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
                  def cause
         
     | 
| 
      
 36 
     | 
    
         
            +
                    @details[:cause] ||= super
         
     | 
| 
       13 
37 
     | 
    
         
             
                  end
         
     | 
| 
       14 
38 
     | 
    
         
             
                end
         
     | 
| 
       15 
39 
     | 
    
         
             
              end
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: dry-behaviour
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.7.0
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Aleksei Matiushkin
         
     | 
| 
         @@ -10,7 +10,7 @@ authors: 
     | 
|
| 
       10 
10 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       11 
11 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       12 
12 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       13 
     | 
    
         
            -
            date: 2018- 
     | 
| 
      
 13 
     | 
    
         
            +
            date: 2018-10-11 00:00:00.000000000 Z
         
     | 
| 
       14 
14 
     | 
    
         
             
            dependencies:
         
     | 
| 
       15 
15 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       16 
16 
     | 
    
         
             
              name: bundler
         
     |