fast_track 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +13 -11
- data/bin/track +2 -1
- data/fast_track.gemspec +5 -1
- data/lib/fast_track.rb +42 -65
- data/lib/fast_track/commands.rb +32 -0
- data/lib/fast_track/config.rb +1 -1
- data/lib/fast_track/dsl.rb +14 -0
- data/lib/fast_track/exceptions.rb +1 -1
- data/lib/fast_track/ext.rb +5 -0
- data/lib/fast_track/generator.rb +30 -4
- data/lib/fast_track/track.rb +103 -67
- data/lib/fast_track/track_methods.rb +51 -1
- data/lib/fast_track/version.rb +1 -1
- data/lib/tracks/awesome_defaults.rb +19 -18
- data/lib/tracks/backbone.rb +17 -33
- data/lib/tracks/better_exceptions.rb +11 -15
- data/lib/tracks/cancan.rb +8 -9
- data/lib/tracks/devise.rb +48 -76
- data/lib/tracks/errbit_heroku.rb +2 -6
- data/lib/tracks/guard.rb +18 -17
- data/lib/tracks/heroku.rb +5 -0
- data/lib/tracks/jquery.rb +6 -15
- data/lib/tracks/mysql.rb +7 -9
- data/lib/tracks/omniauth.rb +61 -62
- data/lib/tracks/quite_assets.rb +7 -0
- data/lib/tracks/rolify.rb +8 -9
- data/lib/tracks/rspec.rb +12 -0
- data/lib/tracks/thin.rb +39 -0
- data/lib/tracks/twitter_bootstrap.rb +50 -55
- metadata +60 -6
- data/lib/fast_track/thin.rb +0 -21
data/README.md
CHANGED
@@ -1,39 +1,41 @@
|
|
1
1
|
# fast_track
|
2
2
|
|
3
|
-
Create Rails apps quickly.
|
3
|
+
Create Rails apps quickly. So far the number of recipes we have is somewhat limited, but it will grow very soon,
|
4
|
+
and very fast.
|
4
5
|
|
5
|
-
##
|
6
|
+
## Install:
|
6
7
|
|
7
|
-
|
8
|
+
fast_track is a tool for building Rails apps, so you don't need to add it to your Gemfile. Just install it as you
|
9
|
+
would any other gem:
|
8
10
|
|
9
11
|
```bash
|
10
|
-
|
11
|
-
cd fast_track
|
12
|
+
gem install fast_track
|
12
13
|
```
|
13
14
|
|
14
|
-
The executable `bin/track` is where all the magic happens for the moment.
|
15
|
-
|
16
15
|
## Examples:
|
17
16
|
|
17
|
+
Here's some examples of what fast_track can do so far. Note that this is actually a rather limited set of things
|
18
|
+
compared to what it will be actually capable of.
|
19
|
+
|
18
20
|
### Create an app with Devise + Cancan + Rolify
|
19
21
|
|
20
22
|
```bash
|
21
|
-
|
23
|
+
track --app cool_site --tracks devise,cancan,rolify
|
22
24
|
```
|
23
25
|
|
24
26
|
### Same as above, but add Devise views
|
25
27
|
|
26
28
|
```bash
|
27
|
-
./bin/track --app
|
29
|
+
./bin/track --app cool_site --tracks devise_with_views,cancan,rolify
|
28
30
|
```
|
29
31
|
|
30
32
|
### Same as above, but with Twitter Bootstrap
|
31
33
|
|
32
34
|
```bash
|
33
|
-
./bin/track --app
|
35
|
+
./bin/track --app cool_site --tracks twitter_bootstrap,devise_with_view,cancan,rolify
|
34
36
|
```
|
35
37
|
|
36
|
-
## Why not use
|
38
|
+
## Why not use Rails Wizard / appscrolls / Rails app composer / some other Rails app builder ?
|
37
39
|
|
38
40
|
In all the projects I've seen, most functionality is implemented in procedural scripts. They are not objects.
|
39
41
|
In `fast_track`, all objects inherit from `Track`. Procedural is fine for quick scripts, but not for robust tools.
|
data/bin/track
CHANGED
data/fast_track.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.email = ["farleyknight@gmail.com"]
|
11
11
|
spec.summary = %q{Create Rails apps quickly.}
|
12
12
|
spec.description = %q{Leverage the Rails generator to architect new Rails apps with lots of default gems, templates, and other recipes, quickly.}
|
13
|
-
spec.homepage = ""
|
13
|
+
spec.homepage = "http://fast-track.io"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
16
16
|
spec.files = `git ls-files`.split($/)
|
@@ -22,4 +22,8 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.add_development_dependency "rake"
|
23
23
|
spec.add_development_dependency "rspec"
|
24
24
|
spec.add_development_dependency "gem-release"
|
25
|
+
|
26
|
+
spec.add_dependency "thor"
|
27
|
+
spec.add_dependency "rails"
|
28
|
+
spec.add_dependency "hooks"
|
25
29
|
end
|
data/lib/fast_track.rb
CHANGED
@@ -1,94 +1,48 @@
|
|
1
1
|
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), 'lib')
|
2
2
|
|
3
3
|
require 'open-uri'
|
4
|
-
require 'slop'
|
5
|
-
|
6
|
-
require 'pry'
|
7
4
|
|
8
5
|
require 'rails/generators'
|
9
6
|
require 'rails/generators/rails/app/app_generator'
|
10
7
|
|
8
|
+
require 'fast_track/ext'
|
9
|
+
require 'fast_track/dsl'
|
11
10
|
require 'fast_track/exceptions'
|
12
11
|
require 'fast_track/config'
|
13
12
|
|
14
13
|
require 'fast_track/track_methods'
|
15
14
|
require 'fast_track/track'
|
16
15
|
|
16
|
+
require 'fast_track/commands'
|
17
17
|
require 'fast_track/generator'
|
18
18
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
# Load FastTrack tracks
|
27
|
-
Dir[File.join(File.dirname(__FILE__), 'lib', 'tracks')].each do |file|
|
28
|
-
load file
|
29
|
-
end
|
30
|
-
|
31
|
-
# Load local tracks
|
32
|
-
Dir[File.join(File.expand_path("~/"), ".fast_track", "*.rb")].each do |file|
|
33
|
-
load file
|
34
|
-
end
|
35
|
-
|
36
|
-
class FastTrack
|
37
|
-
def initialize
|
38
|
-
FastTrack.validate_options!
|
39
|
-
end
|
40
|
-
|
41
|
-
def app
|
42
|
-
@app ||= Generator.new([FastTrack.app_name])
|
43
|
-
end
|
44
|
-
|
45
|
-
def start
|
46
|
-
app.invoke
|
19
|
+
module FastTrack
|
20
|
+
class App
|
21
|
+
def initialize(app_name, tracks)
|
22
|
+
FastTrack.options[:tracks] = tracks
|
23
|
+
@app ||= FastTrack::Generator.new([app_name])
|
24
|
+
@app.invoke
|
25
|
+
end
|
47
26
|
end
|
48
27
|
|
49
28
|
class << self
|
50
29
|
def options
|
51
|
-
@
|
52
|
-
end
|
53
|
-
|
54
|
-
def app_name
|
55
|
-
options[:app]
|
56
|
-
end
|
57
|
-
|
58
|
-
def make_tracks
|
59
|
-
options[:tracks].map do |track|
|
60
|
-
klass = FastTrack.const_get(track.camelize)
|
61
|
-
if klass <= Track
|
62
|
-
klass
|
63
|
-
else
|
64
|
-
raise TrackNotFound.new(klass.name)
|
65
|
-
end
|
66
|
-
end
|
30
|
+
@options ||= {}
|
67
31
|
end
|
68
32
|
|
69
33
|
def tracks
|
70
34
|
@tracks ||= make_tracks
|
71
35
|
end
|
72
36
|
|
73
|
-
def
|
74
|
-
@
|
75
|
-
|
76
|
-
|
77
|
-
on 'A', 'app=', 'The application name'
|
78
|
-
on 'T', 'tracks=', 'The tracks to run', as: Array
|
79
|
-
end
|
80
|
-
|
81
|
-
# TODO: Is there a Ruby gem that has the same functionality as ActiveModel::Validations
|
82
|
-
# but doesn't require ActiveRecord?
|
83
|
-
#
|
84
|
-
# Because we should use that here..
|
85
|
-
|
86
|
-
if @opts[:app].blank?
|
87
|
-
raise "--app can't be blank!"
|
88
|
-
end
|
37
|
+
def available_tracks
|
38
|
+
@available_tracks ||= {}
|
39
|
+
end
|
89
40
|
|
90
|
-
|
91
|
-
|
41
|
+
def find_track(name)
|
42
|
+
if available_tracks[name].present?
|
43
|
+
available_tracks[name]
|
44
|
+
else
|
45
|
+
raise TrackNotFound.new(name)
|
92
46
|
end
|
93
47
|
end
|
94
48
|
|
@@ -103,5 +57,28 @@ class FastTrack
|
|
103
57
|
def template_root
|
104
58
|
File.join(File.expand_path(root), "lib", "templates")
|
105
59
|
end
|
60
|
+
|
61
|
+
protected
|
62
|
+
|
63
|
+
def make_tracks
|
64
|
+
options[:tracks].map do |track|
|
65
|
+
klass = FastTrack.find_track(track)
|
66
|
+
if klass <= Track
|
67
|
+
klass
|
68
|
+
else
|
69
|
+
raise TrackNotFound.new(klass.name)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
106
73
|
end
|
107
74
|
end
|
75
|
+
|
76
|
+
# Load FastTrack tracks
|
77
|
+
Dir[File.join(File.dirname(__FILE__), 'tracks', "*.rb")].each do |file|
|
78
|
+
require file
|
79
|
+
end
|
80
|
+
|
81
|
+
# Load local tracks
|
82
|
+
Dir[File.join(File.expand_path("~/"), ".fast_track", "*.rb")].each do |file|
|
83
|
+
require file
|
84
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require "thor"
|
2
|
+
|
3
|
+
module FastTrack
|
4
|
+
class Commands < Thor
|
5
|
+
desc "new APP_NAME", "Create a new Rails app, called APP_NAME"
|
6
|
+
|
7
|
+
method_option :tracks, {
|
8
|
+
:type => :array,
|
9
|
+
:aliases => "-T",
|
10
|
+
:desc => "Tracks to run with this app",
|
11
|
+
:required => true
|
12
|
+
}
|
13
|
+
|
14
|
+
def new_app(name)
|
15
|
+
FastTrack::App.new(name, options[:tracks])
|
16
|
+
end
|
17
|
+
|
18
|
+
desc "list", "List all available tracks, with descriptions"
|
19
|
+
|
20
|
+
def list
|
21
|
+
puts ""
|
22
|
+
puts "Available Tracks:"
|
23
|
+
puts ""
|
24
|
+
FastTrack::Track.descendants.each do |track|
|
25
|
+
unless track.name.blank?
|
26
|
+
puts "#{track.name.ljust(30)} -- #{track.description}"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
puts ""
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/lib/fast_track/config.rb
CHANGED
data/lib/fast_track/generator.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
module FastTrack
|
2
2
|
class GemInstaller
|
3
3
|
def run(generator)
|
4
4
|
FastTrack.tracks.each do |klass|
|
@@ -19,6 +19,26 @@ class FastTrack
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
+
class AfterBundle
|
23
|
+
def run(generator)
|
24
|
+
FastTrack.tracks.each do |klass|
|
25
|
+
unless klass.after_bundle_block.blank?
|
26
|
+
generator.instance_eval(&klass.after_bundle_block)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
class AfterMigrate
|
33
|
+
def run(generator)
|
34
|
+
FastTrack.tracks.each do |klass|
|
35
|
+
unless klass.after_migrate_block.blank?
|
36
|
+
generator.instance_eval(&klass.after_migrate_block)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
22
42
|
class Runner
|
23
43
|
def run(generator)
|
24
44
|
FastTrack.tracks.each do |klass|
|
@@ -30,18 +50,24 @@ class FastTrack
|
|
30
50
|
end
|
31
51
|
|
32
52
|
class Generator < Rails::Generators::AppGenerator
|
33
|
-
include TrackMethods
|
34
|
-
|
35
53
|
source_root Rails::Generators::AppGenerator.source_root
|
36
54
|
|
37
|
-
def
|
55
|
+
def fast_track
|
38
56
|
FastTrack::GemInstaller.new.run(self)
|
39
57
|
run("bundle install")
|
58
|
+
FastTrack::AfterBundle.new.run(self)
|
40
59
|
|
41
60
|
FastTrack::Runner.new.run(self)
|
42
61
|
|
43
62
|
FastTrack::BeforeMigrate.new.run(self)
|
44
63
|
rake("db:migrate")
|
64
|
+
FastTrack::AfterMigrate.new.run(self)
|
65
|
+
end
|
66
|
+
|
67
|
+
protected
|
68
|
+
|
69
|
+
def do_whatever
|
70
|
+
puts "Does thor call this?"
|
45
71
|
end
|
46
72
|
end
|
47
73
|
end
|
data/lib/fast_track/track.rb
CHANGED
@@ -1,5 +1,8 @@
|
|
1
|
-
|
1
|
+
require "hooks"
|
2
|
+
|
3
|
+
module FastTrack
|
2
4
|
class Track
|
5
|
+
include Hooks
|
3
6
|
include TrackMethods
|
4
7
|
|
5
8
|
attr_accessor :generator
|
@@ -8,72 +11,105 @@ class FastTrack
|
|
8
11
|
@generator = generator
|
9
12
|
end
|
10
13
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
14
|
+
class << self
|
15
|
+
def args=(other)
|
16
|
+
@args = other
|
17
|
+
end
|
18
|
+
|
19
|
+
def args
|
20
|
+
@args || []
|
21
|
+
end
|
22
|
+
|
23
|
+
def name_from_args
|
24
|
+
if args.length == 1
|
25
|
+
@args.first
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def name(name = nil)
|
30
|
+
if name.blank?
|
31
|
+
# @name || name_from_args || ""
|
32
|
+
name_from_args || ""
|
33
|
+
else
|
34
|
+
@name = name
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def description(arg = nil)
|
39
|
+
if arg.blank?
|
40
|
+
@description
|
41
|
+
else
|
42
|
+
@description = arg
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
alias :desc :description
|
47
|
+
|
48
|
+
# The required tracks this track needs.
|
49
|
+
def requires(*args)
|
50
|
+
if args.blank?
|
51
|
+
@requires
|
52
|
+
else
|
53
|
+
@requires = args
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def rubygem(name)
|
58
|
+
@rubygem = name
|
59
|
+
end
|
60
|
+
|
61
|
+
def tutorial_url(url)
|
62
|
+
@tutorial_urls ||= []
|
63
|
+
@tutorial_urls << url
|
64
|
+
end
|
65
|
+
|
66
|
+
def github_url(url)
|
67
|
+
@github_url = url
|
68
|
+
end
|
69
|
+
|
70
|
+
def github_description(description)
|
71
|
+
@github_description = description
|
72
|
+
end
|
73
|
+
|
74
|
+
# Describe a Gemfile using `gem` and `gem_group`
|
75
|
+
def gemfile(&block)
|
76
|
+
@gemfile_block = block
|
77
|
+
end
|
78
|
+
|
79
|
+
def gemfile_block
|
80
|
+
@gemfile_block
|
81
|
+
end
|
82
|
+
|
83
|
+
# Tasks before migration
|
84
|
+
def before_migrate(&block)
|
85
|
+
@before_migrate_block = block
|
86
|
+
end
|
87
|
+
|
88
|
+
def before_migrate_block
|
89
|
+
@before_migrate_block
|
90
|
+
end
|
91
|
+
|
92
|
+
alias :before_migration :before_migrate
|
93
|
+
|
94
|
+
# Tasks before migration
|
95
|
+
def after_migrate(&block)
|
96
|
+
@after_migrate_block = block
|
97
|
+
end
|
98
|
+
|
99
|
+
def after_migrate_block
|
100
|
+
@after_migrate_block
|
101
|
+
end
|
102
|
+
|
103
|
+
alias :after_migration :after_migrate
|
104
|
+
|
105
|
+
# After bundle
|
106
|
+
def after_bundle(&block)
|
107
|
+
@after_bundle_block = block
|
108
|
+
end
|
109
|
+
|
110
|
+
def after_bundle_block
|
111
|
+
@after_bundle_block
|
112
|
+
end
|
77
113
|
end
|
78
114
|
end
|
79
115
|
end
|