laravel 0.5.1 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,30 +1,41 @@
1
- Then /^configuration: "(.*?)" should be updated to "(.*?)"$/ do |config, value|
2
- value = '.*' if value == "__something__"
3
- @app_tester.validate_configuration("'#{config}' => '#{value}'")
4
- step "the stdout should contain \"Updated configuration: #{config}\""
1
+ # specific to most configuration updates #
2
+
3
+ # specify the configuration settings we want to use when running the test
4
+ Given /^I want to (?:set|use|configure) "(.*?)" as(?:| the)(?:| application) "(.*?)"$/ do |value, setting|
5
+ @config = "#{@config}#{setting}:#{value},"
6
+ end
7
+ Given /^I want to "(.*?)" (?:|the )"(.*?)"$/ do |switch, setting|
8
+ switch = ["enable"].include?(switch)
9
+ @config = "#{@config}#{setting}:#{switch ? "on" : "off"},"
5
10
  end
6
11
 
12
+ # run a command in the application being tested
13
+ When /^I run `(.*?)` inside this application$/ do |command|
14
+ step "I run `#{command} --app=#{@app.path}`"
15
+ end
7
16
 
17
+ # make sure that the configuration setting was updated correctly
18
+ Then /^(?:|the )(?:|application )"(.*?)" should be updated to "(.*?)"$/ do |setting, value|
19
+ step "configuration: \"#{setting}\" should be updated to: \"#{value}\""
20
+ end
21
+ Then /^the "(.*?)" should be turned (on|off)$/ do |setting, value|
22
+ step "configuration: \"#{setting}\" should be updated to: \"#{value == "on"}\""
23
+ end
8
24
 
25
+ # specify if we want to generate a new application key
9
26
  Given /^I( do not)? want to generate a new key$/ do |negate|
10
- @args = "#{@args} #{negate ? "--no-key" : "--key"}"
11
- end
12
- When /^(?:|I |we )generate a new key(?:| for this application)$/ do
13
- step "I run `laravel config key --app=#{@app_path}`"
27
+ @config = "#{@config}#{negate ? "" : "key,"}"
14
28
  end
15
- Then /^a new application key should be generated$/ do
16
- step "configuration: \"key\" should be updated to \"__something__\""
29
+ # make sure that the application key was updated to something
30
+ Then /application key should be generated$/ do
31
+ step "configuration: \"key\" should be updated to: \"__something__\""
17
32
  end
18
33
 
19
34
 
20
35
 
21
- Given /^I want to use "(.*?)" as application index$/ do |index|
22
- @args = "#{@args} --index=#{index}"
23
- end
24
- When /^.*udpate application index to "(.*?)"$/ do |index|
25
- step "I run `laravel config index #{index} --app=#{@app_path}`"
26
- end
27
- Then /^the application index should be updated to "(.*?)"$/ do |index|
28
- step "configuration: \"index\" should be updated to \"#{index}\""
36
+ # check configuration for a key => value pair
37
+ Then /^configuration: "(.*?)" should be updated to: "(.*?)"$/ do |config, value|
38
+ validate_configuration(config, value, @app.config_file)
39
+ step "the stdout should contain \"Updated configuration: #{config}\""
29
40
  end
30
41
 
@@ -1,47 +1,78 @@
1
+ # laravel framework exists in a given directory
1
2
  Given /^laravel (?:framework|application)( does not)? exists? in "(.*?)" directory$/ do |negate, dir|
2
- dir = File.expand_path(dir, Laravel::AppTests::TestDirectory)
3
+ dir = expand_path(dir)
3
4
  FileUtils.rm_rf(dir)
4
5
  # easiest way to do this is to download github repository at this location
5
6
  `git clone -q http://github.com/laravel/laravel #{dir}` unless negate
6
7
  end
7
8
 
9
+ # local cache exists for a given repository
8
10
  Given /^local cache for "(.*?)" (does not )?exists?$/ do |repo, negate|
9
- tester = Laravel::AppTests.new(".", repo)
10
- if negate
11
- FileUtils.rm_rf tester.app.cache
12
- elsif not tester.app.has_cache?
13
- # easiest method to ensure local cache exists is to clone repo from github
14
- FileUtils.rm_rf tester.app.cache
15
- `git clone #{tester.app.source} #{tester.app.cache} &>/dev/null`
16
- end
11
+ app = create_test_app nil, repo
12
+ FileUtils.rm_rf app.cache if negate or not app.has_cache?
13
+ # easiest method to ensure local cache exists is to clone repo from github
14
+ `git clone -q #{app.source} #{app.cache}` unless app.has_cache?
17
15
  end
18
16
 
17
+ # no applications have been created => local cache does not exist
19
18
  Given /^(no )?applications? (?:has|have) been created using "(.*?)" as source$/ do |negate, repo|
20
- step "local cache for \"#{repo}\" #{negate ? "does not exist" : "exists"}"
19
+ step "local cache for \"#{repo}\"#{negate ? " does not" : ""} exist"
21
20
  end
22
21
 
23
-
24
-
22
+ # create an application
25
23
  When /^.*create (?:an|this) application(?:| with above requirements)( in the current directory)?$/ do |current_dir|
26
- dir = current_dir ? "." : "my_app"
27
- @source ||= "http://github.com/laravel/laravel"
28
- @app_tester = Laravel::AppTests.new(dir, @source)
29
- @app = @app_tester.app
30
- @app_path = @app_tester.app_path
31
- @cache = @app_tester.app.cache
32
-
33
- step "I run `laravel new #{dir} #{@args}`"
24
+ @source ||= "http://github.com/laravel/laravel"
25
+ @app = create_test_app current_dir, @source
26
+ @config = @config.chomp(",")
27
+ @args = "#{@args} --config=#{@config}" unless @config.empty?
28
+ step "I run `laravel new #{@app.path} #{@args}`"
34
29
  end
35
30
 
36
-
31
+ # make sure that the application is ready for development
37
32
  Then /^(?:|this |the )application should be ready for development$/ do
38
33
  step "local cache should exist"
39
34
  step "application should be created"
35
+ step "I should not fail while doing so"
40
36
  end
37
+ # check if the local cache exists after we create an application
41
38
  Then /^local cache should( not)? exist$/ do |negate|
42
- @app_tester.raise_error?(@app.has_cache?, negate)
39
+ message = "local cache at #{@app.cache} to exist for source => #{@app.source}"
40
+ unexpected?(@app.has_cache?, !negate, message)
43
41
  end
42
+ # check if the application was created successfully
44
43
  Then /^application should( not)? be created$/ do |negate|
45
44
  step "the stdout should contain \"Hurray!\"" unless negate
46
- @app_tester.raise_error?(@app.has_laravel?, negate)
45
+ message = "application to be created"
46
+ unexpected?(@app.has_laravel?, !negate, message)
47
+ end
48
+
49
+ # start creating an application and initialize @args, @config parameters
50
+ Given /.*want to create (?:an|the|a new) application( forcefully)?$/ do |force|
51
+ @config = ""
52
+ @args = force ? "--force" : ""
53
+ end
54
+
55
+ # specify a source repository
56
+ Given /^I want to use( local cache for)? "(.*?)" as source$/ do |use_cache, source|
57
+ @source = source
58
+ @args = "#{@args} --source=#{source}"
59
+ end
60
+
61
+ # specify whether we want to udpate permissions or not
62
+ Given /^I( do not)? want to update file permissions for storage$/ do |negate|
63
+ @args = "#{@args} #{negate ? "--no-perms" : "--perms"}"
64
+ end
65
+ # check if the permissions were updated
66
+ Then /^file permissions on storage should( not)? be updated$/ do |negate|
67
+ step "the stdout should contain \"Updated permissions\"" unless negate
68
+
69
+ storage_dir = File.join(@app.path, "storage")
70
+ # capture the last integer for the permissions mode
71
+ world_bit = sprintf("%o", File.stat(storage_dir).mode).to_s[-1,1].to_i
72
+ # file is world-writable if last integer is 2, 3, 6, or 7
73
+ actual = [2,3,6,7].include?(world_bit)
74
+
75
+ expected = !negate
76
+ message = "#{storage_dir} to be world-writable"
77
+ unexpected?(actual, expected, message)
47
78
  end
@@ -3,7 +3,7 @@ require "laravel"
3
3
 
4
4
  # After a scenario has been ran, deleted the files we may have created.
5
5
  After do
6
- test_directory = File.expand_path(File.join(File.dirname(__FILE__), %w[ .. .. tmp aruba]))
6
+ test_directory = Laravel::TestHelpers::TestDirectory
7
7
  FileUtils.rm_rf(File.join(test_directory, "my_app"))
8
8
  FileUtils.rm_rf(File.join(test_directory, "laravel"))
9
9
  FileUtils.rm_rf(File.join(test_directory, "current"))
@@ -12,3 +12,5 @@ end
12
12
  Before do
13
13
  @aruba_timeout_seconds = 300
14
14
  end
15
+
16
+ World(Laravel::Helpers)
@@ -0,0 +1,74 @@
1
+ module Laravel
2
+ # various methods that help with the Cucumber Tests
3
+ module TestHelpers
4
+ TestDirectory = File.expand_path(File.join(File.dirname(__FILE__), %w[ .. .. tmp aruba]))
5
+
6
+ # expand path to a directory relative to the test directory
7
+ #
8
+ # ==== Parameters
9
+ # +dir+ :: path to the application directory
10
+ #
11
+ # ==== Return
12
+ # +string+ :: absolute path to the application directory
13
+ #
14
+ def expand_path(dir = nil)
15
+ dir ||= Dir.pwd
16
+ File.expand_path(dir, TestDirectory)
17
+ end
18
+
19
+ # checks if the configuration file contains a particular string
20
+ #
21
+ # ==== Parameters
22
+ # +search+ :: the search term/regex pattern to look for
23
+ #
24
+ # ==== Return
25
+ # +boolean+:: true, if the search term was found in the configuration file.
26
+ #
27
+ def validate_configuration(config, value, config_file)
28
+ match = File.read(config_file).match(/'#{config}' => (.*),/)
29
+ expected = !match.nil?
30
+ message = "configuration \"#{config}\" to be present in the configuration file."
31
+ unexpected_unless expected, message
32
+
33
+ # quote the value if it is not boolean
34
+ value = "'#{value}'" unless ["true", "false"].include?(value)
35
+ # config is valid if it matches the passed value or if its "__something__"
36
+ expected = (value == "'__something__'") || (value == match[1])
37
+ message = "configuration \"#{config}\" to be \"#{value}\" instead of \"#{match[1]}\""
38
+ unexpected_unless expected, message
39
+ end
40
+
41
+ def create_test_app(dir = nil, repo = nil)
42
+ dir = dir ? "." : "my_app"
43
+ dir = expand_path(dir)
44
+ options = { :force => true, :quiet => false, :perms => true, :source => repo }
45
+ Laravel::App.new(dir, options)
46
+ end
47
+
48
+ # raises an error based on a condition and negation
49
+ # if negation is not supplied, simply raises an error if condition is not true
50
+ #
51
+ # ==== Parameters
52
+ # +actual+ :: a condition to check against - if +expected+ is not provided,
53
+ # raises an error if +actual+ is (or evaluates to) false
54
+ # +expected+ :: negate the default behaviour
55
+ def unexpected?(actual, expected, message = "")
56
+ message ||= "#{expected} instead of #{actual}"
57
+ message = "#{expected ? "Expected" : "Did not expect"} #{message}"
58
+ # actual and expected can either be boolean or string
59
+ actual = !actual.empty? if actual.is_a?(String) and not expected.is_a?(String)
60
+ raise ExpectationNotMetError, message if actual != expected
61
+ end
62
+
63
+ def unexpected_if(actual, message = "")
64
+ unexpected? actual, false, message
65
+ end
66
+
67
+ def unexpected_unless(actual, message = "")
68
+ unexpected? actual, true, message
69
+ end
70
+
71
+ end
72
+ end
73
+
74
+ World(Laravel::TestHelpers)
@@ -8,8 +8,8 @@ Gem::Specification.new do |gem|
8
8
  gem.version = Laravel::VERSION
9
9
  gem.authors = ["Nikhil Gupta"]
10
10
  gem.email = ["me@nikhgupta.com"]
11
- gem.description = %q{A wrapper around Laravel framework for PHP}
12
- gem.summary = %q{This gem is a wrapper around the Laravel framework for PHP. Initially, the gem would allow to create new laravel apps along with options to modify the default behavior for these new installations.}
11
+ gem.description = %q{Readily build new web applications using Laravel framework for PHP.}
12
+ gem.summary = %q{This gem helps in readily creating new web application based on the Laravel framework for PHP with as much customization as possible. Moreover, it allows configuring existing Laravel applications, and installing Laravel bundles for them.}
13
13
  gem.homepage = "https://github.com/nikhgupta/laravel"
14
14
 
15
15
  gem.files = `git ls-files`.split($/)
@@ -17,12 +17,10 @@ Gem::Specification.new do |gem|
17
17
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
18
  gem.require_paths = ["lib"]
19
19
 
20
+ # add some dependecies for this gem
20
21
  gem.add_dependency 'thor'
21
22
 
23
+ # add some dependencies for this gem when in the development environment
22
24
  gem.add_development_dependency 'rake'
23
25
  gem.add_development_dependency 'aruba'
24
- # gem.add_development_dependency 'rspec'
25
- # gem.add_development_dependency 'guard-rspec'
26
- # gem.add_development_dependency 'rb-fsevent'
27
- # gem.add_development_dependency 'growl'
28
26
  end
@@ -1,6 +1,5 @@
1
1
  # require dependencies
2
2
  require "thor"
3
- require "yaml"
4
3
 
5
4
  # require laravel files
6
5
  require "laravel/version"
@@ -9,4 +8,3 @@ require "laravel/helpers"
9
8
  require "laravel/app_support"
10
9
  require "laravel/app"
11
10
  require "laravel/configuration"
12
- require "laravel/installer"
@@ -4,35 +4,67 @@ module Laravel
4
4
  # AppSupport module, which is being included as a mixin here.
5
5
  #
6
6
  class App
7
- # include the AppSupport module which has all the methods defined.
7
+ # include the Helpers and AppSupport modules which have all the helper methods defined.
8
8
  include Laravel::Helpers
9
9
  include Laravel::AppSupport
10
10
 
11
11
  # these attributes must be available as: object.attribute
12
- attr_reader :cache_folder, :laravel_repo, :app_path, :source, :cache, :options
12
+ attr_reader :path, :source, :cache, :options
13
13
 
14
14
  # This method initializes a new App object for us, on which we can apply
15
15
  # our changes. Logically, this new App object represents an application
16
16
  # based on Laravel.
17
17
  #
18
18
  # ==== Parameters
19
- # +app_path+ :: The path to the Laravel based application. This can either
19
+ # +path+ :: The path to the Laravel based application. This can either
20
20
  # be a relative path to the current directory, or the absolute path. If
21
- # +app_path+ is not supplied, we assume current directory.
21
+ # +path+ is not supplied, we assume current directory.
22
22
  #
23
23
  # +options+ :: A hash of options for this application. This hash can be
24
24
  # created manually, but more closely resembles the options choosen by the
25
25
  # user and forwarded by the Thor to us.
26
26
  #
27
- def initialize(app_path = nil, options = nil)
28
- app_path = Dir.pwd if not app_path or app_path.empty?
29
- @app_path = File.expand_path(app_path)
27
+ def initialize(path = nil, options = nil)
28
+ self.path = path
29
+ self.options = options
30
+ self.source = options[:source] if options
31
+ self.source = LaravelRepo if not @source
32
+ end
33
+
34
+ # Expands the supplied +path+ for the application so that we have an absolute
35
+ # directory path to work with.
36
+ #
37
+ # ==== Parameters
38
+ # +path+ :: The path to the laravel based application. If path is not supplied,
39
+ # we assume the current directory.
40
+ #
41
+ def path=(path="")
42
+ path = Dir.pwd if not path or path.empty?
43
+ @path = File.expand_path(path)
44
+ end
30
45
 
31
- @options = options
46
+ # Merge the given options with the already existing options.
47
+ #
48
+ # ==== Parameters
49
+ # +options+ :: a hash of options to merge
50
+ #
51
+ def options=(options={})
52
+ @options = @options ? @options.merge(options) : options
53
+ end
32
54
 
55
+ # Set the source for this application, and implicitely, set the directory
56
+ # path for the local cache for this source.
57
+ #
58
+ # ==== Parameters
59
+ # +source+ :: the source url or directory path
60
+ #
61
+ def source=(source=nil)
62
+ # source must default to Official Laravel Repository if none is provided
33
63
  @source = options[:source] if options
34
64
  @source = LaravelRepo if not @source or @source.empty?
35
65
 
66
+ # if the specified source is a remote repository, create a cache
67
+ # directory otherwise, use the source as the cache
36
68
  @cache = source_is_local? ? @source : cache_directory
37
69
  end
38
70
 
@@ -42,8 +74,7 @@ module Laravel
42
74
  # cache for the given source, and then copies over the files from this
43
75
  # cache to the specified directory. Finally, it checks if we have a working
44
76
  # Laravel application at which point it either raises and error and cleans
45
- # up, or configures the application and installs tasks/bundles, as
46
- # requested.
77
+ # up, or configures the application, as requested.
47
78
  #
48
79
  def create
49
80
  # check if we are missing the required force
@@ -58,33 +89,36 @@ module Laravel
58
89
  # copy the framework files from the cache
59
90
  copy_over_cache_files
60
91
 
61
- # make necessary changes for the new app, if we were successful in download
62
- # otherwise, remove the downloaded source
92
+ # make necessary changes for the new app, if we were successful in
93
+ # download otherwise, remove the downloaded source
63
94
  if has_laravel?
64
95
  say_success "Cloned Laravel repository."
96
+
97
+ # update permissions on storage/ directory (this is the default)
98
+ update_permissions_on_storage if @options[:perms]
99
+
100
+ # configure this new application, as required
65
101
  configure_from_options
66
- install_from_options
102
+
67
103
  say_success "Hurray! Your Laravel application has been created!"
68
104
  else
69
- say_failed "Downloaded source is not Laravel framework or a possible fork."
105
+ say_failed "Downloaded source is not Laravel framework or its fork."
70
106
  show_info "Cleaning up.."
107
+ # remove all directories that we created, as well as the cache.
71
108
  clean_up
72
- raise InvalidSourceRepositoryError
109
+ # raise an error since we failed.. :(
110
+ raise LaravelError, "Source for downloading repository is corrupt!"
73
111
  end
74
112
  end
75
113
 
76
- # This method installs the required tasks/bundles by the user.
77
- # It does so by invoking the 'from_options' method of the Installer class.
78
- def install_from_options
79
- install = Installer.new(@app_path, @options)
80
- install.from_options
81
- end
82
-
83
114
  # This method configures the application as required by the user.
84
115
  # It does so by invoking the 'from_options' method of the Configuration class.
116
+ #
85
117
  def configure_from_options
86
- config = Configuration.new(@app_path, @options)
87
- config.update_from_options
118
+ if @options[:config]
119
+ config = Configuration.new(@path, @options[:config])
120
+ config.from_options
121
+ end
88
122
  end
89
123
  end
90
124
  end
@@ -3,15 +3,31 @@ require 'digest/md5'
3
3
  module Laravel
4
4
  # various methods that help with various classes defined for the Laravel module
5
5
  module AppSupport
6
+ # include various Laravel Helpers
6
7
  include Laravel::Helpers
7
8
 
9
+ # Run a command using 'artisan'
10
+ #
11
+ # ==== Parameters
12
+ # +command+ :: command to run
13
+ #
14
+ def artisan(command, options = {})
15
+ raise LaravelNotFoundError unless laravel_exists_in_directory?(@path)
16
+ php = `which php`.strip
17
+ raise RequiredLibraryMissingError, "php" unless php
18
+ command = "#{php} #{@path}/artisan #{command}"
19
+ output = `#{command}`
20
+ puts output unless options[:quiet]
21
+ ($?.exitstatus == 0)
22
+ end
23
+
8
24
  # Return the path to the local cache directory for a given Source
9
25
  #
10
26
  # ==== Return
11
27
  # +string+ :: Filepath to the local cache directory
12
28
  #
13
29
  def cache_directory
14
- File.join(Laravel::App::CacheFolder, make_md5(@source))
30
+ File.join(CacheFolder, make_md5(@source))
15
31
  end
16
32
 
17
33
  # Check whether the app directory is the current directory.
@@ -22,7 +38,7 @@ module Laravel
22
38
  # +boolean+ :: True, if the app directory is the current directory.
23
39
  #
24
40
  def create_in_current_directory?
25
- is_current_directory?(@app_path)
41
+ is_current_directory?(@path)
26
42
  end
27
43
 
28
44
  # Check whether the app directory is empty?
@@ -34,7 +50,7 @@ module Laravel
34
50
  # +boolean+ :: True, if the app directory is an empty one.
35
51
  #
36
52
  def create_in_empty_directory?
37
- is_empty_directory?(@app_path)
53
+ is_empty_directory?(@path)
38
54
  end
39
55
 
40
56
  # Check whether the specified source is a local directory or a URL?
@@ -46,25 +62,13 @@ module Laravel
46
62
  File.directory?(@source)
47
63
  end
48
64
 
49
- # Merge the specified options with the options specified on the command line.
50
- #
51
- # ==== Parameters
52
- # +options+ :: hash of options passed at the command line
53
- #
54
- # ==== Return
55
- # +hash+ :: hash of merged options
56
- #
57
- def merge_options(options)
58
- @options.merge!(options)
59
- end
60
-
61
65
  # Return the path to the configuration file for the current application
62
66
  #
63
67
  # ==== Return
64
68
  # +string+ :: path to the configuration file
65
69
  #
66
70
  def config_file
67
- File.join(@app_path, %w[ application config application.php ])
71
+ File.join(@path, %w[ application config application.php ])
68
72
  end
69
73
 
70
74
  # Return the path to a tasks file by its name
@@ -76,7 +80,7 @@ module Laravel
76
80
  # +string+ :: path to the tasks file
77
81
  #
78
82
  def tasks_file(name)
79
- File.expand_path(File.join(@app_path, %w[ application tasks ], name))
83
+ File.expand_path(File.join(@path, %w[ application tasks ], name))
80
84
  end
81
85
 
82
86
  # check if laravel framework exists in the current application's directory
@@ -87,7 +91,7 @@ module Laravel
87
91
  # +boolean+ :: true, if laravel framework exists
88
92
  #
89
93
  def has_laravel?
90
- laravel_exists_in_directory?(@app_path)
94
+ laravel_exists_in_directory?(@path)
91
95
  end
92
96
 
93
97
  # check if the cache exists for the source specified by the current
@@ -105,20 +109,21 @@ module Laravel
105
109
  # the 'force' option, and then checks if the 'force' option is provided
106
110
  # by the user.
107
111
  #
108
- # Whether the path requires 'force' is determined as:
109
- # -- it is not the current directory
110
- # -- it is the current directory but is empty
112
+ # 'force' is required if the application path:
113
+ # -- exists but is not the current directory
114
+ # -- is the current directory but is not empty
111
115
  #
112
- # ==== Return
113
- # +error+ :: raises an error, if the 'force' parameter is required!!
116
+ # ==== Raises
117
+ # +LaravelError+ :: if the 'force' parameter is required!!
114
118
  #
115
119
  def required_force_is_missing?
116
120
  # we need force if path exists and is not the current directory
117
- check_force = (File.exists?(@app_path) and not create_in_current_directory?)
121
+ check_force = (File.exists?(@path) and not create_in_current_directory?)
118
122
  # we need force if path is current directory but is not empty
119
123
  check_force ||= (create_in_current_directory? and not create_in_empty_directory?)
120
124
  # raise an error when we need to force and we have not been supplied with enforcements
121
- raise RequiredForceMissingError if check_force and not @options[:force]
125
+ message = "Overwrite required. You must pass in 'force' flag to overwrite!"
126
+ raise LaravelError, message if check_force and not @options[:force]
122
127
  end
123
128
 
124
129
  # Depending on whether the 'force' parameter is provided, this method
@@ -128,8 +133,8 @@ module Laravel
128
133
  #
129
134
  def apply_force
130
135
  show_info "Creating application forcefully!" if @options[:force]
131
- FileUtils.rm_rf("#{@app_path}/.", :secure => true) if File.exists?(@app_path) and @options[:force]
132
- FileUtils.mkdir_p @app_path
136
+ FileUtils.rm_rf("#{@path}/.", :secure => true) if File.exists?(@path) and @options[:force]
137
+ FileUtils.mkdir_p @path
133
138
  end
134
139
 
135
140
  # This method downloads or updates the local cache for the current source.
@@ -142,17 +147,21 @@ module Laravel
142
147
  # caches it locally.
143
148
  #
144
149
  def download_or_update_local_cache
150
+ # we have nothing to download if the source is a local directory
145
151
  return if source_is_local?
152
+ # we need git for this purpose
146
153
  raise RequiredLibraryMissingError, "git" if `which git`.empty?
154
+
155
+ # create the cache, and download or update as required
147
156
  FileUtils.mkdir_p @cache
148
157
  Dir.chdir(@cache) do
149
158
  if has_cache?
150
159
  show_info "Repository exists in local cache.."
151
160
  show_info "Updating local cache.."
152
- `git pull &>/dev/null`
161
+ `git pull -q`
153
162
  else
154
163
  show_info "Downloading repository to local cache.."
155
- `git clone #{@source} . &>/dev/null`
164
+ `git clone -q #{@source} .`
156
165
  end
157
166
  end
158
167
  end
@@ -161,17 +170,17 @@ module Laravel
161
170
  # application.
162
171
  #
163
172
  def copy_over_cache_files
164
- FileUtils.cp_r "#{@cache}/.", @app_path
173
+ FileUtils.cp_r "#{@cache}/.", @path
165
174
  end
166
175
 
167
- # This method updates the permissions on the storage/ directory inside
168
- # the newly created application. This method does not have a separate exposed
169
- # call from the CLI. This can be skipped by passing '--no-perms' for the 'new'
170
- # command.
176
+ # This method updates the permissions on the storage/ directory inside the
177
+ # newly created application. This method does not have a separate exposed
178
+ # call from the CLI. This can be skipped by passing '--no-perms' flag for
179
+ # the 'new' command.
171
180
  #
172
181
  def update_permissions_on_storage
173
182
  if @options[:perms]
174
- response = system("chmod -R o+w #{File.join(@app_path, 'storage')}")
183
+ response = system("chmod -R o+w #{File.join(@path, 'storage')}")
175
184
  if response
176
185
  say_success "Updated permissions on storage/ directory."
177
186
  else
@@ -186,18 +195,11 @@ module Laravel
186
195
  #
187
196
  # Keeping the local cache does not make sense, since we anyways can not create
188
197
  # applications based on these 'corrupt' repositories.
198
+ #
189
199
  def clean_up
190
- FileUtils.rm_rf "#{@app_path}" unless create_in_current_directory?
200
+ FileUtils.rm_rf "#{@path}" unless create_in_current_directory?
191
201
  FileUtils.rm_rf "#{@cache}"
192
202
  end
193
203
 
194
-
195
- def read_gem_settings
196
- read_yaml GemSettings
197
- end
198
-
199
- def write_gem_settings(data)
200
- write_yaml data, GemSettings
201
- end
202
204
  end
203
205
  end