Class: Tapioca::Generator

Inherits:
Thor::Shell::Color
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/tapioca/generator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Generator

Returns a new instance of Generator.



19
20
21
22
23
24
25
26
27
# File 'lib/tapioca/generator.rb', line 19

def initialize(config)
  @config = config
  @bundle = T.let(nil, T.nilable(Gemfile))
  @loader = T.let(nil, T.nilable(Loader))
  @compiler = T.let(nil, T.nilable(Compilers::SymbolTableCompiler))
  @existing_rbis = T.let(nil, T.nilable(T::Hash[String, String]))
  @expected_rbis = T.let(nil, T.nilable(T::Hash[String, String]))
  super()
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



12
13
14
# File 'lib/tapioca/generator.rb', line 12

def config
  @config
end

Instance Method Details

#build_gem_rbis(gem_names) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/tapioca/generator.rb', line 30

def build_gem_rbis(gem_names)
  require_gem_file

  gems_to_generate(gem_names)
    .reject { |gem| config.exclude.include?(gem.name) }
    .each do |gem|
      say("Processing '#{gem.name}' gem:", :green)
      indent do
        compile_rbi(gem)
        puts
      end
    end

  say("All operations performed in working directory.", [:green, :bold])
  say("Please review changes and commit them.", [:green, :bold])
end

#sync_rbis_with_gemfileObject



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/tapioca/generator.rb', line 48

def sync_rbis_with_gemfile
  anything_done = [
    perform_removals,
    perform_additions,
  ].any?

  if anything_done
    say("All operations performed in working directory.", [:green, :bold])
    say("Please review changes and commit them.", [:green, :bold])
  else
    say("No operations performed, all RBIs are up-to-date.", [:green, :bold])
  end

  puts
end