Class: Skele::Runner
- Inherits:
-
Object
- Object
- Skele::Runner
- Defined in:
- lib/skele.rb
Instance Method Summary collapse
- #blue(text) ⇒ Object
- #bundle_install ⇒ Object
- #colorize(text, color_code) ⇒ Object
- #copy_files ⇒ Object
- #green(text) ⇒ Object
- #indent(string) ⇒ Object
-
#initialize(skeleton, destination, root = SKELETON_ROOT) ⇒ Runner
constructor
A new instance of Runner.
- #red(text) ⇒ Object
- #summon ⇒ Object
Constructor Details
Instance Method Details
#blue(text) ⇒ Object
169 170 171 |
# File 'lib/skele.rb', line 169 def blue(text) colorize text, 34 end |
#bundle_install ⇒ Object
116 117 118 119 120 121 122 123 124 |
# File 'lib/skele.rb', line 116 def bundle_install STDOUT.puts "\nRunning bundle install\n\n" bundle = @skeleton.bundle_install unless bundle.nil? STDOUT.puts indent bundle end end |
#colorize(text, color_code) ⇒ Object
157 158 159 |
# File 'lib/skele.rb', line 157 def colorize(text, color_code) "\e[#{color_code}m#{text}\e[0m" end |
#copy_files ⇒ Object
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 |
# File 'lib/skele.rb', line 126 def copy_files STDOUT.puts "\nCopying files\n\n" file_result = @skeleton.copy_files if file_result.nil? STDOUT.puts indent(red("Error:") + "Skeleton '#{@skeleton.skeleton}' does not exist or is not a directory") else file_result.each do |result| case result[:action] when "mkdir" STDOUT.puts indent(" " + green(result[:action]) + " " + result[:file]) when "create" STDOUT.puts indent(green(result[:action]) + " " + result[:file]) when "exists" STDOUT.puts indent(red(result[:action]) + " " + result[:file]) end end end end |
#green(text) ⇒ Object
165 166 167 |
# File 'lib/skele.rb', line 165 def green(text) colorize text, 32 end |
#indent(string) ⇒ Object
147 148 149 150 151 152 153 154 155 |
# File 'lib/skele.rb', line 147 def indent(string) indented = "" string.split("\n").each do |line| indented += INDENTATION + line + "\n" end return indented end |
#summon ⇒ Object
107 108 109 110 111 112 113 114 |
# File 'lib/skele.rb', line 107 def summon STDOUT.puts "\nSummoning skeleton '#{@skeleton.skeleton}' from '#{@skeleton.destination}'" copy_files bundle_install STDOUT.puts "\nSkeleton complete. Enjoy!\n\n" end |