kitty_gen 0.0.12 → 0.0.13
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/README.textile +1 -0
- data/lib/kitty_gen/base_recipes +1 -0
- data/lib/kitty_gen/cli.rb +33 -2
- data/lib/kitty_gen/recipes/login_with_facebook_and_twitter_recipe.rb +31 -0
- data/lib/kitty_gen/templates/login_with_facebook_and_twitter/omniauth_callbacks_controller.rb +21 -0
- data/lib/kitty_gen/version.rb +1 -1
- metadata +11 -9
data/README.textile
CHANGED
data/lib/kitty_gen/base_recipes
CHANGED
data/lib/kitty_gen/cli.rb
CHANGED
@@ -2,12 +2,43 @@ module KittyGen
|
|
2
2
|
class Cli
|
3
3
|
|
4
4
|
def start(command_line_arguments)
|
5
|
-
|
5
|
+
case ARGV[0]
|
6
|
+
when "new"
|
7
|
+
new(ARGV[1])
|
8
|
+
when list
|
9
|
+
list
|
10
|
+
when add
|
11
|
+
add(ARGV[1])
|
12
|
+
else
|
13
|
+
%Q{Commands available:
|
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
|
+
}
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def new(app_name)
|
6
24
|
exec "rails new #{app_name} -m #{master_template}"
|
7
25
|
end
|
8
26
|
|
27
|
+
def list
|
28
|
+
puts File.read(File.join(kitty_gen_dir, "base_recipes")).split("\n").reject {|r| r.match /^\s*#/}
|
29
|
+
end
|
30
|
+
|
31
|
+
def add(recipe)
|
32
|
+
recipe_location = File.join(kitty_gen_dir, "recipes", (recipe + "_recipe.rb"))
|
33
|
+
exec "rake rails:template #{recipe_location}"
|
34
|
+
end
|
35
|
+
|
9
36
|
def master_template
|
10
|
-
File.
|
37
|
+
File.join(kitty_gen_dir, "master_template.rb")
|
38
|
+
end
|
39
|
+
|
40
|
+
def kitty_gen_dir
|
41
|
+
File.dirname(__FILE__)
|
11
42
|
end
|
12
43
|
|
13
44
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
gem "omniauth"
|
2
|
+
directory "app/controllers/users"
|
3
|
+
copy_template "omniauth_callbacks_controller", "users/omniauth_callbacks_controller"
|
4
|
+
|
5
|
+
inject_into_file "config/intializers/devise.rb", :before => 'end' <<-RUBY
|
6
|
+
# For debugging start here: https://github.com/plataformatec/devise/wiki/OmniAuth:-Overview
|
7
|
+
config.omniauth :facebook, "APP_ID", "APP_SECRET"
|
8
|
+
RUBY
|
9
|
+
|
10
|
+
inject_into_file 'app/models/user.rb', :before => 'end' <<-RUBY
|
11
|
+
|
12
|
+
devise :omniauthable
|
13
|
+
|
14
|
+
# Modify the user model to pass facebook email to devise if available
|
15
|
+
def self.new_with_session(params, session)
|
16
|
+
super.tap do |user|
|
17
|
+
if data = session["devise.facebook_data"] && session["devise.facebook_data"]["extra"]["user_hash"]
|
18
|
+
user.email = data["email"]
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
RUBY
|
23
|
+
|
24
|
+
gsub_file "config/routes.rb", "devise_for :users" <<-RUBY
|
25
|
+
devise_for :users, :controllers => { :omniauth_callbacks => "users/omniauth_callbacks" } do
|
26
|
+
get '/users/auth/:provider' => 'users/omniauth_callbacks#passthru'
|
27
|
+
end
|
28
|
+
RUBY
|
29
|
+
|
30
|
+
#layout
|
31
|
+
# link_to "Sign in with Facebook", user_omniauth_authorize_path(:facebook)
|
@@ -0,0 +1,21 @@
|
|
1
|
+
class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
|
2
|
+
|
3
|
+
def facebook
|
4
|
+
# You need to implement the method below in your model
|
5
|
+
@user = User.find_for_facebook_oauth(env["omniauth.auth"], current_user)
|
6
|
+
|
7
|
+
if @user.persisted?
|
8
|
+
flash[:notice] = I18n.t "devise.omniauth_callbacks.success", :kind => "Facebook"
|
9
|
+
sign_in_and_redirect @user, :event => :authentication
|
10
|
+
else
|
11
|
+
session["devise.facebook_data"] = env["omniauth.auth"]
|
12
|
+
redirect_to new_user_registration_url
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def passthru
|
17
|
+
render :file => "#{Rails.root}/public/404.html", :status => 404, :layout => false
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
|
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.13
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2011-09-24 00:00:00.000000000Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
16
|
-
requirement: &
|
16
|
+
requirement: &2153672300 !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: *2153672300
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: colored
|
27
|
-
requirement: &
|
27
|
+
requirement: &2153671820 !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: *2153671820
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: bundler
|
38
|
-
requirement: &
|
38
|
+
requirement: &2153671160 !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: *2153671160
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: ruby-debug19
|
49
|
-
requirement: &
|
49
|
+
requirement: &2153670640 !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: *2153670640
|
58
58
|
description: Save 5 hours starting your next project and use the latest and greatest
|
59
59
|
best practices.
|
60
60
|
email:
|
@@ -86,6 +86,7 @@ files:
|
|
86
86
|
- lib/kitty_gen/recipes/factory_girl_with_generators_recipe.rb
|
87
87
|
- lib/kitty_gen/recipes/formtastic_recipe.rb
|
88
88
|
- lib/kitty_gen/recipes/initialize_git_repo_recipe.rb
|
89
|
+
- lib/kitty_gen/recipes/login_with_facebook_and_twitter_recipe.rb
|
89
90
|
- lib/kitty_gen/recipes/make_readme_a_textile_file_recipe.rb
|
90
91
|
- lib/kitty_gen/recipes/reload_css_and_html_in_browser_on_save_recipe.rb
|
91
92
|
- lib/kitty_gen/recipes/remove_unwanted_files_recipe.rb
|
@@ -100,6 +101,7 @@ files:
|
|
100
101
|
- lib/kitty_gen/templates/basic_layout_with_login_using_slim/application.html.slim
|
101
102
|
- lib/kitty_gen/templates/basic_layout_with_login_using_slim/layout.css.sass
|
102
103
|
- lib/kitty_gen/templates/initialize_git_repo/gitignore
|
104
|
+
- lib/kitty_gen/templates/login_with_facebook_and_twitter/omniauth_callbacks_controller.rb
|
103
105
|
- lib/kitty_gen/templates/postgresql
|
104
106
|
- lib/kitty_gen/templates/setup_testing_with_capybara_testunit_and_watchr/test_unit.watchr
|
105
107
|
- lib/kitty_gen/unfinished_recipes/backup.rb
|