topkit 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in topkit.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Alex Padgett
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,27 @@
1
+ # topkit
2
+
3
+ Generate Rails app using Topic gems, frameworks and layouts.
4
+
5
+ Props to [thoughtbot](http://thoughtbot.com)'s [Suspenders](https://github.com/thoughtbot/suspenders) and [Gaslight](http://gaslight.co/home)'s [Sparkler](https://github.com/gaslight/sparkler) for inspiration and influence.
6
+
7
+ ## Installation
8
+
9
+ $ gem install topkit
10
+
11
+ ## Usage
12
+
13
+ Currently no extra command line options, so simply:
14
+
15
+ $ topkit APP_NAME
16
+
17
+ ## Contributing
18
+
19
+ 1. Fork it
20
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
21
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
22
+ 4. Push to the branch (`git push origin my-new-feature`)
23
+ 5. Create new Pull Request
24
+
25
+ ## License
26
+
27
+ topkit is Copyright © 2008-2013 Topic Design. It is free software, and may be redistributed under the terms specified in the LICENSE file.
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/topkit ADDED
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require File.expand_path(File.join('..', 'lib', 'topkit', 'generators', 'app_generator'), File.dirname(__FILE__))
4
+ require File.expand_path(File.join('..', 'lib', 'topkit', 'actions'), File.dirname(__FILE__))
5
+ require File.expand_path(File.join('..', 'lib', 'topkit', 'app_builder'), File.dirname(__FILE__))
6
+
7
+ templates_root = File.expand_path(File.join("..", "templates"), File.dirname(__FILE__))
8
+ Topkit::AppGenerator.source_root templates_root
9
+ Topkit::AppGenerator.source_paths << Rails::Generators::AppGenerator.source_root << templates_root
10
+
11
+ Topkit::AppGenerator.start
@@ -0,0 +1,40 @@
1
+ module Topkit
2
+ module Actions
3
+ def concat_file(source, destination)
4
+ contents = IO.read(find_in_source_paths(source))
5
+ append_file destination, contents
6
+ end
7
+
8
+ def replace_in_file(relative_path, find, replace)
9
+ path = File.join(destination_root, relative_path)
10
+ contents = IO.read(path)
11
+ unless contents.gsub!(find, replace)
12
+ raise "#{find.inspect} not found in #{relative_path}"
13
+ end
14
+ File.open(path, "w") { |file| file.write(contents) }
15
+ end
16
+
17
+ def action_mailer_host(rails_env, host)
18
+ host_config = "config.action_mailer.default_url_option = { host: '#{host}' }"
19
+ configure_environment(rails_env, host_config)
20
+ end
21
+
22
+ def configure_environment(rails_env, config)
23
+ inject_into_file(
24
+ "config/environments/#{rails_env}.rb",
25
+ "\n\n #{config}",
26
+ before: "\nend"
27
+ )
28
+ end
29
+
30
+ def download_file(uri_string, destination)
31
+ uri = URI.parse(uri_string)
32
+ http = Net::HTTP.new(uri.host, uri.port)
33
+ http.use_ssl = true if uri_string =~ /^https/
34
+ request = Net::HTTP::Get.new(uri.path)
35
+ contents = http.request(request).body
36
+ path = File.join(destination_root, destination)
37
+ File.open(path, "w") { |file| file.write(contents) }
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,102 @@
1
+ module Topkit
2
+ class AppBuilder < Rails::AppBuilder
3
+ include Topkit::Actions
4
+
5
+ def configure_rspec_generators
6
+ config = <<-RUBY
7
+ config.generators do |g|
8
+ g.fixture true
9
+ g.fixture_replacement "factory_girl"
10
+ g.assets false
11
+ g.test_framework :rspec
12
+ g.view_specs false
13
+ g.controller_specs false
14
+ g.helper_specs false
15
+ g.routing_specs false
16
+ end
17
+
18
+ RUBY
19
+
20
+ inject_into_class 'config/application.rb', 'Application', config
21
+ end
22
+
23
+ def replace_gemfile
24
+ remove_file 'Gemfile'
25
+ copy_file 'Gemfile_clean', 'Gemfile'
26
+ end
27
+
28
+ def template_database_file
29
+ template 'database.mysql.yml.erb', 'config/database.yml', force: true
30
+ end
31
+
32
+ def create_database
33
+ bundle_command "exec rake db:create"
34
+ end
35
+
36
+ def remove_public_index
37
+ remove_file 'public/index.html'
38
+ end
39
+
40
+ def remove_rails_logo_image
41
+ remove_file 'app/assets/images/rails.png'
42
+ end
43
+
44
+ def remove_routes_comment_lines
45
+ replace_in_file 'config/routes.rb',
46
+ /Application\.routes\.draw do.*end/m,
47
+ "Application.routes.draw do\nend"
48
+ end
49
+
50
+ def setup_staging_environment
51
+ run "cp config/environments/production.rb config/environments/staging.rb"
52
+ replace_in_file "config/environments/staging.rb", "config.serve_static_assets = false", "config.serve_static_assets = true"
53
+ replace_in_file "config/environments/staging.rb", "config.assets.compile = false", "config.assets.compile = true"
54
+ replace_in_file "config/environments/staging.rb", "# config.log_level = :debug", "config.log_level = :debug"
55
+ end
56
+
57
+ def create_partials_directory
58
+ empty_directory 'app/views/application'
59
+ end
60
+
61
+ def create_status_partials
62
+ copy_file '_status.html.erb', 'app/views/application/_status.html.erb'
63
+ copy_file '_header.html.erb', 'app/views/application/_header.html.erb'
64
+ copy_file '_footer.html.erb', 'app/views/application/_footer.html.erb'
65
+ end
66
+
67
+ def create_application_layout
68
+ remove_file "app/views/layouts/application.html.erb"
69
+ copy_file "application_layout.html.erb", "app/views/layouts/application.html.erb", force: true
70
+ end
71
+
72
+ def generate_rspec
73
+ generate 'rspec:install'
74
+ end
75
+
76
+ def generate_backbone
77
+ generate "backbone:install"
78
+ end
79
+
80
+ def enable_database_cleaner
81
+ replace_in_file 'spec/spec_helper.rb',
82
+ 'config.use_transactional_fixtures = true',
83
+ 'config.use_transactional_fixtures = false'
84
+
85
+ copy_file 'database_cleaner_rspec.rb', 'spec/support/database_cleaner.rb'
86
+ end
87
+
88
+ def setup_stylesheets
89
+ remove_file 'app/assets/stylesheets/application.css'
90
+ create_file 'application.css.scss'
91
+ end
92
+
93
+ def init_git
94
+ run 'git init'
95
+ end
96
+
97
+ def add_to_git_ignore
98
+ concat_file 'topkit_gitignore', '.gitignore'
99
+ end
100
+
101
+ end
102
+ end
@@ -0,0 +1,100 @@
1
+ require 'rails/generators'
2
+ require 'rails/generators/rails/app/app_generator'
3
+
4
+ module Topkit
5
+ class AppGenerator < Rails::Generators::AppGenerator
6
+ class_option :gitlab, type: :string, aliases: '-G', default: false
7
+
8
+ def finish_template
9
+ invoke :topkit_customization
10
+ super
11
+ end
12
+
13
+ def topkit_customization
14
+ invoke :configure_generators
15
+ invoke :customize_gemfile
16
+ invoke :setup_database
17
+ invoke :remove_useless_files
18
+ invoke :remove_routes_comment_lines
19
+ invoke :setup_staging_environment
20
+ invoke :create_views_and_layouts
21
+ invoke :copy_miscellaneous_files
22
+ invoke :configure_rspec
23
+ invoke :configure_backbone
24
+ invoke :setup_git
25
+ end
26
+
27
+ def configure_generators
28
+ say "Configuring rspec generators"
29
+ build :configure_rspec_generators
30
+ end
31
+
32
+ def customize_gemfile
33
+ say "Setting up gems"
34
+ build :replace_gemfile
35
+ bundle_command "install"
36
+ bundle_command "package"
37
+ end
38
+
39
+ def setup_database
40
+ say "Setting up database"
41
+ build :template_database_file
42
+ build :create_database
43
+ end
44
+
45
+ def remove_useless_files
46
+ build :remove_public_index
47
+ build :remove_rails_logo_image
48
+ end
49
+
50
+ def remove_routes_comment_lines
51
+ build :remove_routes_comment_lines
52
+ end
53
+
54
+ def setup_staging_environment
55
+ say "Setting up staging environment"
56
+ build :setup_staging_environment
57
+ #build :setup_staging_recipes
58
+ end
59
+
60
+ def create_views_and_layouts
61
+ say "Creating partials and default layout"
62
+ build :create_partials_directory
63
+ build :create_status_partials
64
+ build :create_application_layout
65
+ end
66
+
67
+ def copy_miscellaneous_files
68
+ build :setup_stylesheets
69
+ end
70
+
71
+ def configure_rspec
72
+ build :generate_rspec
73
+ build :enable_database_cleaner
74
+ end
75
+
76
+ def configure_backbone
77
+ build :generate_backbone
78
+ end
79
+
80
+ def setup_git
81
+ say "Initializing git repo"
82
+ build :add_to_git_ignore
83
+ build :init_git
84
+ end
85
+
86
+ def outro
87
+ say 'You are good to go!'
88
+ end
89
+
90
+ def run_bundle
91
+ end
92
+
93
+ protected
94
+
95
+ def get_builder_class
96
+ Topkit::AppBuilder
97
+ end
98
+
99
+ end
100
+ end
@@ -0,0 +1,3 @@
1
+ module Topkit
2
+ VERSION = "0.0.1"
3
+ end
data/lib/topkit.rb ADDED
@@ -0,0 +1,5 @@
1
+ require "topkit/version"
2
+
3
+ module Topkit
4
+ # Your code goes here...
5
+ end
@@ -0,0 +1,39 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'rails', '3.2.13'
4
+
5
+ gem 'mysql2'
6
+ gem 'jquery-rails'
7
+ gem 'rails-backbone'
8
+ gem 'simple_form'
9
+ gem 'devise'
10
+ gem 'rails_admin'
11
+
12
+ group :development, :test do
13
+ gem 'thin'
14
+ gem 'capybara'
15
+ gem 'rspec-rails'
16
+ gem 'faker'
17
+ gem 'factory_girl_rails'
18
+ end
19
+
20
+ group :development do
21
+ gem 'capistrano'
22
+ gem 'annotate'
23
+ end
24
+
25
+ group :assets do
26
+ gem 'bootstrap-sass'
27
+ gem 'sass-rails'
28
+ gem 'coffee-rails'
29
+ gem 'uglifier'
30
+ gem 'compass-rails'
31
+ end
32
+
33
+ group :test do
34
+ gem 'database_cleaner'
35
+ end
36
+
37
+ group :staging, :production do
38
+ gem 'unicorn'
39
+ end
@@ -0,0 +1,2 @@
1
+ <footer>
2
+ </footer>
@@ -0,0 +1,2 @@
1
+ <header>
2
+ </header>
@@ -0,0 +1,6 @@
1
+ <% flash.each do |level,message| %>
2
+ <%= content_tag :div, class: "notice alert alert-#{(level == 'notice') ? 'info' : 'error'}" do %>
3
+ <%= link_to '#', class: "close", data: { dismiss: "alert" } %>
4
+ <%= content_tag :p, message %>
5
+ <% end %>
6
+ <% end %>
@@ -0,0 +1,32 @@
1
+ <!DOCTYPE html>
2
+ <!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
3
+ <!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
4
+ <!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
5
+ <!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
6
+ <head>
7
+ <meta charset="utf-8">
8
+ <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
9
+ <meta name="description" content="">
10
+ <meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0, initial-scale=1.0">
11
+ <meta name="apple-mobile-web-app-capable" content="yes">
12
+ <meta name="format-detection" content="telephone=no" />
13
+ <title>Topkit</title>
14
+ <%= stylesheet_link_tag "application", :media => "all" %>
15
+ <%# stylesheet_link_tag "print", :media => "print" %>
16
+ <!--[if IE]>
17
+ <%# stylesheet_link_tag "ie", :media => "screen, projection" %>
18
+ <![endif]-->
19
+ <%= csrf_meta_tags %>
20
+ </head>
21
+ <body data-env="<%= Rails.env %>">
22
+ <div id="container">
23
+ <%= render "status" %>
24
+ <%= render "header" %>
25
+ <div id="content" role="main">
26
+ <%= yield %>
27
+ </div>
28
+ <%= render "footer" %>
29
+ </div>
30
+ <%= javascript_include_tag "application" %>
31
+ </body>
32
+ </html>
@@ -0,0 +1,42 @@
1
+ # MySQL. Versions 4.1 and 5.0 are recommended.
2
+ #
3
+ # Install the MYSQL driver
4
+ # gem install mysql2
5
+ #
6
+ # Ensure the MySQL gem is defined in your Gemfile
7
+ # gem 'mysql2'
8
+ #
9
+ # And be sure to use new-style password hashing:
10
+ # http://dev.mysql.com/doc/refman/5.0/en/old-client.html
11
+ development:
12
+ adapter: mysql2
13
+ encoding: utf8
14
+ reconnect: false
15
+ database: <%= app_name %>_development
16
+ pool: 5
17
+ username: root
18
+ password: root
19
+ socket: /tmp/mysql.sock
20
+
21
+ # Warning: The database defined as "test" will be erased and
22
+ # re-generated from your development database when you run "rake".
23
+ # Do not set this db to the same as development or production.
24
+ test:
25
+ adapter: mysql2
26
+ encoding: utf8
27
+ reconnect: false
28
+ database: <%= app_name %>_test
29
+ pool: 5
30
+ username: root
31
+ password: root
32
+ socket: /tmp/mysql.sock
33
+
34
+ production:
35
+ adapter: mysql2
36
+ encoding: utf8
37
+ reconnect: false
38
+ database: <%= app_name %>_production
39
+ pool: 5
40
+ username: root
41
+ password:
42
+ socket: /tmp/mysql.sock
@@ -0,0 +1,21 @@
1
+ RSpec.configure do |config|
2
+ config.before(:suite) do
3
+ DatabaseCleaner.clean_with(:deletion)
4
+ end
5
+
6
+ config.before(:each) do
7
+ DatabaseCleaner.strategy = :transaction
8
+ end
9
+
10
+ config.before(:each, :js => true) do
11
+ DatabaseCleaner.strategy = :deletion
12
+ end
13
+
14
+ config.before(:each) do
15
+ DatabaseCleaner.start
16
+ end
17
+
18
+ config.after(:each) do
19
+ DatabaseCleaner.clean
20
+ end
21
+ end
@@ -0,0 +1,2 @@
1
+ sass-cache
2
+ esproj
@@ -0,0 +1,7 @@
1
+ require_relative '../../test_helper'
2
+
3
+ describe Topkit do
4
+ it "is versioned" do
5
+ Topkit::VERSION.wont_be_nil
6
+ end
7
+ end
@@ -0,0 +1,3 @@
1
+ require 'minitest/autorun'
2
+ require 'minitest/pride'
3
+ require 'topkit'
data/topkit.gemspec ADDED
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'topkit/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "topkit"
8
+ spec.version = Topkit::VERSION
9
+ spec.authors = ["Alex Padgett"]
10
+ spec.email = ["apadgett@topicdesign.com"]
11
+ spec.description = %q{Generate rails app with Topic gems, frameworks and layouts}
12
+ spec.summary = %q{Generate a Rails app using Topic Design's conventions. Influenced heavily by thoughtbot's Suspenders and Gaslight's sparkler.}
13
+ spec.homepage = "https://github.com/topicdesign/topkit-rails"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rails", "~> 3.2"
23
+ spec.add_development_dependency "rake"
24
+ end
metadata ADDED
@@ -0,0 +1,120 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: topkit
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Alex Padgett
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-06-04 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '1.3'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '1.3'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rails
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: '3.2'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: '3.2'
46
+ - !ruby/object:Gem::Dependency
47
+ name: rake
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ description: Generate rails app with Topic gems, frameworks and layouts
63
+ email:
64
+ - apadgett@topicdesign.com
65
+ executables:
66
+ - topkit
67
+ extensions: []
68
+ extra_rdoc_files: []
69
+ files:
70
+ - .gitignore
71
+ - Gemfile
72
+ - LICENSE.txt
73
+ - README.md
74
+ - Rakefile
75
+ - bin/topkit
76
+ - lib/topkit.rb
77
+ - lib/topkit/actions.rb
78
+ - lib/topkit/app_builder.rb
79
+ - lib/topkit/generators/app_generator.rb
80
+ - lib/topkit/version.rb
81
+ - templates/Gemfile_clean
82
+ - templates/_footer.html.erb
83
+ - templates/_header.html.erb
84
+ - templates/_status.html.erb
85
+ - templates/application_layout.html.erb
86
+ - templates/database.mysql.yml.erb
87
+ - templates/database_cleaner_rspec.rb
88
+ - templates/topkit_gitignore
89
+ - test/lib/topkit/version_test.rb
90
+ - test/test_helper.rb
91
+ - topkit.gemspec
92
+ homepage: https://github.com/topicdesign/topkit-rails
93
+ licenses:
94
+ - MIT
95
+ post_install_message:
96
+ rdoc_options: []
97
+ require_paths:
98
+ - lib
99
+ required_ruby_version: !ruby/object:Gem::Requirement
100
+ none: false
101
+ requirements:
102
+ - - ! '>='
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ required_rubygems_version: !ruby/object:Gem::Requirement
106
+ none: false
107
+ requirements:
108
+ - - ! '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ requirements: []
112
+ rubyforge_project:
113
+ rubygems_version: 1.8.23
114
+ signing_key:
115
+ specification_version: 3
116
+ summary: Generate a Rails app using Topic Design's conventions. Influenced heavily
117
+ by thoughtbot's Suspenders and Gaslight's sparkler.
118
+ test_files:
119
+ - test/lib/topkit/version_test.rb
120
+ - test/test_helper.rb