Class: Isomorfeus::Installer::Gemfile

Inherits:
Object
  • Object
show all
Extended by:
DSL
Defined in:
lib/isomorfeus/installer/gemfile.rb

Class Method Summary collapse

Methods included from DSL

config_path, copy_file, create_common_framework_directories, create_directory, create_file_from_template, install_basic_components, install_basic_policy, install_rake_file, install_spec_files

Class Method Details

.executeObject



7
8
9
# File 'lib/isomorfeus/installer/gemfile.rb', line 7

def execute
  install_gemfile
end

.generate_gem_line(gem_hash) ⇒ Object



11
12
13
14
15
# File 'lib/isomorfeus/installer/gemfile.rb', line 11

def generate_gem_line(gem_hash)
  line = "gem '#{gem_hash[:name]}', '#{gem_hash[:version]}'"
  line << ", require: false" if gem_hash.key?(:require) && !gem_hash[:require]
  line << "\n"
end

.install_gemfileObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/isomorfeus/installer/gemfile.rb', line 17

def install_gemfile
  rack_server_gems = ''
  Isomorfeus::Installer.rack_servers[Isomorfeus::Installer.options[:rack_server]]&.fetch(:gems)&.each do |gem|
    rack_server_gems << generate_gem_line(gem)
  end
  data_hash = { rack_server_gems: rack_server_gems.chop }

  if Isomorfeus::Installer.project_name == 'test_app'
    gem_lines = ''
    %i[isomorfeus isomorfeus-data isomorfeus-empowerment isomorfeus-i18n isomorfeus-mailer isomorfeus-operation isomorfeus-policy isomorfeus-transport].each do |i_module|
      gem_lines << "gem '#{i_module}', path: #{Isomorfeus::Installer.isomorfeus_module == i_module ? "'..'\n" : "'../../#{i_module}'"}\n"
    end
    data_hash[:isomorfeus_gems] = gem_lines.chop
  else
    data_hash[:isomorfeus_gems] = "gem 'isomorfeus', '~> #{Isomorfeus::VERSION}'"
  end

  create_file_from_template(Isomorfeus::Installer.templates_path, 'Gemfile.erb', 'Gemfile', data_hash)
end