Skip to content

Commit a6554e5

Browse files
author
esref.viduslu
committed
KBP-123 #time 5m - Conflict was resolved.
2 parents c9bde7f + 8c6675e commit a6554e5

File tree

9 files changed

+81
-2
lines changed

9 files changed

+81
-2
lines changed

lib/cybele.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
require 'cybele/helpers/simple_form'
1010
require 'cybele/helpers/show_for'
1111
require 'cybele/helpers/recipient_interceptor'
12+
require 'cybele/helpers/haml'
1213
require 'cybele/helpers/locale_language'
1314
require 'cybele/helpers/dotenv'
1415
require 'cybele/app_builder'

lib/cybele/app_builder.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ class AppBuilder < Rails::AppBuilder
99
include Cybele::Helpers::SimpleForm
1010
include Cybele::Helpers::RecipientInterceptor
1111
include Cybele::Helpers::ShowFor
12+
include Cybele::Helpers::Haml
1213
include Cybele::Helpers::LocaleLanguage
1314
include Cybele::Helpers::Dotenv
1415

@@ -36,6 +37,11 @@ def add_ruby_version
3637
copy_file 'ruby-version', '.ruby-version'
3738
end
3839

40+
def add_cybele_version
41+
copy_file 'VERSION.txt', 'VERSION.txt'
42+
run 'ln -s ../VERSION.txt public/VERSION.txt'
43+
end
44+
3945
def use_postgres_config_template
4046
template 'postgresql_database.yml.erb',
4147
'config/database.yml',

lib/cybele/generators/app_generator.rb

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,12 @@ class AppGenerator < Rails::Generators::AppGenerator
5454
default: false,
5555
group: :cybele,
5656
desc: 'Skip show_for integration. Default: don\'t skip'
57+
class_option :skip_haml,
58+
type: :boolean,
59+
aliases: nil,
60+
default: false,
61+
group: :cybele,
62+
desc: 'Skip haml and haml-rails integration. Default: don\'t skip'
5763

5864
def initialize(*args)
5965
super
@@ -68,6 +74,7 @@ def initialize(*args)
6874
option_with_ask_yes(:skip_sidekiq)
6975
option_with_ask_yes(:skip_simple_form)
7076
option_with_ask_yes(:skip_show_for)
77+
option_with_ask_yes(:skip_haml)
7178
@options.freeze
7279
end
7380

@@ -76,6 +83,7 @@ def customize_gemfile
7683
build :add_gems
7784
build :add_simple_form_gem unless @options[:skip_simple_form]
7885
build :add_show_for_gem unless @options[:skip_show_for]
86+
build :add_haml_gems unless @options[:skip_haml]
7987
bundle_command 'install --binstubs=bin/stubs'
8088
end
8189

@@ -89,6 +97,11 @@ def setup_ruby_version
8997
build :add_ruby_version
9098
end
9199

100+
def setup_cybele_version
101+
say 'Add .VERSION.txt file', :green
102+
build :add_cybele_version
103+
end
104+
92105
def remove_files_we_dont_need
93106
say 'Remove files we don\'t need', :green
94107
build :remove_readme_rdoc
@@ -153,6 +166,12 @@ def setup_simple_form
153166
build :configure_simple_form
154167
end
155168

169+
def setup_haml
170+
return if @options[:skip_haml]
171+
say 'Setting up haml and generate haml-rails', :green
172+
build :configure_haml
173+
end
174+
156175
def add_staging_secret_key
157176
say 'Add staging secret key to secret.yml file', :green
158177
build :add_staging_secret_key_to_secrets_yml

lib/cybele/helpers/haml.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# frozen_string_literal: true
2+
3+
module Cybele
4+
module Helpers
5+
module Haml
6+
def configure_haml
7+
# Add initializers
8+
bundle_command 'exec rails generate haml:application_layout convert'
9+
remove_file 'app/views/layouts/application.html.erb'
10+
end
11+
12+
def add_haml_gems
13+
# Add Gems
14+
append_file('Gemfile', template_content('haml/haml_Gemfile.erb'))
15+
end
16+
end
17+
end
18+
end

spec/features/new_default_project_spec.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@
6969
expect(locale_file).to match('destroy:')
7070
end
7171

72+
it 'uses cybele_version' do
73+
expect(File).to exist(file_project_path('VERSION.txt'))
74+
expect(File).to exist(file_project_path('public/VERSION.txt'))
75+
end
76+
7277
it 'uses rollbar' do
7378
gemfile_file = content('Gemfile')
7479
expect(gemfile_file).to match(/^gem 'rollbar'/)
@@ -232,4 +237,13 @@
232237
env_production_file = content('.env.production')
233238
expect(env_production_file).to match('ROOT_PATH=https://dummy_app.herokuapp.com')
234239
end
240+
241+
it 'uses haml' do
242+
gemfile_file = content('Gemfile')
243+
expect(gemfile_file).to match(/^gem 'haml'/)
244+
expect(gemfile_file).to match(/^gem 'haml-rails'/)
245+
246+
expect(File).not_to exist(file_project_path('app/views/layouts/application.html.erb'))
247+
expect(File).to exist(file_project_path('app/views/layouts/application.html.haml'))
248+
end
235249
end

spec/features/new_not_default_project_spec.rb

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
before(:all) do
77
drop_dummy_database
88
remove_project_directory
9-
run_cybele('--database=sqlite3 --skip-create-database --skip-sidekiq --skip-simple-form --skip-show-for')
9+
run_cybele('--database=sqlite3 --skip-create-database --skip-sidekiq --skip-simple-form --skip-show-for'\
10+
' --skip-haml')
1011
setup_app_dependencies
1112
end
1213

@@ -176,6 +177,11 @@
176177
expect(config_staging_file).to match('RecipientInterceptor.new')
177178
end
178179

180+
it 'uses cybele_version' do
181+
expect(File).to exist(file_project_path('VERSION.txt'))
182+
expect(File).to exist(file_project_path('public/VERSION.txt'))
183+
end
184+
179185
it 'do not use simple_form' do
180186
gemfile_file = content('Gemfile')
181187
expect(gemfile_file).not_to match(/^gem 'simple_form'/)
@@ -211,4 +217,13 @@
211217
env_production_file = content('.env.production')
212218
expect(env_production_file).to match('ROOT_PATH=https://dummy_app.herokuapp.com')
213219
end
220+
221+
it 'do not use haml' do
222+
gemfile_file = content('Gemfile')
223+
expect(gemfile_file).not_to match(/^gem 'haml'/)
224+
expect(gemfile_file).not_to match(/^gem 'haml-rails'/)
225+
226+
expect(File).to exist(file_project_path('app/views/layouts/application.html.erb'))
227+
expect(File).not_to exist(file_project_path('app/views/layouts/application.html.haml'))
228+
end
214229
end

templates/Gemfile.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@ gem 'roo', '~> 2.7', '>= 2.7.1'
2626
group :development, :test do
2727
gem 'colorize', '~> 0.8.1'
2828
gem 'better_errors', '~> 2.4'
29-
end
29+
end

templates/VERSION.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
v0.1.0

templates/haml/haml_Gemfile.erb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
# Haml is a templating engine for HTML.
3+
gem 'haml', '~> 5.0', '>= 5.0.4'
4+
# Haml-rails provides Haml generators for Rails.
5+
gem 'haml-rails', '~> 1.0'

0 commit comments

Comments
 (0)