incline 0.2.12 → 0.2.13
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/Gemfile.lock +1 -1
 - data/lib/incline/engine.rb +2 -0
 - data/lib/incline/extensions/current_request.rb +25 -0
 - data/lib/incline/extensions/param_propagation.rb +38 -0
 - data/lib/incline/version.rb +1 -1
 - data/test/incline_test.rb +1 -0
 - metadata +4 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 9190b8771a8a714428aced1fcfe7bfc14805898b
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: ef48cd977e79ac87f6dbf9100d5697b13ea5b636
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: ad6466b33890e04ec20f51901b5fb2c67d8c638742de3621c218687a95e61b90e08d632d4e3965f6efdad2773ff08465537f7f04df0a9b6f95bebc821cdef3a4
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 251f92afc831778e5e06be80165db66b9f2217919f1ab5d0502c4f6dda0ec7d8f66eab031781f52f7d8c1fb011db6d50a2ce5eb764ee49c638fd0406e090ad2a
         
     | 
    
        data/Gemfile.lock
    CHANGED
    
    
    
        data/lib/incline/engine.rb
    CHANGED
    
    | 
         @@ -26,6 +26,7 @@ require 'incline/extensions/active_record_base' 
     | 
|
| 
       26 
26 
     | 
    
         
             
            require 'incline/extensions/connection_adapter'
         
     | 
| 
       27 
27 
     | 
    
         
             
            require 'incline/extensions/main_app'
         
     | 
| 
       28 
28 
     | 
    
         
             
            require 'incline/extensions/action_controller_base'
         
     | 
| 
      
 29 
     | 
    
         
            +
            require 'incline/extensions/current_request'
         
     | 
| 
       29 
30 
     | 
    
         
             
            require 'incline/extensions/action_mailer_base'
         
     | 
| 
       30 
31 
     | 
    
         
             
            require 'incline/extensions/action_view_base'
         
     | 
| 
       31 
32 
     | 
    
         
             
            require 'incline/extensions/session'
         
     | 
| 
         @@ -40,6 +41,7 @@ require 'incline/extensions/float_value' 
     | 
|
| 
       40 
41 
     | 
    
         
             
            require 'incline/extensions/decimal_value'
         
     | 
| 
       41 
42 
     | 
    
         
             
            require 'incline/extensions/date_time_value'
         
     | 
| 
       42 
43 
     | 
    
         
             
            require 'incline/extensions/date_value'
         
     | 
| 
      
 44 
     | 
    
         
            +
            require 'incline/extensions/param_propagation'
         
     | 
| 
       43 
45 
     | 
    
         | 
| 
       44 
46 
     | 
    
         
             
            # Validators
         
     | 
| 
       45 
47 
     | 
    
         
             
            require 'incline/validators/email_validator'
         
     | 
| 
         @@ -0,0 +1,25 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module Incline::Extensions
         
     | 
| 
      
 2 
     | 
    
         
            +
              module CurrentRequest
         
     | 
| 
      
 3 
     | 
    
         
            +
                def self.included(base)
         
     | 
| 
      
 4 
     | 
    
         
            +
                  base.class_eval do
         
     | 
| 
      
 5 
     | 
    
         
            +
                    private
         
     | 
| 
      
 6 
     | 
    
         
            +
                    
         
     | 
| 
      
 7 
     | 
    
         
            +
                    def store_current_request
         
     | 
| 
      
 8 
     | 
    
         
            +
                      ::Thread.current.thread_variable_set :incline_current_request, request
         
     | 
| 
      
 9 
     | 
    
         
            +
                    end
         
     | 
| 
      
 10 
     | 
    
         
            +
                    
         
     | 
| 
      
 11 
     | 
    
         
            +
                    before_action :store_current_request
         
     | 
| 
      
 12 
     | 
    
         
            +
                  end
         
     | 
| 
      
 13 
     | 
    
         
            +
                end
         
     | 
| 
      
 14 
     | 
    
         
            +
              end
         
     | 
| 
      
 15 
     | 
    
         
            +
            end
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
            module Incline
         
     | 
| 
      
 18 
     | 
    
         
            +
              def self.current_request
         
     | 
| 
      
 19 
     | 
    
         
            +
                th = ::Thread.current
         
     | 
| 
      
 20 
     | 
    
         
            +
                th.thread_variable?(:incline_current_request) ? th.thread_variable_get(:incline_current_request) : nil
         
     | 
| 
      
 21 
     | 
    
         
            +
              end
         
     | 
| 
      
 22 
     | 
    
         
            +
            end
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
            ActionController::Base.include ::Incline::Extensions::CurrentRequest
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
         @@ -0,0 +1,38 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'action_dispatch/http/url'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            module ActionDispatch::Http::URL
         
     | 
| 
      
 4 
     | 
    
         
            +
              
         
     | 
| 
      
 5 
     | 
    
         
            +
              ##
         
     | 
| 
      
 6 
     | 
    
         
            +
              # Enables automatic parameter propagation.
         
     | 
| 
      
 7 
     | 
    
         
            +
              #
         
     | 
| 
      
 8 
     | 
    
         
            +
              # This will only propagate within the current thread.  Child threads will not propagate.
         
     | 
| 
      
 9 
     | 
    
         
            +
              # This will not affect other requests in the current session.
         
     | 
| 
      
 10 
     | 
    
         
            +
              #
         
     | 
| 
      
 11 
     | 
    
         
            +
              #   ActionDispatch::Http::URL.propagated_params << :some_param
         
     | 
| 
      
 12 
     | 
    
         
            +
              def self.propagated_params
         
     | 
| 
      
 13 
     | 
    
         
            +
                @propagated_params ||= []
         
     | 
| 
      
 14 
     | 
    
         
            +
              end
         
     | 
| 
      
 15 
     | 
    
         
            +
              
         
     | 
| 
      
 16 
     | 
    
         
            +
              def self.path_for(options)
         
     | 
| 
      
 17 
     | 
    
         
            +
                
         
     | 
| 
      
 18 
     | 
    
         
            +
                if (request = Incline::current_request)
         
     | 
| 
      
 19 
     | 
    
         
            +
                  propagated_params.each do |k|
         
     | 
| 
      
 20 
     | 
    
         
            +
                    if request.params.key? k
         
     | 
| 
      
 21 
     | 
    
         
            +
                      options[:params] ||= {}
         
     | 
| 
      
 22 
     | 
    
         
            +
                      options[:params][k] = request.params[k]
         
     | 
| 
      
 23 
     | 
    
         
            +
                    end
         
     | 
| 
      
 24 
     | 
    
         
            +
                  end
         
     | 
| 
      
 25 
     | 
    
         
            +
                end
         
     | 
| 
      
 26 
     | 
    
         
            +
                
         
     | 
| 
      
 27 
     | 
    
         
            +
                path  = options[:script_name].to_s.chomp("/")
         
     | 
| 
      
 28 
     | 
    
         
            +
                path << options[:path] if options.key?(:path)
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
                add_trailing_slash(path) if options[:trailing_slash]
         
     | 
| 
      
 31 
     | 
    
         
            +
                add_params(path, options[:params]) if options.key?(:params)
         
     | 
| 
      
 32 
     | 
    
         
            +
                add_anchor(path, options[:anchor]) if options.key?(:anchor)
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
                path
         
     | 
| 
      
 35 
     | 
    
         
            +
              end
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
            end
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
    
        data/lib/incline/version.rb
    CHANGED
    
    
    
        data/test/incline_test.rb
    CHANGED
    
    | 
         @@ -34,6 +34,7 @@ class InclineTest < ActiveSupport::TestCase 
     | 
|
| 
       34 
34 
     | 
    
         
             
                assert Incline::Extensions.const_defined? :ConnectionAdapter
         
     | 
| 
       35 
35 
     | 
    
         
             
                assert Incline::Extensions.const_defined? :MainApp
         
     | 
| 
       36 
36 
     | 
    
         
             
                assert Incline::Extensions.const_defined? :ActionControllerBase
         
     | 
| 
      
 37 
     | 
    
         
            +
                assert Incline::Extensions.const_defined? :CurrentRequest
         
     | 
| 
       37 
38 
     | 
    
         
             
                assert Incline::Extensions.const_defined? :ActionMailerBase
         
     | 
| 
       38 
39 
     | 
    
         
             
                assert Incline::Extensions.const_defined? :ActionViewBase
         
     | 
| 
       39 
40 
     | 
    
         
             
                assert Incline::Extensions.const_defined? :Session
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: incline
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.2. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.2.13
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Beau Barker
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: exe
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2017-09- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2017-09-29 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: rails
         
     | 
| 
         @@ -427,6 +427,7 @@ files: 
     | 
|
| 
       427 
427 
     | 
    
         
             
            - lib/incline/extensions/application.rb
         
     | 
| 
       428 
428 
     | 
    
         
             
            - lib/incline/extensions/application_configuration.rb
         
     | 
| 
       429 
429 
     | 
    
         
             
            - lib/incline/extensions/connection_adapter.rb
         
     | 
| 
      
 430 
     | 
    
         
            +
            - lib/incline/extensions/current_request.rb
         
     | 
| 
       430 
431 
     | 
    
         
             
            - lib/incline/extensions/date_time_value.rb
         
     | 
| 
       431 
432 
     | 
    
         
             
            - lib/incline/extensions/date_value.rb
         
     | 
| 
       432 
433 
     | 
    
         
             
            - lib/incline/extensions/decimal_value.rb
         
     | 
| 
         @@ -439,6 +440,7 @@ files: 
     | 
|
| 
       439 
440 
     | 
    
         
             
            - lib/incline/extensions/main_app.rb
         
     | 
| 
       440 
441 
     | 
    
         
             
            - lib/incline/extensions/numeric.rb
         
     | 
| 
       441 
442 
     | 
    
         
             
            - lib/incline/extensions/object.rb
         
     | 
| 
      
 443 
     | 
    
         
            +
            - lib/incline/extensions/param_propagation.rb
         
     | 
| 
       442 
444 
     | 
    
         
             
            - lib/incline/extensions/resource_route_generator.rb
         
     | 
| 
       443 
445 
     | 
    
         
             
            - lib/incline/extensions/session.rb
         
     | 
| 
       444 
446 
     | 
    
         
             
            - lib/incline/extensions/string.rb
         
     |