Skip to content
This repository was archived by the owner on Feb 29, 2024. It is now read-only.

Commit 9723daa

Browse files
authored
Splitted resources into differente recipes (#20)
* Splitted resources into differente recipes
1 parent 7a7ff6e commit 9723daa

File tree

17 files changed

+452
-328
lines changed

17 files changed

+452
-328
lines changed

pathfinder.rb

Lines changed: 65 additions & 315 deletions
Large diffs are not rendered by default.

recipes/airbrake.rb

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
module Recipes
2+
class Airbrake < Base
3+
4+
def gems
5+
@template.gem 'airbrake'
6+
end
7+
8+
def init_file
9+
@template.initializer 'airbrake.rb', <<-CODE
10+
Airbrake.configure do |config|
11+
config.api_key = ENV['AIRBRAKE_API_KEY']
12+
end
13+
CODE
14+
15+
@template.inside 'config' do
16+
@template.append_file 'application.yml.example', "\nAIRBRAKE_API_KEY: ''"
17+
@template.append_file 'application.yml', "\nAIRBRAKE_API_KEY: ''"
18+
end
19+
end
20+
end
21+
end

recipes/assets.rb

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
module Recipes
2+
class Assets < Base
3+
4+
def gems
5+
# Assets
6+
@template.gem 'bootstrap-sass', '~> 3.3.3'
7+
@template.gem 'bootstrap-datepicker-rails', '~> 1.6.0' if @template.yes?("Do you want to use Bootstrap datepicker?")
8+
@template.gem 'font-awesome-sass', '~> 4.3.0'
9+
@template.gem 'sass-rails', '~> 5.0'
10+
@template.gem 'modernizr-rails'
11+
@template.gem 'autoprefixer-rails'
12+
@template.gem 'compass-rails', '~> 3.0.1'
13+
@template.gem 'magnific-popup-rails'
14+
@template.gem 'jquery-rails'
15+
@template.gem 'uglifier', '>= 1.3.0'
16+
@template.gem 'sdoc', '~> 0.4.0', group: :doc
17+
end
18+
end
19+
end

recipes/base.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
module Recipes
2+
class Base
3+
4+
def initialize(pathfinder)
5+
@pathfinder = pathfinder
6+
@template = pathfinder.template
7+
end
8+
9+
def gems
10+
end
11+
12+
def init_file
13+
end
14+
end
15+
end

recipes/bower_rails.rb

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
module Recipes
2+
class BowerRails < Base
3+
4+
def gems
5+
@template.gem 'bower-rails'
6+
end
7+
8+
def init_file
9+
@template.run 'rails g bower_rails:initialize json'
10+
@template.remove_file 'bower.json'
11+
@template.create_file 'bower.json' do <<-TEXT
12+
{
13+
"lib": {
14+
"name": "bower-rails generated lib assets",
15+
"dependencies": { }
16+
},
17+
"vendor": {
18+
"name": "bower-rails generated vendor assets",
19+
"dependencies": {
20+
TEXT
21+
end
22+
23+
24+
packages = resources.map { |package, version| "\"#{package}\": \"#{version}\"" }
25+
.join(",\n")
26+
27+
@template.append_file 'bower.json', "#{packages}\n" unless packages.empty?
28+
@template.append_file 'bower.json' do <<-TEXT
29+
}
30+
}
31+
}
32+
TEXT
33+
end
34+
@template.rake 'bower:install'
35+
@template.rake 'bower:resolve'
36+
end
37+
38+
private
39+
40+
def resources
41+
[['select2', '4.0.3'], ['lodash', '4.16.6']]
42+
end
43+
end
44+
end

recipes/carrier_wave.rb

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
module Recipes
2+
class CarrierWave < Base
3+
4+
def gems
5+
@template.gem 'carrierwave'
6+
@template.gem 'fog-aws'
7+
@template.gem 'mini_magick' if @template.yes?("Are you going to handle images with CarrierWave?")
8+
end
9+
10+
def init_file
11+
@template.initializer 'carrierwave.rb', <<-CODE
12+
require 'carrierwave/storage/fog'
13+
CarrierWave.configure do |config|
14+
config.fog_provider = 'fog/aws'
15+
config.fog_directory = ENV['AWS_S3_BUCKET']
16+
config.fog_public = true
17+
config.storage = :fog
18+
config.cache_dir = Rails.root.join('tmp/cache')
19+
20+
config.fog_credentials = {
21+
provider: 'AWS',
22+
aws_access_key_id: ENV['AWS_ACCESS_KEY'],
23+
aws_secret_access_key: ENV['AWS_SECRET_KEY'],
24+
region: 'eu-west-1'
25+
}
26+
end
27+
CODE
28+
29+
@template.inside 'config' do
30+
@template.append_file 'application.yml.example', "\nAWS_ACCESS_KEY: ''"
31+
@template.append_file 'application.yml', "\nAWS_ACCESS_KEY: ''"
32+
@template.append_file 'application.yml.example', "\nAWS_SECRET_KEY: ''"
33+
@template.append_file 'application.yml', "\nAWS_SECRET_KEY: ''"
34+
@template.append_file 'application.yml.example', "\nAWS_S3_BUCKET: ''"
35+
@template.append_file 'application.yml', "\nAWS_S3_BUCKET: ''"
36+
end
37+
end
38+
end
39+
end

recipes/devise.rb

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
module Recipes
2+
class Devise < Base
3+
4+
def gems
5+
@template.gem 'devise'
6+
end
7+
8+
def init_file
9+
@template.generate 'devise:install'
10+
@template.insert_into_file 'config/environments/development.rb', after: "Rails.application.configure do\n" do <<-RUBY
11+
config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
12+
config.action_controller.asset_host = 'http://localhost:3000'
13+
config.action_mailer.asset_host = 'http://localhost:3000'
14+
config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
15+
config.action_mailer.delivery_method = :smtp
16+
config.action_mailer.smtp_settings = { address: 'localhost', port: 1025 }
17+
RUBY
18+
end
19+
end
20+
end
21+
end

recipes/git_ignore.rb

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
module Recipes
2+
class GitIgnore < Base
3+
4+
def init_file
5+
@template.remove_file '.gitignore'
6+
@template.create_file '.gitignore' do <<-EOF
7+
!/log/.keep
8+
*.rdb
9+
.bundle
10+
config/application.yml
11+
config/database.yml
12+
config/secrets.yml
13+
config/secrets.*.yml
14+
log/*
15+
public/assets
16+
public/uploads
17+
tmp
18+
.DS_Store
19+
*.sublime-*
20+
.rvmrc
21+
stellar.yml
22+
.rubocop.yml
23+
24+
# Ignore generated coverage
25+
/coverage
26+
27+
# Bower stuff
28+
vendor/assets/.bowerrc
29+
vendor/assets/bower.json
30+
vendor/assets/bower_components
31+
EOF
32+
end
33+
end
34+
end
35+
end

recipes/postgres.rb

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
module Recipes
2+
class Postgres < Base
3+
4+
def gems
5+
@template.gem 'pg'
6+
end
7+
8+
def init_file
9+
@template.inside 'config' do
10+
@template.remove_file 'database.yml'
11+
@template.create_file 'database.yml' do <<-EOF
12+
default: &default
13+
adapter: postgresql
14+
encoding: unicode
15+
pool: 5
16+
17+
development:
18+
<<: *default
19+
database: #{@pathfinder.app_name}_development
20+
21+
staging:
22+
<<: *default
23+
database: #{@pathfinder.app_name}_staging
24+
username: #{@pathfinder.app_name}
25+
password: <%= ENV['#{@pathfinder.app_name.upcase}_DATABASE_PASSWORD'] %>
26+
27+
test:
28+
<<: *default
29+
database: #{@pathfinder.app_name}_test
30+
31+
production:
32+
<<: *default
33+
database: #{@pathfinder.app_name}_production
34+
username: #{@pathfinder.app_name}
35+
password: <%= ENV['#{@pathfinder.app_name.upcase}_DATABASE_PASSWORD'] %>
36+
37+
EOF
38+
end
39+
@template.append_file 'application.yml.example', "\n#{@pathfinder.app_name.upcase}_DATABASE_PASSWORD: ''"
40+
@template.append_file 'application.yml', "\n#{@pathfinder.app_name.upcase}_DATABASE_PASSWORD: ''"
41+
end
42+
@template.rake 'db:create'
43+
end
44+
end
45+
end

recipes/pundit.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
module Recipes
2+
class Pundit < Base
3+
4+
def gems
5+
@template.gem 'pundit'
6+
end
7+
8+
def init_file
9+
@template.generate 'pundit:install'
10+
@template.insert_into_file 'app/controllers/application_controller.rb', after: "class ApplicationController < ActionController::Base\n" do <<-RUBY
11+
include Pundit
12+
RUBY
13+
end
14+
end
15+
end
16+
end

0 commit comments

Comments
 (0)