laravel 0.2.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,89 +0,0 @@
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 = nil)
10
- if change_configuration(/'index' => '.*'/, "'index' => '#{new_index}'", app_directory)
11
- Laravel::say_success "Changed Application Index."
12
- else
13
- Laravel::say_failed "Could not change Application Index!"
14
- end
15
- end
16
-
17
- # generates a new key for the application
18
- #
19
- # * *Args* :
20
- # - +app_directory+ -> the directory of the Laravel app, defaults to current working directory
21
- #
22
- def self.generate_key(app_directory = nil)
23
- # 32 char long md5-ed hash
24
- new_key = (0...32).map{ ('a'..'z').to_a[rand(26)] }.join
25
- new_key = Laravel::crypted_name(new_key)
26
-
27
- # show an appropriate message to the user.
28
- if change_configuration(/'key' => '.*'/, "'key' => '#{new_key}'", app_directory)
29
- Laravel::say_success "Generated a new key."
30
- else
31
- Laravel::say_failed "Could not generate a new key!"
32
- end
33
- end
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
-
64
- private
65
-
66
- def self.change_configuration(match, replace, app_directory = nil)
67
- # default to current working directory if path is not specified
68
- app_directory ||= Dir.pwd
69
-
70
- # try to change configuration only if this is a Laravel application
71
- if Laravel::has_laravel? app_directory
72
- # file path to the configuration file
73
- config_file = %w[ application config application.php ]
74
- config_file = File.expand_path(File.join(app_directory, config_file))
75
-
76
- # perform substitution
77
- text = File.read config_file
78
- text = text.gsub(match, replace)
79
- File.open(config_file, "w") {|file| file.puts text}
80
-
81
- # check to ensure we were able to update configuration
82
- File.readlines(config_file).grep(/#{replace}/).any?
83
- else
84
- Laravel::say_error "Is this a valid Laravel application?"
85
- end
86
- end
87
-
88
- end
89
- end
File without changes