Skip to content

Commit

Permalink
KBP-123 #time 5m - Conflict was resolved.
Browse files Browse the repository at this point in the history
  • Loading branch information
esref.viduslu committed Oct 31, 2017
2 parents c9bde7f + 8c6675e commit a6554e5
Show file tree
Hide file tree
Showing 9 changed files with 81 additions and 2 deletions.
1 change: 1 addition & 0 deletions lib/cybele.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
require 'cybele/helpers/simple_form'
require 'cybele/helpers/show_for'
require 'cybele/helpers/recipient_interceptor'
require 'cybele/helpers/haml'
require 'cybele/helpers/locale_language'
require 'cybele/helpers/dotenv'
require 'cybele/app_builder'
6 changes: 6 additions & 0 deletions lib/cybele/app_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class AppBuilder < Rails::AppBuilder
include Cybele::Helpers::SimpleForm
include Cybele::Helpers::RecipientInterceptor
include Cybele::Helpers::ShowFor
include Cybele::Helpers::Haml
include Cybele::Helpers::LocaleLanguage
include Cybele::Helpers::Dotenv

Expand Down Expand Up @@ -36,6 +37,11 @@ def add_ruby_version
copy_file 'ruby-version', '.ruby-version'
end

def add_cybele_version
copy_file 'VERSION.txt', 'VERSION.txt'
run 'ln -s ../VERSION.txt public/VERSION.txt'
end

def use_postgres_config_template
template 'postgresql_database.yml.erb',
'config/database.yml',
Expand Down
19 changes: 19 additions & 0 deletions lib/cybele/generators/app_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ class AppGenerator < Rails::Generators::AppGenerator
default: false,
group: :cybele,
desc: 'Skip show_for integration. Default: don\'t skip'
class_option :skip_haml,
type: :boolean,
aliases: nil,
default: false,
group: :cybele,
desc: 'Skip haml and haml-rails integration. Default: don\'t skip'

def initialize(*args)
super
Expand All @@ -68,6 +74,7 @@ def initialize(*args)
option_with_ask_yes(:skip_sidekiq)
option_with_ask_yes(:skip_simple_form)
option_with_ask_yes(:skip_show_for)
option_with_ask_yes(:skip_haml)
@options.freeze
end

Expand All @@ -76,6 +83,7 @@ def customize_gemfile
build :add_gems
build :add_simple_form_gem unless @options[:skip_simple_form]
build :add_show_for_gem unless @options[:skip_show_for]
build :add_haml_gems unless @options[:skip_haml]
bundle_command 'install --binstubs=bin/stubs'
end

Expand All @@ -89,6 +97,11 @@ def setup_ruby_version
build :add_ruby_version
end

def setup_cybele_version
say 'Add .VERSION.txt file', :green
build :add_cybele_version
end

def remove_files_we_dont_need
say 'Remove files we don\'t need', :green
build :remove_readme_rdoc
Expand Down Expand Up @@ -153,6 +166,12 @@ def setup_simple_form
build :configure_simple_form
end

def setup_haml
return if @options[:skip_haml]
say 'Setting up haml and generate haml-rails', :green
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
Expand Down
18 changes: 18 additions & 0 deletions lib/cybele/helpers/haml.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# frozen_string_literal: true

module Cybele
module Helpers
module Haml
def configure_haml
# Add initializers
bundle_command 'exec rails generate haml:application_layout convert'
remove_file 'app/views/layouts/application.html.erb'
end

def add_haml_gems
# Add Gems
append_file('Gemfile', template_content('haml/haml_Gemfile.erb'))
end
end
end
end
14 changes: 14 additions & 0 deletions spec/features/new_default_project_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@
expect(locale_file).to match('destroy:')
end

it 'uses cybele_version' do
expect(File).to exist(file_project_path('VERSION.txt'))
expect(File).to exist(file_project_path('public/VERSION.txt'))
end

it 'uses rollbar' do
gemfile_file = content('Gemfile')
expect(gemfile_file).to match(/^gem 'rollbar'/)
Expand Down Expand Up @@ -232,4 +237,13 @@
env_production_file = content('.env.production')
expect(env_production_file).to match('ROOT_PATH=https://dummy_app.herokuapp.com')
end

it 'uses haml' do
gemfile_file = content('Gemfile')
expect(gemfile_file).to match(/^gem 'haml'/)
expect(gemfile_file).to match(/^gem 'haml-rails'/)

expect(File).not_to exist(file_project_path('app/views/layouts/application.html.erb'))
expect(File).to exist(file_project_path('app/views/layouts/application.html.haml'))
end
end
17 changes: 16 additions & 1 deletion spec/features/new_not_default_project_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
before(:all) do
drop_dummy_database
remove_project_directory
run_cybele('--database=sqlite3 --skip-create-database --skip-sidekiq --skip-simple-form --skip-show-for')
run_cybele('--database=sqlite3 --skip-create-database --skip-sidekiq --skip-simple-form --skip-show-for'\
' --skip-haml')
setup_app_dependencies
end

Expand Down Expand Up @@ -176,6 +177,11 @@
expect(config_staging_file).to match('RecipientInterceptor.new')
end

it 'uses cybele_version' do
expect(File).to exist(file_project_path('VERSION.txt'))
expect(File).to exist(file_project_path('public/VERSION.txt'))
end

it 'do not use simple_form' do
gemfile_file = content('Gemfile')
expect(gemfile_file).not_to match(/^gem 'simple_form'/)
Expand Down Expand Up @@ -211,4 +217,13 @@
env_production_file = content('.env.production')
expect(env_production_file).to match('ROOT_PATH=https://dummy_app.herokuapp.com')
end

it 'do not use haml' do
gemfile_file = content('Gemfile')
expect(gemfile_file).not_to match(/^gem 'haml'/)
expect(gemfile_file).not_to match(/^gem 'haml-rails'/)

expect(File).to exist(file_project_path('app/views/layouts/application.html.erb'))
expect(File).not_to exist(file_project_path('app/views/layouts/application.html.haml'))
end
end
2 changes: 1 addition & 1 deletion templates/Gemfile.erb
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ gem 'roo', '~> 2.7', '>= 2.7.1'
group :development, :test do
gem 'colorize', '~> 0.8.1'
gem 'better_errors', '~> 2.4'
end
end
1 change: 1 addition & 0 deletions templates/VERSION.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v0.1.0
5 changes: 5 additions & 0 deletions templates/haml/haml_Gemfile.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

# Haml is a templating engine for HTML.
gem 'haml', '~> 5.0', '>= 5.0.4'
# Haml-rails provides Haml generators for Rails.
gem 'haml-rails', '~> 1.0'

0 comments on commit a6554e5

Please sign in to comment.