laravel 0.1.4 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -59,7 +59,19 @@ cached!
59
59
  laravel new my_app --key
60
60
 
61
61
  # use default settings but do not update permissions on storage/ directory
62
- laravel new my_app --no_perms
62
+ laravel new my_app --no-perms
63
+
64
+ # use default settings and download Laravel Generator by Jeffrey Way
65
+ laravel new my_app --generator
66
+
67
+ # the settings I use:
68
+ laravel new my_app --key --generator --index=''
69
+ ## this creates a Laravel application from the official repository,
70
+ ## sets the Application Index to blank, makes the storage directory
71
+ ## world-writable, generates a new key for the application and finally
72
+ ## sets up the :generate tasks by downloading Laravel Generator.
73
+ ## Furthermore, this creates the local cache for the official repository
74
+ ## which makes the future installs quite faster :)
63
75
 
64
76
  ### In an existing Laravel application
65
77
 
data/bin/laravel CHANGED
@@ -30,8 +30,7 @@ module Laravel
30
30
  # --force => overwrite target directory, if it exists
31
31
  # --index => update Application Index for newly created application
32
32
  # --key => generate a new key for this application
33
- # --no_perms => do not update permissions on storage/ directory
34
- # --bundles => comma-separated list of bundles to install
33
+ # --[no-]perms => do not update permissions on storage/ directory
35
34
  desc "new [MY_APP]", "create a new Laravel application"
36
35
  method_option :local, :type => :string, :aliases => "-l", :banner => "DIRECTORY",
37
36
  :desc => "use laravel source from a local directory"
@@ -42,9 +41,10 @@ module Laravel
42
41
  :desc => "change the Application Index"
43
42
  method_option :key, :type => :boolean, :aliases => "-k",
44
43
  :desc => "generate a new key for this application"
45
- method_option :bundles,:type => :string, :aliases => "-b",
46
- :desc => "comma-separated list of bundles to install"
47
- method_option :no_perms, :type => :boolean, :desc => "do not update permissions on storage/ directory"
44
+ method_option :perms, :type => :boolean, :default => true,
45
+ :desc => "default | update permissions on storage/ directory"
46
+ method_option :generator, :type => :boolean, :aliases => "-g",
47
+ :desc => "get the Laravel generator by Jeffrey Way"
48
48
  def new(app_name)
49
49
  Laravel::Create::source app_name, options
50
50
  end
@@ -58,6 +58,8 @@ module Laravel
58
58
  Laravel::Manage::update_index new_index, options[:app]
59
59
  end
60
60
 
61
+ # allow the user to generate a new key
62
+ # --app => use the given directory instead of pwd
61
63
  desc "generate_key", "generate a new key for Laravel application"
62
64
  method_option :app, :type => :string, :aliases => "-a",
63
65
  :desc => "use the specified Laravel application instead of current directory"
@@ -65,11 +67,13 @@ module Laravel
65
67
  Laravel::Manage::generate_key options[:app]
66
68
  end
67
69
 
68
- desc "install_bundles", "comma-separated list of bundles to install"
70
+ # allow the user to download the generator from Jeffrey Way
71
+ # --app => use the given directory instead of pwd
72
+ desc "get_generator", "download the Laravel Generator by Jeffrey Way"
69
73
  method_option :app, :type => :string, :aliases => "-a",
70
74
  :desc => "use the specified Laravel application instead of current directory"
71
- def install_bundles
72
- Laravel::Manage::install_bundles options[:app]
75
+ def get_generator
76
+ Laravel::Manage::get_generator options[:app]
73
77
  end
74
78
 
75
79
  # choose a default task to run
@@ -3,7 +3,7 @@ Feature: Create a new application based on Laravel framework for PHP
3
3
  As a PHP developer acquinted with ruby
4
4
  I want to use Laravel gem to setup Laravel framework
5
5
 
6
- @requires_repository_download @very_slow
6
+ @requires_repository_download @very_slow @online
7
7
  Scenario: create Laravel application with default settings
8
8
  Given local cache does not exist for "official" repository
9
9
  When I run `laravel new my_app`
@@ -16,13 +16,13 @@ Feature: Create a new application based on Laravel framework for PHP
16
16
  When I run `laravel new .`
17
17
  Then the stdout should contain "ERROR"
18
18
 
19
- @requires_repository_download
19
+ @requires_repository_download @online
20
20
  Scenario: create Laravel application using source from a non-official repo
21
21
  Given local cache does not exist for "pastes" repository
22
22
  When I run `laravel new my_app --remote=http://github.com/laravel/pastes`
23
23
  Then laravel application should be ready to use in "my_app" directory using "pastes" repository
24
24
 
25
- @requires_repository_download
25
+ @requires_repository_download @online
26
26
  Scenario: create Laravel application using non-laravel repository
27
27
  When I run `laravel new my_app --remote=http://github.com/github/gitignore`
28
28
  Then local cache for "non_laravel" repository should not exist
@@ -44,19 +44,16 @@ Feature: Create a new application based on Laravel framework for PHP
44
44
 
45
45
  @may_require_repository_download
46
46
  Scenario: create Laravel application but do not update permissions on storage/ directory
47
- When I run `laravel new my_app --no_perms`
47
+ When I run `laravel new my_app --no-perms`
48
48
  Then the stdout should contain "Hurray!"
49
49
  And laravel application must exist in "my_app" directory
50
50
  And permissions should not be updated on "my_app/storage" directory
51
51
 
52
- @may_require_repository_download @focus @announce
52
+ @may_require_repository_download
53
53
  Scenario: create Laravel application with maximum customizations
54
- When I run `laravel new -ki '' -b=bob,anbu -r http://github.com/laravel/pastes my_app --force`
54
+ When I run `laravel new -kgi 'home.php' -r http://github.com/laravel/pastes my_app --force`
55
55
  Then laravel application should be ready to use in "my_app" directory
56
- And "bob" bundle must be installed for "my_app" application
57
- And "anbu" bundle must be installed for "my_app" application
58
56
  And the stdout should contain "Creating application forcefully"
59
- And the stdout should contain "Generated a new key"
60
- And the stdout should contain "Changed Application Index"
61
- And the stdout should contain "Installed bundle: Bob"
62
- And the stdout should contain "Installed bundle: Anbu"
57
+ And application key must be set for "my_app" application
58
+ And application index must be set to "home.php" for "my_app" application
59
+ And generator tasks should be setup for "my_app" application
@@ -8,8 +8,7 @@ Feature: Generate a new key for Laravel application
8
8
  Given laravel application exists in "my_app" directory
9
9
  Then application key must not be set for "my_app" application
10
10
  When I run `laravel generate_key --app=my_app`
11
- Then the stdout should contain "Generated a new key"
12
- And application key must be set for "my_app" application
11
+ Then application key must be set for "my_app" application
13
12
 
14
13
  @may_require_repository_download
15
14
  Scenario: create Laravel application and generate a key for it
@@ -7,8 +7,7 @@ Feature: Update Application Index for a Laravel based application
7
7
  Scenario: update Application Index in a Laravel application
8
8
  Given laravel application exists in "my_app" directory
9
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
10
+ Then application index must be set to "home.php" for "my_app" application
12
11
 
13
12
  @may_require_repository_download
14
13
  Scenario: create Laravel application without an Application Index
@@ -0,0 +1,16 @@
1
+ Feature: Download Laravel Generator by Jeffrey Way
2
+ In order to generate code for my application quickly using :generate tasks
3
+ As a PHP developer acquinted with ruby
4
+ I want to use Laravel gem to download Laravel Generator by Jeffrey Way
5
+
6
+ @may_require_repository_download
7
+ Scenario: download Laravel generator
8
+ Given laravel application exists in "my_app" directory
9
+ When I run `laravel get_generator --app=my_app`
10
+ Then generator tasks should be setup for "my_app" application
11
+
12
+ @may_require_repository_download
13
+ Scenario: download Laravel generator while creating an application
14
+ When I run `laravel new my_app --generator`
15
+ Then laravel application should be ready to use in "my_app" directory
16
+ And generator tasks should be setup for "my_app" application
@@ -63,6 +63,7 @@ end
63
63
 
64
64
  # check if valid permissions were set on the "storage/" directory
65
65
  Then /^permissions should( not)? be updated on "(.*?)" directory$/ do |negation, dir|
66
+ step "the stdout should contain \"Updated permissions\"" unless negation
66
67
  dir = get_relative_path_to_test_directory(dir)
67
68
  world_bit = sprintf("%o", File.stat(dir).mode).to_s[-1,1].to_i
68
69
  is_world_writable = [2,3,6,7].include?(world_bit)
@@ -71,11 +72,27 @@ end
71
72
 
72
73
  # check if application index was set
73
74
  Then /^application index must be set to "(.*?)" for "(.*?)" application$/ do |new_index, app_directory|
75
+ step "the stdout should contain \"Changed Application Index\""
74
76
  check_config_file_for_string("'index' => '#{new_index}'", app_directory)
75
77
  end
76
78
 
77
79
  # check if application key was set
78
80
  Then /^application key must(| not) be set for "(.*?)" application$/ do |negation, app_directory|
81
+ step "the stdout should contain \"Generated a new key\"" unless negation
79
82
  key_regex = negation.empty? ? "[0-9a-f]{32}" : "YourSecretKeyGoesHere!"
80
83
  check_config_file_for_string("'key' => '#{key_regex}'", app_directory)
81
84
  end
85
+
86
+ # check if generator tasks were setup
87
+ Then /^generator tasks should be setup for "(.*?)" application$/ do |dir|
88
+ step "the stdout should contain \"Downloaded Laravel Generator by Jeffrey Way\""
89
+ dir = get_relative_path_to_test_directory(dir)
90
+ generator_tasks_file = File.join(dir, %w[ application tasks generate.php])
91
+ raise_error_based_on_condition(File.exists?(generator_tasks_file))
92
+ unless `which php`.empty?
93
+ artisan = File.join(dir, "artisan")
94
+ step "I run `php #{artisan} generate`"
95
+ step "the stdout should contain \"generate\""
96
+ step "the stdout should not contain \"Sorry\""
97
+ end
98
+ end
@@ -46,9 +46,9 @@ module Laravel
46
46
  # make necessary changes for the new app, if we were successful in download
47
47
  # otherwise, remove the downloaded source
48
48
  if Laravel::has_laravel? path
49
- storage_directory = File.join(path, "storage")
50
49
  Laravel::say_success "Cloned Laravel repository."
51
- unless options.has_key?("no_perms")
50
+ if options[:perms]
51
+ storage_directory = File.join(path, "storage")
52
52
  response = system("chmod -R o+w #{storage_directory}")
53
53
  if response
54
54
  Laravel::say_success "Updated permissions on storage/ directory."
@@ -58,6 +58,7 @@ module Laravel
58
58
  end
59
59
  Laravel::Manage::update_index options[:index], path if options.has_key?("index")
60
60
  Laravel::Manage::generate_key path if options.has_key?("key")
61
+ Laravel::Manage::get_generator path if options.has_key?("generator")
61
62
  Laravel::say_success "Hurray! Your Laravel application has been created!"
62
63
  else
63
64
  Laravel::say_failed "Downloaded source is not Laravel framework or a possible fork."
data/lib/laravel/info.rb CHANGED
@@ -16,8 +16,10 @@ module Laravel
16
16
  # use default settings and update Application Index
17
17
  laravel new my_app --key
18
18
  # use default settings and generate a new key
19
- laravel new my_app --no_perms
19
+ laravel new my_app --no-perms
20
20
  # use default settings but do not update permissions on storage/ directory
21
+ laravel new my_app --generator
22
+ # use default settings and downloaded Laravel generator by Jeffrey Way
21
23
 
22
24
  Update Application Index on existing Laravel applications
23
25
  =========================================================
@@ -32,5 +34,12 @@ module Laravel
32
34
  # in the current directory
33
35
  laravel generate_key --app=./laravel
34
36
  # for application in the specified directory
37
+
38
+ Download Laraevl Generator by Jeffrey Way
39
+ =========================================
40
+ laravel get_generator
41
+ # in the current directory
42
+ laravel get_generator --app=./laravel
43
+ # for application in the specified directory
35
44
  '''
36
45
  end
@@ -32,6 +32,35 @@ module Laravel
32
32
  end
33
33
  end
34
34
 
35
+ # download the Laravel Generator by Jeffrey Way
36
+ #
37
+ # * *Args* :
38
+ # - +app_directory+ -> the directory of the Laravel app, defaults to current working directory
39
+ #
40
+ def self.get_generator(app_directory = nil)
41
+ # default to current working directory if path is not specified
42
+ app_directory ||= Dir.pwd
43
+
44
+ # get the path to the tasks folder
45
+ tasks_directory = File.expand_path(File.join(app_directory, %w[ application tasks ]))
46
+
47
+ # download the Laravel Generator
48
+ generator_url = "https://raw.github.com/JeffreyWay/Laravel-Generator/master/generate.php"
49
+ generator_file = File.join(tasks_directory, "generate.php")
50
+ success = case
51
+ when `which curl` then system("curl -s #{generator_url} > #{generator_file}")
52
+ when `which wget` then system("wget -s #{generator_url} -O #{generator_file}")
53
+ else false
54
+ end
55
+
56
+ # display appropriate output to the user
57
+ if success
58
+ Laravel::say_success "Downloaded Laravel Generator by Jeffrey Way"
59
+ else
60
+ Laravel::say_failed "Could not download Laravel Generator"
61
+ end
62
+ end
63
+
35
64
  private
36
65
 
37
66
  def self.change_configuration(match, replace, app_directory = nil)
@@ -1,3 +1,3 @@
1
1
  module Laravel
2
- VERSION = "0.1.4"
2
+ VERSION = "0.2.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.4
4
+ version: 0.2.1
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-21 00:00:00.000000000 Z
12
+ date: 2012-12-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: thor
@@ -77,7 +77,7 @@ files:
77
77
  - features/S_1_new.feature
78
78
  - features/S_2_generate_key.feature
79
79
  - features/S_3_update_index.feature
80
- - features/S_4_install_bundles.feature
80
+ - features/S_4_generator.feature
81
81
  - features/step_definitions/laravel.rb
82
82
  - features/support/env.rb
83
83
  - features/support/laravel_helpers.rb
@@ -103,7 +103,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
103
103
  version: '0'
104
104
  segments:
105
105
  - 0
106
- hash: -4483550955882994531
106
+ hash: 3710655952266878729
107
107
  required_rubygems_version: !ruby/object:Gem::Requirement
108
108
  none: false
109
109
  requirements:
@@ -112,7 +112,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
112
112
  version: '0'
113
113
  segments:
114
114
  - 0
115
- hash: -4483550955882994531
115
+ hash: 3710655952266878729
116
116
  requirements: []
117
117
  rubyforge_project:
118
118
  rubygems_version: 1.8.24
@@ -125,7 +125,7 @@ test_files:
125
125
  - features/S_1_new.feature
126
126
  - features/S_2_generate_key.feature
127
127
  - features/S_3_update_index.feature
128
- - features/S_4_install_bundles.feature
128
+ - features/S_4_generator.feature
129
129
  - features/step_definitions/laravel.rb
130
130
  - features/support/env.rb
131
131
  - features/support/laravel_helpers.rb
@@ -1,20 +0,0 @@
1
- Feature: Install bundles for Laravel application
2
- In order to extend the functionality of my Laravel application
3
- As a PHP developer acquinted with ruby
4
- I want to use Laravel gem to install Laravel bundles for me
5
-
6
- @may_require_repository_download @focus @announce
7
- Scenario: install a new bundle for a Laravel application
8
- Given laravel application exists in "my_app" directory
9
- And "bob" bundle must not be installed for "my_app" application
10
- When I run `laravel install_bundles "bob" --app=my_app`
11
- Then the stdout should contain "Installed bundle: Bob"
12
- And "bob" bundle must be installed for "my_app" application
13
-
14
- @may_require_repository_download @focus @announce
15
- Scenario: create Laravel application with some bundles
16
- When I run `laravel new my_app --bundles=bob,bootstrapper,anbu`
17
- Then laravel application should be ready to use in "my_app" directory
18
- And "bob" bundle must be installed for "my_app" application
19
- And "bootstrapper" bundle must be installed for "my_app" application
20
- And "anbu" bundle must be installed for "my_app" application