trailblazer-rails 2.2.0 → 2.3.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/CHANGES.md +3 -0
- data/README.md +2 -3
- data/Rakefile +5 -4
- data/gemfiles/rails_5.2.gemfile.lock +1 -1
- data/gemfiles/rails_6.0.gemfile.lock +1 -1
- data/gemfiles/rails_6.1.gemfile.lock +1 -1
- data/gemfiles/rails_7.0.gemfile.lock +1 -1
- data/lib/trailblazer/rails/cell.rb +0 -2
- data/lib/trailblazer/rails/railtie.rb +16 -6
- data/lib/trailblazer/rails/version.rb +1 -1
- data/trailblazer-rails.gemspec +0 -1
- metadata +2 -19
- data/lib/trailblazer/operation/responder.rb +0 -18
- data/lib/trailblazer/rails/railtie/extend_application_controller.rb +0 -28
- data/lib/trailblazer/rails/railtie/loader.rb +0 -58
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: e43931b1874b64a31a8a64c738d6568a213c3fa4d796f4dd28d93b894f3c928a
         | 
| 4 | 
            +
              data.tar.gz: d51bde81af75fcd5fead6b78a2e27b1caddbd1e0b86bf575a139784fd92bd306
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 430cc9f51fe61f924a9d82581ddbcd00343a7b70956e85f82da8cd4a31577e95533f887ab13889a947982957ccebdcca31e1402414886dcb1c5e775ab0fe8421
         | 
| 7 | 
            +
              data.tar.gz: 65c5490e4030fb7638e3cab85d3d7e1a1f7a320e85f5f84cf884f622ce945b86738e34819b835bf883801afe09bb7773aa33d4a399d0a9e5db62d6cd6addb700
         | 
    
        data/CHANGES.md
    CHANGED
    
    
    
        data/README.md
    CHANGED
    
    | @@ -2,10 +2,9 @@ | |
| 2 2 |  | 
| 3 3 | 
             
            *Trailblazer in your Rails controllers.*
         | 
| 4 4 |  | 
| 5 | 
            -
            [](https://gitter.im/trailblazer/chat)
         | 
| 6 5 | 
             
            [](http://trailblazer.to/newsletter/)
         | 
| 7 | 
            -
             | 
| 8 | 
            -
            Status](https:// | 
| 6 | 
            +
            
         | 
| 9 8 | 
             
            [](http://badge.fury.io/rb/trailblazer-rails)
         | 
| 10 9 |  | 
| 11 10 | 
             
            ## Endpoint
         | 
    
        data/Rakefile
    CHANGED
    
    | @@ -8,10 +8,11 @@ Rake::TestTask.new(:test) do |t| | |
| 8 8 | 
             
              t.test_files = FileList["test/**/*_test.rb"]
         | 
| 9 9 | 
             
            end
         | 
| 10 10 |  | 
| 11 | 
            -
             | 
| 12 | 
            -
            require File.expand_path("test/dummy/config/application", __dir__)
         | 
| 13 | 
            -
             | 
| 14 | 
            -
             | 
| 11 | 
            +
            begin
         | 
| 12 | 
            +
              require File.expand_path("test/dummy/config/application", __dir__)
         | 
| 13 | 
            +
              Rails.application.load_tasks
         | 
| 14 | 
            +
            rescue LoadError
         | 
| 15 | 
            +
            end
         | 
| 15 16 |  | 
| 16 17 | 
             
            desc "Running Tests"
         | 
| 17 18 | 
             
            task default: :test
         | 
| @@ -1,17 +1,27 @@ | |
| 1 1 | 
             
            require "rails/railtie"
         | 
| 2 | 
            -
            require "trailblazer/loader"
         | 
| 3 | 
            -
            require "trailblazer/rails/railtie/extend_application_controller"
         | 
| 4 | 
            -
            require "trailblazer/rails/railtie/loader"
         | 
| 5 2 |  | 
| 6 3 | 
             
            module Trailblazer
         | 
| 7 4 | 
             
              class Railtie < ::Rails::Railtie
         | 
| 8 5 | 
             
                config.trailblazer = ActiveSupport::OrderedOptions.new
         | 
| 9 6 | 
             
                ## Accept also an Array of controllers
         | 
| 10 7 | 
             
                config.trailblazer.application_controller ||= "ActionController::Base"
         | 
| 11 | 
            -
                config.trailblazer.enable_loader ||= true
         | 
| 12 8 | 
             
                config.trailblazer.enable_tracing ||= false
         | 
| 13 9 |  | 
| 14 | 
            -
                 | 
| 15 | 
            -
             | 
| 10 | 
            +
                initializer "trailblazer.application_controller", before: "finisher_hook" do
         | 
| 11 | 
            +
                  ActiveSupport::Reloader.to_prepare do
         | 
| 12 | 
            +
                    ActiveSupport.on_load(:action_controller) do |app|
         | 
| 13 | 
            +
                      Trailblazer::Railtie.extend_application_controller!(app)
         | 
| 14 | 
            +
                    end
         | 
| 15 | 
            +
                  end
         | 
| 16 | 
            +
                end
         | 
| 17 | 
            +
             | 
| 18 | 
            +
                def extend_application_controller!(app)
         | 
| 19 | 
            +
                  controllers = Array(::Rails.application.config.trailblazer.application_controller).map(&:to_s)
         | 
| 20 | 
            +
                  if controllers.include? app.to_s
         | 
| 21 | 
            +
                    app.send :include, Trailblazer::Rails::Controller
         | 
| 22 | 
            +
                    app.send :include, Trailblazer::Rails::Controller::Cell if defined?(::Cell)
         | 
| 23 | 
            +
                  end
         | 
| 24 | 
            +
                  app
         | 
| 25 | 
            +
                end
         | 
| 16 26 | 
             
              end
         | 
| 17 27 | 
             
            end
         | 
    
        data/trailblazer-rails.gemspec
    CHANGED
    
    | @@ -18,7 +18,6 @@ Gem::Specification.new do |spec| | |
| 18 18 | 
             
              spec.add_dependency "railties", ">= 5.2.0"
         | 
| 19 19 | 
             
              spec.add_dependency "trailblazer", ">= 2.1.0", "< 2.2.0"
         | 
| 20 20 |  | 
| 21 | 
            -
              spec.add_development_dependency "trailblazer-loader", ">= 0.1.0"
         | 
| 22 21 | 
             
              spec.add_development_dependency "bundler"
         | 
| 23 22 | 
             
              spec.add_development_dependency "minitest"
         | 
| 24 23 | 
             
              spec.add_development_dependency "rake"
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: trailblazer-rails
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 2. | 
| 4 | 
            +
              version: 2.3.0
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Nick Sutterer
         | 
| 8 8 | 
             
            autorequire:
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2021-12- | 
| 11 | 
            +
            date: 2021-12-13 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: railties
         | 
| @@ -44,20 +44,6 @@ dependencies: | |
| 44 44 | 
             
                - - "<"
         | 
| 45 45 | 
             
                  - !ruby/object:Gem::Version
         | 
| 46 46 | 
             
                    version: 2.2.0
         | 
| 47 | 
            -
            - !ruby/object:Gem::Dependency
         | 
| 48 | 
            -
              name: trailblazer-loader
         | 
| 49 | 
            -
              requirement: !ruby/object:Gem::Requirement
         | 
| 50 | 
            -
                requirements:
         | 
| 51 | 
            -
                - - ">="
         | 
| 52 | 
            -
                  - !ruby/object:Gem::Version
         | 
| 53 | 
            -
                    version: 0.1.0
         | 
| 54 | 
            -
              type: :development
         | 
| 55 | 
            -
              prerelease: false
         | 
| 56 | 
            -
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 57 | 
            -
                requirements:
         | 
| 58 | 
            -
                - - ">="
         | 
| 59 | 
            -
                  - !ruby/object:Gem::Version
         | 
| 60 | 
            -
                    version: 0.1.0
         | 
| 61 47 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 62 48 | 
             
              name: bundler
         | 
| 63 49 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| @@ -124,14 +110,11 @@ files: | |
| 124 110 | 
             
            - gemfiles/rails_7.0.gemfile
         | 
| 125 111 | 
             
            - gemfiles/rails_7.0.gemfile.lock
         | 
| 126 112 | 
             
            - lib/trailblazer-rails.rb
         | 
| 127 | 
            -
            - lib/trailblazer/operation/responder.rb
         | 
| 128 113 | 
             
            - lib/trailblazer/rails.rb
         | 
| 129 114 | 
             
            - lib/trailblazer/rails/cell.rb
         | 
| 130 115 | 
             
            - lib/trailblazer/rails/controller.rb
         | 
| 131 116 | 
             
            - lib/trailblazer/rails/form.rb
         | 
| 132 117 | 
             
            - lib/trailblazer/rails/railtie.rb
         | 
| 133 | 
            -
            - lib/trailblazer/rails/railtie/extend_application_controller.rb
         | 
| 134 | 
            -
            - lib/trailblazer/rails/railtie/loader.rb
         | 
| 135 118 | 
             
            - lib/trailblazer/rails/version.rb
         | 
| 136 119 | 
             
            - trailblazer-rails.gemspec
         | 
| 137 120 | 
             
            homepage: https://trailblazer.to/2.1/docs/trailblazer.html#trailblazer-rails
         | 
| @@ -1,18 +0,0 @@ | |
| 1 | 
            -
            module Trailblazer::Operation::Responder
         | 
| 2 | 
            -
              def self.included(base)
         | 
| 3 | 
            -
                base.extend ClassMethods
         | 
| 4 | 
            -
              end
         | 
| 5 | 
            -
             | 
| 6 | 
            -
              module ClassMethods
         | 
| 7 | 
            -
                def model_name
         | 
| 8 | 
            -
                  model_class.model_name
         | 
| 9 | 
            -
                end
         | 
| 10 | 
            -
              end
         | 
| 11 | 
            -
             | 
| 12 | 
            -
              extend Forwardable
         | 
| 13 | 
            -
              def_delegators :@model, :to_param, :destroyed?, :persisted?
         | 
| 14 | 
            -
             | 
| 15 | 
            -
              def to_model
         | 
| 16 | 
            -
                @model
         | 
| 17 | 
            -
              end
         | 
| 18 | 
            -
            end
         | 
| @@ -1,28 +0,0 @@ | |
| 1 | 
            -
            require "active_support/concern"
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            module Trailblazer
         | 
| 4 | 
            -
              class Railtie < ::Rails::Railtie
         | 
| 5 | 
            -
                module ExtendApplicationController
         | 
| 6 | 
            -
                  extend ActiveSupport::Concern
         | 
| 7 | 
            -
             | 
| 8 | 
            -
                  included do
         | 
| 9 | 
            -
                    initializer "trailblazer.application_controller", before: "finisher_hook" do
         | 
| 10 | 
            -
                      ActiveSupport::Reloader.to_prepare do
         | 
| 11 | 
            -
                        ActiveSupport.on_load(:action_controller) do |app|
         | 
| 12 | 
            -
                          Trailblazer::Railtie.extend_application_controller!(app)
         | 
| 13 | 
            -
                        end
         | 
| 14 | 
            -
                      end
         | 
| 15 | 
            -
                    end
         | 
| 16 | 
            -
             | 
| 17 | 
            -
                    def extend_application_controller!(app)
         | 
| 18 | 
            -
                      controllers = Array(::Rails.application.config.trailblazer.application_controller).map(&:to_s)
         | 
| 19 | 
            -
                      if controllers.include? app.to_s
         | 
| 20 | 
            -
                        app.send :include, Trailblazer::Rails::Controller
         | 
| 21 | 
            -
                        app.send :include, Trailblazer::Rails::Controller::Cell if defined?(::Cell)
         | 
| 22 | 
            -
                      end
         | 
| 23 | 
            -
                      app
         | 
| 24 | 
            -
                    end
         | 
| 25 | 
            -
                  end
         | 
| 26 | 
            -
                end
         | 
| 27 | 
            -
              end
         | 
| 28 | 
            -
            end
         | 
| @@ -1,58 +0,0 @@ | |
| 1 | 
            -
            require "active_support/concern"
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            module Trailblazer
         | 
| 4 | 
            -
              class Railtie < ::Rails::Railtie
         | 
| 5 | 
            -
                module Loader
         | 
| 6 | 
            -
                  extend ActiveSupport::Concern
         | 
| 7 | 
            -
             | 
| 8 | 
            -
                  included do
         | 
| 9 | 
            -
                    def self.load_concepts(app)
         | 
| 10 | 
            -
                      load_for(app)
         | 
| 11 | 
            -
             | 
| 12 | 
            -
                      engines.each { |engine| load_for(engine) }
         | 
| 13 | 
            -
                    end
         | 
| 14 | 
            -
             | 
| 15 | 
            -
                    def self.engines
         | 
| 16 | 
            -
                      ::Rails.application.railties.select { |tie| tie.is_a?(::Rails::Engine) }
         | 
| 17 | 
            -
                    end
         | 
| 18 | 
            -
             | 
| 19 | 
            -
                    def self.load_for(app)
         | 
| 20 | 
            -
                      Trailblazer::Loader.new.(prepend: AllModelFiles, root: app.root) { |file| require_dependency(file) }
         | 
| 21 | 
            -
                    end
         | 
| 22 | 
            -
             | 
| 23 | 
            -
                    # Prepend model file, before the concept files like operation.rb get loaded.
         | 
| 24 | 
            -
                    ModelFile = ->(input, options) do
         | 
| 25 | 
            -
                      model = "app/models/#{options[:name]}.rb"
         | 
| 26 | 
            -
                      File.exist?(model) ? [model] + input : input
         | 
| 27 | 
            -
                    end
         | 
| 28 | 
            -
             | 
| 29 | 
            -
                    # Load all model files before any TRB files.
         | 
| 30 | 
            -
                    AllModelFiles = ->(input, options) do
         | 
| 31 | 
            -
                      Dir.glob("#{options[:root]}/app/models/**/*.rb").sort + input
         | 
| 32 | 
            -
                    end
         | 
| 33 | 
            -
             | 
| 34 | 
            -
                    # This is to autoload Operation::Dispatch, etc. I'm simply assuming people find this helpful in Rails.
         | 
| 35 | 
            -
                    initializer "trailblazer.library_autoloading" do
         | 
| 36 | 
            -
                    end
         | 
| 37 | 
            -
             | 
| 38 | 
            -
                    # thank you, http://stackoverflow.com/a/17573888/465070
         | 
| 39 | 
            -
                    initializer "trailblazer.install", after: "reform.form_extensions" do |app|
         | 
| 40 | 
            -
                      # the trb autoloading has to be run after initializers have been loaded, so we can tweak inclusion of features in
         | 
| 41 | 
            -
                      # initializers.
         | 
| 42 | 
            -
             | 
| 43 | 
            -
                      # TODO: remove me in v2.2.0
         | 
| 44 | 
            -
                      if config.trailblazer.use_loader.to_s.present?
         | 
| 45 | 
            -
                        warn "DEPRECATION WARNING [trailblazer-rails]: please use config.trailblazer.enable_loader" \
         | 
| 46 | 
            -
                             " to enable/disable the loader, config.trailblazer.use_loader will be removed from version 2.2.0"
         | 
| 47 | 
            -
                      end
         | 
| 48 | 
            -
             | 
| 49 | 
            -
                      if config.trailblazer.enable_loader || config.trailblazer.use_loader
         | 
| 50 | 
            -
                        ActiveSupport::Reloader.to_prepare do
         | 
| 51 | 
            -
                          Trailblazer::Railtie.load_concepts(app)
         | 
| 52 | 
            -
                        end
         | 
| 53 | 
            -
                      end
         | 
| 54 | 
            -
                    end
         | 
| 55 | 
            -
                  end
         | 
| 56 | 
            -
                end
         | 
| 57 | 
            -
              end
         | 
| 58 | 
            -
            end
         |