Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Initial add of Rake exercises

  • Loading branch information...
commit d1920a03442b330391156537ee7f987ce943c9f4 1 parent 091da72
@MichaelJosephKramer MichaelJosephKramer authored
Showing with 176 additions and 0 deletions.
  1. +3 −0  Rake/Iteration1/Rakefiles
  2. BIN  Rake/Iteration1/images/EuropeanYak.gif
  3. BIN  Rake/Iteration1/images/GrayKoala.jpg
  4. BIN  Rake/Iteration1/images/NewEnglandLighthouse.jpg
  5. BIN  Rake/Iteration1/images/ReallyGrossJellyfish.jpg
  6. BIN  Rake/Iteration1/images/ThreePenguins.jpg
  7. BIN  Rake/Iteration1/images_backup/EuropeanYak.gif
  8. BIN  Rake/Iteration1/images_backup/GrayKoala.jpg
  9. BIN  Rake/Iteration1/images_backup/NewEnglandLighthouse.jpg
  10. BIN  Rake/Iteration1/images_backup/ReallyGrossJellyfish.jpg
  11. BIN  Rake/Iteration1/images_backup/ThreePenguins.jpg
  12. +28 −0 Rake/Iteration1/solution/Rakefile
  13. +28 −0 Rake/Iteration2/Rakefile
  14. BIN  Rake/Iteration2/images/EuropeanYak.gif
  15. BIN  Rake/Iteration2/images/GrayKoala.jpg
  16. BIN  Rake/Iteration2/images/NewEnglandLighthouse.jpg
  17. BIN  Rake/Iteration2/images/ReallyGrossJellyfish.jpg
  18. BIN  Rake/Iteration2/images/ThreePenguins.jpg
  19. BIN  Rake/Iteration2/images_backup/EuropeanYak.gif
  20. BIN  Rake/Iteration2/images_backup/GrayKoala.jpg
  21. BIN  Rake/Iteration2/images_backup/NewEnglandLighthouse.jpg
  22. BIN  Rake/Iteration2/images_backup/ReallyGrossJellyfish.jpg
  23. BIN  Rake/Iteration2/images_backup/ThreePenguins.jpg
  24. +31 −0 Rake/Iteration2/solution/Rakefile
  25. +31 −0 Rake/Iteration3/Rakefile
  26. BIN  Rake/Iteration3/images/EuropeanYak.gif
  27. BIN  Rake/Iteration3/images/GrayKoala.jpg
  28. BIN  Rake/Iteration3/images/NewEnglandLighthouse.jpg
  29. BIN  Rake/Iteration3/images/ReallyGrossJellyfish.jpg
  30. BIN  Rake/Iteration3/images/ThreePenguins.jpg
  31. BIN  Rake/Iteration3/images_backup/EuropeanYak.gif
  32. BIN  Rake/Iteration3/images_backup/GrayKoala.jpg
  33. BIN  Rake/Iteration3/images_backup/NewEnglandLighthouse.jpg
  34. BIN  Rake/Iteration3/images_backup/ReallyGrossJellyfish.jpg
  35. BIN  Rake/Iteration3/images_backup/ThreePenguins.jpg
  36. +55 −0 Rake/Iteration3/solution/Rakefile
View
3  Rake/Iteration1/Rakefiles
@@ -0,0 +1,3 @@
+task :hello_world do
+ p "hello world"
+end
View
BIN  Rake/Iteration1/images/EuropeanYak.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  Rake/Iteration1/images/GrayKoala.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  Rake/Iteration1/images/NewEnglandLighthouse.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  Rake/Iteration1/images/ReallyGrossJellyfish.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  Rake/Iteration1/images/ThreePenguins.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  Rake/Iteration1/images_backup/EuropeanYak.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  Rake/Iteration1/images_backup/GrayKoala.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  Rake/Iteration1/images_backup/NewEnglandLighthouse.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  Rake/Iteration1/images_backup/ReallyGrossJellyfish.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  Rake/Iteration1/images_backup/ThreePenguins.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
28 Rake/Iteration1/solution/Rakefile
@@ -0,0 +1,28 @@
+# This solution works, but is not the only working solution.
+# Feel free to do a better job.
+
+task :process_images do
+ # get the path to the images
+ path = File.join("images", "*")
+
+ # get the files
+ files = Dir.glob(path)
+
+ files.each do |file|
+ new_name = ""
+
+ # split words on capital letter
+ words = File.basename(file).scan(/[A-Z][a-z]+/)
+
+ # remove capital letters, concatenate, and add the _ for each word
+ words.each { |word| new_name += "#{word.downcase}_" }
+
+ # remove trailing _ and readd the file extension
+ new_name = File.join(File.dirname(file), new_name[0...-1] + File.extname(file))
+
+ # rename the files
+ File.rename(file, new_name)
+ end
+
+ p 'File Rename Completed'
+end
View
28 Rake/Iteration2/Rakefile
@@ -0,0 +1,28 @@
+# This solution works, but is not the only working solution.
+# Feel free to do a better job.
+
+task :process_images do
+ # get the path to the images
+ path = File.join("images", "*")
+
+ # get the files
+ files = Dir.glob(path)
+
+ files.each do |file|
+ new_name = ""
+
+ # split words on capital letter
+ words = File.basename(file).scan(/[A-Z][a-z]+/)
+
+ # remove capital letters, concatenate, and add the _ for each word
+ words.each { |word| new_name += "#{word.downcase}_" }
+
+ # remove trailing _ and readd the file extension
+ new_name = File.join(File.dirname(file), new_name[0...-1] + File.extname(file))
+
+ # rename the files
+ File.rename(file, new_name)
+ end
+
+ p 'File Rename Completed'
+end
View
BIN  Rake/Iteration2/images/EuropeanYak.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  Rake/Iteration2/images/GrayKoala.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  Rake/Iteration2/images/NewEnglandLighthouse.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  Rake/Iteration2/images/ReallyGrossJellyfish.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  Rake/Iteration2/images/ThreePenguins.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  Rake/Iteration2/images_backup/EuropeanYak.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  Rake/Iteration2/images_backup/GrayKoala.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  Rake/Iteration2/images_backup/NewEnglandLighthouse.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  Rake/Iteration2/images_backup/ReallyGrossJellyfish.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  Rake/Iteration2/images_backup/ThreePenguins.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
31 Rake/Iteration2/solution/Rakefile
@@ -0,0 +1,31 @@
+# This solution works, but is not the only working solution.
+# Feel free to do a better job.
+
+task :default => [:process_images]
+
+desc 'Process the images'
+task :process_images do
+ # get the path to the images
+ path = File.join("images", "*")
+
+ # get the files
+ files = Dir.glob(path)
+
+ files.each do |file|
+ new_name = ""
+
+ # split words on capital letter
+ words = File.basename(file).scan(/[A-Z][a-z]+/)
+
+ # remove capital letters, concatenate, and add the _ for each word
+ words.each { |word| new_name += "#{word.downcase}_" }
+
+ # remove trailing _ and readd the file extension
+ new_name = File.join("production", new_name[0...-1] + File.extname(file))
+
+ # copy the file
+ cp(file, new_name)
+ end
+
+ p 'File Copy Completed'
+end
View
31 Rake/Iteration3/Rakefile
@@ -0,0 +1,31 @@
+# This solution works, but is not the only working solution.
+# Feel free to do a better job.
+
+task :default => [:process_images]
+
+desc 'Process the images'
+task :process_images do
+ # get the path to the images
+ path = File.join("images", "*")
+
+ # get the files
+ files = Dir.glob(path)
+
+ files.each do |file|
+ new_name = ""
+
+ # split words on capital letter
+ words = File.basename(file).scan(/[A-Z][a-z]+/)
+
+ # remove capital letters, concatenate, and add the _ for each word
+ words.each { |word| new_name += "#{word.downcase}_" }
+
+ # remove trailing _ and readd the file extension
+ new_name = File.join("production", new_name[0...-1] + File.extname(file))
+
+ # copy the file
+ cp(file, new_name)
+ end
+
+ p 'File Copy Completed'
+end
View
BIN  Rake/Iteration3/images/EuropeanYak.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  Rake/Iteration3/images/GrayKoala.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  Rake/Iteration3/images/NewEnglandLighthouse.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  Rake/Iteration3/images/ReallyGrossJellyfish.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  Rake/Iteration3/images/ThreePenguins.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  Rake/Iteration3/images_backup/EuropeanYak.gif
Diff not rendered
View
BIN  Rake/Iteration3/images_backup/GrayKoala.jpg
Diff not rendered
View
BIN  Rake/Iteration3/images_backup/NewEnglandLighthouse.jpg
Diff not rendered
View
BIN  Rake/Iteration3/images_backup/ReallyGrossJellyfish.jpg
Diff not rendered
View
BIN  Rake/Iteration3/images_backup/ThreePenguins.jpg
Diff not rendered
View
55 Rake/Iteration3/solution/Rakefile
@@ -0,0 +1,55 @@
+# This solution works, but is not the only working solution.
+# Feel free to do a better job.
+
+task :default => [:rename_images, :copy_to_staging, :copy_to_production]
+
+desc 'Rename the images'
+task :rename_images, [:extension] do |t, args|
+ args.with_defaults(:extension => 'jpg')
+
+ # get the path to the images
+ path = File.join("images", "*.#{args.extension}")
+
+ # get the files
+ files = Dir.glob(path)
+
+ files.each do |file|
+ new_name = ""
+
+ # split words on capital letter
+ words = File.basename(file).scan(/[A-Z][a-z]+/)
+
+ # remove capital letters, concatenate, and add the _ for each word
+ words.each { |word| new_name += "#{word.downcase}_" }
+
+ # remove trailing _ and readd the file extension
+ new_name = File.join(File.dirname(file), new_name[0...-1] + File.extname(file))
+
+ # rename the files
+ File.rename(file, new_name)
+ end
+
+ p 'File Rename Completed'
+end
+
+task :copy_to_staging do
+ # get the path to the images
+ path = File.join("images", "*_*")
+
+ # get the files
+ files = Dir.glob(path)
+
+ # copy the files
+ files.each{ |file| cp file, File.join('staging', File.basename(file)) }
+end
+
+task :copy_to_production do
+ # get the path to the images
+ path = File.join("staging", "*")
+
+ # get the files
+ files = Dir.glob(path)
+
+ # copy the files
+ files.each{ |file| cp file, File.join('production', File.basename(file)) }
+end
Please sign in to comment.
Something went wrong with that request. Please try again.