Skip to content

Commit

Permalink
Merge pull request #127 from lab2023/feature/update_ruby_rails_to_lat…
Browse files Browse the repository at this point in the history
…est_version

KBP-207 #time 2d - Update rails, ruby and some gems version to latest version
  • Loading branch information
ismailakbudak authored Jul 4, 2018
2 parents 55026e7 + bf9734d commit ee9d462
Show file tree
Hide file tree
Showing 42 changed files with 80 additions and 219 deletions.
3 changes: 1 addition & 2 deletions .flayignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
templates/app_files/app/controllers/**/*.rb
templates/app_files/app/mailers/**/*.rb
lib/cybele/helpers/paperclip.rb
templates/app_files/app/mailers/**/*.rb
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.3.5
2.5.1
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ western colonies from around the 6th century BCE.

Before generating your application, you will need:

* Ruby ~> 2.3.5
* Rails ~> 5.1.4
* Ruby ~> 2.5.1
* Rails ~> 5.2.0

## Usage

Expand Down Expand Up @@ -74,4 +74,4 @@ Once you've made your great commits:

## License

Copyright © 2013-2015 [lab2023 - information technologies](http://lab2023.com)
Copyright © 2013-2018 [lab2023 - information technologies](http://lab2023.com)
4 changes: 2 additions & 2 deletions cybele.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Gem::Specification.new do |spec|
spec.require_paths = %w[lib]

spec.add_dependency 'bundler', '~> 1.5'
spec.add_runtime_dependency 'rails', '~> 5.0', Cybele::RAILS_VERSION
spec.add_runtime_dependency 'rails', Cybele::RAILS_VERSION
spec.add_development_dependency 'pronto', '~> 0.9.5'
spec.add_development_dependency 'pronto-fasterer', '~> 0.9.0'
spec.add_development_dependency 'pronto-flay', '~> 0.9.0'
Expand All @@ -34,4 +34,4 @@ Gem::Specification.new do |spec|
spec.add_development_dependency 'thor', '~> 0.19.4'

spec.extra_rdoc_files = %w[README.md MIT-LICENSE]
end
end
1 change: 0 additions & 1 deletion lib/cybele.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
require 'cybele/helpers/haml'
require 'cybele/helpers/locale_language'
require 'cybele/helpers/mailer'
require 'cybele/helpers/paperclip'
require 'cybele/helpers/devise'
require 'cybele/helpers/docker'
require 'cybele/helpers/error_pages'
Expand Down
1 change: 0 additions & 1 deletion lib/cybele/app_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ class AppBuilder < Rails::AppBuilder # rubocop:disable Metrics/ClassLength
include Cybele::Helpers::Haml
include Cybele::Helpers::LocaleLanguage
include Cybele::Helpers::Mailer
include Cybele::Helpers::Paperclip
include Cybele::Helpers::Devise
include Cybele::Helpers::ErrorPages
include Cybele::Helpers::Audited
Expand Down
17 changes: 4 additions & 13 deletions lib/cybele/generators/app_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,6 @@ def setup_editor_config
build :add_editor_config
end

def setup_ruby_version
say 'Add .ruby-version file', :green
build :add_ruby_version
end

def setup_cybele_version
say 'Add .VERSION.txt file', :green
build :add_cybele_version
Expand Down Expand Up @@ -189,11 +184,6 @@ def setup_haml
build :configure_haml
end

def add_staging_secret_key
say 'Add staging secret key to secret.yml file', :green
build :add_staging_secret_key_to_secrets_yml
end

def setup_bullet_config
say 'Setup bullet config'
build :configure_bullet
Expand All @@ -204,9 +194,9 @@ def force_ssl
build :force_ssl_setting
end

def setup_paperclip_and_add_aws
say 'Setting up paperclip, editing settings.yml and env files', :green
build :configure_paperclip
def active_storage
say 'Make active_storage amazon configuration', :green
build :active_storage_setting
end

def setup_devise
Expand Down Expand Up @@ -260,6 +250,7 @@ def customize_optional_view_files
build :generate_devise_views
build :configure_routes
build :customize_controller_files
build :add_devise_protect_from_forgery
build :add_devise_strong_parameter
build :add_devise_authenticate_admin
build :configure_basic_authentication
Expand Down
8 changes: 7 additions & 1 deletion lib/cybele/helpers/devise.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,16 @@ def add_devise_authenticate_admin
after: 'class Hq::ApplicationController < ApplicationController'
end

def add_devise_protect_from_forgery
inject_into_file 'app/controllers/application_controller.rb',
template_content('devise/devise_protect_from_forgery.rb.erb'),
after: 'respond_to :html, :js, :json'
end

def add_devise_strong_parameter
inject_into_file 'app/controllers/application_controller.rb',
template_content('devise/devise_strong_parameter.rb.erb'),
after: 'protect_from_forgery with: :exception'
after: 'protect_from_forgery with: :exception, prepend: true'

inject_into_file 'app/controllers/application_controller.rb',
template_content('devise/devise_before_action_strong_parameter.rb.erb'),
Expand Down
2 changes: 1 addition & 1 deletion lib/cybele/helpers/error_pages.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def configure_error_pages

inject_into_file 'app/controllers/application_controller.rb',
template_content('error_pages/error_method.erb'),
after: 'protect_from_forgery with: :exception'
after: 'protect_from_forgery with: :exception, prepend: true'

inject_into_file 'config/routes.rb',
template_content('error_pages/error_route.erb.rb'),
Expand Down
31 changes: 27 additions & 4 deletions lib/cybele/helpers/general.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,35 @@ def force_ssl_setting
end
end

def add_editor_config
copy_file 'editorconfig', '.editorconfig'
def active_storage_setting
%w[config/environments/production.rb config/environments/staging.rb
config/environments/development.rb].each do |file|
gsub_file file,
/config.active_storage.service = :local/,
"config.active_storage.service = :amazon"
end
replace_in_file 'config/storage.yml',
'Rails.application.credentials.dig(:aws, :access_key_id)',
"ENV['AWS_ACCESS_KEY_ID']"
replace_in_file 'config/storage.yml',
'Rails.application.credentials.dig(:aws, :secret_access_key)',
"ENV['AWS_SECRET_ACCESS_KEY']"
replace_in_file 'config/storage.yml',
'us-east-1',
"<%= ENV['AWS_REGION'] %>"
replace_in_file 'config/storage.yml',
'your_own_bucket',
"<%= ENV['BUCKET_NAME'] %>"
replace_in_file 'config/storage.yml',
'# Use rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key)',
"# AWS S3 access variable"
%w[.env.local .env.production .env.staging .env.sample].each do |env|
append_file(env, template_content('active_storage/amazon_env_all.erb'))
end
end

def add_ruby_version
copy_file 'ruby-version', '.ruby-version'
def add_editor_config
copy_file 'editorconfig', '.editorconfig'
end

def add_cybele_version
Expand Down
33 changes: 0 additions & 33 deletions lib/cybele/helpers/paperclip.rb

This file was deleted.

4 changes: 0 additions & 4 deletions lib/cybele/helpers/staging.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ module Staging
def setup_staging_environment
run 'cp config/environments/production.rb config/environments/staging.rb'
end

def add_staging_secret_key_to_secrets_yml
append_file 'config/secrets.yml', template_content('secrets.yml.erb')
end
end
end
end
6 changes: 3 additions & 3 deletions lib/cybele/version.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

module Cybele
RAILS_VERSION = '~> 5.1.4'
RAILS_VERSION = '~> 5.2.0', '>= 5.2.0'
RUBY_VERSION = IO.read("#{File.dirname(__FILE__)}/../../.ruby-version").strip
VERSION = '2.0.0'
end
VERSION = '2.1.0'
end
11 changes: 1 addition & 10 deletions spec/features/new_default_project_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
it 'uses default Gemfile' do
gemfile_file = content('Gemfile')
readme_file = content('README.md')
expect(gemfile_file).to match(/^gem 'rails', '#{Cybele::RAILS_VERSION}'/)
expect(gemfile_file).to match(/^gem 'rails', '#{Cybele::RAILS_VERSION.first}'/)
expect(readme_file).to match(/^# #{app_name.capitalize}/)
expect(readme_file).to match(/^# Docker development/)
expect(readme_file).to match(/^➜ ✗ redis-server/)
Expand Down Expand Up @@ -160,19 +160,10 @@
expect(simple_form_tr_yml_file).to match('simple_form')
end

it 'make control secret_key_base for staging' do
secret_file = content('config/secrets.yml')
expect(secret_file).to match('staging')
end

it 'control .env files' do
dotenv_test
end

it 'uses paperclip' do
paperclip_test
end

it 'uses mailer' do
gemfile_file = content('Gemfile')
expect(gemfile_file).to match("gem 'mailtrap'")
Expand Down
9 changes: 0 additions & 9 deletions spec/features/new_not_default_project_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -158,15 +158,6 @@
)
end

it 'make control secret_key_base for staging' do
secret_file = content('config/secrets.yml')
expect(secret_file).to match('staging')
end

it 'uses paperclip' do
paperclip_test
end

it 'control .env files' do
dotenv_test
end
Expand Down
1 change: 0 additions & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
config.include DotenvTestHelper
config.include ConfigTestHelper
config.include DeviseTestHelper
config.include PaperclipTestHelper
config.include LocaleLanguageTestHelper
config.include ResponderTestHelper
config.include ErrorPagesTestHelper
Expand Down
38 changes: 0 additions & 38 deletions spec/support/paperclip_test_helper.rb

This file was deleted.

9 changes: 6 additions & 3 deletions templates/Gemfile.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ gem 'thor', '~> 0.19.4'
gem 'recipient_interceptor', '~> 0.1.2'

# RailsConfig helps you easily manage environment specific Rails settings in an easy and usable manner
gem 'config', '~> 1.5'
gem 'config', '~> 1.7'

# Rollbar is an error tracking service.
gem 'rollbar', '~> 2.15', '>= 2.15.4'
gem 'rollbar', '~> 2.16', '>= 2.16.2'

# Ransack is the successor to the MetaSearch gem.
gem 'ransack', '~> 1.8', '>= 1.8.4'
Expand Down Expand Up @@ -53,7 +53,10 @@ end
gem 'rails-i18n', '~> 5.0', '>= 5.0.4'

# Flexible authentication solution for Rails with Warden
gem 'devise', '~> 4.3'
gem 'devise', '~> 4.4', '>= 4.4.3'

# Audited is an ORM extension that logs all changes to your models
gem 'audited', '~> 4.5'

# Official AWS Ruby gem for Amazon Simple Storage Service (Amazon S3).
gem 'aws-sdk-s3', '~> 1.15'
2 changes: 1 addition & 1 deletion templates/README.md.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# TODOs
- Change email sender domain address and basic_auth info in `config/settings.yml`
- Change email sender domain address in `config/initializers/devise.rb`
- Add your secret keys to `.environments/` directory. In this directory there mus be .env.local file created from .env.sample
- Add your master key variable to `.env` files like in `.env.sample` file.

<% unless @options[:skip_docker] %>
# Docker development
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

# S3 Settings
S3_BUCKET_NAME=
AWS_RAW_URL=
BUCKET_NAME=
AWS_REGION=
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
9 changes: 1 addition & 8 deletions templates/app_files/app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,7 @@ var ready = function(){
});
};

$(document).on('turbolinks:load', function () {
ready();
var script = document.createElement("script");
script.src = "https://use.fontawesome.com/releases/v5.0.1/js/all.js";
document.head.appendChild(script);
});

document.addEventListener("turbolinks:load", ready)
document.addEventListener("turbolinks:load", ready);

$(window).on('page:load', ready);

Expand Down
7 changes: 0 additions & 7 deletions templates/app_files/app/assets/javascripts/hq/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,6 @@ var ready = function(){

document.addEventListener("turbolinks:load", ready);

$(document).on('turbolinks:load', function () {
ready();
var script = document.createElement("script");
script.src = "https://use.fontawesome.com/releases/v5.0.1/js/all.js";
document.head.appendChild(script);
});

$(window).on('page:load', ready);

$(document).on('page:fetch', function() {
Expand Down
Loading

0 comments on commit ee9d462

Please sign in to comment.