meskyanichi-simple_generators 0.1.2 → 0.1.3

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 Michael van Rooijen
1
+ Copyright (c) 2009 Michael van Rooijen
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
@@ -17,4 +17,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
17
  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
18
  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
19
  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.2
1
+ 0.1.3
@@ -1,12 +1,10 @@
1
- Simple Capistrano Recipe
1
+ This generator will generate a simple capistrano template. You can supply some arguments to let the generate fill in the deployment recipe for you as well. This generator is currently made specifically for Ruby on Rails with Phusion Passenger and Git Repository. Of course, you can still generate the deployment recipe and alter the sections within it to get it to deploy to your liking!
2
2
 
3
+ ==== To generate a dry Capistrano Deployment Recipe, run the following command:
4
+ script/generate simple_capistrano_recipe
3
5
 
4
- To generate the default template which you will afterwards manually modify:
6
+ ==== You can also provide arguments to generate an already filled in recipe:
7
+ script/generate simple_capistrano_recipe domain:example.com user:root deploy_path:/var/rails/example.com
8
+ repository_type:git repository_url:ssh://root@example.com/var/git/example.git
5
9
 
6
- script/generate simple_capistrano_recipe
7
-
8
-
9
-
10
- To generate a template dynamically with arguments:
11
-
12
- script/generate simple_capistrano_recipe domain:example.com user:root deploy_path:/var/rails/example.com repository_type:git repository_url:ssh://root@example.com/var/git/example.git
10
+ After generating the deployment recipe (RAILS_ROOT/config/deploy.rb), you might want to double check if everything is set up correctly before you actually try to deploy.
@@ -6,15 +6,15 @@ class SimpleCapistranoRecipeGenerator < Rails::Generator::Base
6
6
  super
7
7
  extract_args
8
8
  set_defaults
9
- system "capify #{RAILS_ROOT}"
10
- File.delete("#{RAILS_ROOT}/config/deploy.rb")
11
9
  end
12
10
 
13
11
  # Processes the file generation/templating
14
12
  # This will automatically be run after the initialize method
15
13
  def manifest
14
+ system "capify #{RAILS_ROOT}" unless File.exist? "#{RAILS_ROOT}/Capfile"
16
15
  record do |m|
17
- m.template "capistrano_recipe.rb", "config/deploy.rb"
16
+ m.directory "config"
17
+ m.template "capistrano_recipe.rb", "config/deploy.rb"
18
18
  end
19
19
  end
20
20
 
@@ -0,0 +1,3 @@
1
+ This is a very small generator that just generates a .gitignore file in the RAILS_ROOT with a couple of predefined ingore lines.
2
+ ==== No arguments can be supplied here:
3
+ script/generate simple_git_template
@@ -10,7 +10,7 @@ class SimpleGitTemplateGenerator < Rails::Generator::Base
10
10
  # This will automatically be run after the initialize method
11
11
  def manifest
12
12
  record do |m|
13
- m.file "git_ignore.tpl", ".gitignore"
13
+ m.file "git_ignore", ".gitignore"
14
14
  end
15
15
  end
16
16
 
@@ -0,0 +1,6 @@
1
+ Now, I always tend to forget all the settings I usually need for my Paperclip model, hence why I created the gem and added this generators as well.
2
+
3
+ ==== To generate a Paperclip Model you are required to supply 2 of the 3 arguments:
4
+ script/generate simple_paperclip_model model:user attachment:avatar [optional: type:image]
5
+
6
+ The optional type:image argument will generate example "styles" for Paperclip.
@@ -13,7 +13,8 @@ class SimplePaperclipModelGenerator < Rails::Generator::Base
13
13
  # This will automatically be run after the initialize method
14
14
  def manifest
15
15
  record do |m|
16
- m.template "paperclip.rb", "app/models/#{@input[:model]}.rb"
16
+ m.directory "app/models"
17
+ m.template "paperclip.rb", "app/models/#{@input[:model]}.rb"
17
18
  end
18
19
  end
19
20
 
@@ -39,17 +40,26 @@ class SimplePaperclipModelGenerator < Rails::Generator::Base
39
40
  def set_defaults
40
41
  @input[:type] ||= "image"
41
42
  end
42
-
43
-
43
+
44
+ # Confirms whether the model and attachment arguments were passed in
45
+ # Raises an error if not
44
46
  def confirm_input
45
47
  if @input[:model].nil? or @input[:attachment].nil?
46
- raise "
47
- A model and attachment must be specified!
48
-
49
- Example:
50
- script/generate simple_paperclip_model model:user attachment:avatar
51
- "
48
+ raise input_error
52
49
  end
53
50
  end
54
51
 
52
+ private
53
+
54
+ def input_error
55
+ <<-eos
56
+
57
+ A model and attachment must be specified!
58
+
59
+ Example:
60
+ script/generate simple_paperclip_model model:user attachment:avatar
61
+
62
+ eos
63
+ end
64
+
55
65
  end
@@ -0,0 +1,25 @@
1
+ === Simple Repository Tasks
2
+
3
+ This generator will generate 3 rake tasks that can help with creating and destroying your applications remote repository using SSH on your own server.
4
+
5
+ ==== To generates these Repository Rake Tasks, run the following command:
6
+ script/generate simple_repository_tasks
7
+
8
+ If you do it this way, you will manually have to open the rake tasks, located in the lib/tasks/simple_tasks/repository.rake file, and add your server settings in there.
9
+
10
+ ==== If you wish to, like I do, let the generator insert these settings in for you, execute the following command:
11
+ script/generate simple_repository_tasks domain:example.com path:/var/git/example.git
12
+ user:root password:mys3cr3tp4ssw0rd
13
+
14
+ ==== Now, when you run the following command:
15
+ rake -T
16
+
17
+ You will see a list of all your available rake tasks, including the Repository Rake Tasks and their description.
18
+
19
+ These rake tasks allow your to quickly, without manually SSH'ing to your server, create and destroy your git repository for a specific Ruby on Rails application. Additionally, if you haven't already, you can run a simple command (rake simple_tasks:repository:add_to_git) to add your remote repository location (origin) to your local repository.
20
+
21
+ ==== These are the commands that are currently available for the Simple Repository Tasks:
22
+
23
+ rake simple_tasks:repository:add_to_git
24
+ rake simple_tasks:repository:create
25
+ rake simple_tasks:repository:destroy
@@ -6,21 +6,14 @@ class SimpleRepositoryTasksGenerator < Rails::Generator::Base
6
6
  super
7
7
  extract_args
8
8
  set_defaults
9
-
10
- unless File.directory?(simple_tasks_path)
11
- Dir.mkdir(simple_tasks_path)
12
- end
13
-
14
- if File.exist?(simple_repository_path)
15
- File.delete(simple_repository_path)
16
- end
17
9
  end
18
10
 
19
11
  # Processes the file generation/templating
20
12
  # This will automatically be run after the initialize method
21
13
  def manifest
22
14
  record do |m|
23
- m.template "repository.rake", "lib/tasks/simple_tasks/repository.rake"
15
+ m.directory "lib/tasks/simple_tasks"
16
+ m.template "repository.rake", "lib/tasks/simple_tasks/repository.rake"
24
17
  end
25
18
  end
26
19
 
@@ -50,17 +43,4 @@ class SimpleRepositoryTasksGenerator < Rails::Generator::Base
50
43
  @input
51
44
  end
52
45
 
53
-
54
- private
55
-
56
- # Defines the simple tasks folder path
57
- def simple_tasks_path
58
- "#{RAILS_ROOT}/lib/tasks/simple_tasks"
59
- end
60
-
61
- # Defines the repository rake file path
62
- def simple_repository_path
63
- "#{RAILS_ROOT}/lib/tasks/simple_tasks/repository.rake"
64
- end
65
-
66
- end
46
+ end
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{simple_generators}
8
- s.version = "0.1.2"
8
+ s.version = "0.1.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Michael van Rooijen"]
@@ -33,8 +33,8 @@ Gem::Specification.new do |s|
33
33
  "generators/simple_git_template/USAGE",
34
34
  "generators/simple_git_template/simple_git_template_generator.rb",
35
35
  "generators/simple_git_template/simple_git_template_generator.rb",
36
- "generators/simple_git_template/templates/git_ignore.tpl",
37
- "generators/simple_git_template/templates/git_ignore.tpl",
36
+ "generators/simple_git_template/templates/git_ignore",
37
+ "generators/simple_git_template/templates/git_ignore",
38
38
  "generators/simple_paperclip_model/USAGE",
39
39
  "generators/simple_paperclip_model/USAGE",
40
40
  "generators/simple_paperclip_model/simple_paperclip_model_generator.rb",
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: meskyanichi-simple_generators
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael van Rooijen
@@ -34,7 +34,7 @@ files:
34
34
  - generators/simple_capistrano_recipe/templates/capistrano_recipe.rb
35
35
  - generators/simple_git_template/USAGE
36
36
  - generators/simple_git_template/simple_git_template_generator.rb
37
- - generators/simple_git_template/templates/git_ignore.tpl
37
+ - generators/simple_git_template/templates/git_ignore
38
38
  - generators/simple_paperclip_model/USAGE
39
39
  - generators/simple_paperclip_model/simple_paperclip_model_generator.rb
40
40
  - generators/simple_paperclip_model/templates/paperclip.rb