Class: DaSuspenders::Create

Inherits:
Object
  • Object
show all
Defined in:
lib/create.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(project_path, with_mongoid, repo) ⇒ Create

Returns a new instance of Create.



15
16
17
18
19
20
21
22
# File 'lib/create.rb', line 15

def initialize(project_path, with_mongoid, repo)
  self.project_path = project_path
  self.with_mongoid = with_mongoid
  self.repo = repo
  validate_project_path
  validate_project_name
  check_for_mongod_process if with_mongoid
end

Instance Attribute Details

#project_pathObject

Returns the value of attribute project_path.



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

def project_path
  @project_path
end

#repoObject

Returns the value of attribute repo.



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

def repo
  @repo
end

#with_mongoidObject

Returns the value of attribute with_mongoid.



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

def with_mongoid
  @with_mongoid
end

Class Method Details

.run!(project_path, with_mongoid, repo) ⇒ Object



10
11
12
13
# File 'lib/create.rb', line 10

def self.run!(project_path, with_mongoid, repo)
  creator = self.new(project_path, with_mongoid == "--with-mongoid", repo)
  creator.create_project!
end

Instance Method Details

#create_project!Object



24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/create.rb', line 24

def create_project!
  command = <<-COMMAND
    rails new #{project_path} \
      --template="#{template}" \
      --database=mysql \
      --skip-test-unit \
      #{'--skip-active-record' if with_mongoid}
  COMMAND
  ENV["REPO"] = repo if repo
  ENV["WITH_MONGOID"] = "1" if with_mongoid
  exec(command)
end