Class: Binda::Shopify::InstallGenerator

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#structureObject

Returns the value of attribute structure.



5
6
7
# File 'lib/generators/binda/shopify/install_generator.rb', line 5

def structure
  @structure
end

Instance Method Details

#create_shopify_settingsObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/generators/binda/shopify/install_generator.rb', line 11

def create_shopify_settings
  puts "1) Setting up Shopify Connection"
  @installer = Installer.new
  @settings = {}
  Binda::Shopify::CONNECTION_KEYS.each do |field_name|
    STDOUT.puts "What is your Shopify #{field_name.to_s.titleize}?"
    @settings[field_name] = STDIN.gets.strip
  end
  Binda::Shopify::STRUCTURES.each do |structure_name, structure_fields|
    default_name = "Shopify #{structure_name.to_s.titleize}"
    puts "How would you like to name your #{structure_name} structure? ['#{default_name}']"
    @settings[structure_name] = STDIN.gets.strip.presence || default_name
  end
  @settings_board = @installer.create_settings_board @settings
  puts
end

#finishObject



37
38
39
40
# File 'lib/generators/binda/shopify/install_generator.rb', line 37

def finish
  puts "Done!"
  puts
end

#setup_structuresObject



28
29
30
31
32
33
34
35
# File 'lib/generators/binda/shopify/install_generator.rb', line 28

def setup_structures 
  Binda::Shopify::STRUCTURES.each.with_index do |(structure_name, structure_fields), index|
    name = @settings[structure_name].presence || structure_name.to_s.titleize
    puts "#{index+2}) Setting up #{name} Structure"
    @installer.create_item_structure structure_name, name
    puts
  end
end

#startObject



7
8
9
# File 'lib/generators/binda/shopify/install_generator.rb', line 7

def start
  puts "Ok, let'do this!"
end