Skip to content
This repository was archived by the owner on Feb 29, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
380 changes: 65 additions & 315 deletions pathfinder.rb

Large diffs are not rendered by default.

21 changes: 21 additions & 0 deletions recipes/airbrake.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
module Recipes
class Airbrake < Base

def gems
@template.gem 'airbrake'
end

def init_file
@template.initializer 'airbrake.rb', <<-CODE
Airbrake.configure do |config|
config.api_key = ENV['AIRBRAKE_API_KEY']
end
CODE

@template.inside 'config' do
@template.append_file 'application.yml.example', "\nAIRBRAKE_API_KEY: ''"
@template.append_file 'application.yml', "\nAIRBRAKE_API_KEY: ''"
end
end
end
end
19 changes: 19 additions & 0 deletions recipes/assets.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
module Recipes
class Assets < Base

def gems
# Assets
@template.gem 'bootstrap-sass', '~> 3.3.3'
@template.gem 'bootstrap-datepicker-rails', '~> 1.6.0' if @template.yes?("Do you want to use Bootstrap datepicker?")
@template.gem 'font-awesome-sass', '~> 4.3.0'
@template.gem 'sass-rails', '~> 5.0'
@template.gem 'modernizr-rails'
@template.gem 'autoprefixer-rails'
@template.gem 'compass-rails', '~> 3.0.1'
@template.gem 'magnific-popup-rails'
@template.gem 'jquery-rails'
@template.gem 'uglifier', '>= 1.3.0'
@template.gem 'sdoc', '~> 0.4.0', group: :doc
end
end
end
15 changes: 15 additions & 0 deletions recipes/base.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module Recipes
class Base

def initialize(pathfinder)
@pathfinder = pathfinder
@template = pathfinder.template
end

def gems
end

def init_file
end
end
end
44 changes: 44 additions & 0 deletions recipes/bower_rails.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
module Recipes
class BowerRails < Base

def gems
@template.gem 'bower-rails'
end

def init_file
@template.run 'rails g bower_rails:initialize json'
@template.remove_file 'bower.json'
@template.create_file 'bower.json' do <<-TEXT
{
"lib": {
"name": "bower-rails generated lib assets",
"dependencies": { }
},
"vendor": {
"name": "bower-rails generated vendor assets",
"dependencies": {
TEXT
end


packages = resources.map { |package, version| "\"#{package}\": \"#{version}\"" }
.join(",\n")

@template.append_file 'bower.json', "#{packages}\n" unless packages.empty?
@template.append_file 'bower.json' do <<-TEXT
}
}
}
TEXT
end
@template.rake 'bower:install'
@template.rake 'bower:resolve'
end

private

def resources
[['select2', '4.0.3'], ['lodash', '4.16.6']]
end
end
end
39 changes: 39 additions & 0 deletions recipes/carrier_wave.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
module Recipes
class CarrierWave < Base

def gems
@template.gem 'carrierwave'
@template.gem 'fog-aws'
@template.gem 'mini_magick' if @template.yes?("Are you going to handle images with CarrierWave?")
end

def init_file
@template.initializer 'carrierwave.rb', <<-CODE
require 'carrierwave/storage/fog'
CarrierWave.configure do |config|
config.fog_provider = 'fog/aws'
config.fog_directory = ENV['AWS_S3_BUCKET']
config.fog_public = true
config.storage = :fog
config.cache_dir = Rails.root.join('tmp/cache')

config.fog_credentials = {
provider: 'AWS',
aws_access_key_id: ENV['AWS_ACCESS_KEY'],
aws_secret_access_key: ENV['AWS_SECRET_KEY'],
region: 'eu-west-1'
}
end
CODE

@template.inside 'config' do
@template.append_file 'application.yml.example', "\nAWS_ACCESS_KEY: ''"
@template.append_file 'application.yml', "\nAWS_ACCESS_KEY: ''"
@template.append_file 'application.yml.example', "\nAWS_SECRET_KEY: ''"
@template.append_file 'application.yml', "\nAWS_SECRET_KEY: ''"
@template.append_file 'application.yml.example', "\nAWS_S3_BUCKET: ''"
@template.append_file 'application.yml', "\nAWS_S3_BUCKET: ''"
end
end
end
end
21 changes: 21 additions & 0 deletions recipes/devise.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
module Recipes
class Devise < Base

def gems
@template.gem 'devise'
end

def init_file
@template.generate 'devise:install'
@template.insert_into_file 'config/environments/development.rb', after: "Rails.application.configure do\n" do <<-RUBY
config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
config.action_controller.asset_host = 'http://localhost:3000'
config.action_mailer.asset_host = 'http://localhost:3000'
config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = { address: 'localhost', port: 1025 }
RUBY
end
end
end
end
35 changes: 35 additions & 0 deletions recipes/git_ignore.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
module Recipes
class GitIgnore < Base

def init_file
@template.remove_file '.gitignore'
@template.create_file '.gitignore' do <<-EOF
!/log/.keep
*.rdb
.bundle
config/application.yml
config/database.yml
config/secrets.yml
config/secrets.*.yml
log/*
public/assets
public/uploads
tmp
.DS_Store
*.sublime-*
.rvmrc
stellar.yml
.rubocop.yml

# Ignore generated coverage
/coverage

# Bower stuff
vendor/assets/.bowerrc
vendor/assets/bower.json
vendor/assets/bower_components
EOF
end
end
end
end
45 changes: 45 additions & 0 deletions recipes/postgres.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
module Recipes
class Postgres < Base

def gems
@template.gem 'pg'
end

def init_file
@template.inside 'config' do
@template.remove_file 'database.yml'
@template.create_file 'database.yml' do <<-EOF
default: &default
adapter: postgresql
encoding: unicode
pool: 5

development:
<<: *default
database: #{@pathfinder.app_name}_development

staging:
<<: *default
database: #{@pathfinder.app_name}_staging
username: #{@pathfinder.app_name}
password: <%= ENV['#{@pathfinder.app_name.upcase}_DATABASE_PASSWORD'] %>

test:
<<: *default
database: #{@pathfinder.app_name}_test

production:
<<: *default
database: #{@pathfinder.app_name}_production
username: #{@pathfinder.app_name}
password: <%= ENV['#{@pathfinder.app_name.upcase}_DATABASE_PASSWORD'] %>

EOF
end
@template.append_file 'application.yml.example', "\n#{@pathfinder.app_name.upcase}_DATABASE_PASSWORD: ''"
@template.append_file 'application.yml', "\n#{@pathfinder.app_name.upcase}_DATABASE_PASSWORD: ''"
end
@template.rake 'db:create'
end
end
end
16 changes: 16 additions & 0 deletions recipes/pundit.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module Recipes
class Pundit < Base

def gems
@template.gem 'pundit'
end

def init_file
@template.generate 'pundit:install'
@template.insert_into_file 'app/controllers/application_controller.rb', after: "class ApplicationController < ActionController::Base\n" do <<-RUBY
include Pundit
RUBY
end
end
end
end
24 changes: 24 additions & 0 deletions recipes/redis.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
module Recipes
class Redis < Base

def init_file
@template.initializer 'redis.rb', <<-CODE
Redis.current = Redis.new(Rails.application.config_for(:redis))
CODE

@template.inside 'config' do
@template.create_file 'redis.yml' do <<-EOF
default: &default
host: localhost
port: 6379

development:
<<: *default
test:
<<: *default
EOF
end
end
end
end
end
29 changes: 29 additions & 0 deletions recipes/rollbar.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
module Recipes
class Rollbar < Base

def gems
@template.gem 'rollbar'
end

def init_file
@template.initializer 'rollbar.rb', <<-CODE
Rollbar.configure do |config|
config.access_token = ENV['ROLLBAR_ACCESS_TOKEN']
config.environment = ENV['ROLLBAR_ENV'] || Rails.env
config.exception_level_filters.merge!(
'ActionController::RoutingError': 'ignore'
)

if Rails.env.test? || Rails.env.development?
config.enabled = false
end
end
CODE

@template.inside 'config' do
@template.append_file 'application.yml.example', "\nROLLBAR_ACCESS_TOKEN: ''"
@template.append_file 'application.yml', "\nROLLBAR_ACCESS_TOKEN: ''"
end
end
end
end
51 changes: 51 additions & 0 deletions recipes/sidekiq.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
module Recipes
class Sidekiq < Base

def init_file
@template.initializer 'sidekiq.rb', <<-CODE
redis_host = Redis.current.client.host
redis_port = Redis.current.client.port

Sidekiq.configure_server do |config|
config.redis = { url: "redis://\#{redis_host}:\#{redis_port}" }
end

Sidekiq.configure_client do |config|
config.redis = { url: "redis://\#{redis_host}:\#{redis_port}" }
end
CODE

@template.inside 'config' do
@template.create_file 'sidekiq.yml' do <<-EOF
---
:concurrency: 5
:pidfile: tmp/pids/sidekiq.pid
staging:
:concurrency: 10
production:
:concurrency: 20
:queues:
- [default, 10]
- [mailers, 10]
EOF
end
end

@template.insert_into_file 'config/routes.rb', before: "Rails.application.routes.draw do\n" do <<-RUBY
require 'sidekiq/web'
RUBY
end

@template.insert_into_file 'config/routes.rb', after: "Rails.application.routes.draw do\n" do <<-RUBY
namespace :admin do
authenticate :user, lambda { |u| u.admin? } do
mount Sidekiq::Web => '/sidekiq'
end
end
get '/404', to: 'errors#not_found'
get '/500', to: 'errors#internal_error'
RUBY
end
end
end
end
13 changes: 13 additions & 0 deletions recipes/simple_form.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module Recipes
class SimpleForm < Base

def gems
# Forms
@template.gem 'simple_form'
end

def init_file
@template.generate 'simple_form:install'
end
end
end
14 changes: 14 additions & 0 deletions recipes/utils.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module Recipes
class Utils

def initialize(template)
@template = template
end

def ask_with_default(question, default:)
answer = @template.ask("#{question} (Default #{default})")
answer.empty? ? default : answer
end

end
end
Loading