Module: FastTrack::TrackMethods

Included in:
Track
Defined in:
lib/fast_track/track_methods.rb

Instance Method Summary collapse

Instance Method Details

#bundle_installObject Also known as: bundle_install!

Do a ‘bundle install`



4
5
6
# File 'lib/fast_track/track_methods.rb', line 4

def bundle_install
  run "bundle install"
end

#configObject



8
9
10
# File 'lib/fast_track/track_methods.rb', line 8

def config
  ::FastTrack.config
end

#create_file(*args) ⇒ Object

Add a file



64
65
66
# File 'lib/fast_track/track_methods.rb', line 64

def create_file(*args)
  g.create_file(*args)
end

#db_migrate!Object

Do a ‘rake db:migrate`



18
19
20
# File 'lib/fast_track/track_methods.rb', line 18

def db_migrate!
  rake "db:migrate"
end

#gObject

If you need to get the base-level generator object, it’s available here.



30
31
32
# File 'lib/fast_track/track_methods.rb', line 30

def g
  generator
end

#gem(*args) ⇒ Object

Add a gem

TODO: Find a way to consolidate all gems at once, so we only have to run ‘bundle install` once.



38
39
40
# File 'lib/fast_track/track_methods.rb', line 38

def gem(*args)
  g.gem(*args)
end

#gem_group(*args, &block) ⇒ Object

Create a gem group



69
70
71
# File 'lib/fast_track/track_methods.rb', line 69

def gem_group(*args, &block)
  generator.gem_group(*args, &block)
end

#generate(*args) ⇒ Object



54
55
56
# File 'lib/fast_track/track_methods.rb', line 54

def generate(*args)
  g.generate(*args)
end

#migration(migration_name, columns = {}) ⇒ Object



12
13
14
15
# File 'lib/fast_track/track_methods.rb', line 12

def migration(migration_name, columns = {})
  migration_columns = columns.map {|k, v| "#{k}:#{v}" }
  generate "migration", migration_name, *migration_columns
end

#model(model_name, columns = {}) ⇒ Object

Create a model ‘model_name`



23
24
25
26
# File 'lib/fast_track/track_methods.rb', line 23

def model(model_name, columns = {})
  model_columns = columns.map {|k, v| "#{k}:#{v}" }
  generate "model", model_name, *model_columns
end

#rake(*args) ⇒ Object

Run rake



43
44
45
# File 'lib/fast_track/track_methods.rb', line 43

def rake(*args)
  g.rake(*args)
end

#read_file(file_name) ⇒ Object

Read a file from the templates directory



74
75
76
# File 'lib/fast_track/track_methods.rb', line 74

def read_file(file_name)
  File.read(File.join(FastTrack.template_root, template_directory, file_name))
end

#route(*args) ⇒ Object

Add a route to config/routes.rb



59
60
61
# File 'lib/fast_track/track_methods.rb', line 59

def route(*args)
  g.route(*args)
end

#run(*args) ⇒ Object

Run any command



48
49
50
# File 'lib/fast_track/track_methods.rb', line 48

def run(*args)
  g.run(*args)
end