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.



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

def structure
  @structure
end

Instance Method Details

#create_shopify_settingsObject



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

def create_shopify_settings
  puts "1) Setting up Shopify Connection"
  @installer = ::Binda::Shopify::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



39
40
41
42
# File 'lib/generators/binda/shopify/install_generator.rb', line 39

def finish
  puts "Done!"
  puts
end

#setup_structuresObject



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

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



9
10
11
# File 'lib/generators/binda/shopify/install_generator.rb', line 9

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