-
Notifications
You must be signed in to change notification settings - Fork 1.4k
RFC/WIP: Looks at what AMS would be like as a mountable rails engine #1414
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| module ActiveModelSerializers | ||
| class ApplicationController < ActionController::API | ||
| end | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. consider |
||
| end | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| module ActiveModelSerializers | ||
| class ApplicationJob < ActiveJob::Base | ||
| end | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. rm |
||
| end | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| module ActiveModelSerializers | ||
| class ApplicationRecord < ActiveRecord::Base | ||
| self.abstract_class = true | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. rails 5! |
||
| end | ||
| end | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| #!/usr/bin/env ruby | ||
| # This command will automatically be run when you run "rails" with Rails 4 gems installed from the root of your application. | ||
|
|
||
| ENGINE_ROOT = File.expand_path('../..', __FILE__) | ||
| ENGINE_PATH = File.expand_path('../../lib/active_model_serializers/engine', __FILE__) | ||
|
|
||
| # Set up gems listed in the Gemfile. | ||
| ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) | ||
| require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE']) | ||
|
|
||
| require 'rails/all' | ||
| require 'rails/engine/commands' |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| # ActiveModelSerializers::Engine.routes.draw do | ||
| # end | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. consider |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,3 +29,4 @@ def self.config | |
| end | ||
|
|
||
| require 'active_model/serializer/railtie' | ||
| # require "active_model_serializers/engine" | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. engine or railtie.. hmm |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| module ActiveModelSerializers | ||
| class Engine < ::Rails::Engine | ||
| isolate_namespace ActiveModelSerializers | ||
| config.generators.api_only = true | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. rm |
||
| end | ||
| end | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| module ActiveModelSerializers | ||
| VERSION = '0.1.0' | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. mv? |
||
| end | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| # desc "Explaining what the task does" | ||
| # task :active_model_serializers do | ||
| # # Task goes here | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. rm? |
||
| # end | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| require 'test_helper' | ||
|
|
||
| class ActiveModelSerializers::Test < ActiveSupport::TestCase | ||
| test 'truth' do | ||
| assert_kind_of Module, ActiveModelSerializers | ||
| end | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. rm? |
||
| end | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| # Add your own tasks in files placed in lib/tasks ending in .rake, | ||
| # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. | ||
|
|
||
| require File.expand_path('../config/application', __FILE__) | ||
|
|
||
| Rails.application.load_tasks |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| class ApplicationController < ActionController::API | ||
| end |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| class ApplicationRecord < ActiveRecord::Base | ||
| self.abstract_class = true | ||
| end |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| #!/usr/bin/env ruby | ||
| ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) | ||
| load Gem.bin_path('bundler', 'bundle') |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| #!/usr/bin/env ruby | ||
| APP_PATH = File.expand_path('../../config/application', __FILE__) | ||
| require_relative '../config/boot' | ||
| require 'rails/commands' |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| #!/usr/bin/env ruby | ||
| require_relative '../config/boot' | ||
| require 'rake' | ||
| Rake.application.run |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| #!/usr/bin/env ruby | ||
| require 'pathname' | ||
| require 'fileutils' | ||
| include FileUtils | ||
|
|
||
| # path to your application root. | ||
| APP_ROOT = Pathname.new File.expand_path('../../', __FILE__) | ||
|
|
||
| def system!(*args) | ||
| system(*args) || abort("\n== Command #{args} failed ==") | ||
| end | ||
|
|
||
| chdir APP_ROOT do | ||
| # This script is a starting point to setup your application. | ||
| # Add necessary setup steps to this file. | ||
|
|
||
| puts '== Installing dependencies ==' | ||
| system! 'gem install bundler --conservative' | ||
| system('bundle check') or system!('bundle install') | ||
|
|
||
| # puts "\n== Copying sample files ==" | ||
| # unless File.exist?('config/database.yml') | ||
| # cp 'config/database.yml.sample', 'config/database.yml' | ||
| # end | ||
|
|
||
| puts "\n== Preparing database ==" | ||
| system! 'bin/rails db:setup' | ||
|
|
||
| puts "\n== Removing old logs and tempfiles ==" | ||
| system! 'bin/rails log:clear tmp:clear' | ||
|
|
||
| puts "\n== Restarting application server ==" | ||
| system! 'bin/rails restart' | ||
| end |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| #!/usr/bin/env ruby | ||
| require 'pathname' | ||
| require 'fileutils' | ||
| include FileUtils | ||
|
|
||
| # path to your application root. | ||
| APP_ROOT = Pathname.new File.expand_path('../../', __FILE__) | ||
|
|
||
| def system!(*args) | ||
| system(*args) || abort("\n== Command #{args} failed ==") | ||
| end | ||
|
|
||
| chdir APP_ROOT do | ||
| # This script is a way to update your development environment automatically. | ||
| # Add necessary update steps to this file. | ||
|
|
||
| puts '== Installing dependencies ==' | ||
| system! 'gem install bundler --conservative' | ||
| system 'bundle check' or system! 'bundle install' | ||
|
|
||
| puts "\n== Updating database ==" | ||
| system! 'bin/rails db:migrate' | ||
|
|
||
| puts "\n== Removing old logs and tempfiles ==" | ||
| system! 'bin/rails log:clear tmp:clear' | ||
|
|
||
| puts "\n== Restarting application server ==" | ||
| system! 'bin/rails restart' | ||
| end |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| # This file is used by Rack-based servers to start the application. | ||
|
|
||
| require ::File.expand_path('../config/environment', __FILE__) | ||
|
|
||
| # Action Cable uses EventMachine which requires that all classes are loaded in advance | ||
| Rails.application.eager_load! | ||
| require 'action_cable/process/logging' | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. rm |
||
|
|
||
| run Rails.application | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| require File.expand_path('../boot', __FILE__) | ||
|
|
||
| # Pick the frameworks you want: | ||
| require 'active_record/railtie' | ||
| require 'action_controller/railtie' | ||
| require 'rails/test_unit/railtie' | ||
|
|
||
| Bundler.require(*Rails.groups) | ||
| require 'active_model_serializers' | ||
|
|
||
| module Dummy | ||
| class Application < Rails::Application | ||
| # Settings in config/environments/* take precedence over those specified here. | ||
| # Application configuration should go into files in config/initializers | ||
| # -- all .rb files in that directory are automatically loaded. | ||
|
|
||
| # Only loads a smaller set of middleware suitable for API only apps. | ||
| # Middleware like session, flash, cookies can be added back manually. | ||
| # Skip views, helpers and assets when generating a new resource. | ||
| config.api_only = true | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. rm :( |
||
| end | ||
| end | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| # Set up gems listed in the Gemfile. | ||
| ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../../Gemfile', __FILE__) | ||
|
|
||
| require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE']) | ||
| $LOAD_PATH.unshift File.expand_path('../../../../lib', __FILE__) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| # SQLite version 3.x | ||
| # gem install sqlite3 | ||
| # | ||
| # Ensure the SQLite 3 gem is defined in your Gemfile | ||
| # gem 'sqlite3' | ||
| # | ||
| default: &default | ||
| adapter: sqlite3 | ||
| pool: 5 | ||
| timeout: 5000 | ||
|
|
||
| development: | ||
| <<: *default | ||
| database: db/development.sqlite3 | ||
|
|
||
| # Warning: The database defined as "test" will be erased and | ||
| # re-generated from your development database when you run "rake". | ||
| # Do not set this db to the same as development or production. | ||
| test: | ||
| <<: *default | ||
| database: db/test.sqlite3 | ||
|
|
||
| production: | ||
| <<: *default | ||
| database: db/production.sqlite3 | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. rm |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| # Load the Rails application. | ||
| require File.expand_path('../application', __FILE__) | ||
|
|
||
| # Initialize the Rails application. | ||
| Rails.application.initialize! |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| Rails.application.configure do | ||
| # Settings specified here will take precedence over those in config/application.rb. | ||
|
|
||
| # In the development environment your application's code is reloaded on | ||
| # every request. This slows down response time but is perfect for development | ||
| # since you don't have to restart the web server when you make code changes. | ||
| config.cache_classes = false | ||
|
|
||
| # Do not eager load code on boot. | ||
| config.eager_load = false | ||
|
|
||
| # Show full error reports. | ||
| config.consider_all_requests_local = true | ||
|
|
||
| # Enable/disable caching. By default caching is disabled. | ||
| if Rails.root.join('tmp/caching-dev.txt').exist? | ||
| config.action_controller.perform_caching = true | ||
| config.cache_store = :memory_store | ||
| config.public_file_server.headers = { | ||
| 'Cache-Control' => 'public, max-age=172800' | ||
| } | ||
| else | ||
| config.action_controller.perform_caching = false | ||
| config.cache_store = :null_store | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. neato |
||
| end | ||
|
|
||
| # Don't care if the mailer can't send. | ||
| config.action_mailer.raise_delivery_errors = false | ||
|
|
||
| # Print deprecation notices to the Rails logger. | ||
| config.active_support.deprecation = :log | ||
|
|
||
| # Raise an error on page load if there are pending migrations. | ||
| config.active_record.migration_error = :page_load | ||
|
|
||
| # Raises error for missing translations | ||
| # config.action_view.raise_on_missing_translations = true | ||
|
|
||
| # Use an evented file watcher to asynchronously detect changes in source code, | ||
| # routes, locales, etc. This feature depends on the listen gem. | ||
| # config.file_watcher = ActiveSupport::EventedFileUpdateChecker | ||
| end | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yard of course