Class: Railman::CLI

Inherits:
Thor
  • Object
show all
Includes:
Creategem::Git, Thor::Actions
Defined in:
lib/railman/cli.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#app_nameObject

Returns the value of attribute app_name.



10
11
12
# File 'lib/railman/cli.rb', line 10

def app_name
  @app_name
end

Class Method Details

.source_rootObject

this is where the thor generator templates are found



13
14
15
# File 'lib/railman/cli.rb', line 13

def self.source_root
  File.expand_path('../../../templates', __FILE__)
end

Instance Method Details

#new(app_name) ⇒ Object



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
# File 'lib/railman/cli.rb', line 18

def new(app_name)
  say "Create a new rails application named: #{app_name}", :green
  @app_name = app_name
  @class_name = Thor::Util.camel_case(app_name)
  @admin_email = ask("What is the adminitrator email address?")
  @domain = ask("What is the url of the application (without http and www)?")
  if yes?("Do you want me to configure www.#{@domain} domain to be redirected to #{@domain}? (y/n)")
    @www_domain = "www.#{@domain}"
    @domains = [@domain, @www_domain]
  else
    @www_domain = nil
    @domains = [@domain]
  end
  @server = ask("What is the name of the production server?")
  @repository = Creategem::Repository.new(vendor: :bitbucket,
                                          user: git_repository_user_name(:bitbucket),
                                          name: app_name,
                                          gem_server_url: gem_server_url(:bitbucket))
  @rake_secret = "TODO: generate with: rake secret"
  @unicorn_behind_nginx = true
  directory "rails_app", app_name
  @rake_secret = Railman::Secret.generate_secret
  @unicorn_behind_nginx = false
  template "rails_app/.env.example.development.tt", "#{app_name}/.env"
  Dir.chdir app_name do
    run "bundle install"
    run "chmod +x bin/*"
    create_local_git_repository
    create_remote_git_repository(@repository) if yes?("Do you want me to create bitbucket repository named #{app_name}? (y/n)")
  end
  say "The rails application '#{app_name}' was successfully created.", :green
  say "Please check the settings in .env", :blue
end

#update(app_name) ⇒ Object



53
54
55
# File 'lib/railman/cli.rb', line 53

def update(app_name)
  puts "TODO update the rails application: #{app_name}"
end