Class: Steer::LayoutGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/rails/generators/steer/layout/layout_generator.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.source_rootObject



13
14
15
# File 'lib/rails/generators/steer/layout/layout_generator.rb', line 13

def self.source_root
  @source_root ||= File.join(File.dirname(__FILE__), 'templates')
end

Instance Method Details

#ask_userObject



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/rails/generators/steer/layout/layout_generator.rb', line 33

def ask_user

  print_table([
    [1, "Stack"],
    [2, "Onboard"]
  ])

  exit_greeting = [
    "Awesome", "Amazing", "Fantastic", "Great", "Brilliant", "Totally rad", "Incredible"
  ].shuffle.first

  exit_message = [
    "you're looking nice today by the way :)",
    "that's a nice top you're wearing by the way :)",
    "that top really suits you by the way :)",
    "I love your hair by the way :)",
    "have you been working out?",
    "I like your socks by the way :D",
    "we should do this again some time!",
    "I told all my other scripts about how cool you are :)",
    "I'm a Ruby script but I still think you're pretty neat ;)",
    "has anyone told you how your eyebrows really make your eyes stand out?",
    "by the way, on a scale of 1-10, I think you're 11 :)",
    "is that top new, by the way?"
  ].shuffle.first

  msg = "\n#{exit_greeting}, #{exit_message}\n"

  case ask("\nWhich one do you want to set up?", Thor::Shell::Color::GREEN)
    when "1", "stack", "Stack"

      copy_file "stack/application.html.erb", "app/views/layouts/application.html.erb"
      copy_file "stack/stylesheets/normalize.css", "app/assets/stylesheets/normalize.css"
      copy_file "stack/stylesheets/global.css", "app/assets/stylesheets/global.css"
      copy_file "stack/stylesheets/products.css", "app/assets/stylesheets/products.css"
      copy_file "stack/stylesheets/application.css", "app/assets/stylesheets/application.css"


      say msg, Thor::Shell::Color::GREEN

    when "2", "onboard", "Onboard"

      say "\n"

      copy_file "onboard/application.html.erb", "app/views/layouts/application.html.erb"
      copy_file "generic/stylesheets/reset.css", "app/assets/stylesheets/reset.css"
      copy_file "generic/stylesheets/skeleton.css", "app/assets/stylesheets/skeleton.css"
      copy_file "onboard/stylesheets/global.css", "app/assets/stylesheets/global.css"
      copy_file "onboard/stylesheets/products.css", "app/assets/stylesheets/products.css"
      copy_file "onboard/stylesheets/application.css", "app/assets/stylesheets/application.css"


      say msg, Thor::Shell::Color::GREEN

    else
      say "\nHmmm didn't understand ya, try again!\n\n"
      ask_user
  end

  return
end

#installObject

Generator Code. Remember this is just suped-up Thor so methods are executed in order



19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/rails/generators/steer/layout/layout_generator.rb', line 19

def install

  say "         888                             
       888                             
       888                             
.d8888b  888888 .d88b.   .d88b.  888d888 
88K      888   d8P  Y8b d8P  Y8b 888P\"   
\"Y8888b. 888   88888888 88888888 888     
   X88 Y88b. Y8b.     Y8b.     888     
 88888P'  \"Y888 \"Y8888   \"Y8888  888     \n\n", Thor::Shell::Color::RED

  say "Here are the projects!\n"
end