jumpstart 0.1.3 → 0.1.4
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/VERSION +1 -1
- data/jumpstart.gemspec +1 -2
- data/lib/jumpstart.rb +18 -3
- data/lib/jumpstart/base.rb +5 -11
- data/test/jumpstart/test_base.rb +20 -23
- metadata +2 -7
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.4
|
data/jumpstart.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{jumpstart}
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.4"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["i0n"]
|
@@ -44,7 +44,6 @@ Gem::Specification.new do |s|
|
|
44
44
|
"lib/jumpstart/filetools.rb",
|
45
45
|
"lib/jumpstart/stringtools.rb",
|
46
46
|
"source_templates/template_config.yml",
|
47
|
-
"test/destination_dir/.gitignore",
|
48
47
|
"test/fake_nginx_path/local_nginx_1.conf",
|
49
48
|
"test/fake_nginx_path/remote_nginx_1.conf",
|
50
49
|
"test/helper.rb",
|
data/lib/jumpstart.rb
CHANGED
@@ -24,12 +24,13 @@ module JumpStart
|
|
24
24
|
require 'jumpstart/filetools'
|
25
25
|
require 'jumpstart/stringtools'
|
26
26
|
|
27
|
+
jumpstart_setup_yaml = YAML.load_file("#{CONFIG_PATH}/jumpstart_setup.yml")
|
27
28
|
# The path to the jumpstart templates directory.
|
28
29
|
# Set as a module instance variable.
|
29
|
-
@templates_path =
|
30
|
+
@templates_path = jumpstart_setup_yaml[:jumpstart_templates_path]
|
30
31
|
# sets the default template to use if it has not been passed as an argument.
|
31
32
|
# Set as a module instance variable.
|
32
|
-
@default_template_name =
|
33
|
+
@default_template_name = jumpstart_setup_yaml[:jumpstart_default_template_name]
|
33
34
|
|
34
35
|
# Get and Set methods for module instance variables.
|
35
36
|
def self.templates_path; @templates_path; end
|
@@ -37,6 +38,14 @@ module JumpStart
|
|
37
38
|
def self.default_template_name; @default_template_name; end
|
38
39
|
def self.default_template_name=(value); @default_template_name = value; end
|
39
40
|
|
41
|
+
class Setup
|
42
|
+
def self.dump_global_yaml
|
43
|
+
File.open( "#{CONFIG_PATH}/jumpstart_setup.yml", 'w' ) do |out|
|
44
|
+
YAML.dump( {:jumpstart_templates_path => JumpStart.templates_path, :jumpstart_default_template_name => JumpStart.default_template_name}, out )
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
40
49
|
end
|
41
50
|
|
42
51
|
module FileUtils
|
@@ -47,4 +56,10 @@ end
|
|
47
56
|
|
48
57
|
class String
|
49
58
|
include JumpStart::StringTools
|
50
|
-
end
|
59
|
+
end
|
60
|
+
|
61
|
+
# Set the jumpstart templates path back to default if it has not been set
|
62
|
+
if JumpStart.templates_path.nil? || JumpStart.templates_path.empty?
|
63
|
+
JumpStart.templates_path = "#{JumpStart::ROOT_PATH}/jumpstart_templates"
|
64
|
+
JumpStart::Setup.dump_global_yaml
|
65
|
+
end
|
data/lib/jumpstart/base.rb
CHANGED
@@ -31,7 +31,7 @@ module JumpStart
|
|
31
31
|
# set instance variable @template_path as the directory to read templates from.
|
32
32
|
@template_path = FileUtils.join_paths(JumpStart.templates_path, @template_name)
|
33
33
|
end
|
34
|
-
|
34
|
+
|
35
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.
|
36
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
37
|
# TODO Write integration tests.
|
@@ -77,7 +77,7 @@ module JumpStart
|
|
77
77
|
|
78
78
|
def start
|
79
79
|
puts "\n******************************************************************************************************************************************\n\n"
|
80
|
-
puts "JumpStarting....\n".purple
|
80
|
+
puts " JumpStarting....\n".purple
|
81
81
|
check_setup
|
82
82
|
execute_install_command
|
83
83
|
run_scripts_from_yaml(:run_after_install_command)
|
@@ -284,7 +284,7 @@ module JumpStart
|
|
284
284
|
case
|
285
285
|
when input.to_i <= @existing_templates.count && input.to_i > 0
|
286
286
|
JumpStart.default_template_name = @existing_templates[(input.to_i - 1)]
|
287
|
-
dump_global_yaml
|
287
|
+
JumpStart::Setup.dump_global_yaml
|
288
288
|
puts " The default jumpstart template has been set to: #{JumpStart.default_template_name.green}"
|
289
289
|
jumpstart_menu
|
290
290
|
when input == "b"
|
@@ -343,7 +343,7 @@ module JumpStart
|
|
343
343
|
files_and_dirs[:dirs].each {|x| FileUtils.mkdir_p(FileUtils.join_paths(input, x))}
|
344
344
|
files_and_dirs[:files].each {|x| FileUtils.cp(FileUtils.join_paths(JumpStart.templates_path, x), FileUtils.join_paths(input, x)) }
|
345
345
|
JumpStart.templates_path = input.to_s
|
346
|
-
dump_global_yaml
|
346
|
+
JumpStart::Setup.dump_global_yaml
|
347
347
|
puts "\nTransfer complete!".green
|
348
348
|
jumpstart_menu
|
349
349
|
rescue
|
@@ -375,7 +375,7 @@ module JumpStart
|
|
375
375
|
@current_files_and_dirs[:dirs].each {|x| FileUtils.mkdir_p(FileUtils.join_paths(ROOT_PATH, '/jumpstart_templates', x))}
|
376
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
377
|
JumpStart.templates_path = FileUtils.join_paths(ROOT_PATH, '/jumpstart_templates')
|
378
|
-
dump_global_yaml
|
378
|
+
JumpStart::Setup.dump_global_yaml
|
379
379
|
puts "\n SUCCESS! the jumpstart templates directory has been set to the default: #{ROOT_PATH}/jumpstart_templates".green
|
380
380
|
templates_dir_menu
|
381
381
|
elsif input == "no" || input == "n"
|
@@ -501,12 +501,6 @@ module JumpStart
|
|
501
501
|
end
|
502
502
|
end
|
503
503
|
end
|
504
|
-
|
505
|
-
def dump_global_yaml
|
506
|
-
File.open( "#{CONFIG_PATH}/jumpstart_setup.yml", 'w' ) do |out|
|
507
|
-
YAML.dump( {:jumpstart_templates_path => JumpStart.templates_path, :jumpstart_default_template_name => JumpStart.default_template_name}, out )
|
508
|
-
end
|
509
|
-
end
|
510
504
|
|
511
505
|
def exit_with_success
|
512
506
|
puts "\n\n Exiting JumpStart...".purple
|
data/test/jumpstart/test_base.rb
CHANGED
@@ -8,11 +8,14 @@ class TestJumpstartBase < Test::Unit::TestCase
|
|
8
8
|
# IO has been setup for testing
|
9
9
|
# runs set_config_file_options to set all instance variables
|
10
10
|
setup do
|
11
|
+
# Creates destination_dir if it does not exist
|
12
|
+
unless File.directory?("#{JumpStart::ROOT_PATH}/test/destination_dir")
|
13
|
+
Dir.mkdir("#{JumpStart::ROOT_PATH}/test/destination_dir")
|
14
|
+
end
|
11
15
|
JumpStart.templates_path = "#{JumpStart::ROOT_PATH}/test/test_jumpstart_templates"
|
12
16
|
JumpStart.default_template_name = "test_template_1"
|
13
17
|
input = StringIO.new
|
14
18
|
output = StringIO.new
|
15
|
-
FileUtils.delete_dir_contents("#{JumpStart::ROOT_PATH}/test/destination_dir")
|
16
19
|
@test_project = JumpStart::Base.new(["test_jumpstart_project"])
|
17
20
|
@test_project.instance_variable_set(:@input, input)
|
18
21
|
@test_project.instance_variable_set(:@output, output)
|
@@ -30,7 +33,6 @@ class TestJumpstartBase < Test::Unit::TestCase
|
|
30
33
|
setup do
|
31
34
|
input = StringIO.new
|
32
35
|
output = StringIO.new
|
33
|
-
FileUtils.delete_dir_contents("#{JumpStart::ROOT_PATH}/test/destination_dir")
|
34
36
|
@test_project_2 = JumpStart::Base.new(["test_jumpstart_project", "a_name_that_does_not_exist"])
|
35
37
|
@test_project_2.instance_eval do
|
36
38
|
@input = input
|
@@ -46,7 +48,6 @@ class TestJumpstartBase < Test::Unit::TestCase
|
|
46
48
|
|
47
49
|
# An invalid project (@template_name), with the project name passed as the argument
|
48
50
|
setup do
|
49
|
-
FileUtils.delete_dir_contents("#{JumpStart::ROOT_PATH}/test/destination_dir")
|
50
51
|
@test_project_3 = JumpStart::Base.new(["test_jumpstart_project"])
|
51
52
|
@test_project_3.instance_variable_set(:@template_name, "a_name_that_does_not_exist")
|
52
53
|
@test_project_3.instance_variable_set(:@template_path, "#{JumpStart::ROOT_PATH}/test/test_jumpstart_templates/test_template_2")
|
@@ -56,7 +57,6 @@ class TestJumpstartBase < Test::Unit::TestCase
|
|
56
57
|
|
57
58
|
# A valid project with the project name passed as the argument
|
58
59
|
setup do
|
59
|
-
FileUtils.delete_dir_contents("#{JumpStart::ROOT_PATH}/test/destination_dir")
|
60
60
|
@test_project_4 = JumpStart::Base.new(["test_jumpstart_project"])
|
61
61
|
@test_project_4.instance_variable_set(:@template_name, "test_template_2")
|
62
62
|
@test_project_4.instance_variable_set(:@template_path, "#{JumpStart::ROOT_PATH}/test/test_jumpstart_templates/test_template_2")
|
@@ -102,7 +102,6 @@ class TestJumpstartBase < Test::Unit::TestCase
|
|
102
102
|
|
103
103
|
teardown do
|
104
104
|
FileUtils.delete_dir_contents("#{JumpStart::ROOT_PATH}/test/destination_dir")
|
105
|
-
FileUtils.touch("#{JumpStart::ROOT_PATH}/test/destination_dir/.gitignore")
|
106
105
|
end
|
107
106
|
|
108
107
|
context "Tests for the JumpStart::Base#intialize instance method. \n" do
|
@@ -569,7 +568,7 @@ class TestJumpstartBase < Test::Unit::TestCase
|
|
569
568
|
|
570
569
|
setup do
|
571
570
|
@test_project.stubs(:jumpstart_menu)
|
572
|
-
|
571
|
+
JumpStart::Setup.stubs(:dump_global_yaml)
|
573
572
|
@test_project.instance_variable_set(:@existing_templates, %w[template1 template2 template3])
|
574
573
|
JumpStart.default_template_name = "temp_default"
|
575
574
|
end
|
@@ -577,7 +576,7 @@ class TestJumpstartBase < Test::Unit::TestCase
|
|
577
576
|
should "set the default template if a number corresponding to an existing template is entered." do
|
578
577
|
@test_project.instance_variable_set(:@input, StringIO.new("1\n"))
|
579
578
|
@test_project.expects(:jumpstart_menu).once
|
580
|
-
|
579
|
+
JumpStart::Setup.expects(:dump_global_yaml).once
|
581
580
|
@test_project.instance_eval {set_default_template_options}
|
582
581
|
assert_equal "template1", JumpStart.default_template_name
|
583
582
|
end
|
@@ -658,7 +657,7 @@ class TestJumpstartBase < Test::Unit::TestCase
|
|
658
657
|
context "Tests for the JumpStart::Base#set_templates_dir instance method." do
|
659
658
|
|
660
659
|
setup do
|
661
|
-
|
660
|
+
JumpStart::Setup.stubs(:dump_global_yaml)
|
662
661
|
@test_project.stubs(:jumpstart_menu)
|
663
662
|
end
|
664
663
|
|
@@ -670,7 +669,7 @@ class TestJumpstartBase < Test::Unit::TestCase
|
|
670
669
|
|
671
670
|
should "create a new directory and copy existing templates into it, then set JumpStart.templates_path to the new location." do
|
672
671
|
@test_project.instance_variable_set(:@input, StringIO.new("#{JumpStart::ROOT_PATH}/test/destination_dir/a_name_that_does_not_exist"))
|
673
|
-
|
672
|
+
JumpStart::Setup.expects(:dump_global_yaml).once
|
674
673
|
@test_project.expects(:jumpstart_menu).once
|
675
674
|
@test_project.instance_eval {set_templates_dir}
|
676
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
|
@@ -705,7 +704,7 @@ class TestJumpstartBase < Test::Unit::TestCase
|
|
705
704
|
context "Tests for the JumpStart::Base#reset_templates_dir_to_default_set instance method." do
|
706
705
|
|
707
706
|
setup do
|
708
|
-
|
707
|
+
JumpStart::Setup.stubs(:dump_global_yaml)
|
709
708
|
@test_project.stubs(:templates_dir_menu)
|
710
709
|
FileUtils.mkdir("#{JumpStart::ROOT_PATH}/test/destination_dir/jumpstart_templates")
|
711
710
|
@normal_root_path = JumpStart::ROOT_PATH.dup
|
@@ -1034,18 +1033,7 @@ class TestJumpstartBase < Test::Unit::TestCase
|
|
1034
1033
|
end
|
1035
1034
|
|
1036
1035
|
end
|
1037
|
-
|
1038
|
-
context "Tests for the JumpStart::Base#dump_global_yaml instance method." do
|
1039
|
-
|
1040
|
-
should "call File.open and Yaml.dump for jumpstart_setup.yml" do
|
1041
|
-
YAML.stubs(:dump)
|
1042
|
-
File.stubs(:open)
|
1043
|
-
File.expects(:open).once
|
1044
|
-
@test_project.instance_eval {dump_global_yaml}
|
1045
|
-
end
|
1046
|
-
|
1047
|
-
end
|
1048
|
-
|
1036
|
+
|
1049
1037
|
context "Tests for the JumpStart::Base#exit_with_success instance method." do
|
1050
1038
|
# As these methods are very simple exit (end script) methods, and are already patched for testing, seems pointless to write tests for them.
|
1051
1039
|
end
|
@@ -1097,7 +1085,16 @@ class TestJumpstartBase < Test::Unit::TestCase
|
|
1097
1085
|
assert JumpStart::Base.remove_last_line?("_l._file.txt")
|
1098
1086
|
end
|
1099
1087
|
|
1100
|
-
end
|
1088
|
+
end
|
1089
|
+
|
1090
|
+
context "Tests for the JumpStart::Setup#dump_global_yaml class method." do
|
1091
|
+
should "call File.open and Yaml.dump for jumpstart_setup.yml" do
|
1092
|
+
YAML.stubs(:dump)
|
1093
|
+
File.stubs(:open)
|
1094
|
+
File.expects(:open).once
|
1095
|
+
JumpStart::Setup.dump_global_yaml
|
1096
|
+
end
|
1097
|
+
end
|
1101
1098
|
|
1102
1099
|
context "Tests for initializing and running JumpStart instances\n" do
|
1103
1100
|
|
metadata
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jumpstart
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash: 29
|
5
4
|
prerelease: false
|
6
5
|
segments:
|
7
6
|
- 0
|
8
7
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
8
|
+
- 4
|
9
|
+
version: 0.1.4
|
11
10
|
platform: ruby
|
12
11
|
authors:
|
13
12
|
- i0n
|
@@ -26,7 +25,6 @@ dependencies:
|
|
26
25
|
requirements:
|
27
26
|
- - ">="
|
28
27
|
- !ruby/object:Gem::Version
|
29
|
-
hash: 3
|
30
28
|
segments:
|
31
29
|
- 0
|
32
30
|
version: "0"
|
@@ -68,7 +66,6 @@ files:
|
|
68
66
|
- lib/jumpstart/filetools.rb
|
69
67
|
- lib/jumpstart/stringtools.rb
|
70
68
|
- source_templates/template_config.yml
|
71
|
-
- test/destination_dir/.gitignore
|
72
69
|
- test/fake_nginx_path/local_nginx_1.conf
|
73
70
|
- test/fake_nginx_path/remote_nginx_1.conf
|
74
71
|
- test/helper.rb
|
@@ -152,7 +149,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
152
149
|
requirements:
|
153
150
|
- - ">="
|
154
151
|
- !ruby/object:Gem::Version
|
155
|
-
hash: 3
|
156
152
|
segments:
|
157
153
|
- 0
|
158
154
|
version: "0"
|
@@ -161,7 +157,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
161
157
|
requirements:
|
162
158
|
- - ">="
|
163
159
|
- !ruby/object:Gem::Version
|
164
|
-
hash: 3
|
165
160
|
segments:
|
166
161
|
- 0
|
167
162
|
version: "0"
|