Class: Rys::IpatchGenerator

Inherits:
PatchGeneratorBase show all
Defined in:
lib/generators/rys/ipatch/ipatch_generator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name


5
6
7
# File 'lib/generators/rys/ipatch/ipatch_generator.rb', line 5

def name
  @name
end

#pluginObject (readonly)

Returns the value of attribute plugin


5
6
7
# File 'lib/generators/rys/ipatch/ipatch_generator.rb', line 5

def plugin
  @plugin
end

#typeObject (readonly)

Returns the value of attribute type


5
6
7
# File 'lib/generators/rys/ipatch/ipatch_generator.rb', line 5

def type
  @type
end

Instance Method Details

#create_patchObject


7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/generators/rys/ipatch/ipatch_generator.rb', line 7

def create_patch
  if Rys::PluginsManagement.all.size.zero?
    puts 'There are no rys plugins'
    exit 1
  end

  require 'tty-prompt'
  @prompt = TTY::Prompt.new(interrupt: :exit)

  @plugin = @prompt.select('Choose target plugin') do |menu|
    Rys::PluginsManagement.all do |plugin|
      menu.choice plugin.name, plugin
    end
  end

  self.destination_root = plugin.root

  loop {
    run
    @prompt.say('---')
    break if !@prompt.yes?('Add more?')
  }
end