laravel 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/features/new.feature CHANGED
@@ -38,4 +38,13 @@ Feature: Laravel 'new'
38
38
  When I run `laravel new my_app --remote=http://github.com/github/gitignore`
39
39
  Then local cache for "non_laravel" repository should not be created
40
40
  And the stdout should contain "source is corrupt"
41
+ And the stdout should contain "ERROR"
41
42
  And laravel application must not be created inside "my_app" directory
43
+
44
+ @may_require_repository_download
45
+ Scenario: create Laravel application in the current directory
46
+ When I run `laravel new . --force`
47
+ Then the stdout should contain "Hurray!"
48
+ And laravel application must be created inside current directory
49
+ When I run `laravel new .`
50
+ Then the stdout should contain "ERROR"
@@ -9,6 +9,11 @@ Then /^laravel application must not be created inside "(.*?)" directory$/ do |di
9
9
  !File.exists?(dir)
10
10
  end
11
11
 
12
+ Then /^laravel application must be created inside current directory$/ do
13
+ dir = File.expand_path(Dir.pwd)
14
+ Laravel::has_laravel?(dir)
15
+ end
16
+
12
17
  Then /^local cache for "(.*?)" repository should not be created$/ do |repo|
13
18
  repo = get_test_repo_path(repo)
14
19
  !File.exists?(repo)
@@ -1,6 +1,13 @@
1
1
  require "aruba/cucumber"
2
2
  require "laravel"
3
3
 
4
+ After do
5
+ test_directory = File.expand_path(File.join(File.dirname(__FILE__), %w[ .. .. tmp aruba]))
6
+ FileUtils.rm_rf(File.join(test_directory, "my_app"))
7
+ FileUtils.rm_rf(File.join(test_directory, "laravel"))
8
+ FileUtils.rm_rf(File.join(test_directory, "current"))
9
+ end
10
+
4
11
  Before('@very_slow') do
5
12
  @aruba_timeout_seconds = 300
6
13
  end
@@ -16,8 +23,3 @@ end
16
23
  Before('@slow') do
17
24
  @aruba_timeout_seconds = 60
18
25
  end
19
-
20
- After do
21
- FileUtils.rm_rf(File.join(%w[ tmp aruba my_app]))
22
- FileUtils.rm_rf(File.join(%w[ tmp aruba laravel]))
23
- end
@@ -1,6 +1,5 @@
1
1
  module LaravelHelpers
2
- # this is what `aruba` changes directory to, when testing
3
- TestDirectory = File.expand_path(File.join(%w[ tmp aruba]))
2
+ TestDirectory = File.expand_path(File.join(File.dirname(__FILE__), %w[ .. .. tmp aruba]))
4
3
 
5
4
  def get_relative_path_to_test_directory(dir, relative_to = nil)
6
5
  relative_to = TestDirectory unless relative_to
@@ -14,26 +14,34 @@ module Laravel
14
14
  # - string containing error message, if any or is otherwise nil
15
15
  #
16
16
  def self.source(path, options = {})
17
+ # get some information about this path
18
+ path = File.expand_path(path)
19
+ is_current_dir = (path == File.expand_path('.'))
20
+ is_not_empty = (Dir.entries(path).size > 2) if File.exists?(path)
17
21
 
18
22
  # make sure that the path does not already exists (no overwrites!)
19
- if File.exists?(path) and not options[:force]
20
- Laravel::say_error "directory already exists!"
23
+ if ((File.exists?(path) and not is_current_dir) or (is_current_dir and is_not_empty)) and not options[:force]
24
+ Laravel::say_error "directory already exists or is not empty!"
21
25
  end
22
26
 
23
27
  # delete the existing files, if we are forced for this
24
28
  if options[:force]
25
29
  Laravel::say_info "Creating application forcefully!"
26
- FileUtils.rm_rf path
30
+ is_current_dir ? FileUtils.rm_rf("#{path}/.", :secure => true) : FileUtils.rm_rf(path)
27
31
  end
28
32
 
29
33
  # create the requisite directory structure
30
- FileUtils.mkdir_p File.dirname(path)
34
+ FileUtils.mkdir_p File.dirname(path) unless is_current_dir
31
35
 
32
36
  # download/update local repository as required
33
37
  local_repo_for_remote_path = options[:local] || self.local_repository(options)
34
38
 
35
39
  # copy the Laravel source to the required path
36
- FileUtils.cp_r local_repo_for_remote_path, path
40
+ if is_current_dir
41
+ FileUtils.cp_r "#{local_repo_for_remote_path}/.", path
42
+ else
43
+ FileUtils.cp_r local_repo_for_remote_path, path
44
+ end
37
45
 
38
46
  # make necessary changes for the new app, if we were successful in download
39
47
  # otherwise, remove the downloaded source
@@ -44,7 +52,7 @@ module Laravel
44
52
  else
45
53
  Laravel::say_failed "Downloaded source is not Laravel framework or a possible fork."
46
54
  Laravel::say_info "Cleaning up.."
47
- FileUtils.rm_rf "#{path}"
55
+ FileUtils.rm_rf "#{path}" unless is_current_dir
48
56
  # delete_corrupted = Laravel::yes? "Should I delete the specified repository from local cache? (default: yes)"
49
57
  # if delete_corrupted
50
58
  # Laravel::say_info "Deleting local cache for this source!"
@@ -1,3 +1,3 @@
1
1
  module Laravel
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: laravel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: