Class: Annotate::Solargraph::Generators::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/annotate/solargraph/install_generator.rb

Instance Method Summary collapse

Instance Method Details

#copy_tasksObject

copy rake tasks



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/generators/annotate/solargraph/install_generator.rb', line 14

def copy_tasks
  template ::Rails::Annotate::Solargraph::RAKEFILE_NAME, ::File.join('lib', 'tasks', ::Rails::Annotate::Solargraph::RAKEFILE_NAME)
  template ::Rails::Annotate::Solargraph::SCHEMA_FILE_NAME, ::Rails::Annotate::Solargraph::SCHEMA_RAILS_PATH

  solargraph_config_file = ::File.join(::Rails.root, ::Rails::Annotate::Solargraph::SOLARGRAPH_FILE_NAME)
  unless ::File.exist? solargraph_config_file
    template(::Rails::Annotate::Solargraph::SOLARGRAPH_FILE_NAME, ::Rails::Annotate::Solargraph::SOLARGRAPH_FILE_PATH)
  end

  solargraph_config = ::YAML.load_file solargraph_config_file
  solargraph_config['include'] = solargraph_config['include'] || []
  solargraph_config['include'].unshift ::Rails::Annotate::Solargraph::SCHEMA_RAILS_PATH
  # make sure there are no duplicated entries
  solargraph_config['include'] = solargraph_config['include'].to_set.to_a

  ::File.write(solargraph_config_file, solargraph_config.to_yaml)
end