jumpstart 0.1.17 → 0.1.19

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2009 Ian Alexander Wood (i0n)
1
+ Copyright (c) 2010 Ian Alexander Wood (i0n)
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.rdoc ADDED
@@ -0,0 +1,161 @@
1
+ =JumpStart
2
+
3
+ Jumpstart is a gem for quickly creating projects.
4
+ It does this by running options from a YAML file that you can create, or you can let the gem do it for you.
5
+ It's dead easy to do.
6
+
7
+ ==Features
8
+ With jumpstart you can:
9
+
10
+ * Run many terminal commands in a specific order
11
+ * Create new projects of any type quickly from templates
12
+ * Create files from three different kinds of templates:
13
+ * Whole templates. A like for like copy from the template to the new project.
14
+ * Append templates. The template is appended to a file generated by a terminal command (e.g. rails)
15
+ * Line templates. The template is inserted into a file generated by a terminal command at a specific line number.
16
+ * Replace strings in the newly generated project with specified tags (like the project name)
17
+ * Automatically configure local Nginx and hosts entries for a new project. (I'm using OS X so this is tailored for the Mac.)
18
+ * Remove unwanted files that may have been created by a terminal command (e.g. rails)
19
+
20
+ == Installation
21
+ gem install jumpstart
22
+
23
+ Or you can clone this git repo:
24
+ git://github.com/i0n/jumpstart.git
25
+ Build jumpstart from the git repo's gemspec:
26
+ gem build jumpstart.gemspec
27
+ Install the newly created gem:
28
+ gem install jumpstart-WHATEVER_THE_CURRENT_VERSION_IS.gem
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.
31
+
32
+ == Getting Started
33
+ There are a couple of ways to use jumpstart.
34
+
35
+ If you have already created a template and set it as your default, you can create a new project with a single command from the terminal. e.g.
36
+ jumpstart my_new_project_name
37
+
38
+ If you haven't created any templates yet, or you want to change one of the configuration options (which I'll get to), just call:
39
+ jumpstart
40
+ This will launch the jumpstart menu.
41
+
42
+ ==Example YAML files.
43
+ 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!
44
+ ---
45
+ :install_path: /Users/i0n/Sites
46
+ :install_command: rails
47
+ :install_command_args: -d mysql -J -T
48
+ :run_after_install_command:
49
+ - rails g controller home
50
+ :remove_files:
51
+ - /app/views/layouts/application.html.erb
52
+ - /public/index.html
53
+ - /public/favicon.ico
54
+ - /public/images/rails.png
55
+ :run_after_jumpstart:
56
+ - rake db:create
57
+ - capify .
58
+ - git init
59
+ - git add .
60
+ - git commit -q -v -a -m "Initial commit"
61
+ :replace_strings:
62
+ - :target_path: /config/deploy.rb
63
+ :symbols:
64
+ :project_name: name_of_my_app
65
+ :remote_server: thoughtplant
66
+ - :target_path: /config/environments/development.rb
67
+ :symbols:
68
+ :project_name: name_of_my_app
69
+ - :target_path: /config/environments/test.rb
70
+ :symbols:
71
+ :project_name: name_of_my_app
72
+ - :target_path: /config/environments/production.rb
73
+ :symbols:
74
+ :project_name: name_of_my_app
75
+ :local_nginx_conf: /usr/local/nginx/conf/nginx.conf
76
+
77
+ Example 2: A blank YAML with commenting to make it easy to see your options when creating templates.
78
+ ---
79
+ # The commands in a jumpstart config file are executed in the order displayed in this file.
80
+
81
+ # The path to where the project directory will be created
82
+ # e.g. :install_path: /Users/i0n/Sites
83
+ :install_path:
84
+
85
+ ## Can be omitted or left blank.
86
+ # The command that this template will run. The main shell command to create the project.
87
+ # e.g. :install_command: rails
88
+ :install_command:
89
+
90
+ ## Can be omitted or left blank.
91
+ # The arguments for :install_command. Broken into it's own value to allow the project name to be inserted between the two values.
92
+ # e.g. :install_command_args: -d mysql -J -T
93
+ :install_command_args:
94
+
95
+ ## Can be omitted or left blank.
96
+ # Add extra commands that you want to run after the main install command, but before template generation has started.
97
+ # e.g.
98
+ # :run_after_install_command:
99
+ # - rails g controller home
100
+ # - rails g model home
101
+ :run_after_install_command:
102
+
103
+ ## Can be omitted or left blank.
104
+ # List files that you would like removed from the newly generated project.
105
+ # Paths use the newly created project folder as root.
106
+ # e.g.
107
+ # :remove_files:
108
+ # - /public/index.html
109
+ # - /public/favicon.ico
110
+ # - /public/images/rails.png
111
+ :remove_files:
112
+
113
+ ## Can be omitted or left blank.
114
+ # Add extra commands that you want to run after template generation has completed.
115
+ # e.g.
116
+ # :run_after_jumpstart:
117
+ # - rake db:create
118
+ # - capify!
119
+ # - git init
120
+ # - git add .
121
+ # - git commit -q -v -a -m "Initial commit"
122
+ :run_after_jumpstart:
123
+
124
+ ## Can be omitted or left blank.
125
+ # 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.
126
+ # Paths use the newly created project folder as root.
127
+ # 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.
128
+ # 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.
129
+ # e.g.
130
+ # :replace_strings:
131
+ # - :target_path: /config/deploy.rb
132
+ # :symbols:
133
+ # :project_name: name_of_my_app
134
+ # :remote_server: thoughtplant
135
+ # - :target_path: /another/config/file.rb
136
+ # :symbols:
137
+ # :project_name: name_of_my_app
138
+ # :womble: uncle_bulgaria
139
+ :replace_strings:
140
+ - :target_path:
141
+ :symbols:
142
+
143
+ ## Can be omitted or left blank.
144
+ # If you would like jumpstart to configure your local nginx setup specify a path. Handy for rails.
145
+ # e.g.
146
+ # :local_nginx_conf: /usr/local/nginx/conf/nginx.conf
147
+ :local_nginx_conf:
148
+
149
+ ==Note on Patches/Pull Requests
150
+
151
+ * Fork the project.
152
+ * Make your feature addition or bug fix.
153
+ * Add tests for it. This is important so I don't break it in a
154
+ future version unintentionally.
155
+ * Commit, do not mess with rakefile, version, or history.
156
+ (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
157
+ * Send me a pull request. Bonus points for topic branches.
158
+
159
+ Copyright
160
+
161
+ Copyright (c) 2010 i0n. See LICENSE for details.
@@ -1,3 +1,3 @@
1
1
  ---
2
2
  :jumpstart_templates_path:
3
- :jumpstart_default_template_name:
3
+ :jumpstart_default_template_name:
@@ -1,4 +1,4 @@
1
1
  ---
2
- :jumpstart_version_patch: 17
3
2
  :jumpstart_version_major: 0
4
3
  :jumpstart_version_minor: 1
4
+ :jumpstart_version_patch: 19
@@ -21,11 +21,14 @@ module JumpStart
21
21
  # setup for testing output
22
22
  @output = $stdout
23
23
  # set the name of the project from the first argument passed, or from the module instance variable JumpStart::Setup.default_template_name if no argument passed.
24
- @project_name = args.shift.dup if args[0] != nil
25
- if args[0] != nil
26
- @template_name = args.shift.dup
27
- elsif JumpStart::Setup.default_template_name != nil
28
- @template_name = JumpStart::Setup.default_template_name
24
+ @project_name = args[0].dup unless args[0].nil?
25
+ @template_name = args[1].dup unless args[1].nil?
26
+ case
27
+ when args.nil?
28
+ @template_name = JumpStart::Setup.default_template_name unless JumpStart::Setup.default_template_name.nil?
29
+ jumpstart_menu
30
+ when args[0] != nil && args[1].nil?
31
+ @template_name = JumpStart::Setup.default_template_name unless JumpStart::Setup.default_template_name.nil?
29
32
  end
30
33
  # set instance variable @template_path as the directory to read templates from.
31
34
  @template_path = FileUtils.join_paths(JumpStart::Setup.templates_path, @template_name)
@@ -141,7 +144,6 @@ module JumpStart
141
144
  end
142
145
  end
143
146
 
144
- # TODO FileUtils.pwd is not behaving as expected. find a way to set this.
145
147
  # 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.
146
148
  # Checks the install path set in @install_path.
147
149
  # Checks that a directory with the same name as the project does not already exist in the install path.
@@ -151,7 +153,7 @@ module JumpStart
151
153
  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."
152
154
  exit_normal
153
155
  end
154
- true
156
+ return true
155
157
  end
156
158
 
157
159
  # Creates a new blank template in whichever directory the default templates directory has been set to.
@@ -482,7 +484,6 @@ module JumpStart
482
484
  end
483
485
  end
484
486
 
485
- # TODO needs more tests as nil values were slipping through
486
487
  # Removes files specified in templates YAML
487
488
  def remove_unwanted_files
488
489
  file_array = []
@@ -509,17 +510,16 @@ module JumpStart
509
510
  end
510
511
  end
511
512
  end
512
-
513
- # TODO Needs more tests as nil values slipped through before refactoring.
513
+
514
514
  # Looks for strings IN_CAPS that are specified for replacement in the templates YAML
515
515
  def check_for_strings_to_replace
516
516
  if @replace_strings.nil? || @replace_strings.empty?
517
- false
517
+ return false
518
518
  else
519
519
  puts "\nChecking for strings to replace inside files...\n\n"
520
520
  @replace_strings.each do |file|
521
521
  if file[:target_path].nil? || file[:symbols].nil?
522
- false
522
+ return false
523
523
  else
524
524
  puts "Target file: #{file[:target_path].green}\n"
525
525
  puts "Strings to replace:\n\n"
@@ -562,7 +562,7 @@ module JumpStart
562
562
  number = file_name.match(/_(\d+)\._\w*/)[1]
563
563
  number.to_i
564
564
  else
565
- false
565
+ return false
566
566
  end
567
567
  end
568
568
 
@@ -570,9 +570,9 @@ module JumpStart
570
570
  # Append templates with the _l._ or _L._ prefix will return true.
571
571
  def remove_last_line?(file_name)
572
572
  if file_name.match(/_([lL]{1})\._{1}\w*/)
573
- true
573
+ return true
574
574
  else
575
- false
575
+ return false
576
576
  end
577
577
  end
578
578
 
@@ -93,11 +93,11 @@ class TestJumpstartBase < Test::Unit::TestCase
93
93
  @input = input
94
94
  @output = output
95
95
  @template_name = "test_template_1"
96
- set_config_file_options
97
96
  @install_path = "#{JumpStart::ROOT_PATH}/test/destination_dir"
98
97
  end
99
98
  @test_project_6.stubs(:exit_normal)
100
99
  @test_project_6.stubs(:exit_with_success)
100
+ @test_project_6.stubs(:jumpstart_menu)
101
101
  end
102
102
 
103
103
  teardown do
@@ -107,7 +107,7 @@ class TestJumpstartBase < Test::Unit::TestCase
107
107
  context "Tests for the JumpStart::Base#intialize instance method. \n" do
108
108
 
109
109
  should "set @jumpstart_template_path" do
110
- assert_equal "#{JumpStart::ROOT_PATH}/test/test_jumpstart_templates", @test_project.instance_eval {JumpStart::Setup.templates_path}
110
+ assert_equal "#{JumpStart::ROOT_PATH}/test/test_jumpstart_templates", JumpStart::Setup.templates_path
111
111
  end
112
112
 
113
113
  should "set JumpStart::Setup.default_template_name" do
@@ -965,13 +965,17 @@ class TestJumpstartBase < Test::Unit::TestCase
965
965
  end
966
966
 
967
967
  should "run remove_unwanted_files method, remove files and return true." do
968
-
969
968
  ["/file_with_extension.txt", "/file_without_extension"].each do |x|
970
969
  FileUtils.touch("#{JumpStart::ROOT_PATH}/test/destination_dir/test_remove/test_remove_files#{x}")
971
970
  end
972
971
  assert @test_project.instance_eval {remove_unwanted_files}
973
972
  end
974
-
973
+
974
+ should "do nothing if passed nil" do
975
+ @test_project.instance_eval {@config_files = {:remove_files => nil}}
976
+ assert @test_project.instance_eval {remove_unwanted_files}
977
+ end
978
+
975
979
  end
976
980
 
977
981
  context "Tests for the JumpStart::Base#run_scripts_from_yaml instance method.\n" do
@@ -1032,6 +1036,11 @@ class TestJumpstartBase < Test::Unit::TestCase
1032
1036
  assert !@test_project.instance_eval {check_for_strings_to_replace}
1033
1037
  end
1034
1038
 
1039
+ should "return false if @replace_strings is populated with an empty entry." do
1040
+ @test_project.instance_eval {@replace_strings = [{:target_path => nil, :symbols => nil}]}
1041
+ assert !@test_project.instance_eval {check_for_strings_to_replace}
1042
+ end
1043
+
1035
1044
  end
1036
1045
 
1037
1046
  context "Tests for the JumpStart::Base#exit_with_success instance method." do
@@ -1145,6 +1154,6 @@ class TestJumpstartBase < Test::Unit::TestCase
1145
1154
  end
1146
1155
 
1147
1156
  end
1148
-
1157
+
1149
1158
  end
1150
1159
  end
@@ -19,6 +19,7 @@ class TestJumpstart < Test::Unit::TestCase
19
19
  end
20
20
  end
21
21
 
22
+ # TODO not sure why but shoulda/test-unit/mocha is loading things in a strange order which is messing up class_eval. Look to split tests for this area into seperate files to try and solve this problem.
22
23
  context "Tests for launching JumpStart with various configurations set" do
23
24
 
24
25
  context "JumpStart::Setup.templates_path and JumpStart::Setup.default_template_name are both set to nil as @jumpstart_setup_yaml is not loaded" do
@@ -119,7 +120,6 @@ class TestJumpstart < Test::Unit::TestCase
119
120
 
120
121
  should "set @install_path to executing directory when it is not set in the template and when passed a valid first and second argument. JumpStart::Setup.templates_path should be set to default." do
121
122
  @project = JumpStart::Base.new(["hello", "test_template_1"])
122
- # FileUtils.stubs(:pwd)
123
123
  @project.stubs(:jumpstart_menu)
124
124
  @project.expects(:set_config_file_options)
125
125
  @project.expects(:lookup_existing_templates)
@@ -128,13 +128,10 @@ class TestJumpstart < Test::Unit::TestCase
128
128
  @project.expects(:check_template_path)
129
129
  @project.expects(:check_install_path)
130
130
  @project.expects(:jumpstart_menu).never
131
- # FileUtils.expects(:pwd)
132
131
  @project.check_setup
133
- # assert_equal "hello", @project.instance_variable_get(:@install_path)
134
132
  end
135
133
 
136
134
  end
137
-
135
+
138
136
  end
139
-
140
137
  end
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: 57
5
4
  prerelease: false
6
5
  segments:
7
6
  - 0
8
7
  - 1
9
- - 17
10
- version: 0.1.17
8
+ - 19
9
+ version: 0.1.19
11
10
  platform: ruby
12
11
  authors:
13
12
  - Ian Alexander Wood (i0n)
@@ -19,33 +18,31 @@ date: 2010-05-29 00:00:00 +01:00
19
18
  default_executable:
20
19
  dependencies:
21
20
  - !ruby/object:Gem::Dependency
22
- version_requirements: &id001 !ruby/object:Gem::Requirement
21
+ name: shoulda
22
+ requirement: &id001 !ruby/object:Gem::Requirement
23
23
  none: false
24
24
  requirements:
25
25
  - - ">="
26
26
  - !ruby/object:Gem::Version
27
- hash: 3
28
27
  segments:
29
28
  - 0
30
29
  version: "0"
31
- requirement: *id001
32
- name: shoulda
33
- prerelease: false
34
30
  type: :development
31
+ prerelease: false
32
+ version_requirements: *id001
35
33
  - !ruby/object:Gem::Dependency
36
- version_requirements: &id002 !ruby/object:Gem::Requirement
34
+ name: mocha
35
+ requirement: &id002 !ruby/object:Gem::Requirement
37
36
  none: false
38
37
  requirements:
39
38
  - - ">="
40
39
  - !ruby/object:Gem::Version
41
- hash: 3
42
40
  segments:
43
41
  - 0
44
42
  version: "0"
45
- requirement: *id002
46
- name: mocha
47
- prerelease: false
48
43
  type: :development
44
+ prerelease: false
45
+ version_requirements: *id002
49
46
  description: |-
50
47
  JumpStart is a script runner and template parser written in Ruby with Ruby projects in mind.
51
48
  That said it should function equally well for any project in any language where many actions need to be performed to setup a new project.
@@ -140,7 +137,7 @@ files:
140
137
  - test/test_jumpstart_templates/test_template_3/jumpstart_config/test_template_3.yml
141
138
  - LICENSE
142
139
  - Rakefile
143
- - README.md
140
+ - README.rdoc
144
141
  has_rdoc: true
145
142
  homepage: http://github.com/i0n/jumpstart
146
143
  licenses: []
@@ -155,7 +152,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
155
152
  requirements:
156
153
  - - ">="
157
154
  - !ruby/object:Gem::Version
158
- hash: 3
159
155
  segments:
160
156
  - 0
161
157
  version: "0"
@@ -164,7 +160,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
164
160
  requirements:
165
161
  - - ">="
166
162
  - !ruby/object:Gem::Version
167
- hash: 23
168
163
  segments:
169
164
  - 1
170
165
  - 3
data/README.md DELETED
@@ -1,47 +0,0 @@
1
- #JumpStart
2
-
3
- Jumpstart is a gem for quickly creating projects.
4
- It does this by running options from a YAML file that you can create, or you can let the gem do it for you.
5
- It's dead easy to do.
6
-
7
- ## Features
8
- With jumpstart you can:
9
-
10
- * Run many terminal commands in a specific order
11
- * Create new projects of any type quickly from templates
12
- * Create files from three different kinds of templates:
13
- * **Whole templates**. A like for like copy from the template to the new project.
14
- * **Append templates**. The template is appended to a file generated by a terminal command (e.g. rails)
15
- * **Line templates**. The template is inserted into a file generated by a terminal command at a specific line number.
16
- * Replace strings in the newly generated project with specified tags (like the project name)
17
- * Automatically configure local Nginx and hosts entries for a new project. (I'm using OS X so this is tailored for the Mac.)
18
- * Remove unwanted files that may have been created by a terminal command (e.g. rails)
19
-
20
- # Installation
21
- `gem install jumpstart` should do it.
22
- - - - - -
23
- Or you can clone this git repo: `git://github.com/i0n/jumpstart.git`
24
- Build jumpstart from the git repo's gemspec: `gem build jumpstart.gemspec`
25
- Install the newly created gem: `gem install jumpstart-WHATEVER_THE_CURRENT_VERSION_IS.gem`
26
-
27
- ## Getting Started
28
- There are a couple of ways to use jumpstart.
29
-
30
- If you have already created a template, you can create a new project with a single command from the terminal.
31
- e.g. **`jumpstart my_new_project_name`**
32
-
33
- If you haven't created any templates yet, or you want to change one of the configuration options (which I'll get to), just call **`jumpstart`** without any arguments. This will launch the jumpstart menu.
34
-
35
- ###Note on Patches/Pull Requests
36
-
37
- * Fork the project.
38
- * Make your feature addition or bug fix.
39
- * Add tests for it. This is important so I don't break it in a
40
- future version unintentionally.
41
- * Commit, do not mess with rakefile, version, or history.
42
- (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
43
- * Send me a pull request. Bonus points for topic branches.
44
-
45
- **Copyright**
46
-
47
- Copyright (c) 2010 i0n. See LICENSE for details.