Class: Carb::Controller
- Inherits:
-
Object
- Object
- Carb::Controller
- Defined in:
- lib/carb/controller.rb
Class Method Summary collapse
-
.assemble(type, target, force) ⇒ Object
the chef.
- .check_target ⇒ Object
- .cook_bearded_octo ⇒ Object
-
.cook_octaplus ⇒ Object
cook the recipes.
- .cook_on_fire ⇒ Object
- .get_bearded_octo ⇒ Object
- .get_moreorless ⇒ Object
-
.get_octaplus ⇒ Object
the ingredients.
- .set_up ⇒ Object
- .tear_down ⇒ Object
Class Method Details
.assemble(type, target, force) ⇒ Object
the chef
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/carb/controller.rb', line 15 def assemble(type, target, force) @type = type @target = target || "." @force = force || false if check_target() == true set_up() case @type when Config::TYPE_OCTAPLUS cook_octaplus() when Config::TYPE_BEARDED_OCTO cook_bearded_octo() when Config::TYPE_ON_FIRE cook_on_fire() end tear_down() else exit(1) end end |
.check_target ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/carb/controller.rb', line 39 def check_target() # check if target exists, if it does and # force is false, stop right here if File.directory?(@target) if @force FileUtils.rm_rf(Dir.glob("#{@target}/*")) return true else Logger::log("⚡ Target folder exists, use --force | -f to overwrite ⚡", Logger::ERROR) return false end end return true end |
.cook_bearded_octo ⇒ Object
119 120 121 122 123 124 125 126 127 128 |
# File 'lib/carb/controller.rb', line 119 def cook_bearded_octo get_bearded_octo() get_moreorless() FileUtils.mkdir_p "#{Config::DIR_COOKPOT}/assets" FileUtils.cp_r "#{Config::DIR_BEARDED}/.", "#{Config::DIR_COOKPOT}/" FileUtils.remove_dir "#{Config::DIR_MOREORLESS}/tests" FileUtils.cp_r "#{Config::DIR_MOREORLESS}/.", "#{Config::DIR_COOKPOT}/assets/css" end |
.cook_octaplus ⇒ Object
cook the recipes
113 114 115 116 117 |
# File 'lib/carb/controller.rb', line 113 def cook_octaplus get_octaplus() FileUtils.cp_r "#{Config::DIR_OCTAPLUS}", "#{Config::DIR_COOKPOT}" end |
.cook_on_fire ⇒ Object
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 |
# File 'lib/carb/controller.rb', line 130 def cook_on_fire get_octaplus() get_bearded_octo() get_moreorless() FileUtils.mkdir_p "#{Config::DIR_COOKPOT}/assets" FileUtils.cp_r "#{Config::DIR_BEARDED}/assets", "#{Config::DIR_COOKPOT}/" FileUtils.remove_dir "#{Config::DIR_MOREORLESS}/tests" FileUtils.cp_r "#{Config::DIR_MOREORLESS}/.", "#{Config::DIR_COOKPOT}/assets/css" FileUtils.remove_dir "#{Config::DIR_OCTAPLUS}/assets" FileUtils.cp_r "#{Config::DIR_OCTAPLUS}/.", "#{Config::DIR_COOKPOT}" FileUtils.cp_r "#{Config::DIR_BEARDED}/index.html", "#{Config::DIR_COOKPOT}/fuel/app/views/welcome" # actions on the views end |
.get_bearded_octo ⇒ Object
95 96 97 98 99 100 |
# File 'lib/carb/controller.rb', line 95 def get_bearded_octo Logger::log(" ⚡ Some bearded-octo seasoning", Logger::INFO) FileUtils.mkdir_p "#{Config::DIR_BEARDED}" %x[curl -L -s https://github.com/proximitybbdo/bearded-octo/tarball/master | tar xz --strip 1 -C bearded] end |
.get_moreorless ⇒ Object
102 103 104 105 106 107 |
# File 'lib/carb/controller.rb', line 102 def get_moreorless Logger::log(" ⚡ A dash of moreorless", Logger::INFO) FileUtils.mkdir_p "#{Config::DIR_MOREORLESS}" %x[curl -L -s https://github.com/rob-bar/moreorless/tarball/master | tar xz --strip 1 -C moreorless] end |
.get_octaplus ⇒ Object
the ingredients
87 88 89 90 91 92 93 |
# File 'lib/carb/controller.rb', line 87 def get_octaplus Logger::log(" ⚡ A bit of Octaplus goodness", Logger::INFO) FileUtils.mkdir_p "#{Config::DIR_OCTAPLUS}" %x[git clone -q --recurse-submodules https://github.com/proximitybbdo/Engine.git octaplus > /dev/null 2>&1] %x[rm -rf octaplus/.git] end |
.set_up ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/carb/controller.rb', line 55 def set_up Logger::log("⚡ Preparing your package, hold on ⚡", Logger::INFO) # clean up if the tear down left some crappers FileUtils.remove_dir "#{Config::TMP_FOLDER}", :force => true # save pwd @pwd = Dir.pwd # create tmp folder FileUtils.mkdir_p "#{Config::TMP_FOLDER}" # and move to the root of them Dir.chdir "#{Config::TMP_FOLDER}" end |
.tear_down ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/carb/controller.rb', line 71 def tear_down # copy the bundle to the current working directory FileUtils.mkdir_p "#{@pwd}/#{@target}" FileUtils.cp_r "#{Config::DIR_COOKPOT}/.", "#{@pwd}/#{@target}" puts "" Logger::log("⚡⚡⚡ Et voila! All set in the ./#{@target} folder ⚡⚡⚡ ", Logger::SUCCESS) # clean up FileUtils.remove_dir "#{Config::TMP_FOLDER}", :force => true end |