jumpstart 0.1.0 → 0.1.1

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 (107) hide show
  1. data/.gitignore +1 -0
  2. data/Gemfile +2 -1
  3. data/VERSION +1 -1
  4. data/config/jumpstart_setup.yml +1 -0
  5. data/jumpstart.gemspec +15 -89
  6. data/jumpstart_templates/{i0n_rails_3/lib/generators/formtastic_erb/controller/templates/view.html.erb → .gitignore} +0 -0
  7. data/lib/jumpstart.rb +15 -39
  8. data/lib/jumpstart/base.rb +111 -111
  9. data/lib/jumpstart/filetools.rb +11 -7
  10. data/lib/jumpstart/stringtools.rb +41 -0
  11. data/test/helper.rb +12 -6
  12. data/test/jumpstart/test_base.rb +848 -106
  13. data/test/jumpstart/test_filetools.rb +42 -10
  14. data/test/jumpstart/test_stringutils.rb +67 -0
  15. data/test/test_jumpstart_templates/test_base/current_files_and_dirs_test_file.txt +1 -0
  16. data/{jumpstart_templates/i0n_rails_3/lib/generators/formtastic_haml/controller/templates/view.html.haml → test/test_jumpstart_templates/test_fileutils/sort_contained_files_and_dirs_test/file_1.txt} +0 -0
  17. data/{jumpstart_templates/i0n_rails_3/lib/generators/haml/controller/templates/view.html.haml → test/test_jumpstart_templates/test_fileutils/sort_contained_files_and_dirs_test/file_2} +0 -0
  18. data/test/test_jumpstart_templates/test_fileutils/sort_contained_files_and_dirs_test/folder_1/file_3.txt +0 -0
  19. data/test/test_jumpstart_templates/test_fileutils/sort_contained_files_and_dirs_test/folder_1/folder_2/file_4.txt +0 -0
  20. data/test/test_jumpstart_templates/test_fileutils/sort_contained_files_and_dirs_test/folder_1/folder_2/folder_3/file_5.txt +0 -0
  21. data/test/test_jumpstart_templates/test_fileutils/sort_contained_files_and_dirs_test/folder_1/folder_2/folder_4/file_6.txt +0 -0
  22. data/test/test_jumpstart_templates/test_template_1/_20._test_line_file_without_extension +1 -1
  23. data/test/test_jumpstart_templates/test_template_2/jumpstart_config/test_template_2.yml +83 -1
  24. metadata +15 -89
  25. data/.bundle/config +0 -2
  26. data/jumpstart_templates/i0n_rails_3/.gitignore +0 -11
  27. data/jumpstart_templates/i0n_rails_3/_._Gemfile +0 -5
  28. data/jumpstart_templates/i0n_rails_3/app/views/home/index.haml +0 -4
  29. data/jumpstart_templates/i0n_rails_3/app/views/layouts/application.haml +0 -32
  30. data/jumpstart_templates/i0n_rails_3/config/_2._routes.rb +0 -1
  31. data/jumpstart_templates/i0n_rails_3/config/_L._database.yml +0 -1
  32. data/jumpstart_templates/i0n_rails_3/config/deploy.rb +0 -62
  33. data/jumpstart_templates/i0n_rails_3/config/environments/_18._development.rb +0 -5
  34. data/jumpstart_templates/i0n_rails_3/config/environments/_27._test.rb +0 -1
  35. data/jumpstart_templates/i0n_rails_3/config/environments/_41._production.rb +0 -3
  36. data/jumpstart_templates/i0n_rails_3/config/initializers/setup_mail.rb +0 -14
  37. data/jumpstart_templates/i0n_rails_3/jumpstart_config/i0n_rails_3.yml +0 -40
  38. data/jumpstart_templates/i0n_rails_3/jumpstart_config/nginx.local.conf +0 -11
  39. data/jumpstart_templates/i0n_rails_3/jumpstart_config/nginx.remote.conf +0 -37
  40. data/jumpstart_templates/i0n_rails_3/lib/development_mail_interceptor.rb +0 -8
  41. data/jumpstart_templates/i0n_rails_3/lib/generators/authlogic.rb +0 -11
  42. data/jumpstart_templates/i0n_rails_3/lib/generators/authlogic/session/session_generator.rb +0 -18
  43. data/jumpstart_templates/i0n_rails_3/lib/generators/authlogic/session/templates/session.rb +0 -2
  44. data/jumpstart_templates/i0n_rails_3/lib/generators/datamapper.rb +0 -80
  45. data/jumpstart_templates/i0n_rails_3/lib/generators/datamapper/migration/migration_generator.rb +0 -26
  46. data/jumpstart_templates/i0n_rails_3/lib/generators/datamapper/migration/templates/migration.rb +0 -21
  47. data/jumpstart_templates/i0n_rails_3/lib/generators/datamapper/model/model_generator.rb +0 -29
  48. data/jumpstart_templates/i0n_rails_3/lib/generators/datamapper/model/templates/migration.rb +0 -17
  49. data/jumpstart_templates/i0n_rails_3/lib/generators/datamapper/model/templates/model.rb +0 -10
  50. data/jumpstart_templates/i0n_rails_3/lib/generators/datamapper/observer/observer_generator.rb +0 -15
  51. data/jumpstart_templates/i0n_rails_3/lib/generators/datamapper/observer/templates/observer.rb +0 -5
  52. data/jumpstart_templates/i0n_rails_3/lib/generators/factory_girl.rb +0 -11
  53. data/jumpstart_templates/i0n_rails_3/lib/generators/factory_girl/model/model_generator.rb +0 -14
  54. data/jumpstart_templates/i0n_rails_3/lib/generators/factory_girl/model/templates/fixtures.rb +0 -7
  55. data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_erb.rb +0 -9
  56. data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_erb/USAGE +0 -8
  57. data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_erb/controller/controller_generator.rb +0 -24
  58. data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_erb/scaffold/scaffold_generator.rb +0 -27
  59. data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_erb/scaffold/templates/_form.html.erb +0 -12
  60. data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_erb/scaffold/templates/edit.html.erb +0 -6
  61. data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_erb/scaffold/templates/index.html.erb +0 -27
  62. data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_erb/scaffold/templates/layout.html.erb +0 -16
  63. data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_erb/scaffold/templates/new.html.erb +0 -5
  64. data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_erb/scaffold/templates/show.html.erb +0 -10
  65. data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_haml.rb +0 -9
  66. data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_haml/USAGE +0 -8
  67. data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_haml/controller/controller_generator.rb +0 -24
  68. data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_haml/scaffold/scaffold_generator.rb +0 -23
  69. data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_haml/scaffold/templates/_form.haml.erb +0 -9
  70. data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_haml/scaffold/templates/edit.haml.erb +0 -7
  71. data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_haml/scaffold/templates/index.haml.erb +0 -23
  72. data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_haml/scaffold/templates/layout.haml.erb +0 -9
  73. data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_haml/scaffold/templates/new.haml.erb +0 -5
  74. data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_haml/scaffold/templates/show.haml.erb +0 -9
  75. data/jumpstart_templates/i0n_rails_3/lib/generators/haml.rb +0 -9
  76. data/jumpstart_templates/i0n_rails_3/lib/generators/haml/controller/controller_generator.rb +0 -24
  77. data/jumpstart_templates/i0n_rails_3/lib/generators/haml/scaffold/scaffold_generator.rb +0 -26
  78. data/jumpstart_templates/i0n_rails_3/lib/generators/haml/scaffold/templates/_form.haml.erb +0 -9
  79. data/jumpstart_templates/i0n_rails_3/lib/generators/haml/scaffold/templates/edit.haml.erb +0 -7
  80. data/jumpstart_templates/i0n_rails_3/lib/generators/haml/scaffold/templates/index.haml.erb +0 -23
  81. data/jumpstart_templates/i0n_rails_3/lib/generators/haml/scaffold/templates/layout.haml.erb +0 -9
  82. data/jumpstart_templates/i0n_rails_3/lib/generators/haml/scaffold/templates/new.haml.erb +0 -5
  83. data/jumpstart_templates/i0n_rails_3/lib/generators/haml/scaffold/templates/show.haml.erb +0 -9
  84. data/jumpstart_templates/i0n_rails_3/lib/generators/machinist.rb +0 -11
  85. data/jumpstart_templates/i0n_rails_3/lib/generators/machinist/model/model_generator.rb +0 -19
  86. data/jumpstart_templates/i0n_rails_3/lib/generators/machinist/model/templates/blueprint.rb +0 -5
  87. data/jumpstart_templates/i0n_rails_3/lib/generators/machinist/model/templates/machinist_initializer.rb +0 -19
  88. data/jumpstart_templates/i0n_rails_3/lib/generators/mongomapper.rb +0 -80
  89. data/jumpstart_templates/i0n_rails_3/lib/generators/mongomapper/model/model_generator.rb +0 -29
  90. data/jumpstart_templates/i0n_rails_3/lib/generators/mongomapper/model/templates/model.rb +0 -24
  91. data/jumpstart_templates/i0n_rails_3/lib/generators/mongomapper/observer/observer_generator.rb +0 -15
  92. data/jumpstart_templates/i0n_rails_3/lib/generators/shoulda.rb +0 -11
  93. data/jumpstart_templates/i0n_rails_3/lib/generators/shoulda/controller/controller_generator.rb +0 -16
  94. data/jumpstart_templates/i0n_rails_3/lib/generators/shoulda/controller/templates/controller.rb +0 -84
  95. data/jumpstart_templates/i0n_rails_3/lib/generators/shoulda/model/model_generator.rb +0 -16
  96. data/jumpstart_templates/i0n_rails_3/lib/generators/shoulda/model/templates/model.rb +0 -7
  97. data/jumpstart_templates/i0n_rails_3/lib/tasks/populate.rake +0 -91
  98. data/jumpstart_templates/i0n_rails_3/public/javascripts/init.js +0 -6
  99. data/jumpstart_templates/i0n_rails_3/public/javascripts/jquery-1.4.2.min.js +0 -154
  100. data/jumpstart_templates/i0n_rails_3/public/javascripts/jquery-ui-1.8.custom.min.js +0 -404
  101. data/jumpstart_templates/i0n_rails_3/public/javascripts/rails.js +0 -126
  102. data/jumpstart_templates/i0n_rails_3/public/stylesheets/sass/_setup.sass +0 -86
  103. data/jumpstart_templates/i0n_rails_3/public/stylesheets/sass/global.sass +0 -58
  104. data/jumpstart_templates/i0n_rails_3/public/stylesheets/sass/handheld.sass +0 -7
  105. data/jumpstart_templates/i0n_rails_3/public/stylesheets/sass/ie.sass +0 -40
  106. data/jumpstart_templates/i0n_rails_3/public/stylesheets/sass/print.sass +0 -57
  107. data/jumpstart_templates/i0n_rails_3/public/stylesheets/sass/screen.sass +0 -170
data/.gitignore CHANGED
@@ -20,6 +20,7 @@ pkg
20
20
 
21
21
  ## PROJECT::SPECIFIC
22
22
  test/destination_dir/*
23
+ jumpstart_templates/*/*
23
24
 
24
25
  ## Bundler
25
26
  vendor/gems/gems
data/Gemfile CHANGED
@@ -3,6 +3,7 @@ source 'http://gemcutter.org'
3
3
  gem 'jumpstart'
4
4
 
5
5
  group :test do
6
- require 'test/unit'
6
+ require 'minitest/unit'
7
7
  require 'shoulda'
8
+ require 'mocha'
8
9
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.1.1
@@ -1,2 +1,3 @@
1
1
  ---
2
2
  :jumpstart_templates_path: /Users/i0n/Sites/jumpstart/jumpstart_templates
3
+ :jumpstart_default_template_name:
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{jumpstart}
8
- s.version = "0.1.0"
8
+ s.version = "0.1.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["i0n"]
12
- s.date = %q{2010-05-24}
12
+ s.date = %q{2010-05-27}
13
13
  s.default_executable = %q{jumpstart}
14
14
  s.description = %q{JumpStart is a script runner and template parser written in Ruby with Ruby projects in mind.
15
15
 
@@ -22,8 +22,7 @@ Gem::Specification.new do |s|
22
22
  "README.rdoc"
23
23
  ]
24
24
  s.files = [
25
- ".bundle/config",
26
- ".document",
25
+ ".document",
27
26
  ".gitignore",
28
27
  "Gemfile",
29
28
  "LICENSE",
@@ -33,91 +32,7 @@ Gem::Specification.new do |s|
33
32
  "bin/jumpstart",
34
33
  "config/jumpstart_setup.yml",
35
34
  "jumpstart.gemspec",
36
- "jumpstart_templates/i0n_rails_3/.gitignore",
37
- "jumpstart_templates/i0n_rails_3/_._Gemfile",
38
- "jumpstart_templates/i0n_rails_3/app/views/home/index.haml",
39
- "jumpstart_templates/i0n_rails_3/app/views/layouts/application.haml",
40
- "jumpstart_templates/i0n_rails_3/config/_2._routes.rb",
41
- "jumpstart_templates/i0n_rails_3/config/_L._database.yml",
42
- "jumpstart_templates/i0n_rails_3/config/deploy.rb",
43
- "jumpstart_templates/i0n_rails_3/config/environments/_18._development.rb",
44
- "jumpstart_templates/i0n_rails_3/config/environments/_27._test.rb",
45
- "jumpstart_templates/i0n_rails_3/config/environments/_41._production.rb",
46
- "jumpstart_templates/i0n_rails_3/config/initializers/setup_mail.rb",
47
- "jumpstart_templates/i0n_rails_3/jumpstart_config/i0n_rails_3.yml",
48
- "jumpstart_templates/i0n_rails_3/jumpstart_config/nginx.local.conf",
49
- "jumpstart_templates/i0n_rails_3/jumpstart_config/nginx.remote.conf",
50
- "jumpstart_templates/i0n_rails_3/lib/development_mail_interceptor.rb",
51
- "jumpstart_templates/i0n_rails_3/lib/generators/authlogic.rb",
52
- "jumpstart_templates/i0n_rails_3/lib/generators/authlogic/session/session_generator.rb",
53
- "jumpstart_templates/i0n_rails_3/lib/generators/authlogic/session/templates/session.rb",
54
- "jumpstart_templates/i0n_rails_3/lib/generators/datamapper.rb",
55
- "jumpstart_templates/i0n_rails_3/lib/generators/datamapper/migration/migration_generator.rb",
56
- "jumpstart_templates/i0n_rails_3/lib/generators/datamapper/migration/templates/migration.rb",
57
- "jumpstart_templates/i0n_rails_3/lib/generators/datamapper/model/model_generator.rb",
58
- "jumpstart_templates/i0n_rails_3/lib/generators/datamapper/model/templates/migration.rb",
59
- "jumpstart_templates/i0n_rails_3/lib/generators/datamapper/model/templates/model.rb",
60
- "jumpstart_templates/i0n_rails_3/lib/generators/datamapper/observer/observer_generator.rb",
61
- "jumpstart_templates/i0n_rails_3/lib/generators/datamapper/observer/templates/observer.rb",
62
- "jumpstart_templates/i0n_rails_3/lib/generators/factory_girl.rb",
63
- "jumpstart_templates/i0n_rails_3/lib/generators/factory_girl/model/model_generator.rb",
64
- "jumpstart_templates/i0n_rails_3/lib/generators/factory_girl/model/templates/fixtures.rb",
65
- "jumpstart_templates/i0n_rails_3/lib/generators/formtastic_erb.rb",
66
- "jumpstart_templates/i0n_rails_3/lib/generators/formtastic_erb/USAGE",
67
- "jumpstart_templates/i0n_rails_3/lib/generators/formtastic_erb/controller/controller_generator.rb",
68
- "jumpstart_templates/i0n_rails_3/lib/generators/formtastic_erb/controller/templates/view.html.erb",
69
- "jumpstart_templates/i0n_rails_3/lib/generators/formtastic_erb/scaffold/scaffold_generator.rb",
70
- "jumpstart_templates/i0n_rails_3/lib/generators/formtastic_erb/scaffold/templates/_form.html.erb",
71
- "jumpstart_templates/i0n_rails_3/lib/generators/formtastic_erb/scaffold/templates/edit.html.erb",
72
- "jumpstart_templates/i0n_rails_3/lib/generators/formtastic_erb/scaffold/templates/index.html.erb",
73
- "jumpstart_templates/i0n_rails_3/lib/generators/formtastic_erb/scaffold/templates/layout.html.erb",
74
- "jumpstart_templates/i0n_rails_3/lib/generators/formtastic_erb/scaffold/templates/new.html.erb",
75
- "jumpstart_templates/i0n_rails_3/lib/generators/formtastic_erb/scaffold/templates/show.html.erb",
76
- "jumpstart_templates/i0n_rails_3/lib/generators/formtastic_haml.rb",
77
- "jumpstart_templates/i0n_rails_3/lib/generators/formtastic_haml/USAGE",
78
- "jumpstart_templates/i0n_rails_3/lib/generators/formtastic_haml/controller/controller_generator.rb",
79
- "jumpstart_templates/i0n_rails_3/lib/generators/formtastic_haml/controller/templates/view.html.haml",
80
- "jumpstart_templates/i0n_rails_3/lib/generators/formtastic_haml/scaffold/scaffold_generator.rb",
81
- "jumpstart_templates/i0n_rails_3/lib/generators/formtastic_haml/scaffold/templates/_form.haml.erb",
82
- "jumpstart_templates/i0n_rails_3/lib/generators/formtastic_haml/scaffold/templates/edit.haml.erb",
83
- "jumpstart_templates/i0n_rails_3/lib/generators/formtastic_haml/scaffold/templates/index.haml.erb",
84
- "jumpstart_templates/i0n_rails_3/lib/generators/formtastic_haml/scaffold/templates/layout.haml.erb",
85
- "jumpstart_templates/i0n_rails_3/lib/generators/formtastic_haml/scaffold/templates/new.haml.erb",
86
- "jumpstart_templates/i0n_rails_3/lib/generators/formtastic_haml/scaffold/templates/show.haml.erb",
87
- "jumpstart_templates/i0n_rails_3/lib/generators/haml.rb",
88
- "jumpstart_templates/i0n_rails_3/lib/generators/haml/controller/controller_generator.rb",
89
- "jumpstart_templates/i0n_rails_3/lib/generators/haml/controller/templates/view.html.haml",
90
- "jumpstart_templates/i0n_rails_3/lib/generators/haml/scaffold/scaffold_generator.rb",
91
- "jumpstart_templates/i0n_rails_3/lib/generators/haml/scaffold/templates/_form.haml.erb",
92
- "jumpstart_templates/i0n_rails_3/lib/generators/haml/scaffold/templates/edit.haml.erb",
93
- "jumpstart_templates/i0n_rails_3/lib/generators/haml/scaffold/templates/index.haml.erb",
94
- "jumpstart_templates/i0n_rails_3/lib/generators/haml/scaffold/templates/layout.haml.erb",
95
- "jumpstart_templates/i0n_rails_3/lib/generators/haml/scaffold/templates/new.haml.erb",
96
- "jumpstart_templates/i0n_rails_3/lib/generators/haml/scaffold/templates/show.haml.erb",
97
- "jumpstart_templates/i0n_rails_3/lib/generators/machinist.rb",
98
- "jumpstart_templates/i0n_rails_3/lib/generators/machinist/model/model_generator.rb",
99
- "jumpstart_templates/i0n_rails_3/lib/generators/machinist/model/templates/blueprint.rb",
100
- "jumpstart_templates/i0n_rails_3/lib/generators/machinist/model/templates/machinist_initializer.rb",
101
- "jumpstart_templates/i0n_rails_3/lib/generators/mongomapper.rb",
102
- "jumpstart_templates/i0n_rails_3/lib/generators/mongomapper/model/model_generator.rb",
103
- "jumpstart_templates/i0n_rails_3/lib/generators/mongomapper/model/templates/model.rb",
104
- "jumpstart_templates/i0n_rails_3/lib/generators/mongomapper/observer/observer_generator.rb",
105
- "jumpstart_templates/i0n_rails_3/lib/generators/shoulda.rb",
106
- "jumpstart_templates/i0n_rails_3/lib/generators/shoulda/controller/controller_generator.rb",
107
- "jumpstart_templates/i0n_rails_3/lib/generators/shoulda/controller/templates/controller.rb",
108
- "jumpstart_templates/i0n_rails_3/lib/generators/shoulda/model/model_generator.rb",
109
- "jumpstart_templates/i0n_rails_3/lib/generators/shoulda/model/templates/model.rb",
110
- "jumpstart_templates/i0n_rails_3/lib/tasks/populate.rake",
111
- "jumpstart_templates/i0n_rails_3/public/javascripts/init.js",
112
- "jumpstart_templates/i0n_rails_3/public/javascripts/jquery-1.4.2.min.js",
113
- "jumpstart_templates/i0n_rails_3/public/javascripts/jquery-ui-1.8.custom.min.js",
114
- "jumpstart_templates/i0n_rails_3/public/javascripts/rails.js",
115
- "jumpstart_templates/i0n_rails_3/public/stylesheets/sass/_setup.sass",
116
- "jumpstart_templates/i0n_rails_3/public/stylesheets/sass/global.sass",
117
- "jumpstart_templates/i0n_rails_3/public/stylesheets/sass/handheld.sass",
118
- "jumpstart_templates/i0n_rails_3/public/stylesheets/sass/ie.sass",
119
- "jumpstart_templates/i0n_rails_3/public/stylesheets/sass/print.sass",
120
- "jumpstart_templates/i0n_rails_3/public/stylesheets/sass/screen.sass",
35
+ "jumpstart_templates/.gitignore",
121
36
  "lib/jumpstart.rb",
122
37
  "lib/jumpstart/base.rb",
123
38
  "lib/jumpstart/doc/JumpStart.html",
@@ -127,12 +42,15 @@ Gem::Specification.new do |s|
127
42
  "lib/jumpstart/doc/index.html",
128
43
  "lib/jumpstart/doc/rdoc.css",
129
44
  "lib/jumpstart/filetools.rb",
45
+ "lib/jumpstart/stringtools.rb",
130
46
  "source_templates/template_config.yml",
47
+ "test/destination_dir/.gitignore",
131
48
  "test/fake_nginx_path/local_nginx_1.conf",
132
49
  "test/fake_nginx_path/remote_nginx_1.conf",
133
50
  "test/helper.rb",
134
51
  "test/jumpstart/test_base.rb",
135
52
  "test/jumpstart/test_filetools.rb",
53
+ "test/jumpstart/test_stringutils.rb",
136
54
  "test/test_jumpstart.rb",
137
55
  "test/test_jumpstart_templates/test_base/_._test_file.txt",
138
56
  "test/test_jumpstart_templates/test_base/_._test_file_.txt",
@@ -141,6 +59,7 @@ Gem::Specification.new do |s|
141
59
  "test/test_jumpstart_templates/test_base/_10._test_file2.txt",
142
60
  "test/test_jumpstart_templates/test_base/_99999._test_file3.txt",
143
61
  "test/test_jumpstart_templates/test_base/_a._test_file4.txt",
62
+ "test/test_jumpstart_templates/test_base/current_files_and_dirs_test_file.txt",
144
63
  "test/test_jumpstart_templates/test_base/test_file",
145
64
  "test/test_jumpstart_templates/test_base/test_file5.txt",
146
65
  "test/test_jumpstart_templates/test_base/test_file_.6txt",
@@ -160,6 +79,12 @@ Gem::Specification.new do |s|
160
79
  "test/test_jumpstart_templates/test_fileutils/remove_files_test_3.txt",
161
80
  "test/test_jumpstart_templates/test_fileutils/remove_lines_test.txt",
162
81
  "test/test_jumpstart_templates/test_fileutils/replace_strings_test.rb",
82
+ "test/test_jumpstart_templates/test_fileutils/sort_contained_files_and_dirs_test/file_1.txt",
83
+ "test/test_jumpstart_templates/test_fileutils/sort_contained_files_and_dirs_test/file_2",
84
+ "test/test_jumpstart_templates/test_fileutils/sort_contained_files_and_dirs_test/folder_1/file_3.txt",
85
+ "test/test_jumpstart_templates/test_fileutils/sort_contained_files_and_dirs_test/folder_1/folder_2/file_4.txt",
86
+ "test/test_jumpstart_templates/test_fileutils/sort_contained_files_and_dirs_test/folder_1/folder_2/folder_3/file_5.txt",
87
+ "test/test_jumpstart_templates/test_fileutils/sort_contained_files_and_dirs_test/folder_1/folder_2/folder_4/file_6.txt",
163
88
  "test/test_jumpstart_templates/test_template_1/_._test_append_file_with_extension.txt",
164
89
  "test/test_jumpstart_templates/test_template_1/_._test_append_file_without_extension",
165
90
  "test/test_jumpstart_templates/test_template_1/_20._test_line_file_without_extension",
@@ -199,6 +124,7 @@ Gem::Specification.new do |s|
199
124
  "test/helper.rb",
200
125
  "test/jumpstart/test_base.rb",
201
126
  "test/jumpstart/test_filetools.rb",
127
+ "test/jumpstart/test_stringutils.rb",
202
128
  "test/test_jumpstart.rb",
203
129
  "test/test_jumpstart_templates/test_fileutils/config_capistrano_source.rb",
204
130
  "test/test_jumpstart_templates/test_fileutils/config_capistrano_test.rb",
@@ -19,6 +19,20 @@ module JumpStart
19
19
 
20
20
  require 'jumpstart/base'
21
21
  require 'jumpstart/filetools'
22
+ require 'jumpstart/stringtools'
23
+
24
+ # The path to the jumpstart templates directory.
25
+ # Set as a module instance variable.
26
+ @templates_path = YAML.load_file("#{CONFIG_PATH}/jumpstart_setup.yml")[:jumpstart_templates_path]
27
+ # sets the default template to use if it has not been passed as an argument.
28
+ # Set as a module instance variable.
29
+ @default_template_name = YAML.load_file("#{CONFIG_PATH}/jumpstart_setup.yml")[:jumpstart_default_template_name]
30
+
31
+ # Get and Set methods for module instance variables.
32
+ def self.templates_path; @templates_path; end
33
+ def self.templates_path=(value); @templates_path = value; end
34
+ def self.default_template_name; @default_template_name; end
35
+ def self.default_template_name=(value); @default_template_name = value; end
22
36
 
23
37
  end
24
38
 
@@ -29,43 +43,5 @@ module FileUtils
29
43
  end
30
44
 
31
45
  class String
32
-
33
- def red; colourise(self, "\e[31m"); end
34
- def red_bold; colourise(self, "\e[1m\e[31m"); end
35
- def green; colourise(self, "\e[32m"); end
36
- def green_bold; colourise(self, "\e[1m\e[32m"); end
37
- def yellow; colourise(self, "\e[1m\e[33m"); end
38
- def blue; colourise(self, "\e[34m"); end
39
- def blue_bold; colourise(self, "\e[1m\e[34m"); end
40
- def purple; colourise(self, "\e[1m\e[35m"); end
41
-
42
- def colourise(text, colour_code) "#{colour_code}#{text}\e[0m" end
43
-
44
- # Codes for changing output text:
45
-
46
- # 0 Turn off all attributes
47
- # 1 Set bright mode
48
- # 4 Set underline mode
49
- # 5 Set blink mode
50
- # 7 Exchange foreground and background colors
51
- # 8 Hide text (foreground colour would be the same as background)
52
- # 30 Black text
53
- # 31 Red text
54
- # 32 Green text
55
- # 33 Yellow text
56
- # 34 Blue text
57
- # 35 Magenta text
58
- # 36 Cyan text
59
- # 37 White text
60
- # 39 Default text colour
61
- # 40 Black background
62
- # 41 Red background
63
- # 42 Green background
64
- # 43 Yellow background
65
- # 44 Blue background
66
- # 45 Magenta background
67
- # 46 Cyan background
68
- # 47 White background
69
- # 49 Default background colour
70
-
46
+ include JumpStart::StringTools
71
47
  end
@@ -2,54 +2,46 @@ module JumpStart
2
2
  class Base
3
3
 
4
4
  # Accessor methods to make testing input or output easier.
5
- attr_accessor :input
6
- attr_reader :output
7
-
8
- # Monkeypatch puts to make testing easier.
9
- def puts(*args)
10
- @output.puts(*args)
11
- end
5
+ attr_accessor :input, :output
12
6
 
13
7
  # Monkeypatch gets to make testing easier.
14
8
  def gets(*args)
15
9
  @input.gets(*args)
16
10
  end
17
11
 
18
- # TODO initialize needs more tests
12
+ # Monkeypatch puts to make testing easier.
13
+ def puts(*args)
14
+ @output.puts(*args)
15
+ end
16
+
17
+ # TODO write a method to set :jumpstart_templates_path when the gem is run for the first time.
18
+
19
19
  def initialize(args)
20
20
  # setup for testing input
21
21
  @input = $stdin
22
22
  # setup for testing output
23
23
  @output = $stdout
24
- # The path to the jumpstart templates directory
25
- @jumpstart_templates_path = YAML.load_file("#{CONFIG_PATH}/jumpstart_setup.yml")[:jumpstart_templates_path]
26
- # sets the default template to use if it has not been passed as an argument.
27
- @default_template_name = YAML.load_file("#{CONFIG_PATH}/jumpstart_setup.yml")[:default_template_name]
28
- # set the name of the project from the first argument passed, or from the constant @default_template_name if no argument passed.
24
+ # set the name of the project from the first argument passed, or from the module instance variable JumpStart.default_template_name if no argument passed.
29
25
  @project_name = args.shift.dup if args[0] != nil
30
26
  if args[0] != nil
31
27
  @template_name = args.shift.dup
32
- elsif @default_template_name != nil
33
- @template_name = @default_template_name
28
+ elsif JumpStart.default_template_name != nil
29
+ @template_name = JumpStart.default_template_name
34
30
  end
35
31
  # set instance variable @template_path as the directory to read templates from.
36
- @template_path = FileUtils.join_paths(@jumpstart_templates_path, @template_name)
37
- # set up instance variable containing an array that will be populated with existing jumpstart templates
32
+ @template_path = FileUtils.join_paths(JumpStart.templates_path, @template_name)
38
33
  end
39
-
40
- # TODO Refactor startup so that if one argument is passed to the jumpstart command it will assume that it is the projects name.
41
- # If a default template has been set, jumpstart should create the project.
42
- # If a default template has not been set then the user should be asked to select an existing template. This could be the same menu as displayed for option 1 above.
43
-
34
+
44
35
  # TODO Ensure that if jumpstart is launched with two arguments they are parsed as @project_name and @template_name, and the command is launched without any menu display.
45
- # TODO Ensure that if jumpstart is launched with one argument it is parsed as @project_name, and if @default_template_name exists then the command is launched without any menu display.
36
+ # TODO Ensure that if jumpstart is launched with one argument it is parsed as @project_name, and if JumpStart.default_template_name exists then the command is launched without any menu display.
37
+ # TODO Write integration tests.
46
38
  # TODO Document methods for RDOC
47
39
  # Finish README etc for github
48
40
 
49
- # TODO set_config_file_options needs tests
41
+ # Look into moving @install_path or refactoring to make setting this variable easier.
50
42
  def set_config_file_options
51
- if File.exists?(FileUtils.join_paths(@jumpstart_templates_path, @template_name, "/jumpstart_config/", "#{@template_name}.yml"))
52
- @config_file = YAML.load_file(FileUtils.join_paths(@jumpstart_templates_path, @template_name, "/jumpstart_config/", "#{@template_name}.yml"))
43
+ if File.exists?(FileUtils.join_paths(JumpStart.templates_path, @template_name, "/jumpstart_config/", "#{@template_name}.yml"))
44
+ @config_file = YAML.load_file(FileUtils.join_paths(JumpStart.templates_path, @template_name, "/jumpstart_config/", "#{@template_name}.yml"))
53
45
  @install_command ||= @config_file[:install_command]
54
46
  @install_command_args ||= @config_file[:install_command_args]
55
47
  @replace_strings ||= @config_file[:replace_strings].each {|x| x}
@@ -59,7 +51,6 @@ module JumpStart
59
51
  end
60
52
  end
61
53
 
62
- # TODO check_setup needs tests
63
54
  def check_setup
64
55
  set_config_file_options
65
56
  lookup_existing_templates
@@ -69,14 +60,16 @@ module JumpStart
69
60
  check_install_path
70
61
  end
71
62
 
72
- # TODO lookup_existing_templates needs tests
63
+ # set up instance variable containing an array that will be populated with existing jumpstart templates
73
64
  def lookup_existing_templates
74
65
  @existing_templates = []
75
- template_dirs = Dir.entries(@jumpstart_templates_path) - IGNORE_DIRS
66
+ template_dirs = Dir.entries(JumpStart.templates_path) - IGNORE_DIRS
76
67
  template_dirs.each do |x|
77
- if Dir.entries(FileUtils.join_paths(@jumpstart_templates_path, x)).include? "jumpstart_config"
78
- if File.exists?(FileUtils.join_paths(@jumpstart_templates_path, x, '/jumpstart_config/', "#{x}.yml"))
79
- @existing_templates << x
68
+ if File.directory?(FileUtils.join_paths(JumpStart.templates_path, x))
69
+ if Dir.entries(FileUtils.join_paths(JumpStart.templates_path, x)).include? "jumpstart_config"
70
+ if File.exists?(FileUtils.join_paths(JumpStart.templates_path, x, '/jumpstart_config/', "#{x}.yml"))
71
+ @existing_templates << x
72
+ end
80
73
  end
81
74
  end
82
75
  end
@@ -89,10 +82,8 @@ module JumpStart
89
82
  execute_install_command
90
83
  run_scripts_from_yaml(:run_after_install_command)
91
84
  parse_template_dir
92
- # makes folders for the project
93
- @dir_list.each {|dir| FileUtils.mkdir_p(FileUtils.join_paths(@install_path, @project_name, dir)) }
94
- # create files from whole templates
95
- @whole_templates.each {|x| FileUtils.cp(FileUtils.join_paths(@template_path, x), FileUtils.join_paths(@install_path, @project_name, x)) }
85
+ create_dirs
86
+ populate_files_from_whole_templates
96
87
  populate_files_from_append_templates
97
88
  populate_files_from_line_templates
98
89
  remove_unwanted_files
@@ -115,7 +106,6 @@ module JumpStart
115
106
 
116
107
  private
117
108
 
118
- # TODO check_project_name needs extra tests for the match elsif
119
109
  def check_project_name
120
110
  if @project_name.nil? || @project_name.empty?
121
111
  puts "\n Enter a name for your project.".yellow
@@ -127,55 +117,52 @@ module JumpStart
127
117
  check_project_name
128
118
  elsif @project_name.match(/^\W/)
129
119
  puts "\n #{@project_name} begins with an invalid character. Please enter a name thats starts with a letter or a number.".red
120
+ @project_name = gets.chomp.strip
130
121
  check_project_name
131
122
  else
132
123
  @project_name
133
124
  end
134
125
  end
135
126
 
136
- # TODO check_template_name needs tests.
137
127
  def check_template_name
138
128
  if @template_name.nil? || @template_name.empty?
139
129
  jumpstart_menu
140
130
  end
141
131
  end
142
132
 
143
- # TODO check_template_path needs tests
144
133
  def check_template_path
145
134
  begin
146
135
  Dir.chdir(@template_path)
147
136
  rescue
148
- puts "\nThe directory #{x.red} could not be found, or you do not have the correct permissions to access it."
137
+ puts "\nThe directory #{@template_path.red} could not be found, or you do not have the correct permissions to access it."
149
138
  exit_normal
150
139
  end
151
140
  end
152
-
153
- # TODO check_install_path needs tests
141
+
142
+ # TODO test check_install_path setting @install_path = FileUtils.pwd from prompt.
154
143
  def check_install_path
155
- @install_path = FileUtils.pwd if @install_path.nil?
156
- if Dir.exists?(FileUtils.join_paths(@install_path, @project_name))
157
- puts
158
- puts "The directory #{FileUtils.join_paths(@install_path, @project_name).red} already exists.\nAs this is the location you have specified for creating your new project jumpstart will now exit to avoid overwriting anything."
144
+ @install_path = FileUtils.pwd if @install_path.nil? || @install_path.empty?
145
+ if File.directory?(FileUtils.join_paths(@install_path, @project_name))
146
+ puts "\nThe directory #{FileUtils.join_paths(@install_path, @project_name).red} already exists.\nAs this is the location you have specified for creating your new project jumpstart will now exit to avoid overwriting anything."
159
147
  exit_normal
160
- end
148
+ end
149
+ true
161
150
  end
162
151
 
163
- # TODO create_template needs tests
164
152
  def create_template
165
- if Dir.exists?(FileUtils.join_paths(@jumpstart_templates_path, @template_name))
166
- puts "\nThe directory #{FileUtils.join_paths(@jumpstart_templates_path, @template_name).red} already exists. The template will not be created."
153
+ if File.directory?(FileUtils.join_paths(JumpStart.templates_path, @template_name))
154
+ puts "\nThe directory #{FileUtils.join_paths(JumpStart.templates_path, @template_name).red} already exists. The template will not be created."
167
155
  exit_normal
168
156
  else
169
- FileUtils.mkdir_p(FileUtils.join_paths(@jumpstart_templates_path, @template_name, "/jumpstart_config"))
157
+ FileUtils.mkdir_p(FileUtils.join_paths(JumpStart.templates_path, @template_name, "/jumpstart_config"))
170
158
  yaml = IO.read(FileUtils.join_paths(ROOT_PATH, "/source_templates/template_config.yml"))
171
- File.open(FileUtils.join_paths(@jumpstart_templates_path, @template_name, "/jumpstart_config", "#{@template_name}.yml"), 'w') do |file|
159
+ File.open(FileUtils.join_paths(JumpStart.templates_path, @template_name, "/jumpstart_config", "#{@template_name}.yml"), 'w') do |file|
172
160
  file.puts yaml
173
161
  end
174
162
  puts "The template #{@template_name.green} has been generated.\n"
175
163
  end
176
164
  end
177
165
 
178
- # TODO jumpstart_menu needs tests
179
166
  def jumpstart_menu
180
167
  puts "\n\n******************************************************************************************************************************************\n\n"
181
168
  puts " JUMPSTART MENU\n".purple
@@ -189,7 +176,6 @@ module JumpStart
189
176
  jumpstart_menu_options
190
177
  end
191
178
 
192
- # TODO jumpstart_menu_options needs tests
193
179
  def jumpstart_menu_options
194
180
  lookup_existing_templates
195
181
  input = gets.chomp.strip
@@ -210,16 +196,16 @@ module JumpStart
210
196
  end
211
197
  end
212
198
 
213
- # TODO Check/finish methods for creating a new project through the menu
214
- # TODO new_project_from_template_menu needs tests
215
199
  def new_project_from_template_menu
216
200
  puts "\n\n******************************************************************************************************************************************\n\n"
217
201
  puts " CREATE A NEW JUMPSTART PROJECT FROM AN EXISTING TEMPLATE\n\n".purple
218
202
  puts " Type a number for the template that you want.\n\n"
219
203
  count = 0
220
- @existing_templates.each do |t|
221
- count += 1
222
- puts " #{count.to_s.yellow} #{t}"
204
+ unless @existing_templates.nil? || @existing_templates.empty?
205
+ @existing_templates.each do |t|
206
+ count += 1
207
+ puts " #{count.to_s.yellow} #{t}"
208
+ end
223
209
  end
224
210
  puts "\n b".yellow + " Back to main menu."
225
211
  puts "\n x".yellow + " Exit jumpstart\n\n"
@@ -227,7 +213,6 @@ module JumpStart
227
213
  new_project_from_template_options
228
214
  end
229
215
 
230
- # TODO new_project_from_template_options needs tests
231
216
  def new_project_from_template_options
232
217
  input = gets.chomp.strip
233
218
  case
@@ -246,7 +231,6 @@ module JumpStart
246
231
  end
247
232
  end
248
233
 
249
- # TODO write tests for new_template_menu
250
234
  def new_template_menu
251
235
  puts "\n\n******************************************************************************************************************************************\n\n"
252
236
  puts " CREATE A NEW JUMPSTART TEMPLATE\n".purple
@@ -258,28 +242,28 @@ module JumpStart
258
242
  new_template_options
259
243
  end
260
244
 
261
- # TODO write tests for new_template_options
245
+ # TODO add functionality for duplicating an existing template
262
246
  def new_template_options
263
247
  puts "\n Enter a unique name for the new template.\n".yellow
264
248
  input = gets.chomp.strip
265
- if @existing_templates.include?(input)
249
+ case
250
+ when @existing_templates.include?(input)
266
251
  puts " A template of the name ".red + input.red_bold + " already exists.".red
267
252
  new_template_options
268
- elsif input.length < 3
253
+ when input.length < 3
269
254
  puts " The template name ".red + input.red_bold + " is too short. Please enter a name that is at least 3 characters long.".red
270
255
  new_template_options
271
- elsif input.match(/^\W/)
256
+ when input.match(/^\W/)
272
257
  puts " The template name ".red + input.red_bold + " begins with an invalid character. Please enter a name that begins with a letter or a number.".red
273
258
  new_template_options
274
259
  else
275
- FileUtils.mkdir_p(FileUtils.join_paths(@jumpstart_templates_path, input, "jumpstart_config"))
276
- FileUtils.cp(FileUtils.join_paths(ROOT_PATH, "source_templates/template_config.yml"), FileUtils.join_paths(@jumpstart_templates_path, input, "jumpstart_config", "#{input}.yml"))
277
- puts " The template ".green + input.green_bold + " has been created in your default jumpstart template directory ".green + @jumpstart_templates_path.green_bold + " ready for editing.".green
260
+ FileUtils.mkdir_p(FileUtils.join_paths(JumpStart.templates_path, input, "jumpstart_config"))
261
+ FileUtils.cp(FileUtils.join_paths(ROOT_PATH, "source_templates/template_config.yml"), FileUtils.join_paths(JumpStart.templates_path, input, "jumpstart_config", "#{input}.yml"))
262
+ puts " The template ".green + input.green_bold + " has been created in your default jumpstart template directory ".green + JumpStart.templates_path.green_bold + " ready for editing.".green
278
263
  jumpstart_menu
279
264
  end
280
265
  end
281
266
 
282
- # TODO Write method(s) for setting the default template
283
267
  def set_default_template_menu
284
268
  puts "\n\n******************************************************************************************************************************************\n\n"
285
269
  puts " JUMPSTART DEFAULT TEMPLATE OPTIONS\n\n".purple
@@ -299,9 +283,9 @@ module JumpStart
299
283
  input = gets.chomp.strip
300
284
  case
301
285
  when input.to_i <= @existing_templates.count && input.to_i > 0
302
- @default_template_name = @existing_templates[(input.to_i - 1)]
286
+ JumpStart.default_template_name = @existing_templates[(input.to_i - 1)]
303
287
  dump_global_yaml
304
- puts " The default jumpstart template has been set to: #{@default_template_name.green}"
288
+ puts " The default jumpstart template has been set to: #{JumpStart.default_template_name.green}"
305
289
  jumpstart_menu
306
290
  when input == "b"
307
291
  jumpstart_menu
@@ -313,7 +297,6 @@ module JumpStart
313
297
  end
314
298
  end
315
299
 
316
- # TODO write tests for templates_dir_menu
317
300
  def templates_dir_menu
318
301
  puts "\n\n******************************************************************************************************************************************\n\n"
319
302
  puts " JUMPSTART TEMPLATES DIRECTORY OPTIONS\n\n".purple
@@ -325,14 +308,13 @@ module JumpStart
325
308
  templates_dir_options
326
309
  end
327
310
 
328
- # TODO templates_dir_options needs tests
329
311
  def templates_dir_options
330
312
  input = gets.chomp.strip
331
313
  case
332
314
  when input == "1"
333
315
  set_templates_dir
334
316
  when input == "2"
335
- reset_templates_dir_to_default
317
+ reset_templates_dir_to_default_check
336
318
  when input == "b"
337
319
  jumpstart_menu
338
320
  when input == "x"
@@ -343,25 +325,24 @@ module JumpStart
343
325
  end
344
326
  end
345
327
 
346
- # TODO set_templates_dir needs tests
347
328
  # Sets the path for templates to be used by JumpStart.
348
329
  def set_templates_dir
349
330
  puts "Please enter the absolute path for the directory that you would like to contain your jumpstart templates."
350
331
  input = gets.chomp.strip
351
332
  root_path = input.sub(/\/\w*\/*$/, '')
352
333
  case
353
- when Dir.exists?(input)
334
+ when File.directory?(input)
354
335
  puts "A directory of that name already exists, please choose a directory that does not exist."
355
- set_template_dir
356
- when Dir.exists?(root_path)
336
+ set_templates_dir
337
+ when File.directory?(root_path)
357
338
  begin
358
339
  Dir.chdir(root_path)
359
340
  Dir.mkdir(input)
360
- files_and_dirs = FileUtils.sort_contained_files_and_dirs(@jumpstart_templates_path)
341
+ files_and_dirs = FileUtils.sort_contained_files_and_dirs(JumpStart.templates_path)
361
342
  puts "\nCopying existing templates to #{input}"
362
343
  files_and_dirs[:dirs].each {|x| FileUtils.mkdir_p(FileUtils.join_paths(input, x))}
363
- files_and_dirs[:files].each {|x| FileUtils.cp(FileUtils.join_paths(@jumpstart_templates_path, x), FileUtils.join_paths(input, x)) }
364
- @jumpstart_templates_path = input.to_s
344
+ files_and_dirs[:files].each {|x| FileUtils.cp(FileUtils.join_paths(JumpStart.templates_path, x), FileUtils.join_paths(input, x)) }
345
+ JumpStart.templates_path = input.to_s
365
346
  dump_global_yaml
366
347
  puts "\nTransfer complete!".green
367
348
  jumpstart_menu
@@ -371,45 +352,55 @@ module JumpStart
371
352
  end
372
353
  end
373
354
 
374
- # TODO reset_templates_dir_to_default needs tests
375
- # Resets the JumpStart template directory to the default location. (within the gem.)
376
- def reset_templates_dir_to_default
377
- if @jumpstart_templates_path == "#{ROOT_PATH}/jumpstart_templates"
355
+ # Checks to see if the JumpStart template directory should be reset to the default location. (within the gem.)
356
+ def reset_templates_dir_to_default_check
357
+ if JumpStart.templates_path == "#{ROOT_PATH}/jumpstart_templates"
378
358
  puts " You do not need to reset the jumpstart templates directory, it is already set to: #{ROOT_PATH}/jumpstart_templates\n\n".red
359
+ templates_dir_menu
379
360
  else
380
361
  puts " Resetting the jumpstart templates directory to the default: #{ROOT_PATH}/jumpstart_templates\n\n"
381
- current_files_and_dirs = FileUtils.sort_contained_files_and_dirs(@jumpstart_templates_path)
362
+ @current_files_and_dirs = FileUtils.sort_contained_files_and_dirs(JumpStart.templates_path)
382
363
  puts " Moving your jumpstart templates back to the default directory will delete any templates that are currently there. Proceed?\n".yellow
383
364
  puts " Type yes (" + "y".yellow + ") or no (" + "n".yellow + ")\n\n"
384
- input = gets.chomp.strip
385
- if input == "yes" || input == "y"
386
- FileUtils.delete_dir_contents(FileUtils.join_paths(ROOT_PATH, '/jumpstart_templates'))
387
- current_files_and_dirs[:dirs].each {|x| FileUtils.mkdir_p(FileUtils.join_paths(ROOT_PATH, '/jumpstart_templates', x))}
388
- current_files_and_dirs[:files].each {|x| FileUtils.cp(FileUtils.join_paths(@jumpstart_templates_path, x), FileUtils.join_paths(ROOT_PATH, '/jumpstart_templates', x)) }
389
- @jumpstart_templates_path = FileUtils.join_paths(ROOT_PATH, '/jumpstart_templates')
390
- dump_global_yaml
391
- puts "\n SUCCESS! the jumpstart templates directory has been set to the default: #{ROOT_PATH}/jumpstart_templates".green
392
- end
365
+ reset_templates_dir_to_default_set
393
366
  end
394
- templates_dir_menu
395
367
  end
396
-
397
- # TODO execute_install_command needs tests
368
+
369
+ # Resets the JumpStart template directory to the default location. (within the gem.)
370
+ def reset_templates_dir_to_default_set
371
+ input = gets.chomp.strip
372
+ if input == "yes" || input == "y"
373
+ FileUtils.delete_dir_contents(FileUtils.join_paths(ROOT_PATH, '/jumpstart_templates'))
374
+ FileUtils.touch(FileUtils.join_paths(ROOT_PATH, '.gitignore'))
375
+ @current_files_and_dirs[:dirs].each {|x| FileUtils.mkdir_p(FileUtils.join_paths(ROOT_PATH, '/jumpstart_templates', x))}
376
+ @current_files_and_dirs[:files].each {|x| FileUtils.cp(FileUtils.join_paths(JumpStart.templates_path, x), FileUtils.join_paths(ROOT_PATH, '/jumpstart_templates', x)) }
377
+ JumpStart.templates_path = FileUtils.join_paths(ROOT_PATH, '/jumpstart_templates')
378
+ dump_global_yaml
379
+ puts "\n SUCCESS! the jumpstart templates directory has been set to the default: #{ROOT_PATH}/jumpstart_templates".green
380
+ templates_dir_menu
381
+ elsif input == "no" || input == "n"
382
+ puts "\n You have chosen not to move the jumpstart templates directory, nothing has been changed."
383
+ templates_dir_menu
384
+ else
385
+ puts "\n The command you entered could not be understood, please enter yes '" + "y".yellow + "' or no '" + "n".yellow + "'"
386
+ reset_templates_dir_to_default_set
387
+ end
388
+ end
389
+
398
390
  def execute_install_command
399
391
  Dir.chdir(@install_path)
400
- unless @install_command.nil?
392
+ unless @install_command.nil? || @install_command.empty?
401
393
  puts "Executing command: #{@install_command.green} #{@project_name.green} #{@install_command_args.green}"
402
394
  system "#{@install_command} #{@project_name} #{@install_command_args}"
403
395
  end
404
396
  end
405
-
406
- # TODO parse_template_dir needs tests
397
+
407
398
  def parse_template_dir
408
399
  @dir_list = []
409
400
  file_list = []
410
- @whole_templates = []
411
401
  @append_templates = []
412
402
  @line_templates = []
403
+ @whole_templates = []
413
404
  Find.find(@template_path) do |x|
414
405
  case
415
406
  when File.file?(x) && x !~ /\/jumpstart_config/ then
@@ -432,8 +423,17 @@ module JumpStart
432
423
  end
433
424
  end
434
425
  end
435
-
436
- #TODO populate_files_from_append_templates needs tests
426
+
427
+ # makes folders for the project
428
+ def create_dirs
429
+ @dir_list.each {|dir| FileUtils.mkdir_p(FileUtils.join_paths(@install_path, @project_name, dir)) } unless @dir_list.nil?
430
+ end
431
+
432
+ # create files from whole templates
433
+ def populate_files_from_whole_templates
434
+ @whole_templates.each {|x| FileUtils.cp(FileUtils.join_paths(@template_path, x), FileUtils.join_paths(@install_path, @project_name, x)) } unless @whole_templates.nil?
435
+ end
436
+
437
437
  def populate_files_from_append_templates
438
438
  @append_templates.each do |x|
439
439
  new_name = x.sub(/_([lL]?)\._{1}/, '')
@@ -442,7 +442,6 @@ module JumpStart
442
442
  end
443
443
  end
444
444
 
445
- # TODO populate_files_from_line_templates needs tests
446
445
  def populate_files_from_line_templates
447
446
  @line_templates.each do |x|
448
447
  new_name = x.sub(/_(\d+)\._{1}/, '')
@@ -450,10 +449,11 @@ module JumpStart
450
449
  FileUtils.insert_text_at_line_number(FileUtils.join_paths(@template_path, x), FileUtils.join_paths(@install_path, @project_name, new_name), JumpStart::Base.get_line_number(x))
451
450
  end
452
451
  end
453
-
454
- # TODO check_local_nginx_configuration needs tests
452
+
455
453
  def check_local_nginx_configuration
456
- unless @nginx_local_template.nil? && @config_file[:local_nginx_conf].nil?
454
+ if @nginx_local_template.nil? || @config_file[:local_nginx_conf].nil?
455
+ puts " \nNginx will not be configured as options have not been set for this."
456
+ else
457
457
  FileUtils.config_nginx(@nginx_local_template, @config_file[:local_nginx_conf], @project_name)
458
458
  FileUtils.config_hosts("/etc/hosts", @project_name)
459
459
  end
@@ -501,10 +501,10 @@ module JumpStart
501
501
  end
502
502
  end
503
503
  end
504
-
504
+
505
505
  def dump_global_yaml
506
506
  File.open( "#{CONFIG_PATH}/jumpstart_setup.yml", 'w' ) do |out|
507
- YAML.dump( {:jumpstart_templates_path => @jumpstart_templates_path, :default_template_name => @default_template_name}, out )
507
+ YAML.dump( {:jumpstart_templates_path => JumpStart.templates_path, :jumpstart_default_template_name => JumpStart.default_template_name}, out )
508
508
  end
509
509
  end
510
510
 
@@ -514,7 +514,7 @@ module JumpStart
514
514
  puts "******************************************************************************************************************************************\n"
515
515
  exit
516
516
  end
517
-
517
+
518
518
  def exit_normal
519
519
  puts "\n\n Exiting JumpStart...".purple
520
520
  puts "\n Goodbye!\n\n"