Class: CookbookCreator::Generator::Context
- Inherits:
-
Object
- Object
- CookbookCreator::Generator::Context
- Defined in:
- lib/cookbook_creator/generator.rb
Overview
This is here to hold attr_accessor data for Generator context variables
Class Method Summary collapse
- .add_attr(name) ⇒ Object
- .cookbook_full_path ⇒ Object
- .cookbook_name ⇒ Object
- .cookbook_name_or_path ⇒ Object
- .cookbook_root ⇒ Object
- .have_git? ⇒ Boolean
- .recipe ⇒ Object
- .recipe_name ⇒ Object
- .reset ⇒ Object
Class Method Details
.add_attr(name) ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/cookbook_creator/generator.rb', line 16 def self.add_attr(name) @attributes ||= [ ] if !@attributes.include?(name) @attributes << name attr_accessor(name) end end |
.cookbook_full_path ⇒ Object
29 30 31 |
# File 'lib/cookbook_creator/generator.rb', line 29 def self.cookbook_full_path File.(cookbook_name_or_path, Dir.pwd) end |
.cookbook_name ⇒ Object
46 47 48 |
# File 'lib/cookbook_creator/generator.rb', line 46 def self.cookbook_name File.basename(cookbook_full_path) end |
.cookbook_name_or_path ⇒ Object
33 34 35 36 |
# File 'lib/cookbook_creator/generator.rb', line 33 def self.cookbook_name_or_path name = ARGV[0] File.(name, Dir.pwd) end |
.cookbook_root ⇒ Object
25 26 27 |
# File 'lib/cookbook_creator/generator.rb', line 25 def self.cookbook_root File.dirname(cookbook_full_path) end |
.have_git? ⇒ Boolean
50 51 52 53 54 |
# File 'lib/cookbook_creator/generator.rb', line 50 def self.have_git? path = ENV["PATH"] || "" paths = path.split(File::PATH_SEPARATOR) paths.any? {|bin_path| File.exist?(File.join(bin_path, "git#{RbConfig::CONFIG['EXEEXT']}"))} end |
.recipe ⇒ Object
38 39 40 |
# File 'lib/cookbook_creator/generator.rb', line 38 def self.recipe "cookbook" end |
.recipe_name ⇒ Object
42 43 44 |
# File 'lib/cookbook_creator/generator.rb', line 42 def self.recipe_name "default" end |
.reset ⇒ Object
56 57 58 59 60 61 62 63 64 |
# File 'lib/cookbook_creator/generator.rb', line 56 def self.reset return if @attributes.nil? @attributes.each do |attr| remove_method(attr) end @attributes = nil end |