Class: Bearonrails::AppBuilder

Inherits:
Rails::AppBuilder
  • Object
show all
Defined in:
lib/bearonrails/app_builder.rb

Instance Method Summary collapse

Instance Method Details

#add_common_rake_tasksObject



5
6
7
# File 'lib/bearonrails/app_builder.rb', line 5

def add_common_rake_tasks
  directory 'tasks', 'lib/tasks'
end

#add_custom_gemsObject



13
14
15
16
17
18
19
20
21
# File 'lib/bearonrails/app_builder.rb', line 13

def add_custom_gems
  additions_path = find_in_source_paths 'Gemfile_additions'
  new_gems = File.open(additions_path).read
  inject_into_file(
    'Gemfile',
    "\n#{new_gems}",
    after: /^end/
  )
end

#add_dot_envObject



37
38
39
40
41
42
43
44
45
# File 'lib/bearonrails/app_builder.rb', line 37

def add_dot_env
  copy_file '.env', '.env'

  inject_into_file(
    'config/application.rb',
    "Dotenv.load\n\n",
    before: /^module/
  )
end

#add_new_relic_configObject



27
28
29
30
31
32
33
34
35
# File 'lib/bearonrails/app_builder.rb', line 27

def add_new_relic_config
  copy_file 'config/newrelic.yml', 'config/newrelic.yml'

  replace_in_file(
    '.env',
    /change-this-to-your-app-name/m,
    "#{app_name}"
  )
end

#add_rspec_helper_addonObject



51
52
53
54
55
56
57
58
59
# File 'lib/bearonrails/app_builder.rb', line 51

def add_rspec_helper_addon
  additions_path = find_in_source_paths 'spec/rails_helper_addon'
  addon_config = File.open(additions_path).read
  inject_into_file(
    'spec/rails_helper.rb',
    "\n#{addon_config}",
    before: /^end/
  )
end

#add_rubocop_configObject



23
24
25
# File 'lib/bearonrails/app_builder.rb', line 23

def add_rubocop_config
  copy_file '.rubocop.yml', '.rubocop.yml'
end

#init_gitObject



9
10
11
# File 'lib/bearonrails/app_builder.rb', line 9

def init_git
  run 'git init'
end

#install_rspecObject



47
48
49
# File 'lib/bearonrails/app_builder.rb', line 47

def install_rspec
  run 'bundle exec rails g rspec:install'
end

#remove_routes_comment_linesObject



61
62
63
64
65
66
67
# File 'lib/bearonrails/app_builder.rb', line 61

def remove_routes_comment_lines
  replace_in_file(
    'config/routes.rb',
    /Rails\.application\.routes\.draw do.*end/m,
    "Rails.application.routes.draw do\nend"
  )
end