jumpstart 0.1.15 → 0.1.16
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.
- data/config/jumpstart_version.yml +1 -1
- data/lib/jumpstart.rb +1 -0
- data/lib/jumpstart/base.rb +22 -13
- data/test/jumpstart/test_base.rb +4 -4
- metadata +2 -2
data/lib/jumpstart.rb
CHANGED
@@ -21,6 +21,7 @@ module JumpStart
|
|
21
21
|
LIB_PATH = File.expand_path(File.dirname(__FILE__))
|
22
22
|
CONFIG_PATH = File.expand_path(File.join(File.dirname(__FILE__), '../config'))
|
23
23
|
IGNORE_DIRS = ['.','..']
|
24
|
+
LAUNCH_PATH = FileUtils.pwd
|
24
25
|
|
25
26
|
require 'jumpstart/setup'
|
26
27
|
require 'jumpstart/base'
|
data/lib/jumpstart/base.rb
CHANGED
@@ -141,11 +141,12 @@ module JumpStart
|
|
141
141
|
end
|
142
142
|
end
|
143
143
|
|
144
|
+
# TODO FileUtils.pwd is not behaving as expected. find a way to set this.
|
144
145
|
# Sets the install path to executing directory if @install_path varibale is nil or empty. This should result in projects being created in directory from which the jumpstart command was called, if the template specified does not set this option.
|
145
146
|
# Checks the install path set in @install_path.
|
146
147
|
# Checks that a directory with the same name as the project does not already exist in the install path.
|
147
148
|
def check_install_path
|
148
|
-
@install_path =
|
149
|
+
@install_path = JumpStart::LAUNCH_PATH if @install_path.nil? || @install_path.empty?
|
149
150
|
if File.directory?(FileUtils.join_paths(@install_path, @project_name))
|
150
151
|
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."
|
151
152
|
exit_normal
|
@@ -481,14 +482,17 @@ module JumpStart
|
|
481
482
|
end
|
482
483
|
end
|
483
484
|
|
485
|
+
# TODO needs more tests as nil values were slipping through
|
484
486
|
# Removes files specified in templates YAML
|
485
487
|
def remove_unwanted_files
|
486
488
|
file_array = []
|
487
489
|
root_path = FileUtils.join_paths(@install_path, @project_name)
|
488
|
-
@config_file[:remove_files].
|
489
|
-
|
490
|
+
unless @config_file[:remove_files].nil?
|
491
|
+
@config_file[:remove_files].each do |file|
|
492
|
+
file_array << FileUtils.join_paths(root_path, file)
|
493
|
+
end
|
494
|
+
FileUtils.remove_files(file_array)
|
490
495
|
end
|
491
|
-
FileUtils.remove_files(file_array)
|
492
496
|
end
|
493
497
|
|
494
498
|
# Runs additional scripts specified in YAML. Runs one set after the install command has executed, and another after the templates have been generated.
|
@@ -506,6 +510,7 @@ module JumpStart
|
|
506
510
|
end
|
507
511
|
end
|
508
512
|
|
513
|
+
# TODO Needs more tests as nil values slipped through before refactoring.
|
509
514
|
# Looks for strings IN_CAPS that are specified for replacement in the templates YAML
|
510
515
|
def check_for_strings_to_replace
|
511
516
|
if @replace_strings.nil? || @replace_strings.empty?
|
@@ -513,16 +518,20 @@ module JumpStart
|
|
513
518
|
else
|
514
519
|
puts "\nChecking for strings to replace inside files...\n\n"
|
515
520
|
@replace_strings.each do |file|
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
puts "
|
521
|
-
|
521
|
+
if file[:target_path].nil? || file[:symbols].nil?
|
522
|
+
false
|
523
|
+
else
|
524
|
+
puts "Target file: #{file[:target_path].green}\n"
|
525
|
+
puts "Strings to replace:\n\n"
|
526
|
+
check_replace_string_pairs_for_project_name_sub(file[:symbols])
|
527
|
+
file[:symbols].each do |x,y|
|
528
|
+
puts "Key: #{x.to_s.green}"
|
529
|
+
puts "Value: #{y.to_s.green}\n\n"
|
530
|
+
end
|
531
|
+
puts "\n"
|
532
|
+
path = FileUtils.join_paths(@install_path, @project_name, file[:target_path])
|
533
|
+
FileUtils.replace_strings(path, file[:symbols])
|
522
534
|
end
|
523
|
-
puts "\n"
|
524
|
-
path = FileUtils.join_paths(@install_path, @project_name, file[:target_path])
|
525
|
-
FileUtils.replace_strings(path, file[:symbols])
|
526
535
|
end
|
527
536
|
end
|
528
537
|
end
|
data/test/jumpstart/test_base.rb
CHANGED
@@ -358,7 +358,7 @@ class TestJumpstartBase < Test::Unit::TestCase
|
|
358
358
|
should "set the install path to the current directory if @install_path is nil and then run the method again, checking the path of @install_path + @project_name" do
|
359
359
|
@test_project.instance_variable_set(:@install_path, nil)
|
360
360
|
assert(@test_project.instance_eval {check_install_path})
|
361
|
-
assert_equal
|
361
|
+
assert_equal JumpStart::ROOT_PATH , @test_project.instance_variable_get(:@install_path)
|
362
362
|
end
|
363
363
|
|
364
364
|
end
|
@@ -469,15 +469,15 @@ class TestJumpstartBase < Test::Unit::TestCase
|
|
469
469
|
@test_project.instance_eval {lookup_existing_templates}
|
470
470
|
end
|
471
471
|
|
472
|
+
# TODO Look into testing this method in a different way. The fact that a new class object is instantiated makes it difficult to test with mocha.
|
472
473
|
should "create a new project with the specified template name, checking that the project name is valid when a valid number is entered" do
|
473
474
|
JumpStart::Setup.templates_path = "#{JumpStart::ROOT_PATH}/test/test_jumpstart_templates"
|
474
475
|
JumpStart::Setup.default_template_name = "test_template_1"
|
475
476
|
@test_project.expects(:check_project_name).once
|
476
477
|
@test_project.instance_variable_set(:@input, StringIO.new("1\n"))
|
477
478
|
@test_project.instance_eval {new_project_from_template_options}
|
478
|
-
|
479
|
-
|
480
|
-
FileUtils.remove_dir("#{JumpStart::ROOT_PATH}/test/test_jumpstart_templates/test_template_1/test_jumpstart_project")
|
479
|
+
assert File.directory?("#{JumpStart::ROOT_PATH}/test_jumpstart_project")
|
480
|
+
FileUtils.remove_dir("#{JumpStart::ROOT_PATH}/test_jumpstart_project")
|
481
481
|
end
|
482
482
|
|
483
483
|
should "launch the jumpstart_menu method if 'b' is entered" do
|