laravel 0.0.2 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.travis.yml CHANGED
@@ -4,3 +4,6 @@ rvm:
4
4
  - 1.9.2
5
5
  - 1.9.3
6
6
  - ruby-head
7
+ matrix:
8
+ allow_failures:
9
+ - rvm: ruby-head
data/README.md CHANGED
@@ -8,7 +8,8 @@ Still in development.
8
8
 
9
9
  [![Code
10
10
  Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/nikhgupta/laravel)
11
-
11
+ | [![Dependency
12
+ Status](https://gemnasium.com/nikhgupta/laravel.png)](https://gemnasium.com/nikhgupta/laravel) | [![Build Status](https://travis-ci.org/nikhgupta/laravel.png?branch=master)](https://travis-ci.org/nikhgupta/laravel)
12
13
  ## Installation
13
14
 
14
15
  Add this line to your application's Gemfile:
@@ -39,25 +40,34 @@ source, you can create new Laravel application based on your own or someone
39
40
  else's fork of Laravel, if required. And, yes! These repositories will be
40
41
  cached!
41
42
 
42
- # with default settings (fetches source from http://github.com/laravel/laravel.git)
43
+ # use default settings (fetches source from http://github.com/laravel/laravel.git)
43
44
  laravel new my_app
44
45
 
45
46
  # force a clean install on existing directory
46
47
  laravel new my_app --force
47
48
 
48
- # using an existing (already downloaded) source
49
+ # use an existing (already downloaded) source
49
50
  laravel new my_app --local=/usr/src/laravel
50
51
 
51
- # using a remote repository
52
+ # use a remote repository
52
53
  laravel new my_app --remote="http://github.com/user/my_laravel_fork"
53
54
 
55
+ # use default settings and update Application Index
56
+ laravel new my_app --index='home.php'
57
+
58
+ ### In an existing Laravel application
59
+
60
+ # update Application Index for the application
61
+ laravel update_index '' # removes application index for app in current directory
62
+ laravel update_index 'home.php' --app=./new_app # update for app in specified directory
63
+
54
64
  ### Help
55
65
 
56
66
  laravel help
57
67
 
58
68
  ## Coming Soon..
59
69
  # create and customize a new Laravel application
60
- laravel new my_app --index='' # set application index to blank
70
+ <del>laravel new my_app --index='' # set application index to blank</del>
61
71
  laravel new my_app --[no-]key # generate a new key
62
72
  laravel new my_app --database=db_my_app # create a database, defaults to app name
63
73
  laravel new my_app --[no-]generator # download the Laravel Generator by Jeffrey Way
@@ -70,3 +80,10 @@ cached!
70
80
  3. Commit your changes (`git commit -am 'Add some feature'`)
71
81
  4. Push to the branch (`git push origin my-new-feature`)
72
82
  5. Create new Pull Request
83
+
84
+ ## Testing
85
+
86
+ Note that, the tests for this gem can be really slow, since we download
87
+ repositories from github for properly testing the gem. Moreover, running the
88
+ test suite will download the official Laravel repository in the local cache,
89
+ thereby, speeding up creation of new applications.
data/Rakefile CHANGED
@@ -1,7 +1,10 @@
1
1
  require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
2
+ require 'cucumber'
3
+ require 'cucumber/rake/task'
3
4
 
4
- RSpec::Core::RakeTask.new
5
+ Cucumber::Rake::Task.new(:features) do |t|
6
+ t.cucumber_opts = "features --format pretty"
7
+ end
5
8
 
6
- task :default => :spec
7
- task :test => :spec
9
+ task :default => :features
10
+ task :test => :features
data/bin/laravel CHANGED
@@ -6,41 +6,48 @@ require "pathname"
6
6
  bin_file = Pathname.new(__FILE__).realpath
7
7
 
8
8
  # add self to libpath
9
- $:.unshift File.expand_path("../../lib", bin_file)
9
+ $:.unshift File.expand_path(File.join(%w[ .. .. lib]), bin_file)
10
10
 
11
- require "laravel"
12
- require "thor"
11
+ require "laravel" # which indirectly requires 'thor'
13
12
 
14
13
  module Laravel
15
14
  class CLI < Thor
16
15
 
17
16
  # display version/information about this gem
17
+ # default => display usage information for the gem
18
+ # --version => display current Laravel version
18
19
  desc "info", "displays usage information about this gem."
19
20
  method_options %w( version -v) => :boolean
20
21
  def info
21
- if options[:version]
22
- puts "Laravel v#{Laravel::VERSION}"
23
- else
24
- puts Laravel::INFO
25
- end
22
+ puts options[:version] ? "Laravel v#{Laravel::VERSION}" : Laravel::INFO
26
23
  # puts "Made possible by efforts of Laravel Community"
27
24
  end
28
25
 
29
26
  # create a new laravel application
27
+ # default => create a bare bone Laravel application
28
+ # --local => use a local directory for source
29
+ # --remote => use a remote git repository for source
30
+ # --index => update Application Index for newly created application
31
+ # --force => overwrite target directory, if it exists
30
32
  desc "new [MY_APP]", "install a new Laravel application"
31
- method_option :local, :type => :string, :aliases => "-l", :banner => "DIRECTORY",
33
+ method_option :local, :type => :string, :aliases => "-l", :banner => "DIRECTORY",
32
34
  :desc => "use laravel source from a local directory"
33
35
  method_option :remote, :type => :string, :aliases => "-r", :banner => "GIT_REPO",
34
36
  :desc => "use this git repository instead (useful when working with forks, e.g.)"
35
- method_option :force, :type => :boolean, :aliases => "-f",
36
- :desc => "force overwrite"
37
+ method_option :force, :type => :boolean, :desc => "force overwrite"
38
+ method_option :index, :type => :string, :aliases => "-i",
39
+ :desc => "change the Application Index"
37
40
  def new(app_name)
38
- result = Laravel::Download::source app_name, options
39
- if result
40
- say_status "ERROR!!", result, :red
41
- else
42
- say_status "Success", "Application Downloaded Successfully!"
43
- end
41
+ Laravel::Create::source app_name, options
42
+ end
43
+
44
+ # allow the user to modify Application Index
45
+ # --app => use the given directory instead of pwd
46
+ desc "update_index [NEW_INDEX]", "modify the Application Index for Laravel application"
47
+ method_option :app, :type => :string, :aliases => "-a",
48
+ :desc => "use the specified Laravel application instead of current directory"
49
+ def update_index(new_index)
50
+ Laravel::Manage::update_index new_index, options[:app]
44
51
  end
45
52
 
46
53
  # choose a default task to run
@@ -49,4 +56,4 @@ module Laravel
49
56
  end
50
57
  end
51
58
 
52
- Laravel::CLI.start
59
+ Laravel::CLI.start # starts our CLI application
@@ -0,0 +1,41 @@
1
+ Feature: Laravel 'new'
2
+ In order to create a new application based on Laravel framework
3
+ As a PHP developer acquinted with ruby
4
+ I want to use Laravel gem
5
+
6
+ @requires_repository_download @very_slow
7
+ Scenario: create Laravel application with default settings
8
+ Given local cache does not exist for "official" repository
9
+ When I run `laravel new my_app`
10
+ Then local cache for "official" repository should exist
11
+ And the stdout should contain "Hurray!"
12
+ And laravel application must be created inside "my_app" directory
13
+
14
+ @requires_repository_download
15
+ Scenario: create Laravel application using source from a non-official repo
16
+ Given local cache does not exist for "pastes" repository
17
+ When I run `laravel new my_app --remote=http://github.com/laravel/pastes`
18
+ Then local cache for "pastes" repository should exist
19
+ And the stdout should contain "Hurray!"
20
+ And laravel application must be created inside "my_app" directory
21
+
22
+ @may_require_repository_download
23
+ Scenario: create Laravel application using repository from local cache
24
+ Given local cache exists for "official" repository
25
+ When I run `laravel new my_app --remote=http://github.com/laravel/pastes`
26
+ Then the stdout should contain "Hurray!"
27
+ And laravel application must be created inside "my_app" directory
28
+
29
+ @may_require_repository_download
30
+ Scenario: create Laravel application using source from a directory
31
+ Given laravel source has already been downloaded in "laravel" directory
32
+ When I run `laravel new my_app --local=laravel`
33
+ Then the stdout should contain "Hurray!"
34
+ And laravel application must be created inside "my_app" directory
35
+
36
+ @requires_repository_download
37
+ Scenario: create Laravel application using non-laravel repository
38
+ When I run `laravel new my_app --remote=http://github.com/github/gitignore`
39
+ Then local cache for "non_laravel" repository should not be created
40
+ And the stdout should contain "source is corrupt"
41
+ And laravel application must not be created inside "my_app" directory
@@ -0,0 +1,34 @@
1
+ # existance of local cache
2
+ Given /^local cache exists for "(.*?)" repository$/ do |repo|
3
+ repo_url = get_test_repo_url(repo)
4
+ repo_path = get_test_repo_path(repo, repo_url)
5
+ # easiest method to ensure local cache exists is to clone repo from github
6
+ unless Laravel::has_laravel?(repo_path)
7
+ FileUtils.rm_rf repo_path
8
+ `git clone #{repo_url} #{repo_path} &>/dev/null`
9
+ end
10
+ end
11
+
12
+ Given /^local cache does not exist for "(.*?)" repository$/ do |repo|
13
+ repo_path = get_test_repo_path(repo)
14
+ FileUtils.rm_rf repo_path
15
+ end
16
+
17
+ Then /^local cache for "(.*?)" repository should exist$/ do |repo|
18
+ repo_path = get_test_repo_path(repo)
19
+ Laravel::has_laravel?(repo_path)
20
+ end
21
+
22
+ # download related
23
+ Given /^laravel source has already been downloaded in "(.*?)" directory$/ do |dir|
24
+ default_repo = get_test_repo_path("official")
25
+ dir = get_relative_path_to_test_directory(dir)
26
+ # creating new default app is virtually same as downloading the source code
27
+ Laravel::Create::source(dir, :force => true, :quiet => true) unless Laravel::has_laravel?(dir)
28
+ end
29
+
30
+ # suppress any output from Thor based shell while testing
31
+ module Laravel
32
+ def self.say(status, message = "", log_status = true)
33
+ end
34
+ end
@@ -0,0 +1,21 @@
1
+ # creation of applications
2
+ Then /^laravel application must be created inside "(.*?)" directory$/ do |dir|
3
+ dir = get_relative_path_to_test_directory(dir)
4
+ Laravel::has_laravel?(dir)
5
+ end
6
+
7
+ Then /^laravel application must not be created inside "(.*?)" directory$/ do |dir|
8
+ dir = get_relative_path_to_test_directory(dir)
9
+ !File.exists?(dir)
10
+ end
11
+
12
+ Then /^local cache for "(.*?)" repository should not be created$/ do |repo|
13
+ repo = get_test_repo_path(repo)
14
+ !File.exists?(repo)
15
+ end
16
+
17
+ # suppress any output from Thor based shell while testing
18
+ module Laravel
19
+ def self.say(status, message = "", log_status = true)
20
+ end
21
+ end
@@ -0,0 +1,16 @@
1
+ Given /^laravel application exists in "(.*?)" directory$/ do |dir|
2
+ dir = get_relative_path_to_test_directory(dir)
3
+ Laravel::Create::source(dir) unless Laravel::has_laravel?(dir)
4
+ end
5
+
6
+ Then /^application index must be set to "(.*?)" for "(.*?)" application$/ do |new_index, dir|
7
+ dir = get_relative_path_to_test_directory(dir)
8
+ config_file = File.join(dir, %w[ application config application.php ])
9
+ File.readlines(config_file).grep(/'index' => '#{new_index}'/).any?
10
+ end
11
+
12
+ # suppress any output from Thor based shell while testing
13
+ module Laravel
14
+ def self.say(status, message = "", log_status = true)
15
+ end
16
+ end
@@ -0,0 +1,23 @@
1
+ require "aruba/cucumber"
2
+ require "laravel"
3
+
4
+ Before('@very_slow') do
5
+ @aruba_timeout_seconds = 300
6
+ end
7
+
8
+ Before('@requires_repository_download') do
9
+ @aruba_timeout_seconds = 300
10
+ end
11
+
12
+ Before('@may_require_repository_download') do
13
+ @aruba_timeout_seconds = 300
14
+ end
15
+
16
+ Before('@slow') do
17
+ @aruba_timeout_seconds = 60
18
+ 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
@@ -0,0 +1,25 @@
1
+ module LaravelHelpers
2
+ # this is what `aruba` changes directory to, when testing
3
+ TestDirectory = File.expand_path(File.join(%w[ tmp aruba]))
4
+
5
+ def get_relative_path_to_test_directory(dir, relative_to = nil)
6
+ relative_to = TestDirectory unless relative_to
7
+ File.expand_path(dir, relative_to)
8
+ end
9
+
10
+ def get_test_repo_url(repo = nil)
11
+ case repo
12
+ when nil, "official", "default" then Laravel::OfficialRepository
13
+ when "pastes" then "http://github.com/laravel/pastes"
14
+ when "non_laravel" then "http://github.com/github/gitignore"
15
+ else repo
16
+ end
17
+ end
18
+
19
+ def get_test_repo_path(repo = nil, repo_url = nil)
20
+ repo_url = get_test_repo_url(repo) unless repo_url
21
+ Laravel::crypted_path(repo_url)
22
+ end
23
+ end
24
+
25
+ World(LaravelHelpers)
@@ -0,0 +1,19 @@
1
+ Feature: Laravel 'update_index'
2
+ In order to update Application Index in a Laravel application
3
+ As a PHP developer acquinted with ruby
4
+ I want to use Laravel gem
5
+
6
+ @may_require_repository_download
7
+ Scenario: update Application Index in a Laravel application
8
+ Given laravel application exists in "my_app" directory
9
+ When I run `laravel update_index 'home.php' --app=my_app`
10
+ Then the stdout should contain "Changed Application Index"
11
+ And application index must be set to "home.php" for "my_app" application
12
+
13
+ @may_require_repository_download
14
+ Scenario: create Laravel application without an Application Index
15
+ When I run `laravel new my_app --index=''`
16
+ Then local cache for "official" repository should exist
17
+ And the stdout should contain "Hurray!"
18
+ And laravel application must be created inside "my_app" directory
19
+ And application index must be set to "" for "my_app" application
data/laravel.gemspec CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |gem|
10
10
  gem.email = ["me@nikhgupta.com"]
11
11
  gem.description = %q{A wrapper around Laravel framework for PHP}
12
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.}
13
- gem.homepage = "https://rubygems.org/gems/laravel"
13
+ gem.homepage = "https://github.com/nikhgupta/laravel"
14
14
 
15
15
  gem.files = `git ls-files`.split($/)
16
16
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
@@ -20,7 +20,9 @@ Gem::Specification.new do |gem|
20
20
  gem.add_dependency 'thor'
21
21
 
22
22
  gem.add_development_dependency 'rake'
23
- gem.add_development_dependency 'rspec'
24
- gem.add_development_dependency 'guard-rspec'
25
- gem.add_development_dependency 'rb-fsevent'
23
+ 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'
26
28
  end
data/lib/laravel.rb CHANGED
@@ -1,4 +1,9 @@
1
+ # require dependencies
2
+ require "thor"
3
+
4
+ # require laravel files
1
5
  require "laravel/version"
2
6
  require "laravel/info"
3
7
  require "laravel/helpers"
4
- require "laravel/download"
8
+ require "laravel/manage"
9
+ require "laravel/create"
@@ -1,5 +1,5 @@
1
1
  module Laravel
2
- class Download
2
+ class Create
3
3
  # This method downloads the Laravel source files.
4
4
  #
5
5
  # When downloading from remote repositories, it checks to see if we have
@@ -13,32 +13,48 @@ module Laravel
13
13
  # * *Returns* :
14
14
  # - string containing error message, if any or is otherwise nil
15
15
  #
16
- def self.source(path, options)
16
+ def self.source(path, options = {})
17
17
 
18
18
  # make sure that the path does not already exists (no overwrites!)
19
19
  if File.exists?(path) and not options[:force]
20
- return "directory already exists!"
20
+ Laravel::say_error "directory already exists!"
21
21
  end
22
22
 
23
23
  # delete the existing files, if we are forced for this
24
- FileUtils.rm_rf path if options[:force]
24
+ if options[:force]
25
+ Laravel::say_info "Creating application forcefully!"
26
+ FileUtils.rm_rf path
27
+ end
25
28
 
26
29
  # create the requisite directory structure
27
30
  FileUtils.mkdir_p File.dirname(path)
28
31
 
29
32
  # download/update local repository as required
30
- local_repo_for_remote_path = options[:local] || Laravel::Download::local_repository(options)
33
+ local_repo_for_remote_path = options[:local] || self.local_repository(options)
31
34
 
32
35
  # copy the Laravel source to the required path
33
36
  FileUtils.cp_r local_repo_for_remote_path, path
34
37
 
35
- # remove the downloaded source if it is not a valid laravel source
36
- unless Laravel::has_laravel? path
38
+ # make necessary changes for the new app, if we were successful in download
39
+ # otherwise, remove the downloaded source
40
+ if Laravel::has_laravel? path
41
+ Laravel::say_success "Cloned Laravel repository."
42
+ Laravel::Manage::update_index options[:index], path if options.has_key?("index")
43
+ Laravel::say_success "Hurray! Your Laravel application has been created!"
44
+ else
45
+ Laravel::say_failed "Downloaded source is not Laravel framework or a possible fork."
46
+ Laravel::say_info "Cleaning up.."
37
47
  FileUtils.rm_rf "#{path}"
48
+ # delete_corrupted = Laravel::yes? "Should I delete the specified repository from local cache? (default: yes)"
49
+ # if delete_corrupted
50
+ # Laravel::say_info "Deleting local cache for this source!"
51
+ # FileUtils.rm_rf "#{local_repo_for_remote_path}"
52
+ # else
53
+ # Laravel::say_info "Local cache for this source was not deleted!"
54
+ # end
38
55
  FileUtils.rm_rf "#{local_repo_for_remote_path}"
39
- return "laravel source is corrupted!"
56
+ Laravel::say_error "Specified Laravel source is corrupt!"
40
57
  end
41
-
42
58
  end
43
59
 
44
60
  # Create or update local repository whenever a remote source is specified.
@@ -50,7 +66,7 @@ module Laravel
50
66
  #
51
67
  def self.local_repository(options = {})
52
68
  # do not attempt download/update if user specifically wants to stay offline
53
- return if options.has_key?(:local)
69
+ return if options.has_key?("local")
54
70
 
55
71
  # prefer remote path, if specifically supplied by user
56
72
  # otherwise, default to the official repository
@@ -61,17 +77,22 @@ module Laravel
61
77
  git = `which git`.strip
62
78
 
63
79
  # string which will suppress the output of commands in quiet mode
64
- quiet = options[:quiet] ? "&>/dev/null" : "1>/dev/null"
80
+ # quiet = options[:quiet] ? "&>/dev/null" : "1>/dev/null"
81
+ quiet = "&>/dev/null"
65
82
 
66
83
  # update or download the remote repository
67
84
  FileUtils.mkdir_p local_path_for_remote_repo
85
+ # say_info "Created requisite directory structure."
68
86
  Dir.chdir local_path_for_remote_repo do
87
+ # do an update if cache exists, otherwise download it
88
+ # do this every time before creating new app so that we are always up-to-date
69
89
  if Laravel::local_repository_exists?(remote_repo)
70
- puts "Updating repository in local cache.." unless options[:quiet]
71
- puts `#{git} pull #{quiet}`
90
+ Laravel::say_info "Repository exists in local cache.."
91
+ Laravel::say_info "Updating repository in local cache.."
92
+ print `#{git} pull #{quiet}`
72
93
  else
73
- puts "Downloading repository to local cache.." unless options[:quiet]
74
- puts `#{git} clone #{remote_repo} . #{quiet}`
94
+ Laravel::say_info "Downloading repository to local cache.."
95
+ print `#{git} clone #{remote_repo} . #{quiet}`
75
96
  end
76
97
  end
77
98
 
@@ -12,16 +12,10 @@ module Laravel
12
12
  true
13
13
  end
14
14
 
15
- # check if this is the first installation from this gem
16
-
17
15
  # check if local repository exists for a given remote git source
18
16
  def self.local_repository_exists?(source)
19
17
  local_repository_path = Laravel::crypted_path(source)
20
- if Laravel::has_laravel? local_repository_path
21
- local_repository_path
22
- else
23
- nil
24
- end
18
+ Laravel::has_laravel?(local_repository_path) ? local_repository_path : nil
25
19
  end
26
20
 
27
21
  # return the crypted folder name for a given remote repository
@@ -33,4 +27,33 @@ module Laravel
33
27
  def self.crypted_path(source)
34
28
  File.join(Laravel::LocalRepositories, Laravel::crypted_name(source))
35
29
  end
30
+
31
+ # ask user for confirmation
32
+ def self.yes?(message, color=nil)
33
+ shell = Thor::Shell::Color.new
34
+ shell.yes?(message, color)
35
+ end
36
+
37
+ # say something to the user.
38
+ def self.say(status, message = "", log_status = true)
39
+ shell = Thor::Shell::Color.new
40
+ shell.say_status(status, message, log_status)
41
+ end
42
+
43
+ def self.say_info(message)
44
+ self.say "Information", message, :cyan
45
+ end
46
+
47
+ def self.say_success(message)
48
+ self.say "Success", message, :green
49
+ end
50
+
51
+ def self.say_failed(message)
52
+ self.say "Failed!!", message, :yellow
53
+ end
54
+
55
+ def self.say_error(message)
56
+ self.say "!!ERROR!!", message, :red
57
+ exit
58
+ end
36
59
  end
data/lib/laravel/info.rb CHANGED
@@ -1,18 +1,23 @@
1
1
  module Laravel
2
2
  INFO = '''
3
3
  Create a new Laravel application
4
-
5
- # with default settings
6
- # fetches source from http://github.com/laravel/laravel.git
4
+ ================================
7
5
  laravel new my_app
8
-
9
- # force a clean install on existing directory
6
+ # use default settings
7
+ # fetches source from http://github.com/laravel/laravel.git
10
8
  laravel new my_app --force
11
-
12
- # using an existing (already downloaded) source
13
- laravel new my_app --local=/usr/src/laravel
14
-
15
- # using a remote repository
9
+ # force a clean install on existing directory
16
10
  laravel new my_app --remote="http://github.com/user/my_laravel_fork"
11
+ # use an existing (already downloaded) source
12
+ # use a remote repository
13
+ laravel new my_app --index=home.php
14
+ # use default settings and update Application Index
15
+
16
+ Update Application Index on existing Laravel applications
17
+ =========================================================
18
+ laravel update_index "home.php"
19
+ # in the current directory
20
+ laravel update_index "" --app=./laravel
21
+ # for application in the specified directory
17
22
  '''
18
23
  end
@@ -0,0 +1,40 @@
1
+ module Laravel
2
+ class Manage
3
+ # modify the Application Index for application
4
+ #
5
+ # * *Args* :
6
+ # - +new_index+ -> the new Application Index
7
+ # - +app_directory+ -> the directory of the Laravel app, defaults to current working directory
8
+ #
9
+ def self.update_index(new_index, app_directory = '')
10
+ # default to current working directory if path is not specified
11
+ app_directory ||= Dir.pwd
12
+
13
+ # try to change index only if this is a Laravel application
14
+ if Laravel::has_laravel? app_directory
15
+ # file path to the configuration file
16
+ config_file = %w[ application config application.php ]
17
+ config_file = File.expand_path(File.join(app_directory, config_file))
18
+
19
+ # perform substitution
20
+ text = File.read config_file
21
+ text = text.gsub(/'index' => '.*'/, "'index' => '#{new_index}'")
22
+ File.open(config_file, "w") {|file| file.puts text}
23
+
24
+ # check to ensure we were able to update index
25
+ check = File.readlines(config_file).grep(/'index' => '#{new_index}'/).any?
26
+
27
+ # show an appropriate message to the user.
28
+ if check
29
+ Laravel::say_success "Changed Application Index."
30
+ else
31
+ Laravel::say_failed "Could not change Application Index!"
32
+ end
33
+
34
+ else
35
+ Laravel::say_error "Is this a valid Laravel application?"
36
+ end
37
+ end
38
+
39
+ end
40
+ end
@@ -1,3 +1,3 @@
1
1
  module Laravel
2
- VERSION = "0.0.2"
2
+ VERSION = "0.1.0"
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.0.2
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-12-18 00:00:00.000000000 Z
12
+ date: 2012-12-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: thor
@@ -44,39 +44,7 @@ dependencies:
44
44
  - !ruby/object:Gem::Version
45
45
  version: '0'
46
46
  - !ruby/object:Gem::Dependency
47
- name: rspec
48
- requirement: !ruby/object:Gem::Requirement
49
- none: false
50
- requirements:
51
- - - ! '>='
52
- - !ruby/object:Gem::Version
53
- version: '0'
54
- type: :development
55
- prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
- requirements:
59
- - - ! '>='
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- - !ruby/object:Gem::Dependency
63
- name: guard-rspec
64
- requirement: !ruby/object:Gem::Requirement
65
- none: false
66
- requirements:
67
- - - ! '>='
68
- - !ruby/object:Gem::Version
69
- version: '0'
70
- type: :development
71
- prerelease: false
72
- version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
- requirements:
75
- - - ! '>='
76
- - !ruby/object:Gem::Version
77
- version: '0'
78
- - !ruby/object:Gem::Dependency
79
- name: rb-fsevent
47
+ name: aruba
80
48
  requirement: !ruby/object:Gem::Requirement
81
49
  none: false
82
50
  requirements:
@@ -102,22 +70,26 @@ files:
102
70
  - .gitignore
103
71
  - .travis.yml
104
72
  - Gemfile
105
- - Guardfile
106
73
  - LICENSE.txt
107
74
  - README.md
108
75
  - Rakefile
109
76
  - bin/laravel
77
+ - features/new.feature
78
+ - features/step_definitions/laravel.rb
79
+ - features/step_definitions/new.rb
80
+ - features/step_definitions/update_index.rb
81
+ - features/support/env.rb
82
+ - features/support/laravel_helpers.rb
83
+ - features/update_index.feature
110
84
  - laravel.gemspec
111
85
  - lib/laravel.rb
112
- - lib/laravel/download.rb
86
+ - lib/laravel/create.rb
113
87
  - lib/laravel/helpers.rb
114
88
  - lib/laravel/info.rb
89
+ - lib/laravel/manage.rb
115
90
  - lib/laravel/version.rb
116
91
  - repositories/.gitkeep
117
- - spec/laravel/download/download_spec.rb
118
- - spec/laravel/laravel_spec.rb
119
- - spec/spec_helper.rb
120
- homepage: https://rubygems.org/gems/laravel
92
+ homepage: https://github.com/nikhgupta/laravel
121
93
  licenses: []
122
94
  post_install_message:
123
95
  rdoc_options: []
@@ -144,6 +116,10 @@ summary: This gem is a wrapper around the Laravel framework for PHP. Initially,
144
116
  gem would allow to create new laravel apps along with options to modify the default
145
117
  behavior for these new installations.
146
118
  test_files:
147
- - spec/laravel/download/download_spec.rb
148
- - spec/laravel/laravel_spec.rb
149
- - spec/spec_helper.rb
119
+ - features/new.feature
120
+ - features/step_definitions/laravel.rb
121
+ - features/step_definitions/new.rb
122
+ - features/step_definitions/update_index.rb
123
+ - features/support/env.rb
124
+ - features/support/laravel_helpers.rb
125
+ - features/update_index.feature
data/Guardfile DELETED
@@ -1,24 +0,0 @@
1
- # A sample Guardfile
2
- # More info at https://github.com/guard/guard#readme
3
-
4
- guard 'rspec' do
5
- watch(%r{^spec/.+_spec\.rb$})
6
- watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
7
- watch('spec/spec_helper.rb') { "spec" }
8
-
9
- # Rails example
10
- watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
11
- watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
12
- watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
13
- watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
14
- watch('config/routes.rb') { "spec/routing" }
15
- watch('app/controllers/application_controller.rb') { "spec/controllers" }
16
-
17
- # Capybara features specs
18
- watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/features/#{m[1]}_spec.rb" }
19
-
20
- # Turnip features and steps
21
- watch(%r{^spec/acceptance/(.+)\.feature$})
22
- watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
23
- end
24
-
@@ -1,78 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Laravel::Download do
4
-
5
- before(:each) { Laravel::Tests::cleanup }
6
- after(:each) { Laravel::Tests::cleanup }
7
-
8
- it "should download source from a manually specified laravel repository" do
9
- # preparations
10
- options = { :remote => "https://github.com/laravel/pastes.git" }
11
- Laravel::Tests::cleanup options[:remote]
12
-
13
- # actions
14
- print " downloading git repository.. this may take a while.."
15
- app_path = Laravel::Tests::app_downloads_nicely? options
16
-
17
- # expectations
18
- app_path.should_not be_nil
19
- Laravel::local_repository_exists?(options[:remote])
20
- Laravel::Tests::download_was_performed?(app_path)
21
- end
22
-
23
- it "should not download source from a non-laravel app" do
24
- # preparations
25
- options = { :remote => "http://github.com/nikhgupta/snipmate-snippets.git" }
26
-
27
- # actions
28
- print " downloading git repository.. this may take a while.."
29
- app_path = Laravel::Tests::app_downloads_nicely? options
30
-
31
- # expectations
32
- app_path.should be_nil
33
- !Laravel::local_repository_exists?(options[:remote])
34
- !Laravel::Tests::download_was_performed?(app_path)
35
- end
36
-
37
- it "should download source from the official repository" do
38
- # preparations
39
- Laravel::Tests::cleanup Laravel::OfficialRepository
40
-
41
- # actions
42
- print " downloading git repository.. this may take a while.."
43
- app_path = Laravel::Tests::app_downloads_nicely?
44
-
45
- # expectations
46
- app_path.should_not be_nil
47
- Laravel::local_repository_exists?(Laravel::OfficialRepository)
48
- Laravel::Tests::download_was_performed?(app_path)
49
- end
50
-
51
- it "should copy source from local repository cache" do
52
- # preparations
53
- # should only be run with the previous test
54
- # act as cached repo
55
- options = { :remote => Laravel::crypted_path(Laravel::OfficialRepository) }
56
-
57
- # actions
58
- app_path = Laravel::Tests::app_downloads_nicely?
59
-
60
- # expectations
61
- app_path.should_not be_nil
62
- Laravel::Tests::download_was_performed?(app_path)
63
- end
64
-
65
- it "should copy source from a manually specified directory" do
66
- # preparations
67
- # acts as local directory
68
- options = { :local => Laravel::crypted_path(Laravel::OfficialRepository) }
69
-
70
- # actions
71
- app_path = Laravel::Tests::app_downloads_nicely? options
72
-
73
- # expectations
74
- app_path.should_not be_nil
75
- Laravel::Tests::download_was_performed?(app_path)
76
- end
77
-
78
- end
@@ -1,24 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Laravel do
4
- it "should have a version" do
5
- Laravel::VERSION.should_not be_nil
6
- end
7
-
8
- context "when creating a new application" do
9
-
10
- before(:each) { Laravel::Tests::cleanup }
11
- after(:each) { Laravel::Tests::cleanup }
12
-
13
- it "should run with default options" do
14
- # actions
15
- print ' downloading git repository.. this may take a while..'
16
- app_path = Laravel::Tests::app_downloads_nicely?
17
-
18
- # expectations
19
- app_path.should_not be_nil
20
- Laravel::Tests::app_was_created? app_path
21
- end
22
- end
23
- end
24
-
data/spec/spec_helper.rb DELETED
@@ -1,45 +0,0 @@
1
- require 'laravel'
2
-
3
- module Laravel
4
- class Tests
5
- TestAppDirectory = File.join( File.dirname(__FILE__), %w[ .. __tests ] )
6
-
7
- # get path to the test application
8
- def self.app_path(app_name)
9
- File.join(Laravel::Tests::TestAppDirectory, app_name)
10
- end
11
-
12
- # perform an application download using Laravel::Download
13
- def self.app_downloads_nicely?(options = {}, app_name = "")
14
- app_name ||= (('a'..'z').to_a+('A'..'Z').to_a).shuffle[0,32].join
15
- options[:quiet] = true
16
- app_path = Laravel::Tests::app_path app_name
17
- error = Laravel::Download::source(app_path, options)
18
- error ? nil : app_path
19
- end
20
-
21
- # check if the download was successful
22
- def self.download_was_performed?(app_path)
23
- app_path && File.directory?(app_path)
24
- end
25
-
26
- # check if the application was created?
27
- def self.app_was_created?(app_path)
28
- return false unless Laravel::Tests::download_was_performed?(app_path)
29
- return false unless Laravel::has_laravel?(app_path)
30
- true
31
- end
32
-
33
- # cleanup before and after our tests
34
- def self.cleanup(repo = "")
35
- FileUtils.rm_rf Laravel::Tests::TestAppDirectory
36
- FileUtils.rm_rf Laravel::crypted_path(repo) if repo
37
- end
38
- end
39
- end
40
-
41
- RSpec.configure do |c|
42
- c.fail_fast = true
43
- c.color = true
44
- c.formatter = :documentation
45
- end