kitty_gen 0.0.16 → 0.0.17
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -0
- data/README.textile +9 -6
- data/lib/kitty_gen.rb +5 -3
- data/lib/kitty_gen/cli.rb +41 -14
- data/lib/kitty_gen/cook.rb +21 -0
- data/lib/kitty_gen/{cooking_helpers.rb → helpers.rb} +47 -18
- data/lib/kitty_gen/kittens/kitty_1 +0 -0
- data/lib/kitty_gen/master_template.rb +0 -5
- data/lib/kitty_gen/recipes/formtastic_recipe.rb +0 -1
- data/lib/kitty_gen/recipes/login_with_facebook_and_twitter_recipe.rb +17 -10
- data/lib/kitty_gen/templates/kittygenrc/kittygenrc +2 -0
- data/lib/kitty_gen/version.rb +1 -1
- metadata +14 -11
data/Gemfile
CHANGED
data/README.textile
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
h1. KittyGen: Rails 3.1 Application Template Management System
|
2
2
|
|
3
|
-
Shave hours off your next project and amaze your client and friends. This productivity crazed "rails developer in london":http://www.jackkinsella.ie/rails-developer-london has put all his favourite configurations and gems into this Rails 3.1 app generator. How would you like:
|
3
|
+
Shave hours off your next project and amaze your client and friends. This productivity crazed "rails developer in london":http://www.jackkinsella.ie/rails-developer-london.html has put all his favourite configurations and gems into this Rails 3.1 app generator. How would you like:
|
4
4
|
|
5
5
|
# To have a unique RVM gemset setup automatically with an rvmrc file already trusted
|
6
6
|
# Have watchr running your unit and integrations tests on save, notifying you on Growl, working out of the box
|
@@ -13,22 +13,25 @@ Shave hours off your next project and amaze your client and friends. This produc
|
|
13
13
|
# All those annoying files you never use removed
|
14
14
|
|
15
15
|
Unlike other application templates this one is *packaged in a gem* meaning you can call it from the command line as simply as this:
|
16
|
-
@$
|
16
|
+
@$ kitty_gen new MY_NEW_APP_NAME@
|
17
17
|
|
18
18
|
Not only that, but kitty_gen lets you *upgrade existing applications with its modules*. Want to setup "livereload"? Easy
|
19
19
|
|
20
|
-
@$
|
20
|
+
@$ kitty_gen add livereload@
|
21
21
|
|
22
|
-
|
22
|
+
And to see a list of all available recipes:
|
23
|
+
|
24
|
+
@$ kitty_gen list@
|
23
25
|
|
24
26
|
h2. Design Decisions
|
25
27
|
|
26
28
|
# This is Mac only and will remain Mac only. Sorry.
|
27
29
|
# Each recipe is self-contained and so should include all the gems, bundling and generation it needs to do its thing. Yes the generator is slower this way, but the advantage is modularity.
|
28
30
|
# Gems are installed inline instead of in one big file.
|
29
|
-
# Rspec and Cucumber are not included by default
|
30
|
-
# A commit is made after every step.
|
31
|
+
# Rspec and Cucumber are not included by default since the new best practice is to stay with Test::Unit. DHH was right all along.
|
32
|
+
# A commit is made after every step with a descriptive message.
|
31
33
|
# Each recipe is in its own namespace meaning that variables you assign in one recipe do not carry over to others
|
34
|
+
#[not implemented] Your ~/.kitty_gen.rc file will contain the default recipes you use for new apps, alongside configuration information such as your aws, postgres password, paypal details, email address and son.
|
32
35
|
|
33
36
|
h2. Features
|
34
37
|
|
data/lib/kitty_gen.rb
CHANGED
data/lib/kitty_gen/cli.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
module KittyGen
|
2
2
|
class Cli
|
3
|
+
require "kitty_gen/cook"
|
3
4
|
|
4
5
|
def start(command_line_arguments)
|
5
6
|
case ARGV[0]
|
@@ -10,36 +11,54 @@ module KittyGen
|
|
10
11
|
when "add"
|
11
12
|
add(ARGV[1])
|
12
13
|
else
|
13
|
-
|
14
|
-
kitty_gen new APPNAME # create a new app APPNAME using preffered recipes
|
15
|
-
kitty_gen list # lists available recipes
|
16
|
-
kitty_gen add RECIPE # adds a recipe RECIPE
|
17
|
-
}
|
14
|
+
puts help
|
18
15
|
end
|
19
16
|
end
|
20
17
|
|
21
18
|
private
|
22
19
|
|
23
20
|
def new(app_name)
|
24
|
-
exec "rails new #{app_name}
|
21
|
+
exec "rails new #{app_name}"
|
22
|
+
run_generator(master_template)
|
25
23
|
end
|
26
24
|
|
27
25
|
def list
|
28
|
-
recipe_list = File.read(File.join(kitty_gen_dir, "base_recipes")).split("\n").reject {|r| r.match /^\s*#/}.join("\n ")
|
29
26
|
puts <<-MESSAGE
|
27
|
+
|
30
28
|
## Kitty Gen ##
|
31
29
|
## Listing all possible recipes you can add to your application ##
|
32
30
|
|
33
|
-
#{"
|
31
|
+
#{recipes.map.with_index {|recipe, index| " #{index}: #{recipe} "}.join("\n")}
|
32
|
+
|
33
|
+
USAGE: kitty_gen add recipe_name_or_number
|
34
|
+
EXAMPLE: kitty_gen add formtastic
|
35
|
+
kitty_gen add 5
|
36
|
+
MESSAGE
|
37
|
+
end
|
38
|
+
|
39
|
+
def recipes
|
40
|
+
File.read(File.join(kitty_gen_dir, "base_recipes")).split("\n").reject {|r| r.match /^\s*#/}
|
41
|
+
end
|
42
|
+
|
43
|
+
# Examples:
|
44
|
+
# add(formtastic)
|
45
|
+
# add(3)
|
46
|
+
def add(recipe_or_index)
|
47
|
+
if is_a_number?(recipe_or_index)
|
48
|
+
index = recipe_or_index.to_i
|
49
|
+
recipe = recipes[index]
|
50
|
+
else
|
51
|
+
recipe = recipe
|
52
|
+
end
|
53
|
+
run_generator(recipe)
|
54
|
+
end
|
34
55
|
|
35
|
-
|
36
|
-
|
56
|
+
def run_generator(template)
|
57
|
+
Cook.new(template)
|
37
58
|
end
|
38
59
|
|
39
|
-
def
|
40
|
-
|
41
|
-
puts recipe_location
|
42
|
-
exec "rake rails:template LOCATION=#{recipe_location}"
|
60
|
+
def is_a_number?(parameter)
|
61
|
+
parameter.match(/\A[+-]?\d+?(\.\d+)?\Z/) == nil ? false : true
|
43
62
|
end
|
44
63
|
|
45
64
|
def master_template
|
@@ -50,5 +69,13 @@ MESSAGE
|
|
50
69
|
File.dirname(__FILE__)
|
51
70
|
end
|
52
71
|
|
72
|
+
def help
|
73
|
+
%Q{Commands available:
|
74
|
+
kitty_gen new APPNAME # create a new app APPNAME using preffered recipes
|
75
|
+
kitty_gen list # lists available recipes
|
76
|
+
kitty_gen add RECIPE # adds a recipe RECIPE
|
77
|
+
}
|
78
|
+
end
|
79
|
+
|
53
80
|
end
|
54
81
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require "rails/generators"
|
2
|
+
require "rails"
|
3
|
+
require 'rails/generators/rails/app/app_generator'
|
4
|
+
require "kitty_gen/helpers"
|
5
|
+
module KittyGen
|
6
|
+
class Cook
|
7
|
+
|
8
|
+
require "rails/generators"
|
9
|
+
require "rails"
|
10
|
+
require 'rails/generators/rails/app/app_generator'
|
11
|
+
require "kitty_gen/helpers"
|
12
|
+
|
13
|
+
def initialize(template)
|
14
|
+
generator = Rails::Generators::AppGenerator.new [Dir.pwd], {}, :destination_root => Dir.pwd
|
15
|
+
generator.extend(::KittyGen::Helpers)
|
16
|
+
generator.recipe template
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
@@ -3,7 +3,7 @@ require "thor"
|
|
3
3
|
require "colored"
|
4
4
|
module KittyGen
|
5
5
|
|
6
|
-
module
|
6
|
+
module Helpers
|
7
7
|
attr_accessor :current_recipe
|
8
8
|
|
9
9
|
def introduce_yourself
|
@@ -16,7 +16,17 @@ module KittyGen
|
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
|
-
|
19
|
+
# Importantly, this runs each recipe
|
20
|
+
# in its own exclusive scope. This means
|
21
|
+
# symbols from one recipe cannot pollute
|
22
|
+
# the namespace
|
23
|
+
def recipe(thing_to_do)
|
24
|
+
thing_to_do = thing_to_do.to_s
|
25
|
+
self.current_recipe = thing_to_do
|
26
|
+
log_recipe_name thing_to_do
|
27
|
+
apply "#{thing_to_do}_recipe.rb"
|
28
|
+
git_commit_with_message
|
29
|
+
end
|
20
30
|
|
21
31
|
def tell_thor_where_your_files_will_go
|
22
32
|
self.destination_root = Dir.pwd
|
@@ -26,13 +36,44 @@ module KittyGen
|
|
26
36
|
self.source_paths << File.expand_path("../recipes/", __FILE__)
|
27
37
|
end
|
28
38
|
|
39
|
+
private
|
40
|
+
|
41
|
+
def self.extended(base)
|
42
|
+
base.tell_thor_where_your_files_will_go
|
43
|
+
base.tell_those_where_you_keep_your_recipes
|
44
|
+
end
|
45
|
+
|
46
|
+
# Return hash of configuration optios locaed at
|
47
|
+
# ~/.kittygenrc
|
48
|
+
def kitty_gen_config
|
49
|
+
create_kittygenrc unless File.exist?(kittygenrc_location)
|
50
|
+
YAML.load(File.open(kittygenrc_location))
|
51
|
+
end
|
52
|
+
|
53
|
+
def create_kittygenrc
|
54
|
+
log_recipe_name("Installing a kittygenrc file in ~. This is where you store configurations global across all applications you generate")
|
55
|
+
thor_within_scope("kittygenrc") do
|
56
|
+
copy_file "kittygenrc", kittygenrc_location
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def thor_within_scope(recipe, &thor_commands)
|
61
|
+
self.source_paths << File.expand_path("../templates/#{recipe}", __FILE__)
|
62
|
+
thor_commands.call
|
63
|
+
self.source_paths.pop
|
64
|
+
end
|
65
|
+
|
66
|
+
def kittygenrc_location
|
67
|
+
"#{Dir.home}/.kittygenrc"
|
68
|
+
end
|
69
|
+
|
29
70
|
#this method places the template folder with the same name as the recipe in scope
|
30
71
|
#before copying the file, the removes it again
|
31
72
|
|
32
73
|
def copy_template(file_name, destination)
|
33
|
-
|
34
|
-
|
35
|
-
|
74
|
+
thor_within_scope(current_recipe) do
|
75
|
+
copy_file file_name, destination
|
76
|
+
end
|
36
77
|
end
|
37
78
|
|
38
79
|
|
@@ -57,19 +98,7 @@ module KittyGen
|
|
57
98
|
|
58
99
|
def git_commit_with_message
|
59
100
|
git :add => '.'
|
60
|
-
git :commit => "-m KittyGen added: #{current_recipe.humanize}"
|
61
|
-
end
|
62
|
-
|
63
|
-
# Importantly, this runs each recipe
|
64
|
-
# in its own exclusive scope. This means
|
65
|
-
# symbols from one recipe cannot pollute
|
66
|
-
# the namespace
|
67
|
-
def recipe(thing_to_do)
|
68
|
-
thing_to_do = thing_to_do.to_s
|
69
|
-
self.current_recipe = thing_to_do
|
70
|
-
log_recipe_name thing_to_do
|
71
|
-
apply "#{thing_to_do}_recipe.rb"
|
72
|
-
# git_commit_with_message
|
101
|
+
git :commit => "-m 'KittyGen added: #{current_recipe.humanize}'"
|
73
102
|
end
|
74
103
|
|
75
104
|
end
|
File without changes
|
@@ -1,11 +1,6 @@
|
|
1
|
-
require "kitty_gen/cooking_helpers"
|
2
|
-
extend ::KittyGen::CookingHelpers
|
3
1
|
#try getting cook to inherit from AppGenerator
|
4
|
-
|
5
2
|
introduce_yourself
|
6
3
|
#hack since thor expends an empty options hash
|
7
4
|
# @options = {}
|
8
5
|
app_name = ARGV.first
|
9
|
-
tell_thor_where_your_files_will_go
|
10
|
-
tell_those_where_you_keep_your_recipes
|
11
6
|
prepare_standard_features
|
@@ -1,16 +1,17 @@
|
|
1
1
|
gem "omniauth"
|
2
|
-
|
3
|
-
copy_template "omniauth_callbacks_controller", "users/omniauth_callbacks_controller"
|
2
|
+
empty_directory "app/controllers/users"
|
3
|
+
copy_template "omniauth_callbacks_controller.rb", "app/controllers/users/omniauth_callbacks_controller.rb"
|
4
4
|
|
5
|
-
inject_into_file "config/
|
5
|
+
inject_into_file "config/initializers/devise.rb", :after => 'Devise.setup do |config|' do %Q{
|
6
6
|
# For debugging start here: https://github.com/plataformatec/devise/wiki/OmniAuth:-Overview
|
7
|
-
config.omniauth :facebook, "
|
8
|
-
|
7
|
+
config.omniauth :facebook, "#{kitty_gen_config[:facebook_app_id]}", "#{kitty_gen_config[:facebook_app_secret]}"
|
8
|
+
}
|
9
|
+
end
|
9
10
|
|
10
|
-
inject_into_file 'app/models/user.rb', :before => 'end' <<-RUBY
|
11
|
+
inject_into_file 'app/models/user.rb', :before => 'end' do <<-RUBY
|
11
12
|
|
12
13
|
devise :omniauthable
|
13
|
-
|
14
|
+
|
14
15
|
# Modify the user model to pass facebook email to devise if available
|
15
16
|
def self.new_with_session(params, session)
|
16
17
|
super.tap do |user|
|
@@ -20,12 +21,18 @@ inject_into_file 'app/models/user.rb', :before => 'end' <<-RUBY
|
|
20
21
|
end
|
21
22
|
end
|
22
23
|
RUBY
|
24
|
+
end
|
23
25
|
|
24
|
-
gsub_file "config/routes.rb", "devise_for :users" <<-RUBY
|
26
|
+
gsub_file "config/routes.rb", "devise_for :users" do <<-RUBY
|
25
27
|
devise_for :users, :controllers => { :omniauth_callbacks => "users/omniauth_callbacks" } do
|
26
28
|
get '/users/auth/:provider' => 'users/omniauth_callbacks#passthru'
|
27
29
|
end
|
28
30
|
RUBY
|
31
|
+
end
|
32
|
+
|
33
|
+
inject_into_file "app/views/layouts/_login.html.slim", :after => "li = link_to 'Login', new_user_session_path" do
|
34
|
+
%Q{
|
35
|
+
li = link_to "Login with Facebook", user_omniauth_authorize_path(:facebook)
|
36
|
+
}
|
37
|
+
end
|
29
38
|
|
30
|
-
#layout
|
31
|
-
# link_to "Sign in with Facebook", user_omniauth_authorize_path(:facebook)
|
data/lib/kitty_gen/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kitty_gen
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.17
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-09-
|
12
|
+
date: 2011-09-25 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
16
|
-
requirement: &
|
16
|
+
requirement: &2157011160 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '3.1'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2157011160
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: colored
|
27
|
-
requirement: &
|
27
|
+
requirement: &2157010760 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *2157010760
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: bundler
|
38
|
-
requirement: &
|
38
|
+
requirement: &2157010160 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: 1.0.0
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *2157010160
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: ruby-debug19
|
49
|
-
requirement: &
|
49
|
+
requirement: &2157009740 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,7 +54,7 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *2157009740
|
58
58
|
description: Save 5 hours starting your next project and use the latest and greatest
|
59
59
|
best practices.
|
60
60
|
email:
|
@@ -76,7 +76,9 @@ files:
|
|
76
76
|
- lib/kitty_gen/base_recipes
|
77
77
|
- lib/kitty_gen/cli.rb
|
78
78
|
- lib/kitty_gen/configure/default.rb
|
79
|
-
- lib/kitty_gen/
|
79
|
+
- lib/kitty_gen/cook.rb
|
80
|
+
- lib/kitty_gen/helpers.rb
|
81
|
+
- lib/kitty_gen/kittens/kitty_1
|
80
82
|
- lib/kitty_gen/master_template.rb
|
81
83
|
- lib/kitty_gen/recipes/add_handy_application_wide_helpers_recipe.rb
|
82
84
|
- lib/kitty_gen/recipes/basic_layout_with_login_using_slim_recipe.rb
|
@@ -101,6 +103,7 @@ files:
|
|
101
103
|
- lib/kitty_gen/templates/basic_layout_with_login_using_slim/application.html.slim
|
102
104
|
- lib/kitty_gen/templates/basic_layout_with_login_using_slim/layout.css.sass
|
103
105
|
- lib/kitty_gen/templates/initialize_git_repo/gitignore
|
106
|
+
- lib/kitty_gen/templates/kittygenrc/kittygenrc
|
104
107
|
- lib/kitty_gen/templates/login_with_facebook_and_twitter/omniauth_callbacks_controller.rb
|
105
108
|
- lib/kitty_gen/templates/postgresql
|
106
109
|
- lib/kitty_gen/templates/setup_testing_with_capybara_testunit_and_watchr/test_unit.watchr
|