jumpstart 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -27,7 +27,7 @@ Build jumpstart from the git repo's gemspec:
27
27
  Install the newly created gem:
28
28
  gem install jumpstart-WHATEVER_THE_CURRENT_VERSION_IS.gem
29
29
 
30
- NOTE! If you install jumpstart using sudo then you will probably need to run jumpstart with it as well to grant writes to the YAML files in the gem.
30
+ ====NOTE! If you install jumpstart using sudo then you will probably need to run jumpstart with it as well to grant writes to the YAML files in the gem.
31
31
 
32
32
  == Getting Started
33
33
  There are a few ways to use jumpstart.
@@ -61,11 +61,81 @@ If the file you specify doesn't have as many lines as you said it would, whitesp
61
61
 
62
62
  == The JumpStart Menu
63
63
 
64
- == YAML Options
65
-
66
64
  == Task Execution Order
65
+ Jumpstart tasks are executed in the order that the YAML options below are displayed.
66
+
67
+ == YAML Options
68
+ ===:install_path:
69
+ Can be omitted or left blank.
70
+ If :install_path: is omitted, the new project will be created in whatever directory you are in when you run the command. It is the path where the project directory will be created
71
+ e.g.
72
+ :install_path: /Users/i0n/Sites
73
+
74
+ ===:install_command:
75
+ Can be omitted or left blank.
76
+ The command that this template will run. The main shell command to create the project.
77
+ e.g.
78
+ :install_command: rails
79
+
80
+ ===:install_command_args:
81
+ Can be omitted or left blank.
82
+ The arguments for :install_command. Broken into it's own value to allow the project name to be inserted between the two values.
83
+ e.g. :install_command_args: -d mysql -J -T
84
+
85
+ ===:run_after_install_command:
86
+ Can be omitted or left blank.
87
+ Add extra commands that you want to run after the main install command, but before template generation has started.
88
+ e.g.
89
+ :run_after_install_command:
90
+ - rails g controller home
91
+ - rails g model home
92
+
93
+ ===:remove_files:
94
+ Can be omitted or left blank.
95
+ List files that you would like removed from the newly generated project.
96
+ Paths use the newly created project folder as root.
97
+ e.g.
98
+ :remove_files:
99
+ - /public/index.html
100
+ - /public/favicon.ico
101
+ - /public/images/rails.png
102
+
103
+ ===:run_after_jumpstart:
104
+ Can be omitted or left blank.
105
+ Add extra commands that you want to run after template generation has completed.
106
+ e.g.
107
+ :run_after_jumpstart:
108
+ - rake db:create
109
+ - capify!
110
+ - git init
111
+ - git add .
112
+ - git commit -q -v -a -m "Initial commit"
113
+
114
+ ===:replace_strings:
115
+ Can be omitted or left blank.
116
+ 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.
117
+ Paths use the newly created project folder as root.
118
+ 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.
119
+
120
+ 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.
121
+ e.g.
122
+ :replace_strings:
123
+ - :target_path: /config/deploy.rb
124
+ :symbols:
125
+ :project_name: name_of_my_app
126
+ :remote_server: thoughtplant
127
+ - :target_path: /another/config/file.rb
128
+ :symbols:
129
+ :project_name: name_of_my_app
130
+ :womble: uncle_bulgaria
131
+
132
+ ===:local_nginx_conf:
133
+ Can be omitted or left blank.
134
+ If you would like jumpstart to configure your local nginx setup specify a path. Handy for rails.
135
+ e.g.
136
+ :local_nginx_conf: /usr/local/nginx/conf/nginx.conf
67
137
 
68
- ==Example YAML files
138
+ ==Example YAML
69
139
  Example 1: Sets up a new Rails project, creating MySQL Dbs and other options. Creates a home controller. Removes superfluous files created by Rails generator. Capifys the project. Creates a git repo and checks everything in to it. Replaces PROJECT_NAME string in capistrano deploy.rb with the name of the new project. Creates and appends to files generated by Rails to get everything ready to go straight away. Configures local Nginx environment. Not bad for one YAML!
70
140
  ---
71
141
  :install_path: /Users/i0n/Sites
@@ -107,79 +177,6 @@ Example 1: Sets up a new Rails project, creating MySQL Dbs and other options. Cr
107
177
 
108
178
  :local_nginx_conf: /usr/local/nginx/conf/nginx.conf
109
179
 
110
- Example 2: A blank YAML with commenting to make it easy to see your options when creating templates.
111
- ---
112
- # The commands in a jumpstart config file are executed in the order displayed in this file.
113
-
114
- ## Can be omitted or left blank. If :install_path: is omitted, the new project will be created in whatever directory you are in when you run the command.
115
- # The path to where the project directory will be created
116
- # e.g. :install_path: /Users/i0n/Sites
117
- :install_path:
118
-
119
- ## Can be omitted or left blank.
120
- # The command that this template will run. The main shell command to create the project.
121
- # e.g. :install_command: rails
122
- :install_command:
123
-
124
- ## Can be omitted or left blank.
125
- # The arguments for :install_command. Broken into it's own value to allow the project name to be inserted between the two values.
126
- # e.g. :install_command_args: -d mysql -J -T
127
- :install_command_args:
128
-
129
- ## Can be omitted or left blank.
130
- # Add extra commands that you want to run after the main install command, but before template generation has started.
131
- # e.g.
132
- # :run_after_install_command:
133
- # - rails g controller home
134
- # - rails g model home
135
- :run_after_install_command:
136
-
137
- ## Can be omitted or left blank.
138
- # List files that you would like removed from the newly generated project.
139
- # Paths use the newly created project folder as root.
140
- # e.g.
141
- # :remove_files:
142
- # - /public/index.html
143
- # - /public/favicon.ico
144
- # - /public/images/rails.png
145
- :remove_files:
146
-
147
- ## Can be omitted or left blank.
148
- # Add extra commands that you want to run after template generation has completed.
149
- # e.g.
150
- # :run_after_jumpstart:
151
- # - rake db:create
152
- # - capify!
153
- # - git init
154
- # - git add .
155
- # - git commit -q -v -a -m "Initial commit"
156
- :run_after_jumpstart:
157
-
158
- ## Can be omitted or left blank.
159
- # 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.
160
- # Paths use the newly created project folder as root.
161
- # 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.
162
- # 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.
163
- # e.g.
164
- # :replace_strings:
165
- # - :target_path: /config/deploy.rb
166
- # :symbols:
167
- # :project_name: name_of_my_app
168
- # :remote_server: thoughtplant
169
- # - :target_path: /another/config/file.rb
170
- # :symbols:
171
- # :project_name: name_of_my_app
172
- # :womble: uncle_bulgaria
173
- :replace_strings:
174
- - :target_path:
175
- :symbols:
176
-
177
- ## Can be omitted or left blank.
178
- # If you would like jumpstart to configure your local nginx setup specify a path. Handy for rails.
179
- # e.g.
180
- # :local_nginx_conf: /usr/local/nginx/conf/nginx.conf
181
- :local_nginx_conf:
182
-
183
180
  ==Note on Patches/Pull Requests
184
181
 
185
182
  * Fork the project.
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :jumpstart_version_major: 0
3
3
  :jumpstart_version_minor: 2
4
- :jumpstart_version_patch: 1
4
+ :jumpstart_version_patch: 2
@@ -110,7 +110,13 @@ module JumpStart
110
110
  # Makes sure that the chosen project name is suitable. (Not nil or empty, at least 3 characters long, and starts with a letter or a number.)
111
111
  # Returns with the value of @project_name
112
112
  def check_project_name
113
- if @project_name.nil? || @project_name.empty?
113
+ if @project_name == "b"
114
+ @project_name = nil
115
+ jumpstart_menu
116
+ elsif @project_name == "x"
117
+ @project_name = nil
118
+ exit_normal
119
+ elsif @project_name.nil? || @project_name.empty?
114
120
  puts "\n Enter a name for your project.".yellow
115
121
  @project_name = gets.chomp.strip
116
122
  check_project_name
@@ -215,7 +221,7 @@ module JumpStart
215
221
  unless @existing_templates.nil? || @existing_templates.empty?
216
222
  @existing_templates.each do |t|
217
223
  count += 1
218
- puts " #{count.to_s.yellow} #{t}"
224
+ puts " #{count.to_s.yellow} #{t.green}"
219
225
  end
220
226
  end
221
227
  puts "\n b".yellow + " Back to main menu."
@@ -241,6 +247,7 @@ module JumpStart
241
247
  exit_normal
242
248
  else
243
249
  puts "That command hasn't been understood. Try again!".red
250
+ new_project_from_template_options
244
251
  end
245
252
  end
246
253
 
@@ -253,6 +260,8 @@ module JumpStart
253
260
  @existing_templates.each do |x|
254
261
  puts " #{x.green}\n"
255
262
  end
263
+ puts "\n b".yellow + " Back to main menu."
264
+ puts "\n x".yellow + " Exit jumpstart\n\n"
256
265
  new_template_options
257
266
  end
258
267
 
@@ -262,6 +271,10 @@ module JumpStart
262
271
  puts "\n Enter a unique name for the new template.\n".yellow
263
272
  input = gets.chomp.strip
264
273
  case
274
+ when input == "b"
275
+ jumpstart_menu
276
+ when input == "x"
277
+ exit_normal
265
278
  when @existing_templates.include?(input)
266
279
  puts " A template of the name ".red + input.red_bold + " already exists.".red
267
280
  new_template_options
@@ -282,11 +295,11 @@ module JumpStart
282
295
  # Displays output for the "jumpstart default template options menu"
283
296
  def set_default_template_menu
284
297
  puts "\n\n******************************************************************************************************************************************\n\n"
285
- puts " JUMPSTART DEFAULT TEMPLATE OPTIONS\n\n".purple
298
+ puts " SELECT A DEFAULT JUMPSTART TEMPLATE\n\n".purple
286
299
  count = 0
287
300
  @existing_templates.each do |t|
288
301
  count += 1
289
- puts " #{count.to_s.yellow} #{t}"
302
+ puts " #{count.to_s.yellow} #{t.green}"
290
303
  end
291
304
  puts "\n b".yellow + " Back to main menu.\n\n"
292
305
  puts " x".yellow + " Exit jumpstart\n\n"
@@ -301,7 +314,7 @@ module JumpStart
301
314
  when input.to_i <= @existing_templates.count && input.to_i > 0
302
315
  JumpStart.default_template_name = @existing_templates[(input.to_i - 1)]
303
316
  JumpStart.dump_jumpstart_setup_yaml
304
- puts " The default jumpstart template has been set to: #{JumpStart.default_template_name.green}"
317
+ puts " The default jumpstart template has been set to: ".green + JumpStart.default_template_name.green_bold
305
318
  jumpstart_menu
306
319
  when input == "b"
307
320
  jumpstart_menu
@@ -330,6 +343,7 @@ module JumpStart
330
343
  input = gets.chomp.strip
331
344
  case
332
345
  when input == "1"
346
+ puts "Please enter the absolute path for the directory that you would like to contain your jumpstart templates.\n".yellow
333
347
  set_templates_dir
334
348
  when input == "2"
335
349
  reset_templates_dir_to_default_check
@@ -347,12 +361,15 @@ module JumpStart
347
361
  # Copies templates in the existing template dir to the new location.
348
362
  # The folder specified must not exist yet, but it's parent should.
349
363
  def set_templates_dir
350
- puts "Please enter the absolute path for the directory that you would like to contain your jumpstart templates."
351
364
  input = gets.chomp.strip
352
365
  root_path = input.sub(/\/\w*\/*$/, '')
353
366
  case
367
+ when input == "b"
368
+ jumpstart_menu
369
+ when input == "x"
370
+ exit_normal
354
371
  when File.directory?(input)
355
- puts "A directory of that name already exists, please choose a directory that does not exist."
372
+ puts "A directory of that name already exists, please choose a directory that does not exist.".red
356
373
  set_templates_dir
357
374
  when File.directory?(root_path)
358
375
  begin
@@ -369,13 +386,16 @@ module JumpStart
369
386
  rescue
370
387
  puts "It looks like you do not have the correct permissions to create a directory in #{root_path.red}"
371
388
  end
389
+ else
390
+ puts "Couldn't find a directory of that name. Try again.".red
391
+ set_templates_dir
372
392
  end
373
393
  end
374
394
 
375
395
  # Checks to see if the JumpStart template directory should be reset to the default location. (within the gem.)
376
396
  def reset_templates_dir_to_default_check
377
397
  if JumpStart.templates_path == "#{ROOT_PATH}/jumpstart_templates"
378
- puts " You do not need to reset the jumpstart templates directory, it is already set to: #{ROOT_PATH}/jumpstart_templates\n\n".red
398
+ puts " You do not need to reset the jumpstart templates directory, it is already set to: #{ROOT_PATH}/jumpstart_templates".red
379
399
  templates_dir_menu
380
400
  else
381
401
  puts " Resetting the jumpstart templates directory to the default: #{ROOT_PATH}/jumpstart_templates\n\n"
@@ -456,7 +456,7 @@ class TestJumpstartBase < Test::Unit::TestCase
456
456
  @test_project.expects(:new_project_from_template_options).once
457
457
  @test_project.instance_variable_set(:@existing_templates, %w[project1 project2 project3])
458
458
  @test_project.instance_eval {new_project_from_template_menu}
459
- assert_equal "\n\n******************************************************************************************************************************************\n\n\e[1m\e[35m CREATE A NEW JUMPSTART PROJECT FROM AN EXISTING TEMPLATE\n\n\e[0m\n Type a number for the template that you want.\n\n \e[1m\e[33m1\e[0m project1\n \e[1m\e[33m2\e[0m project2\n \e[1m\e[33m3\e[0m project3\n\e[1m\e[33m\n b\e[0m Back to main menu.\n\e[1m\e[33m\n x\e[0m Exit jumpstart\n\n******************************************************************************************************************************************\n\n", @test_project.output.string
459
+ assert_equal "\n\n******************************************************************************************************************************************\n\n\e[1m\e[35m CREATE A NEW JUMPSTART PROJECT FROM AN EXISTING TEMPLATE\n\n\e[0m\n Type a number for the template that you want.\n\n \e[1m\e[33m1\e[0m \e[32mproject1\e[0m\n \e[1m\e[33m2\e[0m \e[32mproject2\e[0m\n \e[1m\e[33m3\e[0m \e[32mproject3\e[0m\n\e[1m\e[33m\n b\e[0m Back to main menu.\n\e[1m\e[33m\n x\e[0m Exit jumpstart\n\n******************************************************************************************************************************************\n\n", @test_project.output.string
460
460
  assert_equal ['project1', 'project2', 'project3'], @test_project.instance_variable_get(:@existing_templates)
461
461
  end
462
462
 
@@ -492,10 +492,11 @@ class TestJumpstartBase < Test::Unit::TestCase
492
492
  @test_project.instance_eval {new_project_from_template_options}
493
493
  end
494
494
 
495
+ # Raises a NoMethodError in the test as loop is not stopped by user input and cannot perform chomp on nil.
495
496
  should "output a message saying that the input has not been understood for any other input" do
496
497
  @test_project.instance_variable_set(:@input, StringIO.new("blarg\n"))
497
- @test_project.instance_eval {new_project_from_template_options}
498
- assert_equal "\e[31mThat command hasn't been understood. Try again!\e[0m\n", @test_project.output.string
498
+ assert_raises(NoMethodError) {@test_project.instance_eval {new_project_from_template_options}}
499
+ # assert_equal "\e[31mThat command hasn't been understood. Try again!\e[0m\n", @test_project.output.string
499
500
  end
500
501
 
501
502
  end
@@ -509,7 +510,7 @@ class TestJumpstartBase < Test::Unit::TestCase
509
510
  @test_project.expects(:lookup_existing_templates).once
510
511
  @test_project.expects(:new_template_options).once
511
512
  @test_project.instance_eval {new_template_menu}
512
- assert_equal "\n\n******************************************************************************************************************************************\n\n\e[1m\e[35m CREATE A NEW JUMPSTART TEMPLATE\n\e[0m\n Existing templates:\n \e[32mproject1\e[0m\n \e[32mproject2\e[0m\n \e[32mproject3\e[0m\n", @test_project.output.string
513
+ assert_equal "\n\n******************************************************************************************************************************************\n\n\e[1m\e[35m CREATE A NEW JUMPSTART TEMPLATE\n\e[0m\n Existing templates:\n \e[32mproject1\e[0m\n \e[32mproject2\e[0m\n \e[32mproject3\e[0m\n\e[1m\e[33m\n b\e[0m Back to main menu.\n\e[1m\e[33m\n x\e[0m Exit jumpstart\n\n", @test_project.output.string
513
514
  assert_equal %w[project1 project2 project3], @test_project.instance_variable_get(:@existing_templates)
514
515
  end
515
516
 
@@ -559,7 +560,7 @@ class TestJumpstartBase < Test::Unit::TestCase
559
560
  @test_project.stubs(:set_default_template_options)
560
561
  @test_project.expects(:set_default_template_options).once
561
562
  @test_project.instance_eval {set_default_template_menu}
562
- assert_equal "\n\n******************************************************************************************************************************************\n\n\e[1m\e[35m JUMPSTART DEFAULT TEMPLATE OPTIONS\n\n\e[0m\n \e[1m\e[33m1\e[0m one\n \e[1m\e[33m2\e[0m two\n \e[1m\e[33m3\e[0m three\n\e[1m\e[33m\n b\e[0m Back to main menu.\n\n\e[1m\e[33m x\e[0m Exit jumpstart\n\n******************************************************************************************************************************************\n\n", @test_project.output.string
563
+ assert_equal "\n\n******************************************************************************************************************************************\n\n\e[1m\e[35m SELECT A DEFAULT JUMPSTART TEMPLATE\n\n\e[0m\n \e[1m\e[33m1\e[0m \e[32mone\e[0m\n \e[1m\e[33m2\e[0m \e[32mtwo\e[0m\n \e[1m\e[33m3\e[0m \e[32mthree\e[0m\n\e[1m\e[33m\n b\e[0m Back to main menu.\n\n\e[1m\e[33m x\e[0m Exit jumpstart\n\n******************************************************************************************************************************************\n\n", @test_project.output.string
563
564
  end
564
565
 
565
566
  end
@@ -672,7 +673,7 @@ class TestJumpstartBase < Test::Unit::TestCase
672
673
  JumpStart.expects(:dump_jumpstart_setup_yaml).once
673
674
  @test_project.expects(:jumpstart_menu).once
674
675
  @test_project.instance_eval {set_templates_dir}
675
- assert_equal "Please enter the absolute path for the directory that you would like to contain your jumpstart templates.\n\nCopying existing templates to /Users/i0n/Sites/jumpstart/test/destination_dir/a_name_that_does_not_exist\n\e[32m\nTransfer complete!\e[0m\n", @test_project.output.string
676
+ assert_equal "\nCopying existing templates to /Users/i0n/Sites/jumpstart/test/destination_dir/a_name_that_does_not_exist\n\e[32m\nTransfer complete!\e[0m\n", @test_project.output.string
676
677
  assert File.exists?("#{JumpStart::ROOT_PATH}/test/destination_dir/a_name_that_does_not_exist/test_template_1/jumpstart_config/test_template_1.yml")
677
678
  end
678
679
 
@@ -689,7 +690,7 @@ class TestJumpstartBase < Test::Unit::TestCase
689
690
  JumpStart.templates_path = "#{JumpStart::ROOT_PATH}/jumpstart_templates"
690
691
  @test_project.expects(:templates_dir_menu).once
691
692
  @test_project.instance_eval {reset_templates_dir_to_default_check}
692
- assert_equal "\e[31m You do not need to reset the jumpstart templates directory, it is already set to: /Users/i0n/Sites/jumpstart/jumpstart_templates\n\n\e[0m\n", @test_project.output.string
693
+ assert_equal "\e[31m You do not need to reset the jumpstart templates directory, it is already set to: /Users/i0n/Sites/jumpstart/jumpstart_templates\e[0m\n", @test_project.output.string
693
694
  end
694
695
 
695
696
  should "run reset_templates_dir_to_default_set if the current JumpStart.templates_path is not the default." do
@@ -5,7 +5,10 @@ class TestJumpStartWithNoGlobalDefaults < Test::Unit::TestCase
5
5
  context "JumpStart::Setup.templates_path and JumpStart::Setup.default_template_name are both set to nil as @jumpstart_setup_yaml is not loaded" do
6
6
 
7
7
  setup do
8
- JumpStart.module_eval {@jumpstart_setup_yaml = nil}
8
+ JumpStart.module_eval do
9
+ @jumpstart_setup_yaml = nil
10
+ @default_template_name = nil
11
+ end
9
12
  @project.stubs(:jumpstart_menu)
10
13
  end
11
14
 
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 2
8
- - 1
9
- version: 0.2.1
8
+ - 2
9
+ version: 0.2.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Ian Alexander Wood (i0n)