Class: Laravel::App
- Inherits:
-
Object
- Object
- Laravel::App
- Includes:
- AppSupport, Helpers
- Defined in:
- lib/laravel/app.rb
Overview
This class provides a means to create new applications based on the Laravel framework. Most of the methods used here have been defined in the AppSupport module, which is being included as a mixin here.
Constant Summary
Constants included from Helpers
Helpers::CacheFolder, Helpers::LaravelRepo
Instance Attribute Summary collapse
-
#cache ⇒ Object
readonly
these attributes must be available as: object.attribute.
-
#options ⇒ Object
these attributes must be available as: object.attribute.
-
#path ⇒ Object
these attributes must be available as: object.attribute.
-
#source ⇒ Object
these attributes must be available as: object.attribute.
Instance Method Summary collapse
-
#configure_from_options ⇒ Object
This method configures the application as required by the user.
-
#create ⇒ Object
This method creates a new Laravel based application for us.
-
#initialize(path = nil, options = nil) ⇒ App
constructor
This method initializes a new App object for us, on which we can apply our changes.
Methods included from AppSupport
#apply_force, #artisan, #cache_directory, #clean_up, #config_file, #copy_over_cache_files, #create_in_current_directory?, #create_in_empty_directory?, #download_or_update_local_cache, #has_cache?, #has_laravel?, #required_force_is_missing?, #source_is_local?, #tasks_file, #update_permissions_on_storage
Methods included from Helpers
#download_resource, #is_blank?, #is_current_directory?, #is_empty_directory?, #laravel_exists_in_directory?, #make_md5, #say, #say_failed, #say_success, #show_info
Constructor Details
#initialize(path = nil, options = nil) ⇒ App
This method initializes a new App object for us, on which we can apply our changes. Logically, this new App object represents an application based on Laravel.
Parameters
path-
The path to the Laravel based application. This can either
be a relative path to the current directory, or the absolute path. If path is not supplied, we assume current directory.
options-
A hash of options for this application. This hash can be
created manually, but more closely resembles the options choosen by the user and forwarded by the Thor to us.
27 28 29 30 31 32 |
# File 'lib/laravel/app.rb', line 27 def initialize(path = nil, = nil) self.path = path self. = self.source = [:source] if self.source = LaravelRepo if not @source end |
Instance Attribute Details
#cache ⇒ Object (readonly)
these attributes must be available as: object.attribute
12 13 14 |
# File 'lib/laravel/app.rb', line 12 def cache @cache end |
#options ⇒ Object
these attributes must be available as: object.attribute
12 13 14 |
# File 'lib/laravel/app.rb', line 12 def @options end |
#path ⇒ Object
these attributes must be available as: object.attribute
12 13 14 |
# File 'lib/laravel/app.rb', line 12 def path @path end |
#source ⇒ Object
these attributes must be available as: object.attribute
12 13 14 |
# File 'lib/laravel/app.rb', line 12 def source @source end |
Instance Method Details
#configure_from_options ⇒ Object
This method configures the application as required by the user. It does so by invoking the ‘from_options’ method of the Configuration class.
117 118 119 120 121 122 |
# File 'lib/laravel/app.rb', line 117 def if @options[:config] config = Configuration.new(@path, @options[:config]) config. end end |
#create ⇒ Object
This method creates a new Laravel based application for us. This method is invoked by the ‘new’ task. It first checks if we can create the application in the specified directory, then updates/downloads the local cache for the given source, and then copies over the files from this cache to the specified directory. Finally, it checks if we have a working Laravel application at which point it either raises and error and cleans up, or configures the application, as requested.
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/laravel/app.rb', line 79 def create # check if we are missing the required force required_force_is_missing? # apply some force, when we are boosted with one apply_force # download or update local cache download_or_update_local_cache # copy the framework files from the cache copy_over_cache_files # make necessary changes for the new app, if we were successful in # download otherwise, remove the downloaded source if has_laravel? say_success "Cloned Laravel repository." # update permissions on storage/ directory (this is the default) if @options[:perms] # configure this new application, as required say_success "Hurray! Your Laravel application has been created!" else say_failed "Downloaded source is not Laravel framework or its fork." show_info "Cleaning up.." # remove all directories that we created, as well as the cache. clean_up # raise an error since we failed.. :( raise LaravelError, "Source for downloading repository is corrupt!" end end |