jumpstart 0.1.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.
Files changed (168) hide show
  1. data/.bundle/config +2 -0
  2. data/.document +5 -0
  3. data/.gitignore +28 -0
  4. data/Gemfile +8 -0
  5. data/LICENSE +20 -0
  6. data/README.rdoc +19 -0
  7. data/Rakefile +54 -0
  8. data/VERSION +1 -0
  9. data/bin/jumpstart +5 -0
  10. data/config/jumpstart_setup.yml +2 -0
  11. data/jumpstart.gemspec +222 -0
  12. data/jumpstart_templates/i0n_rails_3/.gitignore +11 -0
  13. data/jumpstart_templates/i0n_rails_3/_._Gemfile +5 -0
  14. data/jumpstart_templates/i0n_rails_3/app/views/home/index.haml +4 -0
  15. data/jumpstart_templates/i0n_rails_3/app/views/layouts/application.haml +32 -0
  16. data/jumpstart_templates/i0n_rails_3/config/_2._routes.rb +1 -0
  17. data/jumpstart_templates/i0n_rails_3/config/_L._database.yml +1 -0
  18. data/jumpstart_templates/i0n_rails_3/config/deploy.rb +62 -0
  19. data/jumpstart_templates/i0n_rails_3/config/environments/_18._development.rb +5 -0
  20. data/jumpstart_templates/i0n_rails_3/config/environments/_27._test.rb +1 -0
  21. data/jumpstart_templates/i0n_rails_3/config/environments/_41._production.rb +3 -0
  22. data/jumpstart_templates/i0n_rails_3/config/initializers/setup_mail.rb +14 -0
  23. data/jumpstart_templates/i0n_rails_3/jumpstart_config/i0n_rails_3.yml +40 -0
  24. data/jumpstart_templates/i0n_rails_3/jumpstart_config/nginx.local.conf +11 -0
  25. data/jumpstart_templates/i0n_rails_3/jumpstart_config/nginx.remote.conf +37 -0
  26. data/jumpstart_templates/i0n_rails_3/lib/development_mail_interceptor.rb +8 -0
  27. data/jumpstart_templates/i0n_rails_3/lib/generators/authlogic.rb +11 -0
  28. data/jumpstart_templates/i0n_rails_3/lib/generators/authlogic/session/session_generator.rb +18 -0
  29. data/jumpstart_templates/i0n_rails_3/lib/generators/authlogic/session/templates/session.rb +2 -0
  30. data/jumpstart_templates/i0n_rails_3/lib/generators/datamapper.rb +80 -0
  31. data/jumpstart_templates/i0n_rails_3/lib/generators/datamapper/migration/migration_generator.rb +26 -0
  32. data/jumpstart_templates/i0n_rails_3/lib/generators/datamapper/migration/templates/migration.rb +21 -0
  33. data/jumpstart_templates/i0n_rails_3/lib/generators/datamapper/model/model_generator.rb +29 -0
  34. data/jumpstart_templates/i0n_rails_3/lib/generators/datamapper/model/templates/migration.rb +17 -0
  35. data/jumpstart_templates/i0n_rails_3/lib/generators/datamapper/model/templates/model.rb +10 -0
  36. data/jumpstart_templates/i0n_rails_3/lib/generators/datamapper/observer/observer_generator.rb +15 -0
  37. data/jumpstart_templates/i0n_rails_3/lib/generators/datamapper/observer/templates/observer.rb +5 -0
  38. data/jumpstart_templates/i0n_rails_3/lib/generators/factory_girl.rb +11 -0
  39. data/jumpstart_templates/i0n_rails_3/lib/generators/factory_girl/model/model_generator.rb +14 -0
  40. data/jumpstart_templates/i0n_rails_3/lib/generators/factory_girl/model/templates/fixtures.rb +7 -0
  41. data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_erb.rb +9 -0
  42. data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_erb/USAGE +8 -0
  43. data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_erb/controller/controller_generator.rb +24 -0
  44. data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_erb/controller/templates/view.html.erb +0 -0
  45. data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_erb/scaffold/scaffold_generator.rb +27 -0
  46. data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_erb/scaffold/templates/_form.html.erb +12 -0
  47. data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_erb/scaffold/templates/edit.html.erb +6 -0
  48. data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_erb/scaffold/templates/index.html.erb +27 -0
  49. data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_erb/scaffold/templates/layout.html.erb +16 -0
  50. data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_erb/scaffold/templates/new.html.erb +5 -0
  51. data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_erb/scaffold/templates/show.html.erb +10 -0
  52. data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_haml.rb +9 -0
  53. data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_haml/USAGE +8 -0
  54. data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_haml/controller/controller_generator.rb +24 -0
  55. data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_haml/controller/templates/view.html.haml +0 -0
  56. data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_haml/scaffold/scaffold_generator.rb +23 -0
  57. data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_haml/scaffold/templates/_form.haml.erb +9 -0
  58. data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_haml/scaffold/templates/edit.haml.erb +7 -0
  59. data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_haml/scaffold/templates/index.haml.erb +23 -0
  60. data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_haml/scaffold/templates/layout.haml.erb +9 -0
  61. data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_haml/scaffold/templates/new.haml.erb +5 -0
  62. data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_haml/scaffold/templates/show.haml.erb +9 -0
  63. data/jumpstart_templates/i0n_rails_3/lib/generators/haml.rb +9 -0
  64. data/jumpstart_templates/i0n_rails_3/lib/generators/haml/controller/controller_generator.rb +24 -0
  65. data/jumpstart_templates/i0n_rails_3/lib/generators/haml/controller/templates/view.html.haml +0 -0
  66. data/jumpstart_templates/i0n_rails_3/lib/generators/haml/scaffold/scaffold_generator.rb +26 -0
  67. data/jumpstart_templates/i0n_rails_3/lib/generators/haml/scaffold/templates/_form.haml.erb +9 -0
  68. data/jumpstart_templates/i0n_rails_3/lib/generators/haml/scaffold/templates/edit.haml.erb +7 -0
  69. data/jumpstart_templates/i0n_rails_3/lib/generators/haml/scaffold/templates/index.haml.erb +23 -0
  70. data/jumpstart_templates/i0n_rails_3/lib/generators/haml/scaffold/templates/layout.haml.erb +9 -0
  71. data/jumpstart_templates/i0n_rails_3/lib/generators/haml/scaffold/templates/new.haml.erb +5 -0
  72. data/jumpstart_templates/i0n_rails_3/lib/generators/haml/scaffold/templates/show.haml.erb +9 -0
  73. data/jumpstart_templates/i0n_rails_3/lib/generators/machinist.rb +11 -0
  74. data/jumpstart_templates/i0n_rails_3/lib/generators/machinist/model/model_generator.rb +19 -0
  75. data/jumpstart_templates/i0n_rails_3/lib/generators/machinist/model/templates/blueprint.rb +5 -0
  76. data/jumpstart_templates/i0n_rails_3/lib/generators/machinist/model/templates/machinist_initializer.rb +19 -0
  77. data/jumpstart_templates/i0n_rails_3/lib/generators/mongomapper.rb +80 -0
  78. data/jumpstart_templates/i0n_rails_3/lib/generators/mongomapper/model/model_generator.rb +29 -0
  79. data/jumpstart_templates/i0n_rails_3/lib/generators/mongomapper/model/templates/model.rb +24 -0
  80. data/jumpstart_templates/i0n_rails_3/lib/generators/mongomapper/observer/observer_generator.rb +15 -0
  81. data/jumpstart_templates/i0n_rails_3/lib/generators/shoulda.rb +11 -0
  82. data/jumpstart_templates/i0n_rails_3/lib/generators/shoulda/controller/controller_generator.rb +16 -0
  83. data/jumpstart_templates/i0n_rails_3/lib/generators/shoulda/controller/templates/controller.rb +84 -0
  84. data/jumpstart_templates/i0n_rails_3/lib/generators/shoulda/model/model_generator.rb +16 -0
  85. data/jumpstart_templates/i0n_rails_3/lib/generators/shoulda/model/templates/model.rb +7 -0
  86. data/jumpstart_templates/i0n_rails_3/lib/tasks/populate.rake +91 -0
  87. data/jumpstart_templates/i0n_rails_3/public/javascripts/init.js +6 -0
  88. data/jumpstart_templates/i0n_rails_3/public/javascripts/jquery-1.4.2.min.js +154 -0
  89. data/jumpstart_templates/i0n_rails_3/public/javascripts/jquery-ui-1.8.custom.min.js +404 -0
  90. data/jumpstart_templates/i0n_rails_3/public/javascripts/rails.js +126 -0
  91. data/jumpstart_templates/i0n_rails_3/public/stylesheets/sass/_setup.sass +86 -0
  92. data/jumpstart_templates/i0n_rails_3/public/stylesheets/sass/global.sass +58 -0
  93. data/jumpstart_templates/i0n_rails_3/public/stylesheets/sass/handheld.sass +7 -0
  94. data/jumpstart_templates/i0n_rails_3/public/stylesheets/sass/ie.sass +40 -0
  95. data/jumpstart_templates/i0n_rails_3/public/stylesheets/sass/print.sass +57 -0
  96. data/jumpstart_templates/i0n_rails_3/public/stylesheets/sass/screen.sass +170 -0
  97. data/lib/jumpstart.rb +71 -0
  98. data/lib/jumpstart/base.rb +547 -0
  99. data/lib/jumpstart/doc/JumpStart.html +139 -0
  100. data/lib/jumpstart/doc/JumpStart/Base.html +1566 -0
  101. data/lib/jumpstart/doc/base_rb.html +52 -0
  102. data/lib/jumpstart/doc/created.rid +2 -0
  103. data/lib/jumpstart/doc/index.html +101 -0
  104. data/lib/jumpstart/doc/rdoc.css +706 -0
  105. data/lib/jumpstart/filetools.rb +270 -0
  106. data/source_templates/template_config.yml +77 -0
  107. data/test/fake_nginx_path/local_nginx_1.conf +81 -0
  108. data/test/fake_nginx_path/remote_nginx_1.conf +54 -0
  109. data/test/helper.rb +31 -0
  110. data/test/jumpstart/test_base.rb +422 -0
  111. data/test/jumpstart/test_filetools.rb +350 -0
  112. data/test/test_jumpstart.rb +9 -0
  113. data/test/test_jumpstart_templates/test_base/_._test_file.txt +0 -0
  114. data/test/test_jumpstart_templates/test_base/_._test_file_.txt +0 -0
  115. data/test/test_jumpstart_templates/test_base/_1._test_file1.txt +0 -0
  116. data/test/test_jumpstart_templates/test_base/_1._test_file1_.txt +0 -0
  117. data/test/test_jumpstart_templates/test_base/_10._test_file2.txt +0 -0
  118. data/test/test_jumpstart_templates/test_base/_99999._test_file3.txt +0 -0
  119. data/test/test_jumpstart_templates/test_base/_a._test_file4.txt +0 -0
  120. data/test/test_jumpstart_templates/test_base/test_file +0 -0
  121. data/test/test_jumpstart_templates/test_base/test_file5.txt +0 -0
  122. data/test/test_jumpstart_templates/test_base/test_file_.6txt +0 -0
  123. data/test/test_jumpstart_templates/test_fileutils/append_after_line_test.txt +6 -0
  124. data/test/test_jumpstart_templates/test_fileutils/append_to_end_of_file_source.txt +1 -0
  125. data/test/test_jumpstart_templates/test_fileutils/append_to_end_of_file_test.txt +5 -0
  126. data/test/test_jumpstart_templates/test_fileutils/check_source_type +5 -0
  127. data/test/test_jumpstart_templates/test_fileutils/check_source_type.txt +10 -0
  128. data/test/test_jumpstart_templates/test_fileutils/config_capistrano_source.rb +62 -0
  129. data/test/test_jumpstart_templates/test_fileutils/config_capistrano_test.rb +62 -0
  130. data/test/test_jumpstart_templates/test_fileutils/config_nginx_source.txt +1 -0
  131. data/test/test_jumpstart_templates/test_fileutils/config_nginx_test.txt +82 -0
  132. data/test/test_jumpstart_templates/test_fileutils/hosts_test +11 -0
  133. data/test/test_jumpstart_templates/test_fileutils/insert_text_at_line_number_source.txt +1 -0
  134. data/test/test_jumpstart_templates/test_fileutils/insert_text_at_line_number_test.txt +4 -0
  135. data/test/test_jumpstart_templates/test_fileutils/remove_files_test_2.txt +0 -0
  136. data/test/test_jumpstart_templates/test_fileutils/remove_files_test_3.txt +0 -0
  137. data/test/test_jumpstart_templates/test_fileutils/remove_lines_test.txt +10 -0
  138. data/test/test_jumpstart_templates/test_fileutils/replace_strings_test.rb +62 -0
  139. data/test/test_jumpstart_templates/test_template_1/_._test_append_file_with_extension.txt +1 -0
  140. data/test/test_jumpstart_templates/test_template_1/_._test_append_file_without_extension +1 -0
  141. data/test/test_jumpstart_templates/test_template_1/_20._test_line_file_without_extension +1 -0
  142. data/test/test_jumpstart_templates/test_template_1/_5._test_line_file_with_extension.txt +1 -0
  143. data/test/test_jumpstart_templates/test_template_1/_L._test_append_to_end_of_file_remove_last_line_1.txt +1 -0
  144. data/test/test_jumpstart_templates/test_template_1/_l._test_append_to_end_of_file_remove_last_line_2.txt +1 -0
  145. data/test/test_jumpstart_templates/test_template_1/folder with spaces/_._test_append_file_with_extension.txt +1 -0
  146. data/test/test_jumpstart_templates/test_template_1/folder with spaces/_._test_append_file_without_extension +1 -0
  147. data/test/test_jumpstart_templates/test_template_1/folder with spaces/_5._test_line_file_with_extension.txt +1 -0
  148. data/test/test_jumpstart_templates/test_template_1/folder with spaces/_50._test_line_file_without_extension +1 -0
  149. data/test/test_jumpstart_templates/test_template_1/folder with spaces/test_whole_file_with_extension.txt +1 -0
  150. data/test/test_jumpstart_templates/test_template_1/folder with spaces/test_whole_file_without_extension +1 -0
  151. data/test/test_jumpstart_templates/test_template_1/jumpstart_config/test_template_1.yml +31 -0
  152. data/test/test_jumpstart_templates/test_template_1/normal_folder_name/_._test_append_file_with_extension.txt +1 -0
  153. data/test/test_jumpstart_templates/test_template_1/normal_folder_name/_._test_append_file_without_extension +1 -0
  154. data/test/test_jumpstart_templates/test_template_1/normal_folder_name/_5._test_line_file_with_extension.txt +1 -0
  155. data/test/test_jumpstart_templates/test_template_1/normal_folder_name/_50._test_line_file_without_extension +1 -0
  156. data/test/test_jumpstart_templates/test_template_1/normal_folder_name/test_whole_file_with_extension.txt +1 -0
  157. data/test/test_jumpstart_templates/test_template_1/normal_folder_name/test_whole_file_without_extension +1 -0
  158. data/test/test_jumpstart_templates/test_template_1/test_append_to_end_of_file_remove_last_line_1.txt +10 -0
  159. data/test/test_jumpstart_templates/test_template_1/test_append_to_end_of_file_remove_last_line_2.txt +10 -0
  160. data/test/test_jumpstart_templates/test_template_1/test_remove_files/file_with_extension.txt +1 -0
  161. data/test/test_jumpstart_templates/test_template_1/test_remove_files/file_without_extension +1 -0
  162. data/test/test_jumpstart_templates/test_template_1/test_replace_strings/replace_strings_1.rb +62 -0
  163. data/test/test_jumpstart_templates/test_template_1/test_replace_strings/replace_strings_2.txt +23 -0
  164. data/test/test_jumpstart_templates/test_template_1/test_whole_file_with_extension.txt +1 -0
  165. data/test/test_jumpstart_templates/test_template_1/test_whole_file_without_extension +1 -0
  166. data/test/test_jumpstart_templates/test_template_2/jumpstart_config/test_template_2.yml +8 -0
  167. data/test/test_jumpstart_templates/test_template_3/jumpstart_config/test_template_3.yml +22 -0
  168. metadata +254 -0
@@ -0,0 +1,270 @@
1
+ module JumpStart::FileTools
2
+
3
+ # For inserting a line after a specific line in a file. Note that this method will match only the first line it finds.
4
+ def append_after_line(target_file, target_line, new_line)
5
+ file = IO.readlines(target_file)
6
+ new_file = file.dup
7
+ file.each do |line|
8
+ if line.chomp == target_line.chomp && new_line != nil
9
+ new_file.insert((file.find_index(line) + 1), new_line)
10
+ new_line = nil
11
+ end
12
+ end
13
+ File.open(target_file, "w") do |x|
14
+ x.puts new_file
15
+ end
16
+ end
17
+
18
+ # For appending text provided as a sring or a target file (source) to the end of another file (target_file). Takes an optional true/false as a third argument to remove the last line of the target file.
19
+ def append_to_end_of_file(source, target_file, remove_last_line=false)
20
+ t_file = IO.readlines(target_file)
21
+ t_file.pop if remove_last_line == true
22
+ new_file = []
23
+ new_file << t_file << check_source_type(source)
24
+ File.open(target_file, "w") do |x|
25
+ x.puts new_file
26
+ end
27
+ end
28
+
29
+ # For inserting text provided as a string or a target file (source) to a specific line number (line_number) of another file (target_file)
30
+ def insert_text_at_line_number(source, target_file, line_number)
31
+ if line_number > 0
32
+ line_number -= 1
33
+ file = IO.readlines(target_file)
34
+ file.insert((line_number), check_source_type(source))
35
+ File.open(target_file, "w") do |x|
36
+ x.puts file
37
+ end
38
+ else
39
+ raise ArgumentError, "Line number must be 1 or higher.".red
40
+ end
41
+ end
42
+
43
+ # Deletes all files and folders in a directory. Leaves target_dir intact.
44
+ def delete_dir_contents(target_dir)
45
+ files_and_dirs = Find.find(target_dir)
46
+ files_and_dirs.each do |x|
47
+ if File.file?(x)
48
+ FileUtils.rm(x)
49
+ elsif File.directory?(x) && x != target_dir && Dir.exists?(x)
50
+ FileUtils.remove_dir(x)
51
+ end
52
+ end
53
+ end
54
+
55
+ def remove_files(file_array)
56
+ file_array.each do |x|
57
+ begin
58
+ if File.exists?(x)
59
+ if File.writable?(x)
60
+ puts
61
+ puts "Removing the unwanted file: #{x.green}"
62
+ File.delete(x)
63
+ else
64
+ puts
65
+ puts "You do not have the correct privileges to delete #{x.red}. It has NOT been deleted."
66
+ end
67
+ else
68
+ puts
69
+ puts "The file #{x.red} could not be deleted as it could not be found."
70
+ end
71
+ rescue
72
+ puts
73
+ puts "Uh-oh, we've hit a snag with the remove_files method.".red
74
+ puts "The file #{x.red} could not be deleted, do you have the correct privileges to access it?"
75
+ end
76
+ end
77
+ end
78
+
79
+ # For removing lines in a file that (A) match a specific pattern, and/or (B) or are specified by line number.
80
+ # Both types of removal are passed to the method via the arguments hash.
81
+ # e.g. remove lines macthing a pattern, do FileUtils.remove_lines(target_file, :pattern => "Hello!")
82
+ # e.g. remove lines by line number, do FileUtils.remove_lines(target_file, :lines => [1,2,3,4,99])
83
+ # e.g. You can also remove a single line by line number by passing :line. (FileUtils.remove_lines(target_file, :line => 2))
84
+ # You can remove lines using :lines/:line and :pattern at the same time.
85
+ # In Ruby 1.9+ you can also pass a hash like this: FileUtils.remove_lines(target_file, pattern: "hello!", lines: [1,2,3,4,99])
86
+ def remove_lines(target_file, args)
87
+ new_file = []
88
+ original_lines = IO.readlines(target_file)
89
+ if args[:line] != nil && args[:lines] == nil
90
+ args[:line] -= 1
91
+ original_lines.slice!(args[:line])
92
+ elsif args[:lines] != nil && args[:line] == nil
93
+ args[:lines].map! {|x| x -= 1}
94
+ args[:lines].each do |y|
95
+ original_lines[y] = nil
96
+ end
97
+ elsif args[:lines] != nil && args[:line] != nil
98
+ puts
99
+ puts "You have used an incorrect syntax for the FileUtils.remove_lines method.".red
100
+ puts "You have specified a" + " :line".red_bold + " argument at the same time as a " + ":lines".red_bold + " argument, only one can be used at a time."
101
+ raise ArgumentError
102
+ end
103
+ if args[:pattern] != nil then
104
+ original_lines.each do |line|
105
+ if line =~ /#{args[:pattern]}/
106
+ original_lines[original_lines.find_index(line)] = nil
107
+ end
108
+ end
109
+ end
110
+ original_lines.compact!
111
+ new_file += original_lines
112
+ File.open(target_file, "w") do |x|
113
+ x.puts new_file
114
+ end
115
+ end
116
+
117
+ # This method generates string replacements via a hash passed to the method, this enables versatile string replacement.
118
+ # To replace values in the target file, simply add the name of the key for that replacement in CAPS.
119
+ # e.g. You might call the method with something like: FileUtils.replace_strings(target_file, :name => "Ian", :country => "England")
120
+ # ... and in the template it would look like this:
121
+ # Hello there NAME from COUNTRY
122
+ def replace_strings(target_file, args)
123
+ txt = IO.read(target_file)
124
+ args.each do |x, y|
125
+ txt.gsub!(/#{x.upcase}/, y)
126
+ end
127
+ File.open(target_file, "w") do |file|
128
+ file.puts txt
129
+ end
130
+ end
131
+
132
+ # For setting up app in Nginx
133
+ def config_nginx(source_file, target_file, app_name)
134
+ if source_file == nil || target_file == nil || app_name == nil
135
+ puts
136
+ puts "******************************************************************************************************************************************"
137
+ puts
138
+ puts "You need to specify three paramters to use this script:\n\n1: The Source File.\n2: The Target File.\n3: The App Name.".yellow
139
+ puts
140
+ puts "e.g. nginx_auto_config /Users/i0n/Sites/bin/templates/rails/config/nginx.local.conf /usr/local/nginx/conf/nginx.conf test_app"
141
+ puts
142
+ puts "******************************************************************************************************************************************"
143
+ puts
144
+ else
145
+ puts
146
+ puts "******************************************************************************************************************************************"
147
+ puts
148
+ puts "Configuring NginX at: #{target_file}"
149
+ puts
150
+ if File.writable?(target_file)
151
+ nginx_config = IO.readlines(target_file)
152
+ while nginx_config.last !~ /^\}[\n]*/
153
+ nginx_config.pop
154
+ end
155
+ @nginx_last_line = nginx_config.pop
156
+ source_config = IO.read(source_file)
157
+ nginx_config.push source_config
158
+ nginx_config.push @nginx_last_line
159
+ nginx_config.each {|line| line.gsub!(/\#\{app_name\}/, "#{app_name}")}
160
+ File.open(target_file, "w") do |file|
161
+ file.puts nginx_config
162
+ end
163
+ puts "Success! NginX config for #{app_name.green} has been added to #{target_file.green}"
164
+ puts
165
+ puts "******************************************************************************************************************************************"
166
+ puts
167
+ else
168
+ puts "It doesn't look like you have write access for #{target_file}. Would you like to use sudo to change them?".yellow
169
+ puts "Type yes (" + "y".green + ") or no (" + "n".red + ")"
170
+ input = gets.chomp
171
+ if input == "yes" || input == "y"
172
+ puts "Setting permissions for #{target_file.green}"
173
+ system "sudo chmod 755 #{target_file}"
174
+ config_nginx(source_file, target_file, app_name)
175
+ else
176
+ puts "Skipping automatic NginX config."
177
+ end
178
+ end
179
+ end
180
+ end
181
+
182
+ # For configuring /etc/hosts. Necessary under OS X for NginX configuration to work.
183
+ def config_hosts(target_file, app_name)
184
+ puts
185
+ puts "******************************************************************************************************************************************"
186
+ puts
187
+ puts "Configuring /etc/hosts"
188
+ puts
189
+ begin
190
+ if File.writable?(target_file)
191
+ etc_hosts = IO.readlines(target_file)
192
+ etc_hosts << "127.0.0.1 #{app_name}.local"
193
+ etc_hosts.compact!
194
+ File.open(target_file, "w") do |file|
195
+ file.puts etc_hosts
196
+ end
197
+ puts "Success! #{app_name.green} has been added to #{target_file.green}"
198
+ puts
199
+ else
200
+ puts "It doesn't look like you have write access for #{target_file}. Would you like to use sudo to change them?".yellow
201
+ puts "Type yes (" + "y".yellow + ") or no (" + "n".yellow + ")"
202
+ puts
203
+ input = gets.chomp
204
+ if input == "yes" || input == "y"
205
+ puts "Setting permissions for #{target_file.green}"
206
+ puts
207
+ system "sudo chmod 755 #{target_file}"
208
+ config_etc_hosts(app_name)
209
+ else
210
+ puts "Skipping automatic #{target_file} config."
211
+ end
212
+ end
213
+ rescue
214
+ puts "There was a problem accessing the file #{target_file.red}, you may need to adjust the privileges."
215
+ puts
216
+ end
217
+ puts "******************************************************************************************************************************************"
218
+ puts
219
+ end
220
+
221
+ def check_source_type(source)
222
+ if File.file?(source)
223
+ source_file = IO.readlines(source)
224
+ else
225
+ source_file = source
226
+ end
227
+ source_file
228
+ end
229
+
230
+ # Method for joining paths together. Paths can be supplied as a mixture of strings and arrays.
231
+ # If too many or not enough forward slashes are provided at the start/end of the paths, this will be corrected.
232
+ # Accidentally passing nil values mixed with strings/arrays will be corrected.
233
+ # Whitespace and line breaks mixed with the path will be corrected.
234
+ # If too many files (paths containing one or more '.' fullstops) are specified in the supplied paths, the first one that creates a path will be returned.
235
+ # If the path is an absolute path (starting with /) this will be preserved.
236
+ def join_paths(*args)
237
+ paths = args.dup
238
+ paths.flatten!
239
+ full_path = []
240
+ file_detected = false
241
+ absolute_path = true if paths[0].to_s.start_with?('/')
242
+ paths.each do |path|
243
+ unless path.nil?
244
+ path.strip!
245
+ path.slice!(0) while path.start_with?('/')
246
+ path.chop! while path.end_with?('/')
247
+ if file_detected == false
248
+ file_detected = true if path =~ /\w*\.\w*/
249
+ full_path << path
250
+ end
251
+ end
252
+ end
253
+ full_path[0].insert(0, '/') if absolute_path
254
+ full_path.join('/')
255
+ end
256
+
257
+ def sort_contained_files_and_dirs(path)
258
+ dirs, files = [], []
259
+ Find.find(path) do |x|
260
+ case
261
+ when File.directory?(x)
262
+ dirs << x.sub(path, '')
263
+ when File.file?(x)
264
+ files << x.sub(path, '')
265
+ end
266
+ end
267
+ {:files => files, :dirs => dirs}
268
+ end
269
+
270
+ end
@@ -0,0 +1,77 @@
1
+ ---
2
+ # The commands in a jumpstart config file are executed in the order displayed in this file.
3
+
4
+ # The path to where the project directory will be created
5
+ # e.g. :install_path: /Users/i0n/Sites
6
+ :install_path:
7
+
8
+ ## Can be omitted or left blank.
9
+ # The command that this template will run. The main shell command to create the project.
10
+ # e.g. :install_command: rails
11
+ :install_command:
12
+
13
+ ## Can be omitted or left blank.
14
+ # The arguments for :install_command. Broken into it's own value to allow the project name to be inserted between the two values.
15
+ # e.g. :install_command_args: -d mysql -J -T
16
+ :install_command_args:
17
+
18
+ ## Can be omitted or left blank.
19
+ # Add extra commands that you want to run after the main install command, but before template generation has started.
20
+ # e.g.
21
+ # :run_after_install_command:
22
+ # - rails g controller home
23
+ # - rails g model home
24
+ :run_after_install_command:
25
+
26
+ ## Can be omitted or left blank.
27
+ # List files that you would like removed from the newly generated project.
28
+ # Paths use the newly created project folder as root.
29
+ # e.g.
30
+ # :remove_files:
31
+ # - /public/index.html
32
+ # - /public/favicon.ico
33
+ # - /public/images/rails.png
34
+ :remove_files:
35
+
36
+ ## Can be omitted or left blank.
37
+ # Add extra commands that you want to run after template generation has completed.
38
+ # e.g.
39
+ # :run_after_jumpstart:
40
+ # - rake db:create
41
+ # - capify!
42
+ # - git init
43
+ # - git add .
44
+ # - git commit -q -v -a -m "Initial commit"
45
+ :run_after_jumpstart:
46
+
47
+ ## Can be omitted or left blank.
48
+ # List files that you would like to perform string substitution on. This can be useful for populating files such as a capistrano deploy.rb file.
49
+ # Paths use the newly created project folder as root.
50
+ # Any key:value pair can be used for substitution, simply add the key name in CAPS to the template file then specify the symbol key and value as in the example.
51
+ # Note! The value of :project_name is hard coded to be the same as the projects name, no matter the value entered in this config file. This helps with capistrano.
52
+ # e.g.
53
+ # :replace_strings:
54
+ # - :target_path: /config/deploy.rb
55
+ # :symbols:
56
+ # :project_name: name_of_my_app
57
+ # :remote_server: thoughtplant
58
+ # - :target_path: /another/config/file.rb
59
+ # :symbols:
60
+ # :project_name: name_of_my_app
61
+ # :womble: uncle_bulgaria
62
+ :replace_strings:
63
+ - :target_path:
64
+ :symbols:
65
+
66
+ ## Can be omitted or left blank.
67
+ # If you would like jumpstart to configure your local nginx setup specify a path. Handy for rails.
68
+ # e.g.
69
+ # :local_nginx_conf: /usr/local/nginx/conf/nginx.conf
70
+ :local_nginx_conf:
71
+
72
+ ## Can be omitted or left blank.
73
+ # If you would like jumpstart to configure your remote nginx setup specify a path.
74
+ # EXPERIMENTAL FEATURE NOT YET IMPLEMENTED
75
+ # e.g.
76
+ # :remote_nginx_conf: /opt/nginx/conf/nginx.conf
77
+ :remote_nginx_conf:
@@ -0,0 +1,81 @@
1
+ daemon off;
2
+ worker_processes 4;
3
+ events {
4
+ worker_connections 8192;
5
+ }
6
+ http {
7
+ passenger_root /Users/i0n/.rvm/gems/ruby-1.9.2-head/gems/passenger-2.2.11;
8
+ passenger_ruby /Users/i0n/.rvm/bin/passenger_ruby;
9
+ include mime.types;
10
+ default_type application/octet-stream;
11
+ keepalive_timeout 65;
12
+ gzip on;
13
+ gzip_http_version 1.1;
14
+ gzip_vary on;
15
+ gzip_comp_level 6;
16
+ gzip_proxied any;
17
+ gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
18
+
19
+ server {
20
+ listen 80 default;
21
+ server_name _;
22
+ return 444;
23
+ }
24
+
25
+ server {
26
+ listen 80;
27
+ server_name test_haml.local;
28
+ rails_env development;
29
+ client_max_body_size 10M;
30
+ client_body_buffer_size 128k;
31
+ location / {
32
+ passenger_enabled on;
33
+ root /Users/i0n/Sites/test_haml/public;
34
+ }
35
+ }
36
+ server {
37
+ listen 80;
38
+ server_name test_rails_3.local;
39
+ rails_env development;
40
+ client_max_body_size 10M;
41
+ client_body_buffer_size 128k;
42
+ location / {
43
+ passenger_enabled on;
44
+ root /Users/i0n/Sites/test_rails_3/public;
45
+ }
46
+ }
47
+
48
+ server {
49
+ listen 80;
50
+ server_name test_rails.local;
51
+ rails_env development;
52
+ client_max_body_size 10M;
53
+ client_body_buffer_size 128k;
54
+ location / {
55
+ passenger_enabled on;
56
+ root /Users/i0n/Sites/test_rails/public;
57
+ }
58
+ }
59
+
60
+ server {
61
+ listen 80;
62
+ server_name test_rspec.local;
63
+ rails_env development;
64
+ client_max_body_size 10M;
65
+ client_body_buffer_size 128k;
66
+ location / {
67
+ passenger_enabled on;
68
+ root /Users/i0n/Sites/test_rspec/public;
69
+ }
70
+ }
71
+ server {
72
+ listen 80;
73
+ server_name test_sinatra.local;
74
+ client_max_body_size 10M;
75
+ client_body_buffer_size 128k;
76
+ location / {
77
+ passenger_enabled on;
78
+ root /Users/i0n/Sites/test_sinatra/public;
79
+ }
80
+ }
81
+ }
@@ -0,0 +1,54 @@
1
+ user www-data;
2
+ worker_processes 10;
3
+ error_log /opt/nginx/logs/error.log;
4
+ pid /opt/nginx/logs/nginx.pid;
5
+ events { worker_connections 1024; }
6
+ http {
7
+ include mime.types;
8
+ default_type application/octet-stream;
9
+ access_log /var/log/nginx/access.log;
10
+ sendfile on;
11
+ tcp_nopush on;
12
+ keepalive_timeout 30;
13
+ tcp_nodelay on;
14
+ passenger_root /usr/local/lib/ruby/gems/1.9.1/gems/passenger-2.2.11;
15
+ passenger_ruby /usr/local/bin/ruby;
16
+
17
+ server {
18
+ listen 80;
19
+ server_name testomatic_app_1.com;
20
+ rails_env production;
21
+ gzip on;
22
+ gzip_proxied any;
23
+ gzip_vary on;
24
+ gzip_disable 'MSIE [1-6]\.';
25
+ gzip_http_version 1.1;
26
+ gzip_min_length 10;
27
+ gzip_comp_level 9;
28
+ gzip_types text/plain application/xhtml+xml text/css application/x-javascript text/xml application/xml;
29
+ location / {
30
+ root /home/i0n/sites/testomatic_app_1/current/public/;
31
+ passenger_enabled on;
32
+ if ($request_filename ~ '.+\.(jpg|jpeg|gif|css|png|js|ico|html)$') { access_log off; expires 30d; }
33
+ }
34
+ }
35
+ server {
36
+ listen 80;
37
+ server_name www.testomatic_app_1.com;
38
+ rewrite ^ http://testomatic_app_1.com$request_uri?;
39
+ rails_env production;
40
+ gzip on;
41
+ gzip_proxied any;
42
+ gzip_vary on;
43
+ gzip_disable 'MSIE [1-6]\.';
44
+ gzip_http_version 1.1;
45
+ gzip_min_length 10;
46
+ gzip_comp_level 9;
47
+ gzip_types text/plain application/xhtml+xml text/css application/x-javascript text/xml application/xml;
48
+ location / {
49
+ root /home/i0n/sites/testomatic_app_1/current/public/;
50
+ passenger_enabled on;
51
+ if ($request_filename ~ '.+\.(jpg|jpeg|gif|css|png|js|ico|html)$') { access_log off; expires 30d; }
52
+ }
53
+ }
54
+ }