Sha256: 1f8efd1850ff5280236240719205ab1dfd1d909910430f1715b6ba6d1f130d8b

Contents?: true

Size: 948 Bytes

Versions: 4

Compression:

Stored size: 948 Bytes

Contents

require 'front_end_builds/routing_constraints/html_routing_constraint'

module ActionDispatch::Routing
  class Mapper

    # Create a front end in your rails router.
    def front_end(name, path = name, options = {})

      # Generic routes that have nothing to do with the app
      # name. Use this for testing or providing a non
      # app api endpoint.
      namespace :front_end_builds do
        resources :builds, only: [:index, :create]
      end

      # Create a new build for this app.
      post(
        "#{path}" => "front_end_builds/builds#create",
        defaults: {
          app_name: name
        }
      )

      # Get a build for this app.
      constraints FrontEndBuilds::HtmlRoutingConstraint.new do
        get(
          "/#{path}/(*path)" => "front_end_builds/builds#index",
          defaults: {
            branch: :master,
            app_name: name
          }.merge(options)
        )
      end
    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
front_end_builds-0.0.5 lib/front_end_builds/ext/routes.rb
front_end_builds-0.0.4 lib/front_end_builds/ext/routes.rb
front_end_builds-0.0.3 lib/front_end_builds/ext/routes.rb
front_end_builds-0.0.2 lib/front_end_builds/ext/routes.rb