Class: Crafti::Root

Inherits:
Object
  • Object
show all
Includes:
FileUtilsExtension
Defined in:
lib/crafti.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from FileUtilsExtension

#chmod, #chmod_r, #copy, #mkdir, #mkdirs, #run, #sudo, #template, #touch

Constructor Details

#initialize(appname) ⇒ Root

Returns a new instance of Root.



131
132
133
134
# File 'lib/crafti.rb', line 131

def initialize(appname)
  @appname  = appname
  @app_path = ::Pathname.new(appname).expand_path
end

Instance Attribute Details

#app_pathObject (readonly)

Returns the value of attribute app_path.



129
130
131
# File 'lib/crafti.rb', line 129

def app_path
  @app_path
end

#appnameObject (readonly)

Returns the value of attribute appname.



129
130
131
# File 'lib/crafti.rb', line 129

def appname
  @appname
end

Class Method Details

.root(appname, &block) ⇒ Object



123
124
125
126
127
# File 'lib/crafti.rb', line 123

def self.root(appname, &block)
  app = new((::Crafti::AppName.name || appname))
  app.create_root_directory
  app.evaluate(&block) if block_given?
end

Instance Method Details

#create_root_directoryObject



140
141
142
# File 'lib/crafti.rb', line 140

def create_root_directory
  ::FileUtils.mkdir_p(app_path)
end

#evaluate(&block) ⇒ Object



136
137
138
# File 'lib/crafti.rb', line 136

def evaluate(&block)
  instance_eval &block
end