kitty_gen 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. data/.gitignore +6 -0
  2. data/Gemfile +4 -0
  3. data/Gemfile.lock +113 -0
  4. data/README.textile +100 -0
  5. data/Rakefile +2 -0
  6. data/bin/kitty_gen +3 -0
  7. data/kitty_gen.gemspec +26 -0
  8. data/lib/kitty_gen.rb +5 -0
  9. data/lib/kitty_gen/base_recipes +14 -0
  10. data/lib/kitty_gen/cli.rb +14 -0
  11. data/lib/kitty_gen/configure/default.rb +3 -0
  12. data/lib/kitty_gen/cooking_helpers.rb +66 -0
  13. data/lib/kitty_gen/master_template.rb +12 -0
  14. data/lib/kitty_gen/recipes/add_handy_application_wide_helpers_recipe.rb +37 -0
  15. data/lib/kitty_gen/recipes/basic_layout_with_login_using_slim_recipe.rb +13 -0
  16. data/lib/kitty_gen/recipes/debugging_and_console_helpers_recipe.rb +7 -0
  17. data/lib/kitty_gen/recipes/decent_exposure_recipe.rb +1 -0
  18. data/lib/kitty_gen/recipes/devise_with_user_model_recipe.rb +6 -0
  19. data/lib/kitty_gen/recipes/factory_girl_with_generators_recipe.rb +2 -0
  20. data/lib/kitty_gen/recipes/formtastic_recipe.rb +21 -0
  21. data/lib/kitty_gen/recipes/initialize_git_repo_recipe.rb +4 -0
  22. data/lib/kitty_gen/recipes/make_readme_a_textile_file_recipe.rb +1 -0
  23. data/lib/kitty_gen/recipes/remove_unwanted_files_recipe.rb +3 -0
  24. data/lib/kitty_gen/recipes/rvm_with_gemset_recipe.rb +21 -0
  25. data/lib/kitty_gen/recipes/sensible_defaults_recipe.rb +13 -0
  26. data/lib/kitty_gen/recipes/setup_testing_with_capybara_testunit_and_watchr_recipe.rb +5 -0
  27. data/lib/kitty_gen/templates/backup_and_pull_db +11 -0
  28. data/lib/kitty_gen/templates/basic_layout_with_login_using_slim/_login.html.slim +4 -0
  29. data/lib/kitty_gen/templates/basic_layout_with_login_using_slim/_navigation.html.slim +2 -0
  30. data/lib/kitty_gen/templates/basic_layout_with_login_using_slim/_register.html.slim +5 -0
  31. data/lib/kitty_gen/templates/basic_layout_with_login_using_slim/application.html.slim +20 -0
  32. data/lib/kitty_gen/templates/basic_layout_with_login_using_slim/layout.css.sass +44 -0
  33. data/lib/kitty_gen/templates/initialize_git_repo/gitignore +11 -0
  34. data/lib/kitty_gen/templates/postgresql +22 -0
  35. data/lib/kitty_gen/templates/setup_testing_with_capybara_testunit_and_watchr/test_unit.watchr +73 -0
  36. data/lib/kitty_gen/unfinished_recipes/backup.rb +1 -0
  37. data/lib/kitty_gen/unfinished_recipes/heroku.rb +15 -0
  38. data/lib/kitty_gen/unfinished_recipes/omniauth.rb +12 -0
  39. data/lib/kitty_gen/version.rb +4 -0
  40. data/recipe.thor +17 -0
  41. metadata +145 -0
data/.gitignore ADDED
@@ -0,0 +1,6 @@
1
+ .sass-cache
2
+ pkg/*
3
+ *.gem
4
+ .bundle
5
+ .DS_Store
6
+ tmp/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source :rubygems
2
+
3
+ # Specify your gem's dependencies in foodie.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,113 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ kitty_gen (0.0.1)
5
+ colored
6
+ rails (~> 3.1)
7
+ rvm
8
+
9
+ GEM
10
+ remote: http://rubygems.org/
11
+ specs:
12
+ actionmailer (3.1.0)
13
+ actionpack (= 3.1.0)
14
+ mail (~> 2.3.0)
15
+ actionpack (3.1.0)
16
+ activemodel (= 3.1.0)
17
+ activesupport (= 3.1.0)
18
+ builder (~> 3.0.0)
19
+ erubis (~> 2.7.0)
20
+ i18n (~> 0.6)
21
+ rack (~> 1.3.2)
22
+ rack-cache (~> 1.0.3)
23
+ rack-mount (~> 0.8.2)
24
+ rack-test (~> 0.6.1)
25
+ sprockets (~> 2.0.0)
26
+ activemodel (3.1.0)
27
+ activesupport (= 3.1.0)
28
+ bcrypt-ruby (~> 3.0.0)
29
+ builder (~> 3.0.0)
30
+ i18n (~> 0.6)
31
+ activerecord (3.1.0)
32
+ activemodel (= 3.1.0)
33
+ activesupport (= 3.1.0)
34
+ arel (~> 2.2.1)
35
+ tzinfo (~> 0.3.29)
36
+ activeresource (3.1.0)
37
+ activemodel (= 3.1.0)
38
+ activesupport (= 3.1.0)
39
+ activesupport (3.1.0)
40
+ multi_json (~> 1.0)
41
+ archive-tar-minitar (0.5.2)
42
+ arel (2.2.1)
43
+ bcrypt-ruby (3.0.1)
44
+ builder (3.0.0)
45
+ colored (1.2)
46
+ columnize (0.3.4)
47
+ erubis (2.7.0)
48
+ hike (1.2.1)
49
+ i18n (0.6.0)
50
+ linecache19 (0.5.12)
51
+ ruby_core_source (>= 0.1.4)
52
+ mail (2.3.0)
53
+ i18n (>= 0.4.0)
54
+ mime-types (~> 1.16)
55
+ treetop (~> 1.4.8)
56
+ mime-types (1.16)
57
+ multi_json (1.0.3)
58
+ polyglot (0.3.2)
59
+ rack (1.3.3)
60
+ rack-cache (1.0.3)
61
+ rack (>= 0.4)
62
+ rack-mount (0.8.3)
63
+ rack (>= 1.0.0)
64
+ rack-ssl (1.3.2)
65
+ rack
66
+ rack-test (0.6.1)
67
+ rack (>= 1.0)
68
+ rails (3.1.0)
69
+ actionmailer (= 3.1.0)
70
+ actionpack (= 3.1.0)
71
+ activerecord (= 3.1.0)
72
+ activeresource (= 3.1.0)
73
+ activesupport (= 3.1.0)
74
+ bundler (~> 1.0)
75
+ railties (= 3.1.0)
76
+ railties (3.1.0)
77
+ actionpack (= 3.1.0)
78
+ activesupport (= 3.1.0)
79
+ rack-ssl (~> 1.3.2)
80
+ rake (>= 0.8.7)
81
+ rdoc (~> 3.4)
82
+ thor (~> 0.14.6)
83
+ rake (0.9.2)
84
+ rdoc (3.9.4)
85
+ ruby-debug-base19 (0.11.25)
86
+ columnize (>= 0.3.1)
87
+ linecache19 (>= 0.5.11)
88
+ ruby_core_source (>= 0.1.4)
89
+ ruby-debug19 (0.11.6)
90
+ columnize (>= 0.3.1)
91
+ linecache19 (>= 0.5.11)
92
+ ruby-debug-base19 (>= 0.11.19)
93
+ ruby_core_source (0.1.5)
94
+ archive-tar-minitar (>= 0.5.2)
95
+ rvm (1.8.3)
96
+ sprockets (2.0.0)
97
+ hike (~> 1.2)
98
+ rack (~> 1.0)
99
+ tilt (!= 1.3.0, ~> 1.1)
100
+ thor (0.14.6)
101
+ tilt (1.3.3)
102
+ treetop (1.4.10)
103
+ polyglot
104
+ polyglot (>= 0.3.1)
105
+ tzinfo (0.3.29)
106
+
107
+ PLATFORMS
108
+ ruby
109
+
110
+ DEPENDENCIES
111
+ bundler (~> 1.0.0)
112
+ kitty_gen!
113
+ ruby-debug19
data/README.textile ADDED
@@ -0,0 +1,100 @@
1
+ h1. Rails 3.1 Application Template
2
+
3
+ Shave off 3 hours from the start of your next project. Your client will be amazed! This "rails developer in london":http://www.jackkinsella.ie/rails-developer-london has put all his favourite configuations, gems, settings and favourites into this Rails 3.1 app generator so as to get you adding business vlaue to your clients' venture as soon as possible.
4
+
5
+ h2. Design Decisions
6
+
7
+ # 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.
8
+
9
+ # Gems are installed inline instead of in one big file.
10
+
11
+ #Rspec and Cucubmer are not included by default since, frankly, they add needless complexity and waste time for serious developers. See DHH.
12
+
13
+ # A commit is made after every steps
14
+
15
+ h2. Features
16
+
17
+ h4. Starts Up A Git Repo
18
+
19
+ initialize_git_repo
20
+
21
+ h4. Railscasts style basic layout
22
+
23
+ railscasts_layout
24
+
25
+ h4. Devise set up and installed with a user model to go.
26
+
27
+ devise_with_user
28
+
29
+ # Omniauth too. Everyone wants to login with Facebook Twitter these days.
30
+ # Comments removed from routes and env files.
31
+ # Debugging tools: ruby-debug
32
+ # Terminal tools: awesome_print, looksee and map_by_method
33
+ # Exception Notification: because you should care
34
+ # Heroku deploy
35
+ # Fast backup using Heroku
36
+ # Set rid of annoying files like public/index.html
37
+ # Decent Exposure: finally controllers start making sense
38
+ # RVM gemsets. You are using these right?
39
+ # A sensible gitignore
40
+ # A Textile readme
41
+ # Automatically setting all attributes to protected. Anti-hacking glory.
42
+ # Google Analytics
43
+ # SEOHelper Methods
44
+ # Better Forms with SimpleForm
45
+ # Sitemaps
46
+ # Watchr. Encourage us to test more.
47
+ # CarrierWave: modern file uploading done right.
48
+ # Friendly-ID for permalinks
49
+ # Rails-erd for diagrams of your DB and its connections
50
+ Use with: @rake erd@
51
+ Creates file ERD.pdf :-)
52
+ _May require brew installations to work_
53
+ @brew install cairo pango graphviz@
54
+
55
+ h2. How To Use
56
+
57
+ @kittygen your-new-app-name@
58
+
59
+ h2. All Possible Recipes
60
+ formtastic
61
+ factory_girl_with_generators
62
+ decent_exposure
63
+ debugging_and_console_helpers
64
+ sensible_defaults
65
+ setup_testing_with_capybara_testunit_and_watchr
66
+ make_readme_a_textile_file
67
+ basic_layout_with_login_using_slim
68
+ devise_with_user_model
69
+ rvm_with_gemset
70
+ remove_unwanted_files
71
+ add_handy_application_wide_helpers
72
+
73
+ h2. How To Add New Recipes
74
+
75
+ Here's the best part of this gem: it's really easy to add your
76
+ own recipes. Just follow this simple guide.
77
+
78
+ 1) Choose a good, descriptive name from your recipe. For example you might
79
+ one I already picked was "add_omniauth_login".
80
+
81
+ 2) Clone the gem locally and cd on in.
82
+
83
+ 3)Type
84
+ @thor recipe:new remove_unwanted_files@ from within the gems source directory..
85
+
86
+ This adds a {recipe_name}_recipe.rb to lib/kitty_gen/recipes/. This recipe file contains the instructions you'd like KittyGen to follow when cooking up your piece of functionality.
87
+
88
+ 4) Add any files you need to copy or templates you'd like
89
+ to use to lib/kitty_gen/templates/{recipe_name}/.
90
+
91
+ 5) Send a pull request and I'll add your recipe. That way everyone can share the goodness.
92
+
93
+ 6) Use these commands:
94
+ copy_template file_name, final_location_in_rails_app
95
+ empty_directory
96
+ _create an empty dir_
97
+ gem gem_name, :group => :gem_group
98
+
99
+ h4. Resources
100
+ "Guide to useful commands for making recipes":http://blog.madebydna.com/all/code/2010/10/11/cooking-up-a-custom-rails3-template.html
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
data/bin/kitty_gen ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ require "kitty_gen"
3
+ KittyGen::Cli.new.start(ARGV)
data/kitty_gen.gemspec ADDED
@@ -0,0 +1,26 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path("../lib/kitty_gen/version", __FILE__)
3
+ Gem::Specification.new do |s|
4
+ s.name = "kitty_gen"
5
+ s.version = KittyGen::VERSION
6
+ s.platform = Gem::Platform::RUBY
7
+ s.authors = ["Jack Kinsella"]
8
+ s.email = ["jack.kinsella@can-be-found-on-github.com"]
9
+ # s.homepage = "http://rubygems.org/gems/rails_templater"
10
+ s.summary = "The best template generator for Ruby on Rails 3.1 applications"
11
+ s.description = "Save 5 hours starting your next project and use the latst and greatest best practices."
12
+
13
+ s.required_rubygems_version = ">= 1.3.6"
14
+ s.homepage = "http://rubygems.org/gems/kitty_gen"
15
+ s.rubyforge_project = "kitty_gen"
16
+ s.add_dependency "rails", "~> 3.1"
17
+ s.add_dependency "colored"
18
+ s.add_dependency "rvm"
19
+ s.add_development_dependency "bundler", "~> 1.0.0"
20
+ s.add_development_dependency "ruby-debug19"
21
+
22
+ s.files = `git ls-files`.split("\n")
23
+ s.executables = `git ls-files`.split("\n").map{|f| f =~ /^bin\/(.*)/ ? $1 : nil}.compact
24
+ s.require_path = 'lib'
25
+ end
26
+
data/lib/kitty_gen.rb ADDED
@@ -0,0 +1,5 @@
1
+ module KittyGen
2
+
3
+ require "kitty_gen/cli"
4
+
5
+ end
@@ -0,0 +1,14 @@
1
+ # Order here is important
2
+ # Comment out what you don't want
3
+ rvm_with_gemset
4
+ sensible_defaults
5
+ devise_with_user_model
6
+ basic_layout_with_login_using_slim
7
+ remove_unwanted_files
8
+ add_handy_application_wide_helpers
9
+ make_readme_a_textile_file
10
+ setup_testing_with_capybara_testunit_and_watchr
11
+ debugging_and_console_helpers
12
+ decent_exposure
13
+ factory_girl_with_generators
14
+ formtastic
@@ -0,0 +1,14 @@
1
+ module KittyGen
2
+ class Cli
3
+
4
+ def start(command_line_arguments)
5
+ app_name = ARGV.first
6
+ exec "rails new #{app_name} -m #{master_template}"
7
+ end
8
+
9
+ def master_template
10
+ File.expand_path(File.join(File.dirname(__FILE__), "master_template.rb"))
11
+ end
12
+
13
+ end
14
+ end
@@ -0,0 +1,3 @@
1
+ @ruby_version = '1.9.2-p180'
2
+ @database = 'postgresql'
3
+ @cucumber = false
@@ -0,0 +1,66 @@
1
+ require "rails/generators"
2
+ require "thor"
3
+ require "colored"
4
+ module KittyGen
5
+
6
+ module CookingHelpers
7
+ attr_accessor :current_recipe
8
+
9
+ def introduce_yourself
10
+ title "Welcome To Kitty Gen. Lets Make You an App"
11
+ end
12
+
13
+ def prepare_standard_features
14
+ File.open(File.join(File.dirname(__FILE__), "base_recipes")).each do |recipe_name|
15
+ recipe recipe_name.chomp.intern unless recipe_name.match(/\s?#/)
16
+ end
17
+ end
18
+
19
+ private
20
+
21
+ def tell_thor_where_your_files_will_go
22
+ self.destination_root = Dir.pwd
23
+ end
24
+
25
+ def tell_those_where_you_keep_your_recipes
26
+ self.source_paths << File.expand_path("../recipes/", __FILE__)
27
+ end
28
+
29
+ #this method places the template folder with the same name as the recipe in scope
30
+ #before copying the file, the removes it again
31
+
32
+ def copy_template(file_name, destination)
33
+ self.source_paths << File.expand_path("../templates/#{current_recipe}", __FILE__)
34
+ copy_file file_name, destination, :force => true
35
+ self.source_paths.pop
36
+ end
37
+
38
+
39
+ def title(message)
40
+ puts "\n\n## #{message} ##\n\n".red.bold
41
+ end
42
+
43
+ def log_recipe_name(message)
44
+ message = message.humanize
45
+ puts "\n--> #{message}\n".blue
46
+ end
47
+
48
+ def inform(message)
49
+ puts "\n:-) :-) #{message.capitalize}\n".yellow
50
+ end
51
+
52
+ def git_commit_with_message
53
+ git :add => '.'
54
+ git :commit => "-m KittyGen added: #{current_recipe.humanize}"
55
+ end
56
+
57
+ def recipe(thing_to_do)
58
+ thing_to_do = thing_to_do.to_s
59
+ self.current_recipe = thing_to_do
60
+ log_recipe_name thing_to_do
61
+ apply "#{thing_to_do}_recipe.rb"
62
+ # git_commit_with_message
63
+ end
64
+
65
+ end
66
+ end
@@ -0,0 +1,12 @@
1
+ require "kitty_gen/cooking_helpers"
2
+ extend ::KittyGen::CookingHelpers
3
+ #try getting cook to inherit from AppGenerator
4
+
5
+ introduce_yourself
6
+ #hack since thor expends an empty options hash
7
+ # @options = {}
8
+ app_name = ARGV.first
9
+ tell_thor_where_your_files_will_go
10
+ tell_those_where_you_keep_your_recipes
11
+ prepare_standard_features
12
+ # take_orders_for_specialties
@@ -0,0 +1,37 @@
1
+ #hack so kitty gen doesn't try to interpolate methods within the app
2
+ ga_id = '#{ga_id}'
3
+ inject_into_file 'app/helpers/application_helper.rb', :after => "module ApplicationHelper\n" do
4
+ %Q{
5
+ #Set the page title from view file
6
+ def title=(title)
7
+ content_for(:title, title.to_s)
8
+ end
9
+
10
+ #Show the page title in your layouts
11
+ def title
12
+ given_title = content_for(:title)
13
+ given_title.empty? ? sitename : given_title + " | " + sitename
14
+ end
15
+
16
+ #Set the seo_desc from view file
17
+ def seo_desc=(seo_desc)
18
+ content_for(:seo_desc, seo_desc.to_s)
19
+ end
20
+
21
+ #Show the page seo_desc in your layouts
22
+ def seo_desc
23
+ given_seo_desc = content_for(:seo_desc)
24
+ given_seo_desc.empty? ? "#{app_name} is just what you need" : given_seo_desc
25
+ end
26
+
27
+ def sitename
28
+ "#{app_name}"
29
+ end
30
+
31
+ def google_analytics(ga_id)
32
+ content_tag :script do
33
+ %{ var _gaq = _gaq || []; _gaq.push(['_setAccount', '#{ga_id}']); _gaq.push(['_trackPageview']); (function() {var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(ga);})(); }
34
+ end
35
+ end
36
+ }
37
+ end
@@ -0,0 +1,13 @@
1
+ %W{_login _navigation _register application}.each do |layout_file|
2
+ layout_file = "#{layout_file}.html.slim"
3
+ copy_template(layout_file, "app/views/layouts/#{layout_file}")
4
+ end
5
+ remove_file "app/views/layouts/application.html.erb"
6
+ gem "slim-rails"
7
+ run_bundle
8
+ generate "controller pages home about"
9
+ empty_directory "app/assets/stylesheets"
10
+ application "config.sass.preferred_syntax = :sass"
11
+ inform "adding slim"
12
+ copy_template("layout.css.sass", "app/assets/stylesheets/layout.css.sass")
13
+ inform "adding a sass layout file to asset"
@@ -0,0 +1,7 @@
1
+ gem "rails-footnotes", :group => [:development, :test]
2
+ gem "rails-erd", :group => [:development]
3
+ gem "wirble"
4
+ gem "looksee"
5
+ gem "awesome_print"
6
+ gem "map_by_method"
7
+ gem "ruby-debug19", :require => "ruby-debug", :group => [:development, :test]
@@ -0,0 +1 @@
1
+ gem 'decent_exposure'
@@ -0,0 +1,6 @@
1
+ gem "devise"
2
+ run_bundle
3
+ rake "devise:install"
4
+ inform "creating a devise user"
5
+ generate "devise User"
6
+ rake "db:migrate"
@@ -0,0 +1,2 @@
1
+ gem "factory_girl_rails", :group => [:test]
2
+ gem "rails-3-generators", :group => [:development]
@@ -0,0 +1,21 @@
1
+ gem "formtastic"
2
+ run_bundle
3
+ generate "formtastic:install "
4
+
5
+ append_to_file "app/assets/stylesheets/application.css" do
6
+ %Q{
7
+ *= require formtastic
8
+ *= require my_formtastic_changes
9
+ }
10
+ end
11
+
12
+ create_file "app/assets/stylesheets/ie6.css" do
13
+ %Q{
14
+ *= require formtastic_ie6
15
+ }
16
+ end
17
+ create_file "app/assets/stylesheets/ie7.css" do
18
+ %Q{
19
+ *= require formtastic_ie7
20
+ }
21
+ end
@@ -0,0 +1,4 @@
1
+ copy_template "gitignore", ".gitignore"
2
+ run "git init", :capture => true
3
+ run "git add .", :capture => true
4
+ run "git commit -a -m 'Initial commit'", :capture => true
@@ -0,0 +1 @@
1
+ run "mv README README.textile"
@@ -0,0 +1,3 @@
1
+ %w[README doc/ public/index.html public/favicon.ico app/assets/images/rails.png].each do |file|
2
+ remove_file file
3
+ end
@@ -0,0 +1,21 @@
1
+ require "rvm"
2
+ rvm_ruby = "ruby-1.9.2-p180"
3
+ @env = RVM::Environment.new(rvm_ruby)
4
+
5
+ puts "Creating gemset #{app_name} in #{rvm_ruby}"
6
+ @env.gemset_create(app_name)
7
+ puts "Now using gemset #{app_name}"
8
+ @env.gemset_use!(app_name)
9
+
10
+ puts "Installing bundler gem."
11
+ puts "Successfully installed bundler" if @env.system("gem", "install", "bundler")
12
+ puts "Installing rails gem."
13
+ puts "Successfully installed rails" if @env.system("gem", "install", "rails")
14
+
15
+ # rvm_gemset = [ruby_version, app_name].join('@')
16
+ # inform "Adding this gemset: #{rvm_gemset}"
17
+ # create_file ".rvmrc" do
18
+ # "rvm #{rvm_gemset} --create"
19
+ # end
20
+ # run "rvm rvmrc trust"
21
+ # run "rvm use --create #{rvm_gemset}"
@@ -0,0 +1,13 @@
1
+ application "
2
+ # Configure default generator behavior
3
+ config.app_generators do |g|
4
+ g.template_engine :slim
5
+ g.test_framework :test_unit, :fixture => false, :fixture_replacement => :factory_girl
6
+ g.view_specs false
7
+ g.helper false
8
+ g.stylesheets false
9
+ end
10
+
11
+ #require you to declare every attribute accessible - a security measure.
12
+ config.active_record.whitelist_attributes = true
13
+ "
@@ -0,0 +1,5 @@
1
+ gem "capybara", :group => :test
2
+ gem "launchy", :group => :test
3
+ gem "watchr", :group => :test
4
+ copy_template "test_unit.watchr", "test_unit.watchr"
5
+ gem "growl", :group => :test
@@ -0,0 +1,11 @@
1
+ #use with source backup_and_pull_db.sh
2
+ function current_backup_name () {
3
+ heroku pgbackups --app <%= app_name %> | tail -n 1 | cut -d"|" -f 1
4
+ }
5
+ #find out name of last bundle (as you'll need to destroy it)
6
+ heroku pgbackups:destroy --app <%= app_name %> `current_backup_name`
7
+ heroku pgbackups:capture --app <%= app_name %>
8
+ #find out name of latest bundle (you'll need this)
9
+ curl $(heroku pgbackups:url --app <%= app_name %> `current_backup_name`) > temporary_backup.dump
10
+ pg_restore --verbose --clean --no-acl --no-owner -h localhost -U jack -d <%= app_name %> temporary_backup.dump
11
+ rm -f temporary_backup.dump
@@ -0,0 +1,4 @@
1
+ - if user_signed_in?
2
+ li = link_to 'Logout', destroy_user_session_path, :method => :delete
3
+ - else
4
+ li = link_to 'Login', new_user_session_path
@@ -0,0 +1,2 @@
1
+ li = link_to "Home", root_path
2
+ li = link_to "About", about_path
@@ -0,0 +1,5 @@
1
+ - if user_signed_in?
2
+ li = link_to 'Edit registration', edit_user_registration_path
3
+ - else
4
+ li = link_to 'Register', new_user_registration_path
5
+
@@ -0,0 +1,20 @@
1
+ doctype html
2
+ html
3
+ head
4
+ title
5
+ = render_page_title
6
+ = stylesheet_link_tag "application"
7
+ = javascript_include_tag "application"
8
+ = csrf_meta_tags
9
+ = google_analytics "UA-XXXX-XXX"
10
+ body
11
+ #container
12
+ h1 = sitename
13
+ #navigation
14
+ ul
15
+ = render "layouts/navigation"
16
+ = render "layouts/register"
17
+ = render "layouts/login"
18
+ p.notice = notice
19
+ p.alert = alert
20
+ = yield
@@ -0,0 +1,44 @@
1
+ // Global layout styles only here
2
+
3
+ $primary_color: #4B7399
4
+
5
+ body
6
+ :background-color $primary_color
7
+ :font
8
+ :family Verdana, Helvetica, Arial
9
+ :size 14px
10
+
11
+ a
12
+ :color #0000FF
13
+ img
14
+ :border none
15
+
16
+ .clear
17
+ :clear both
18
+ :height 0
19
+ :overflow hidden
20
+
21
+ .alert
22
+ :border 1px solid #fbb
23
+ :background-color #fdd
24
+
25
+ .notice
26
+ :border 1px solid #ddf
27
+ :background-color #eef
28
+
29
+
30
+ #container
31
+ :width 75%
32
+ :margin 0 auto
33
+ :background #fff
34
+ :padding 20px 40px
35
+ :border solid 1px black
36
+ :margin-top 20px
37
+
38
+ #navigation
39
+ ul
40
+ :list-style none
41
+ :padding-left 0px
42
+ li
43
+ :display inline
44
+ :margin-right 20px
@@ -0,0 +1,11 @@
1
+ *.DS_Store
2
+ .bundle
3
+ db/*.sqlite3
4
+ log
5
+ config/database.yml
6
+ rerun.txt
7
+ coverage
8
+ public/system
9
+ public/cache
10
+ pull*.dat
11
+ tmp
@@ -0,0 +1,22 @@
1
+ setup: &setup
2
+ adapter: postgresql
3
+ encoding: utf8
4
+ host: localhost
5
+ pool: 5
6
+ username: postgres
7
+ password: postgres
8
+
9
+
10
+ development:
11
+ <<: *setup
12
+ database: <%= database_name('development') %>
13
+
14
+
15
+ test:
16
+ <<: *setup
17
+ database: <%= database_name('test') %>
18
+
19
+
20
+ production:
21
+ <<: *setup
22
+ database: <%= database_name('production') %>
@@ -0,0 +1,73 @@
1
+ ENV["WATCHR"] = "1"
2
+ system 'clear'
3
+
4
+ def growl(message)
5
+ growlnotify = `which growlnotify`.chomp
6
+ title = "Watchr Test Results"
7
+ image = message.include?('0 failures, 0 errors') ? "~/.watchr_images/passed.png" : "~/.watchr_images/failed.png"
8
+ options = "-w -n Watchr --image '#{File.expand_path(image)}' -m '#{message}' '#{title}'"
9
+ system %(#{growlnotify} #{options} &)
10
+ end
11
+
12
+ def run(cmd)
13
+ puts(cmd)
14
+ `#{cmd}`
15
+ end
16
+
17
+ def run_test_file(file)
18
+ system('clear')
19
+ result = run(%Q(ruby -I"lib:test" -rubygems #{file}))
20
+ growl result.split("\n").last rescue nil
21
+ puts result
22
+ end
23
+
24
+ def run_all_unit_tests
25
+ system('clear')
26
+ result = run "rake test"
27
+ growl result.split("\n").last rescue nil
28
+ puts result
29
+ end
30
+
31
+ def run_all_integrations
32
+ system('clear')
33
+ run "rake test:integration"
34
+ end
35
+
36
+ def related_test_files(path)
37
+ unit_tests = Dir['test/unit/*.rb'] +
38
+ Dir['test/functional/*.rb']
39
+ unit_tests.select { |file| file =~ /#{File.basename(path).split(".").first}_test.rb/ }
40
+ end
41
+
42
+ def run_suite
43
+ run_all_unit_tests
44
+ run_all_integrations
45
+ end
46
+
47
+ watch('test/test_helper\.rb') { run_all_unit_tests }
48
+ watch('test/.*/.*_test\.rb') { |m| run_test_file(m[0]) }
49
+ watch('app/.*/.*\.rb') { |m| related_test_files(m[0]).map {|tf| run_test_file(tf) } }
50
+ watch('test/integration/.*_test\.rb') { run_all_integrations }
51
+
52
+ # Ctrl-\
53
+ Signal.trap 'QUIT' do
54
+ puts " --- Running all tests ---\n\n"
55
+ run_all_unit_tests
56
+ end
57
+
58
+ @interrupted = false
59
+
60
+ # Ctrl-C
61
+ Signal.trap 'INT' do
62
+ if @interrupted then
63
+ @wants_to_quit = true
64
+ abort("\n")
65
+ else
66
+ puts "Interrupt a second time to quit"
67
+ @interrupted = true
68
+ Kernel.sleep 1.5
69
+ # raise Interrupt, nil # let the run loop catch it
70
+ run_suite
71
+ end
72
+ end
73
+
@@ -0,0 +1 @@
1
+ get "#{@template_path}/resources/backup_and_pull_db", ".backup_and_pull_db.sh", :force => true
@@ -0,0 +1,15 @@
1
+ run "heroku create #{app_name}"
2
+ def heroku(cmd, arguments="")
3
+ run "heroku #{cmd} #{arguments}"
4
+ end
5
+ heroku :"config:add", "BUNDLE_WITHOUT='development:test' --app #{app_name}"
6
+
7
+ # addons
8
+ heroku :"addons:add", "custom_domains:basic"
9
+ heroku :"addons:add", "newrelic:bronze"
10
+ heroku :"addons:add", "cron:daily"
11
+
12
+ git :push => "heroku master"
13
+ heroku :rake, "db:migrate --app #{app_name}-#{env}"
14
+ heroku :open, "--app #{app_name}-#{env}"
15
+
@@ -0,0 +1,12 @@
1
+ route "match '/auth/:provider/callback', :to => 'sessions#create'"
2
+ route "match '/logout', :to => 'sessions#destroy'"
3
+ generate "model authorization provider:string uid:string user_id:integer"
4
+ generate "model user name:string"
5
+
6
+ get "https://github.com/aentos/rails3-templates/raw/master/omniauth/user.rb", "app/models/user.rb"
7
+ get "https://github.com/aentos/rails3-templates/raw/master/omniauth/authorization.rb", 'app/models/authorization.rb'
8
+ get "https://github.com/aentos/rails3-templates/raw/master/omniauth/sessions_controller.rb", "app/controllers/sessions_controller.rb"
9
+ get "https://github.com/aentos/rails3-templates/raw/master/omniauth/application_controller.rb", "app/controllers/application_controller.rb"
10
+
11
+ git :add => '.'
12
+ git :commit => '-m "Ominauth"'
@@ -0,0 +1,4 @@
1
+ module KittyGen
2
+ VERSION = "0.0.1" #aka Beta
3
+ end
4
+
data/recipe.thor ADDED
@@ -0,0 +1,17 @@
1
+ class Recipe < Thor
2
+ include Thor::Actions
3
+ desc "new RECIPE_NAME", "Create blanks files and dirs for new recipe you want to create"
4
+
5
+ def new(recipe_name)
6
+ self.destination_root = File.expand_path("lib/kitty_gen/")
7
+
8
+ empty_directory File.join(destination_root, "templates", recipe_name)
9
+
10
+ inside File.join(destination_root, "recipes") do
11
+ create_file "#{recipe_name}_recipe.rb"
12
+ end
13
+
14
+ append_file "base_recipes", "#{recipe_name}\n"
15
+ inject_into_file "../../README.textile", "#{recipe_name}\n", :after => "All Possible Recipes\n"
16
+ end
17
+ end
metadata ADDED
@@ -0,0 +1,145 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: kitty_gen
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Jack Kinsella
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-09-22 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rails
16
+ requirement: &2157089660 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '3.1'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *2157089660
25
+ - !ruby/object:Gem::Dependency
26
+ name: colored
27
+ requirement: &2157089260 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *2157089260
36
+ - !ruby/object:Gem::Dependency
37
+ name: rvm
38
+ requirement: &2157088680 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :runtime
45
+ prerelease: false
46
+ version_requirements: *2157088680
47
+ - !ruby/object:Gem::Dependency
48
+ name: bundler
49
+ requirement: &2157088140 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: 1.0.0
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: *2157088140
58
+ - !ruby/object:Gem::Dependency
59
+ name: ruby-debug19
60
+ requirement: &2157087680 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ type: :development
67
+ prerelease: false
68
+ version_requirements: *2157087680
69
+ description: Save 5 hours starting your next project and use the latst and greatest
70
+ best practices.
71
+ email:
72
+ - jack.kinsella@can-be-found-on-github.com
73
+ executables:
74
+ - kitty_gen
75
+ extensions: []
76
+ extra_rdoc_files: []
77
+ files:
78
+ - .gitignore
79
+ - Gemfile
80
+ - Gemfile.lock
81
+ - README.textile
82
+ - Rakefile
83
+ - bin/kitty_gen
84
+ - kitty_gen.gemspec
85
+ - lib/.DS_Store
86
+ - lib/kitty_gen.rb
87
+ - lib/kitty_gen/.DS_Store
88
+ - lib/kitty_gen/base_recipes
89
+ - lib/kitty_gen/cli.rb
90
+ - lib/kitty_gen/configure/default.rb
91
+ - lib/kitty_gen/cooking_helpers.rb
92
+ - lib/kitty_gen/master_template.rb
93
+ - lib/kitty_gen/recipes/add_handy_application_wide_helpers_recipe.rb
94
+ - lib/kitty_gen/recipes/basic_layout_with_login_using_slim_recipe.rb
95
+ - lib/kitty_gen/recipes/debugging_and_console_helpers_recipe.rb
96
+ - lib/kitty_gen/recipes/decent_exposure_recipe.rb
97
+ - lib/kitty_gen/recipes/devise_with_user_model_recipe.rb
98
+ - lib/kitty_gen/recipes/factory_girl_with_generators_recipe.rb
99
+ - lib/kitty_gen/recipes/formtastic_recipe.rb
100
+ - lib/kitty_gen/recipes/initialize_git_repo_recipe.rb
101
+ - lib/kitty_gen/recipes/make_readme_a_textile_file_recipe.rb
102
+ - lib/kitty_gen/recipes/remove_unwanted_files_recipe.rb
103
+ - lib/kitty_gen/recipes/rvm_with_gemset_recipe.rb
104
+ - lib/kitty_gen/recipes/sensible_defaults_recipe.rb
105
+ - lib/kitty_gen/recipes/setup_testing_with_capybara_testunit_and_watchr_recipe.rb
106
+ - lib/kitty_gen/templates/.DS_Store
107
+ - lib/kitty_gen/templates/backup_and_pull_db
108
+ - lib/kitty_gen/templates/basic_layout_with_login_using_slim/_login.html.slim
109
+ - lib/kitty_gen/templates/basic_layout_with_login_using_slim/_navigation.html.slim
110
+ - lib/kitty_gen/templates/basic_layout_with_login_using_slim/_register.html.slim
111
+ - lib/kitty_gen/templates/basic_layout_with_login_using_slim/application.html.slim
112
+ - lib/kitty_gen/templates/basic_layout_with_login_using_slim/layout.css.sass
113
+ - lib/kitty_gen/templates/initialize_git_repo/gitignore
114
+ - lib/kitty_gen/templates/postgresql
115
+ - lib/kitty_gen/templates/setup_testing_with_capybara_testunit_and_watchr/test_unit.watchr
116
+ - lib/kitty_gen/unfinished_recipes/backup.rb
117
+ - lib/kitty_gen/unfinished_recipes/heroku.rb
118
+ - lib/kitty_gen/unfinished_recipes/omniauth.rb
119
+ - lib/kitty_gen/version.rb
120
+ - recipe.thor
121
+ homepage: http://rubygems.org/gems/kitty_gen
122
+ licenses: []
123
+ post_install_message:
124
+ rdoc_options: []
125
+ require_paths:
126
+ - lib
127
+ required_ruby_version: !ruby/object:Gem::Requirement
128
+ none: false
129
+ requirements:
130
+ - - ! '>='
131
+ - !ruby/object:Gem::Version
132
+ version: '0'
133
+ required_rubygems_version: !ruby/object:Gem::Requirement
134
+ none: false
135
+ requirements:
136
+ - - ! '>='
137
+ - !ruby/object:Gem::Version
138
+ version: 1.3.6
139
+ requirements: []
140
+ rubyforge_project: kitty_gen
141
+ rubygems_version: 1.8.8
142
+ signing_key:
143
+ specification_version: 3
144
+ summary: The best template generator for Ruby on Rails 3.1 applications
145
+ test_files: []