Class: Reciper
- Inherits:
-
Object
- Object
- Reciper
- Includes:
- Helpers
- Defined in:
- lib/reciper.rb,
lib/reciper/helpers.rb,
lib/reciper/version.rb
Defined Under Namespace
Modules: Helpers Classes: NoFileOrMultipleFilesFound, NoFileToBeOverriden, NoTestOutput
Constant Summary collapse
- VERSION =
"0.2.1"
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#recipe_path ⇒ Object
readonly
Returns the value of attribute recipe_path.
-
#ruby_app_path ⇒ Object
readonly
Returns the value of attribute ruby_app_path.
Instance Method Summary collapse
-
#execute(&block) ⇒ Object
Executes a recipe inside the block.
-
#initialize(name, recipe_path, ruby_app_template_path) ⇒ Reciper
constructor
Initialize the recipe with the paths.
Methods included from Helpers
#copy_file, #copy_line_range, #override_file, #run_command, #run_rake_task, #run_tests
Constructor Details
#initialize(name, recipe_path, ruby_app_template_path) ⇒ Reciper
Initialize the recipe with the paths. It will clone the ruby_app_template_path to a path that we will run the migration.
name - the recipe name recipe_path - the recipe path (absolute or relative to the current path) ruby_app_template_path - the ruby app template path (it will be cloned and it will run the migrations on this copy)
Examples
Recipe.new("My freaking awesome recipe", "~/Code/recipe", "~/Code/rails_app/path")
Returns a recipe instance with all paths configured
21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/reciper.rb', line 21 def initialize(name, recipe_path, ruby_app_template_path) @name = name @recipe_path = recipe_path @ruby_app_path = File.join(".", "tmp", name.parameterize("_")) if File.directory?(@ruby_app_path) FileUtils.rm_rf(@ruby_app_path) end FileUtils.mkdir_p("tmp") FileUtils.cp_r(ruby_app_template_path, @ruby_app_path) end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
8 9 10 |
# File 'lib/reciper.rb', line 8 def name @name end |
#recipe_path ⇒ Object (readonly)
Returns the value of attribute recipe_path.
8 9 10 |
# File 'lib/reciper.rb', line 8 def recipe_path @recipe_path end |
#ruby_app_path ⇒ Object (readonly)
Returns the value of attribute ruby_app_path.
8 9 10 |
# File 'lib/reciper.rb', line 8 def ruby_app_path @ruby_app_path end |
Instance Method Details
#execute(&block) ⇒ Object
Executes a recipe inside the block.
Examples
recipe.execute do
run_rake_task("db:migrate")
copy_file("file.rb", :as => "user.rb")
end
Returns nothing.
45 46 47 48 49 |
# File 'lib/reciper.rb', line 45 def execute(&block) if block_given? instance_eval(&block) end end |